From 2eab708bb60de9714e9dedf91b501d53785d5795 Mon Sep 17 00:00:00 2001 From: schmurger Date: Fri, 26 Apr 2024 10:40:28 +1000 Subject: [PATCH] Added configuration for notification animation duration --- dll/dll/settings.h | 1 + dll/settings_parser.cpp | 4 ++++ overlay_experimental/overlay/steam_overlay.h | 1 - overlay_experimental/steam_overlay.cpp | 18 +++++++++++------- .../configs.overlay.EXAMPLE.ini | 3 +++ 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/dll/dll/settings.h b/dll/dll/settings.h index 6fb99201..db1acad7 100644 --- a/dll/dll/settings.h +++ b/dll/dll/settings.h @@ -125,6 +125,7 @@ struct Overlay_Appearance { float notification_b = 0.48f; float notification_a = 1.0f; float notification_rounding = 0.0f; + float notification_animation = 0.0f; std::string ach_unlock_datetime_format = "%Y/%m/%d - %H:%M:%S"; float background_r = -1.0f; diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 464a6c34..ce115424 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -256,6 +256,10 @@ static void load_overlay_appearance(class Settings *settings_client, class Setti 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("Notification_Animation") == 0) { + float nnotification_animation = std::stof(value, NULL); + settings_client->overlay_appearance.notification_animation = nnotification_animation; + settings_server->overlay_appearance.notification_animation = nnotification_animation; } else if (name.compare("Achievement_Unlock_Datetime_Format") == 0) { settings_client->overlay_appearance.ach_unlock_datetime_format = value; settings_server->overlay_appearance.ach_unlock_datetime_format = value; diff --git a/overlay_experimental/overlay/steam_overlay.h b/overlay_experimental/overlay/steam_overlay.h index d3c89503..5f9413f6 100644 --- a/overlay_experimental/overlay/steam_overlay.h +++ b/overlay_experimental/overlay/steam_overlay.h @@ -62,7 +62,6 @@ enum class notification_type struct Notification { static constexpr float width_percent = 0.25f; // percentage from total width - static constexpr float animation_duration = 500.0f; //animation duration in miliseconds static constexpr std::chrono::milliseconds fade_in = std::chrono::milliseconds(2000); static constexpr std::chrono::milliseconds fade_out = std::chrono::milliseconds(2000); static constexpr std::chrono::milliseconds show_time = std::chrono::milliseconds(6000) + fade_in + fade_out; diff --git a/overlay_experimental/steam_overlay.cpp b/overlay_experimental/steam_overlay.cpp index 2e7df075..dfacb99f 100644 --- a/overlay_experimental/steam_overlay.cpp +++ b/overlay_experimental/steam_overlay.cpp @@ -940,14 +940,18 @@ void Steam_Overlay::set_next_notification_pos(float width, float height, float e float Steam_Overlay::animate_factor(float elapsed) { float factor = 0.0f; + float animation_duration = settings->overlay_appearance.notification_animation * 1000; PRINT_DEBUG("ELAPSED %f", elapsed); - if (elapsed < Notification::animation_duration) { - factor = 1 - (elapsed / Notification::animation_duration); - PRINT_DEBUG("SHOW FACTOR %f", factor); - } - else if (elapsed > Notification::show_time.count() - Notification::animation_duration) { - factor = 1 - (Notification::show_time.count() - elapsed) / Notification::animation_duration; - PRINT_DEBUG("HIDE FACTOR %f", factor); + + if (animation_duration > 0) { + if (elapsed < animation_duration) { + factor = 1 - (elapsed / animation_duration); + PRINT_DEBUG("SHOW FACTOR %f", factor); + } + else if (elapsed > Notification::show_time.count() - animation_duration) { + factor = 1 - (Notification::show_time.count() - elapsed) / animation_duration; + PRINT_DEBUG("HIDE FACTOR %f", factor); + } } return factor; diff --git a/post_build/steam_settings.EXAMPLE/configs.overlay.EXAMPLE.ini b/post_build/steam_settings.EXAMPLE/configs.overlay.EXAMPLE.ini index 5863b3e4..31dc4088 100644 --- a/post_build/steam_settings.EXAMPLE/configs.overlay.EXAMPLE.ini +++ b/post_build/steam_settings.EXAMPLE/configs.overlay.EXAMPLE.ini @@ -50,6 +50,9 @@ Notification_A=1.0 # notification rounded corners Notification_Rounding=10.0 +# notification animation in seconds +Notification_Animation=0.5 + # format for the achievement unlock date/time, limited to 79 characters # if the output formatted string exceeded this limit, the builtin format will be used # look for the format here: https://en.cppreference.com/w/cpp/chrono/c/strftime