Added configuration for notification animation duration

This commit is contained in:
schmurger 2024-04-26 10:40:28 +10:00 committed by otavepto
parent 6f0eea3a10
commit 2eab708bb6
5 changed files with 19 additions and 8 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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