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.
This commit is contained in:
Misa 2024-01-06 15:45:40 -08:00
parent f4bdea7d6d
commit 44fb76ba90
1 changed files with 26 additions and 16 deletions

View File

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