From d0193b953d5204c2b90f45676cdf788d2a0462e3 Mon Sep 17 00:00:00 2001 From: schmurger Date: Tue, 23 Apr 2024 11:38:00 +1000 Subject: [PATCH] Improve achievement notification --- dll/dll/settings.h | 2 +- dll/settings_parser.cpp | 7 ++++++- overlay_experimental/steam_overlay.cpp | 19 +++++++++++++------ .../configs.overlay.EXAMPLE.ini | 9 ++++++--- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/dll/dll/settings.h b/dll/dll/settings.h index cd2ec720..60e79128 100644 --- a/dll/dll/settings.h +++ b/dll/dll/settings.h @@ -124,7 +124,7 @@ struct Overlay_Appearance { float notification_g = 0.29f; float notification_b = 0.48f; float notification_a = 1.0f; - + float notification_rounding = 0.f; float background_r = -1.0f; float background_g = -1.0f; float background_b = -1.0f; diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 2dad1155..a7922c15 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -252,7 +252,12 @@ static void load_overlay_appearance(class Settings *settings_client, class Setti float nnotification_a = std::stof(value, NULL); settings_client->overlay_appearance.notification_a = nnotification_a; settings_server->overlay_appearance.notification_a = nnotification_a; - } else if (name.compare("Background_R") == 0) { + } else if (name.compare("Notification_Rounding") == 0) { + float nnotification_rounding = std::stof(value, NULL); + settings_client->overlay_appearance.notification_rounding = nnotification_rounding; + settings_server->overlay_appearance.notification_rounding = nnotification_rounding; + } + else if (name.compare("Background_R") == 0) { float nbackground_r = std::stof(value, NULL); settings_client->overlay_appearance.background_r = nbackground_r; settings_server->overlay_appearance.background_r = nbackground_r; diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index 3bf3ad9b..f4ad5235 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -836,12 +836,21 @@ void Steam_Overlay::build_friend_window(Friend const& frd, friend_window_state& // set the position of the next notification void Steam_Overlay::set_next_notification_pos(float width, float height, float font_size, notification_type type, struct NotificationsIndexes &idx) { + // Add window rounding + ImGuiStyle& style = ImGui::GetStyle(); + style.WindowRounding = settings->overlay_appearance.notification_rounding; + + const float noti_width = width * Notification::width_percent; + float noti_height = Notification::height * font_size; // 0 on the y-axis is top, 0 on the x-axis is left // get the required position Overlay_Appearance::NotificationPosition pos = Overlay_Appearance::default_pos; switch (type) { - case notification_type::notification_type_achievement: pos = settings->overlay_appearance.ach_earned_pos; break; + case notification_type::notification_type_achievement: + pos = settings->overlay_appearance.ach_earned_pos; + noti_height = settings->overlay_appearance.icon_size + style.FramePadding.y * Notification::height; + break; case notification_type::notification_type_invite: pos = settings->overlay_appearance.invite_pos; break; case notification_type::notification_type_message: pos = settings->overlay_appearance.chat_msg_pos; break; default: /* satisfy compiler warning */ break; @@ -849,8 +858,6 @@ void Steam_Overlay::set_next_notification_pos(float width, float height, float f float x = 0.0f; float y = 0.0f; - const float noti_width = width * Notification::width_percent; - const float noti_height = Notification::height * font_size; switch (pos) { // top case Overlay_Appearance::NotificationPosition::top_left: @@ -890,6 +897,8 @@ void Steam_Overlay::set_next_notification_pos(float width, float height, float f } ImGui::SetNextWindowPos(ImVec2( x, y )); + ImGui::SetNextWindowSize(ImVec2(width * Notification::width_percent, noti_height)); + ImGui::SetNextWindowBgAlpha(0.9f); } void Steam_Overlay::build_notifications(int width, int height) @@ -903,9 +912,7 @@ void Steam_Overlay::build_notifications(int width, int height) auto elapsed_notif = now - it->start_time; set_next_notification_pos(width, height, font_size, (notification_type)it->type, idx); - ImGui::SetNextWindowSize(ImVec2( width * Notification::width_percent, Notification::height * font_size )); - ImGui::SetNextWindowBgAlpha(0.9f); - + if ( elapsed_notif < Notification::fade_in) { // still appearing (fading in) float alpha = settings->overlay_appearance.notification_a * (elapsed_notif.count() / static_cast(Notification::fade_in.count())); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, alpha)); diff --git a/post_build/steam_settings.EXAMPLE/configs.overlay.EXAMPLE.ini b/post_build/steam_settings.EXAMPLE/configs.overlay.EXAMPLE.ini index 34fecd5f..021f38e1 100644 --- a/post_build/steam_settings.EXAMPLE/configs.overlay.EXAMPLE.ini +++ b/post_build/steam_settings.EXAMPLE/configs.overlay.EXAMPLE.ini @@ -42,11 +42,14 @@ Icon_Size=64.0 Font_Glyph_Extra_Spacing_x=1.0 Font_Glyph_Extra_Spacing_y=0.0 -Notification_R=0.16 -Notification_G=0.29 -Notification_B=0.48 +Notification_R=0.14 +Notification_G=0.15 +Notification_B=0.18 Notification_A=1.0 +# Notification rounded corners +Notification_Rounding=10 + Background_R=-1.0 Background_G=-1.0 Background_B=-1.0