Skip to content

Commit

Permalink
Adjust the notification size
Browse files Browse the repository at this point in the history
  • Loading branch information
OFFTKP committed Aug 12, 2024
1 parent 5bac217 commit 879d438
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7107,10 +7107,10 @@ static void frame(void) {
float top = menu_height;
float right = screen_x+screen_width/se_dpi_scale();
float bottom = height/se_dpi_scale();
float padding = 30;
float padding = screen_width * 0.02;

if (gui_state.settings.draw_notifications)
retro_achievements_draw_notifications(left+padding,top+padding);
retro_achievements_draw_notifications(left+padding,top+padding,screen_width);

if (gui_state.settings.draw_progress_indicators)
retro_achievements_draw_progress_indicator(right-padding,top+padding);
Expand Down
27 changes: 14 additions & 13 deletions src/retro_achievements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1336,7 +1336,7 @@ float easeOutBack(float t) {
return 1 + c3 * (t1 * t1 * t1) + c1 * (t1 * t1);
}

void retro_achievements_draw_notifications(float left, float top)
void retro_achievements_draw_notifications(float left, float top, float screen_width)
{
ra_game_state_ptr game_state = ra_state->game_state;

Expand Down Expand Up @@ -1384,25 +1384,26 @@ void retro_achievements_draw_notifications(float left, float top)
if (easing < 0.97f)
continue;

float padding_adj = padding * easing;

#define ALPHA(x) ((uint32_t)(multiplier * x) << 24)

float image_width = 64 * easing;
float image_height = 64 * easing;
float padding_adj = 0.01 * screen_width * easing;
float image_width = screen_width * 0.05f * easing;
float image_height = screen_width * 0.05f * easing;
float placard_width =
padding_adj + 300 * easing + padding_adj; // notifications that have the same width are more appealing
padding_adj + screen_width * 0.30f * easing + padding_adj; // notifications that have the same width are more appealing
float wrap_width = placard_width - padding_adj * 2 - image_width;
float title_font_size = 0.02f * screen_width * easing;
float submessage_font_size = 0.015f * screen_width * easing;

float title_height = 0, submessage_height = 0;

ImVec2 out;
ImFont* font = igGetFont();
ImFont_CalcTextSizeA(&out, font, 22.0f * easing, std::numeric_limits<float>::max(), wrap_width,
ImFont_CalcTextSizeA(&out, font, title_font_size, std::numeric_limits<float>::max(), wrap_width,
notification.submessage.c_str(), NULL, NULL);
title_height = out.y;

ImFont_CalcTextSizeA(&out, font, 18.0f * easing, std::numeric_limits<float>::max(), wrap_width,
ImFont_CalcTextSizeA(&out, font, submessage_font_size, std::numeric_limits<float>::max(), wrap_width,
notification.submessage2.c_str(), NULL, NULL);
submessage_height = out.y;

Expand Down Expand Up @@ -1453,11 +1454,11 @@ void retro_achievements_draw_notifications(float left, float top)
text_alpha *= easing;

ImDrawList_AddTextFontPtr(
ig, igGetFont(), 22.0f * easing,
ig, igGetFont(), title_font_size,
ImVec2{top_left.x + padding_adj + image_width + padding_adj, top_left.y + padding_adj},
0xffffff | ALPHA(text_alpha), notification.submessage.c_str(), NULL, wrap_width, NULL);
ImDrawList_AddTextFontPtr(
ig, igGetFont(), 18.0f * easing,
ig, igGetFont(), submessage_font_size,
ImVec2{top_left.x + padding_adj + image_width + padding_adj, top_left.y + padding_adj + title_height + padding_adj},
0xc0c0c0 | ALPHA(text_alpha), notification.submessage2.c_str(), NULL, wrap_width, NULL);
} else {
Expand All @@ -1469,11 +1470,11 @@ void retro_achievements_draw_notifications(float left, float top)
text_alpha = (255 * text_time) / text_half_time;
}
text_alpha *= easing;
ImFont_CalcTextSizeA(&out, font, 22.0f * easing, std::numeric_limits<float>::max(), wrap_width,
ImFont_CalcTextSizeA(&out, font, title_font_size, std::numeric_limits<float>::max(), wrap_width,
notification.title.c_str(), NULL, NULL);
title_height = out.y;
ImDrawList_AddTextFontPtr(ig, igGetFont(), 22.0f * easing,
ImVec2{top_left.x + padding_adj + image_width + padding_adj, top_left.y + image_height / 2 - title_height / 2},
ImDrawList_AddTextFontPtr(ig, igGetFont(), title_font_size,
ImVec2{top_left.x + padding_adj + image_width + padding_adj, top_left.y + + padding_adj},
0xffffff | ALPHA(text_alpha), notification.title.c_str(), NULL,
wrap_width, NULL);
}
Expand Down
2 changes: 1 addition & 1 deletion src/retro_achievements.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void retro_achievements_update_atlases();

void retro_achievements_keep_alive();

void retro_achievements_draw_notifications(float left, float top);
void retro_achievements_draw_notifications(float left, float top, float screen_width);

void retro_achievements_draw_progress_indicator(float right, float top);

Expand Down

0 comments on commit 879d438

Please sign in to comment.