From 21545509fd736fb7bd851f124ca5d2bfe183ca5b Mon Sep 17 00:00:00 2001 From: otavepto <153766569+otavepto@users.noreply.github.com> Date: Sat, 6 Jan 2024 07:41:32 +0200 Subject: [PATCH] new type of notification when the auto accept config file is used --- overlay_experimental/overlay/steam_overlay.h | 4 +++ overlay_experimental/steam_overlay.cpp | 38 ++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/overlay_experimental/overlay/steam_overlay.h b/overlay_experimental/overlay/steam_overlay.h index f7087351..eff2d4b8 100644 --- a/overlay_experimental/overlay/steam_overlay.h +++ b/overlay_experimental/overlay/steam_overlay.h @@ -48,6 +48,7 @@ enum notification_type notification_type_message = 0, notification_type_invite, notification_type_achievement, + notification_type_auto_accept_invite, }; struct Notification @@ -150,6 +151,7 @@ class Steam_Overlay void NotifyUser(friend_window_state& friend_state); void NotifyUserAchievement(); + void NotifySoundAutoAcceptFriendInvite(); // Right click on friend void BuildContextMenu(Friend const& frd, friend_window_state &state); @@ -195,6 +197,7 @@ public: void AddMessageNotification(std::string const& message); void AddAchievementNotification(nlohmann::json const& ach); void AddInviteNotification(std::pair &wnd_state); + void AddAutoAcceptInviteNotification(); }; #else @@ -237,6 +240,7 @@ public: void AddMessageNotification(std::string const& message) {} void AddAchievementNotification(nlohmann::json const& ach) {} void AddInviteNotification(std::pair &wnd_state) {} + void AddAutoAcceptInviteNotification() {} }; #endif diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index bd77f3de..27caea64 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -355,6 +355,17 @@ void Steam_Overlay::NotifyUserAchievement() } } +void Steam_Overlay::NotifySoundAutoAcceptFriendInvite() +{ +#ifdef __WINDOWS__ + if (notif_achievement_wav_custom_inuse) { + PlaySoundA((LPCSTR)notif_achievement_wav_custom, NULL, SND_ASYNC | SND_MEMORY); + } else { + PlaySoundA((LPCSTR)notif_invite_wav, NULL, SND_ASYNC | SND_MEMORY); + } +#endif +} + void Steam_Overlay::SetLobbyInvite(Friend friendId, uint64 lobbyId) { std::lock_guard lock(overlay_mutex); @@ -512,6 +523,31 @@ void Steam_Overlay::AddInviteNotification(std::pair lock(notifications_mutex); + int id = find_free_notification_id(notifications); + if (id != 0) + { + Notification notif{}; + notif.id = id; + notif.type = notification_type_auto_accept_invite; + + { + char tmp[TRANSLATION_BUFFER_SIZE]{}; + snprintf(tmp, sizeof(tmp), "%s", translationAutoAcceptFriendInvite[current_language]); + notif.message = tmp; + } + + notif.start_time = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()); + notifications.emplace_back(notif); + NotifySoundAutoAcceptFriendInvite(); + have_notifications = true; + } else { + PRINT_DEBUG("No free id to create an auto-accept notification window\n"); + } +} + bool Steam_Overlay::FriendJoinable(std::pair &f) { Steam_Friends* steamFriends = get_steam_client()->steam_friends; @@ -761,6 +797,8 @@ void Steam_Overlay::BuildNotifications(int width, int height) break; case notification_type_message: ImGui::TextWrapped("%s", it->message.c_str()); break; + case notification_type_auto_accept_invite: + ImGui::TextWrapped("%s", it->message.c_str()); break; } ImGui::End();