Improve achievement notification

This commit is contained in:
schmurger 2024-04-23 11:38:00 +10:00 committed by otavepto
parent 36960f7095
commit d0193b953d
4 changed files with 26 additions and 11 deletions

View File

@ -124,7 +124,7 @@ struct Overlay_Appearance {
float notification_g = 0.29f; float notification_g = 0.29f;
float notification_b = 0.48f; float notification_b = 0.48f;
float notification_a = 1.0f; float notification_a = 1.0f;
float notification_rounding = 0.f;
float background_r = -1.0f; float background_r = -1.0f;
float background_g = -1.0f; float background_g = -1.0f;
float background_b = -1.0f; float background_b = -1.0f;

View File

@ -252,7 +252,12 @@ static void load_overlay_appearance(class Settings *settings_client, class Setti
float nnotification_a = std::stof(value, NULL); float nnotification_a = std::stof(value, NULL);
settings_client->overlay_appearance.notification_a = nnotification_a; settings_client->overlay_appearance.notification_a = nnotification_a;
settings_server->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); float nbackground_r = std::stof(value, NULL);
settings_client->overlay_appearance.background_r = nbackground_r; settings_client->overlay_appearance.background_r = nbackground_r;
settings_server->overlay_appearance.background_r = nbackground_r; settings_server->overlay_appearance.background_r = nbackground_r;

View File

@ -836,12 +836,21 @@ void Steam_Overlay::build_friend_window(Friend const& frd, friend_window_state&
// set the position of the next notification // 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) 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 // 0 on the y-axis is top, 0 on the x-axis is left
// get the required position // get the required position
Overlay_Appearance::NotificationPosition pos = Overlay_Appearance::default_pos; Overlay_Appearance::NotificationPosition pos = Overlay_Appearance::default_pos;
switch (type) { 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_invite: pos = settings->overlay_appearance.invite_pos; break;
case notification_type::notification_type_message: pos = settings->overlay_appearance.chat_msg_pos; break; case notification_type::notification_type_message: pos = settings->overlay_appearance.chat_msg_pos; break;
default: /* satisfy compiler warning */ 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 x = 0.0f;
float y = 0.0f; float y = 0.0f;
const float noti_width = width * Notification::width_percent;
const float noti_height = Notification::height * font_size;
switch (pos) { switch (pos) {
// top // top
case Overlay_Appearance::NotificationPosition::top_left: 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::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) 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; auto elapsed_notif = now - it->start_time;
set_next_notification_pos(width, height, font_size, (notification_type)it->type, idx); 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) if ( elapsed_notif < Notification::fade_in) { // still appearing (fading in)
float alpha = settings->overlay_appearance.notification_a * (elapsed_notif.count() / static_cast<float>(Notification::fade_in.count())); float alpha = settings->overlay_appearance.notification_a * (elapsed_notif.count() / static_cast<float>(Notification::fade_in.count()));
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, alpha)); ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0, 0, 0, alpha));

View File

@ -42,11 +42,14 @@ Icon_Size=64.0
Font_Glyph_Extra_Spacing_x=1.0 Font_Glyph_Extra_Spacing_x=1.0
Font_Glyph_Extra_Spacing_y=0.0 Font_Glyph_Extra_Spacing_y=0.0
Notification_R=0.16 Notification_R=0.14
Notification_G=0.29 Notification_G=0.15
Notification_B=0.48 Notification_B=0.18
Notification_A=1.0 Notification_A=1.0
# Notification rounded corners
Notification_Rounding=10
Background_R=-1.0 Background_R=-1.0
Background_G=-1.0 Background_G=-1.0
Background_B=-1.0 Background_B=-1.0