From 2533e144b648e45e7afdd0fcd2da0f81629e9366 Mon Sep 17 00:00:00 2001 From: Dav999 Date: Tue, 5 Dec 2023 04:00:47 +0100 Subject: [PATCH] Fix centering of game complete texts if level font != interface font Textboxes created with graphics.createtextboxflipme() use PR_FONT_LEVEL by default, but can be overridden with graphics.textboxprintflags() to, for example, set PR_FONT_INTERFACE. This happens for the textboxes on the Game Complete screen, which use interface text. The textboxes are centered by setting the X position to -1 though, which means they're solely centered based on the width of the first line, in the level font (because the font hasn't been changed to the interface font yet). Normally, this isn't a problem, because in the main game (where the Game Complete screen usually appears), the level font is always equal to the interface font. However, in custom levels you can still get it (by calling gamestate 3500) and in that case some of the text may be misaligned. This change fixes that by adding graphics.textboxcenterx() to these textboxes. As far as I can tell, these are the only textboxes that are centered by just x=-1 despite changing the font afterwards. --- desktop_version/src/Game.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 8a0e5194..8d5ea50e 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -2881,6 +2881,7 @@ void Game::updatestate(void) graphics.createtextboxflipme(loc::gettext("All Crew Members Rescued!"), -1, 64, TEXT_COLOUR("transparent")); graphics.textboxprintflags(PR_FONT_INTERFACE); + graphics.textboxcenterx(); char buffer[SCREEN_WIDTH_CHARS + 1]; timestringcenti(buffer, sizeof(buffer)); savetime = buffer; @@ -2956,11 +2957,13 @@ void Game::updatestate(void) ); graphics.createtextboxflipme(buffer, -1, 158, TEXT_COLOUR("transparent")); graphics.textboxprintflags(PR_FONT_INTERFACE); + graphics.textboxcenterx(); graphics.createtextboxflipme( loc::gettext_roomname(map.custommode, hardestroom_x, hardestroom_y, hardestroom.c_str(), hardestroom_specialname), -1, 170, TEXT_COLOUR("transparent") ); graphics.textboxprintflags(PR_FONT_INTERFACE); + graphics.textboxcenterx(); break; } case 3508: