From 44fb76ba90c768272507f4168a353b64ab53f2df Mon Sep 17 00:00:00 2001 From: Misa Date: Sat, 6 Jan 2024 15:45:40 -0800 Subject: [PATCH] Fix clash between timer and return editor text The "[Press {button} to return to editor]" and the "TIME:" text overlapped, which resulted in an ugly clash. To fix this, make the return editor text take priority over the timer text. This involves a minor refactor to first calculate whether or not we should draw the return editor text before we check if we should draw the timer text. --- desktop_version/src/Render.cpp | 42 +++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 2c082d58..3bb14946 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -2205,12 +2205,23 @@ void gamerender(void) } } + int return_editor_alpha = 0; + bool draw_return_editor_text = false; + if (map.custommode && !map.custommodeforreal && !game.advancetext) + { + return_editor_alpha = graphics.lerp( + ed.old_return_message_timer, ed.return_message_timer + ); + draw_return_editor_text = return_editor_alpha > 100; + } + if (graphics.fademode == FADE_NONE && !game.intimetrial && !game.isingamecompletescreen() && (!game.swnmode || game.swngame != SWN_SUPERGRAVITRON) && game.showingametimer - && !roomname_translator::enabled) + && !roomname_translator::enabled + && !draw_return_editor_text) { const char* tempstring = loc::gettext("TIME:"); int label_len = font::len(0, tempstring); @@ -2252,21 +2263,20 @@ void gamerender(void) } } - if(map.custommode && !map.custommodeforreal && !game.advancetext){ - //Return to level editor - int alpha = graphics.lerp(ed.old_return_message_timer, ed.return_message_timer); - - if (alpha > 100) - { - char buffer[SCREEN_WIDTH_CHARS + 1]; - vformat_buf( - buffer, sizeof(buffer), - loc::gettext("[Press {button} to return to editor]"), - "button:but", - vformat_button(ActionSet_InGame, Action_InGame_Map) - ); - font::print(PR_BRIGHTNESS(alpha) | PR_BOR, 5, 5, buffer, 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2)); - } + if (draw_return_editor_text) + { + char buffer[SCREEN_WIDTH_CHARS + 1]; + vformat_buf( + buffer, sizeof(buffer), + loc::gettext("[Press {button} to return to editor]"), + "button:but", + vformat_button(ActionSet_InGame, Action_InGame_Map) + ); + font::print( + PR_BRIGHTNESS(return_editor_alpha) | PR_BOR, + 5, 5, buffer, + 220 - (help.glow), 220 - (help.glow), 255 - (help.glow / 2) + ); } graphics.cutscenebars();