From 689d6e3e97073330803330364b12dbcda474f80c Mon Sep 17 00:00:00 2001 From: Dav999-v Date: Fri, 13 Jan 2023 20:32:05 +0100 Subject: [PATCH] Print activity zone text in correct font, remove Graphics::drawtextbox Activity zones need to be in the interface font if the message is from the system (like Press ENTER to activate terminal, which may be in a different language) and in the level font if it's a customized message (setactivitytext). Graphics::drawtextbox was counting the textbox width and height in 8x8 characters, even including the borders as characters, so it'd need to be told what the font for the textbox is, and then probably only the height needs to be adapted to the font and not the width because that's adapted to the screen width... So just call Graphics::drawpixeltextbox directly instead. It was already weird enough how actual cutscene textboxes called Graphics::drawtextbox with x/8, y/8 before the previous commit, (when you already have the pixel width and height!) only to have that be a wrapper for drawpixeltextbox by doing x*8, y*8. --- desktop_version/src/BlockV.cpp | 8 ++++++-- desktop_version/src/BlockV.h | 2 ++ desktop_version/src/Entity.cpp | 6 ++++++ desktop_version/src/Game.h | 1 + desktop_version/src/Graphics.cpp | 12 ------------ desktop_version/src/Graphics.h | 2 -- desktop_version/src/Logic.cpp | 1 + desktop_version/src/Render.cpp | 14 +++++++------- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/desktop_version/src/BlockV.cpp b/desktop_version/src/BlockV.cpp index 43f240a1..b88c5fa6 100644 --- a/desktop_version/src/BlockV.cpp +++ b/desktop_version/src/BlockV.cpp @@ -2,6 +2,8 @@ #include +#include "Font.h" + blockclass::blockclass(void) { clear(); @@ -28,10 +30,12 @@ void blockclass::clear(void) activity_x = 0; activity_y = 0; - /* std::strings get initialized automatically, but this is */ - /* in case this function gets called again after construction */ + /* std::strings get initialized automatically, but this is + * in case this function gets called again after construction */ script.clear(); prompt.clear(); + + print_flags = PR_FONT_INTERFACE; } void blockclass::rectset(const int xi, const int yi, const int wi, const int hi) diff --git a/desktop_version/src/BlockV.h b/desktop_version/src/BlockV.h index 3c4c3151..58ecb419 100644 --- a/desktop_version/src/BlockV.h +++ b/desktop_version/src/BlockV.h @@ -2,6 +2,7 @@ #define BLOCKV_H #include +#include #include class blockclass @@ -22,6 +23,7 @@ public: std::string script, prompt; int r, g, b; int activity_x, activity_y; + uint32_t print_flags; }; #endif /* BLOCKV_H */ diff --git a/desktop_version/src/Entity.cpp b/desktop_version/src/Entity.cpp index 9928e2af..acd84ccc 100644 --- a/desktop_version/src/Entity.cpp +++ b/desktop_version/src/Entity.cpp @@ -4,6 +4,7 @@ #include #include "CustomLevels.h" +#include "Font.h" #include "Game.h" #include "GlitchrunnerMode.h" #include "Graphics.h" @@ -1087,8 +1088,13 @@ void entityclass::createblock( int t, int xp, int yp, int w, int h, int trig /*= if (customactivitytext != "") { block.prompt = customactivitytext; + block.print_flags = PR_FONT_LEVEL; customactivitytext = ""; } + else + { + block.print_flags = PR_FONT_INTERFACE; + } if (customactivitycolour != "") { diff --git a/desktop_version/src/Game.h b/desktop_version/src/Game.h index a93ed3e0..7a789441 100644 --- a/desktop_version/src/Game.h +++ b/desktop_version/src/Game.h @@ -429,6 +429,7 @@ public: int oldreadytotele; int activity_r, activity_g, activity_b, activity_x, activity_y; std::string activity_lastprompt; + uint32_t activity_print_flags; std::string telesummary, quicksummary, customquicksummary; bool save_exists(void); diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index e47656fa..7ea2dace 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -1334,18 +1334,6 @@ void Graphics::drawpixeltextbox( drawcoloredtile(x + w - 8, y + h - 8, 47, r, g, b); } -void Graphics::drawtextbox( - const int x, - const int y, - const int w, - const int h, - const int r, - const int g, - const int b -) { - return drawpixeltextbox(x, y, w*8, 16 + (h-2)*font::height(PR_FONT_LEVEL), r, g, b); -} - void Graphics::textboxactive(void) { //Remove all but the most recent textbox diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index 715d7e22..5b692b28 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -125,8 +125,6 @@ public: void textboxactive(void); - void drawtextbox(int x, int y, int w, int h, int r, int g, int b); - void drawpixeltextbox(int x, int y, int w, int h, int r, int g, int b); void drawcrewman(int x, int y, int t, bool act, bool noshift =false); diff --git a/desktop_version/src/Logic.cpp b/desktop_version/src/Logic.cpp index a2545729..5cf608b9 100644 --- a/desktop_version/src/Logic.cpp +++ b/desktop_version/src/Logic.cpp @@ -1427,6 +1427,7 @@ void gamelogic(void) && INBOUNDS_VEC(game.activeactivity, obj.blocks)) { game.activity_lastprompt = obj.blocks[game.activeactivity].prompt; + game.activity_print_flags = obj.blocks[game.activeactivity].print_flags; game.activity_r = obj.blocks[game.activeactivity].r; game.activity_g = obj.blocks[game.activeactivity].g; game.activity_b = obj.blocks[game.activeactivity].b; diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 72cc13d8..7269645c 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -2213,12 +2213,12 @@ void gamerender(void) game.activity_lastprompt.c_str() ); - int centered_x = ((160 ) - ((graphics.len(final_string)) / 2)); + int centered_x = ((160 ) - ((font::len(game.activity_print_flags, final_string)) / 2)); if (game.activity_r == 0 && game.activity_g == 0 && game.activity_b == 0) { font::print( - PR_COLORGLYPH_BRI(act_alpha*255), + game.activity_print_flags | PR_COLORGLYPH_BRI(act_alpha*255), centered_x + game.activity_x, game.activity_y + 12, final_string, @@ -2229,17 +2229,17 @@ void gamerender(void) } else { - graphics.drawtextbox( + graphics.drawpixeltextbox( game.activity_x + 4, game.activity_y + 4, - 39, - 3, + 39*8, + 16 + font::height(game.activity_print_flags), game.activity_r*act_alpha, game.activity_g*act_alpha, game.activity_b*act_alpha ); font::print( - PR_COLORGLYPH_BRI(act_alpha*255) | PR_CJK_LOW, + game.activity_print_flags | PR_COLORGLYPH_BRI(act_alpha*255) | PR_CJK_LOW, centered_x + game.activity_x, game.activity_y + 12, final_string, @@ -2431,7 +2431,7 @@ void maprender(void) graphics.fill_rect(0, 12, 320, 240, 10, 24, 26 ); //Menubar: - graphics.drawtextbox( -10, 212, 43, 3, 65, 185, 207); + graphics.drawpixeltextbox( -10, 212, 43*8, 16 + font::height(PR_FONT_INTERFACE), 65, 185, 207); // Draw the selected page name at the bottom // menupage 0 - 3 is the pause screen