From 103b4d36a1aafba1480fe96e5c78d89a3c1209d1 Mon Sep 17 00:00:00 2001 From: AllyTally Date: Sun, 20 Aug 2023 14:11:44 -0300 Subject: [PATCH] Add `textimage` for `levelcomplete` and `gamecomplete` `levelcomplete` and `gamecomplete` were hardcoded using textbox colors which were offset by 1. This PR fixes that, no longer requiring slightly-off colors, and instead adding a new property to textboxes which tell the game to display either level complete or game complete. --- desktop_version/src/Game.cpp | 6 ++++-- desktop_version/src/Graphics.cpp | 15 +++++++++++++-- desktop_version/src/Graphics.h | 2 ++ desktop_version/src/Script.cpp | 19 +++++++++++++++++++ desktop_version/src/Script.h | 1 + desktop_version/src/Textbox.cpp | 7 +++++++ desktop_version/src/Textbox.h | 10 ++++++++++ 7 files changed, 56 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 1c82f568..e97fabf4 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -663,12 +663,13 @@ void Game::savecustomlevelstats(void) void Game::levelcomplete_textbox(void) { - graphics.createtextboxflipme("", -1, 12, 165, 165, 255); + graphics.createtextboxflipme("", -1, 12, TEXT_COLOUR("cyan")); graphics.addline(" "); graphics.addline(""); graphics.addline(""); graphics.textboxprintflags(PR_FONT_8X8); graphics.textboxcenterx(); + graphics.setimage(TEXTIMAGE_LEVELCOMPLETE); } void Game::crewmate_textbox(const int color) @@ -2861,12 +2862,13 @@ void Game::updatestate(void) setstatedelay(75); music.play(Music_PLENARY); - graphics.createtextboxflipme("", -1, 12, 164, 165, 255); + graphics.createtextboxflipme("", -1, 12, TEXT_COLOUR("cyan")); graphics.addline(" "); graphics.addline(""); graphics.addline(""); graphics.textboxprintflags(PR_FONT_8X8); graphics.textboxcenterx(); + graphics.setimage(TEXTIMAGE_GAMECOMPLETE); break; case 3502: { diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 0d0b8ff9..b49bc2af 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -944,7 +944,7 @@ void Graphics::drawgui(void) continue; } - if (textboxes[i].yp == 12 && textboxes[i].r == 165) + if (textboxes[i].image == TEXTIMAGE_LEVELCOMPLETE) { // Level complete const char* english = "Level Complete!"; @@ -981,7 +981,7 @@ void Graphics::drawgui(void) } } } - else if (textboxes[i].yp == 12 && textboxes[i].g == 165) + else if (textboxes[i].image == TEXTIMAGE_GAMECOMPLETE) { // Game complete const char* english = "Game Complete!"; @@ -1430,6 +1430,17 @@ void Graphics::addsprite(int x, int y, int tile, int col) textboxes[m].addsprite(x, y, tile, col); } +void Graphics::setimage(TextboxImage image) +{ + if (!INBOUNDS_VEC(m, textboxes)) + { + vlog_error("setimage() out-of-bounds!"); + return; + } + + textboxes[m].setimage(image); +} + void Graphics::addline( const std::string& t ) { if (!INBOUNDS_VEC(m, textboxes)) diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index ce748552..8383678a 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -124,6 +124,8 @@ public: void addsprite(int x, int y, int tile, int col); + void setimage(TextboxImage image); + void textboxremove(void); void textboxremovefast(void); diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 260144da..cd593d1b 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -54,6 +54,7 @@ scriptclass::scriptclass(void) textbuttons = false; textlarge = false; textbox_sprites.clear(); + textbox_image = TEXTIMAGE_NONE; } void scriptclass::add_default_colours(void) @@ -530,6 +531,7 @@ void scriptclass::run(void) textpadtowidth = 0; textboxtimer = 0; textbox_sprites.clear(); + textbox_image = TEXTIMAGE_NONE; translate_dialogue(); } @@ -709,6 +711,21 @@ void scriptclass::run(void) sprite.col = ss_toi(words[4]); textbox_sprites.push_back(sprite); } + else if (words[0] == "textimage") + { + if (words[1] == "levelcomplete") + { + textbox_image = TEXTIMAGE_LEVELCOMPLETE; + } + else if (words[1] == "gamecomplete") + { + textbox_image = TEXTIMAGE_GAMECOMPLETE; + } + else + { + textbox_image = TEXTIMAGE_NONE; + } + } else if (words[0] == "flipme") { textflipme = !textflipme; @@ -745,6 +762,8 @@ void scriptclass::run(void) graphics.addsprite(textbox_sprites[i].x, textbox_sprites[i].y, textbox_sprites[i].tile, textbox_sprites[i].col); } + graphics.setimage(textbox_image); + // Some textbox formatting that can be set by translations... if (textcentertext) { diff --git a/desktop_version/src/Script.h b/desktop_version/src/Script.h index 6bc19715..bf9f8d97 100644 --- a/desktop_version/src/Script.h +++ b/desktop_version/src/Script.h @@ -125,6 +125,7 @@ public: bool textlarge; int textboxtimer; std::vector textbox_sprites; + TextboxImage textbox_image; //Misc int i, j, k; diff --git a/desktop_version/src/Textbox.cpp b/desktop_version/src/Textbox.cpp index 1546b425..a538f35f 100644 --- a/desktop_version/src/Textbox.cpp +++ b/desktop_version/src/Textbox.cpp @@ -30,6 +30,8 @@ textboxclass::textboxclass(void) fill_buttons = false; sprites.clear(); + + image = TEXTIMAGE_NONE; } void textboxclass::addsprite(int x, int y, int tile, int col) @@ -42,6 +44,11 @@ void textboxclass::addsprite(int x, int y, int tile, int col) sprites.push_back(sprite); } +void textboxclass::setimage(TextboxImage new_image) +{ + image = new_image; +} + void textboxclass::centerx(void) { resize(); diff --git a/desktop_version/src/Textbox.h b/desktop_version/src/Textbox.h index 92da145d..4f4a927e 100644 --- a/desktop_version/src/Textbox.h +++ b/desktop_version/src/Textbox.h @@ -13,6 +13,13 @@ struct TextboxSprite int tile; }; +enum TextboxImage +{ + TEXTIMAGE_NONE, + TEXTIMAGE_LEVELCOMPLETE, + TEXTIMAGE_GAMECOMPLETE +}; + class textboxclass { public: @@ -20,6 +27,8 @@ public: void addsprite(int x, int y, int tile, int col); + void setimage(TextboxImage image); + void centerx(void); void centery(void); @@ -65,6 +74,7 @@ public: bool fill_buttons; std::vector sprites; + TextboxImage image; }; #endif /* TEXTBOX_H */