From 76483f96efc60577fdc0e2b44a5d41c0c4c11e30 Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 21 Jan 2024 11:04:00 -0800 Subject: [PATCH] Move Comms Relay text boxes to new system These seemed annoying to do without copy-pasting, because I didn't want to make a separate function for every single dialogue, and I didn't know how to pass through the English text, until I realized that I can just use the existing original.lines vector in the text box to store the English text. After that, getting it translated on-the-fly isn't too bad. --- desktop_version/src/Game.cpp | 28 ++++++++++++++-------------- desktop_version/src/Graphics.cpp | 20 +++++++++++++++++--- desktop_version/src/Graphics.h | 2 +- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 37ee6979..c2c48587 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -1632,56 +1632,56 @@ void Game::updatestate(void) case 50: music.playef(Sound_VIOLET); - graphics.createtextbox(loc::gettext("Help! Can anyone hear this message?"), 5, 8, TEXT_COLOUR("purple")); - graphics.textboxcommsrelay(); + graphics.createtextbox("", 5, 8, TEXT_COLOUR("purple")); + graphics.textboxcommsrelay("Help! Can anyone hear this message?"); graphics.textboxtimer(60); incstate(); setstatedelay(100); break; case 51: music.playef(Sound_VIOLET); - graphics.createtextbox(loc::gettext("Verdigris? Are you out there? Are you ok?"), 5, 8, TEXT_COLOUR("purple")); - graphics.textboxcommsrelay(); + graphics.createtextbox("", 5, 8, TEXT_COLOUR("purple")); + graphics.textboxcommsrelay("Verdigris? Are you out there? Are you ok?"); graphics.textboxtimer(60); incstate(); setstatedelay(100); break; case 52: music.playef(Sound_VIOLET); - graphics.createtextbox(loc::gettext("Please help us! We've crashed and need assistance!"), 5, 8, TEXT_COLOUR("purple")); - graphics.textboxcommsrelay(); + graphics.createtextbox("", 5, 8, TEXT_COLOUR("purple")); + graphics.textboxcommsrelay("Please help us! We've crashed and need assistance!"); graphics.textboxtimer(60); incstate(); setstatedelay(100); break; case 53: music.playef(Sound_VIOLET); - graphics.createtextbox(loc::gettext("Hello? Anyone out there?"), 5, 8, TEXT_COLOUR("purple")); - graphics.textboxcommsrelay(); + graphics.createtextbox("", 5, 8, TEXT_COLOUR("purple")); + graphics.textboxcommsrelay("Hello? Anyone out there?"); graphics.textboxtimer(60); incstate(); setstatedelay(100); break; case 54: music.playef(Sound_VIOLET); - graphics.createtextbox(loc::gettext("This is Doctor Violet from the D.S.S. Souleye! Please respond!"), 5, 8, TEXT_COLOUR("purple")); - graphics.textboxcommsrelay(); + graphics.createtextbox("", 5, 8, TEXT_COLOUR("purple")); + graphics.textboxcommsrelay("This is Doctor Violet from the D.S.S. Souleye! Please respond!"); graphics.textboxtimer(60); incstate(); setstatedelay(100); break; case 55: music.playef(Sound_VIOLET); - graphics.createtextbox(loc::gettext("Please... Anyone..."), 5, 8, TEXT_COLOUR("purple")); - graphics.textboxcommsrelay(); + graphics.createtextbox("", 5, 8, TEXT_COLOUR("purple")); + graphics.textboxcommsrelay("Please... Anyone..."); graphics.textboxtimer(60); incstate(); setstatedelay(100); break; case 56: music.playef(Sound_VIOLET); - graphics.createtextbox(loc::gettext("Please be alright, everyone..."), 5, 8, TEXT_COLOUR("purple")); - graphics.textboxcommsrelay(); + graphics.createtextbox("", 5, 8, TEXT_COLOUR("purple")); + graphics.textboxcommsrelay("Please be alright, everyone..."); graphics.textboxtimer(60); setstate(50); setstatedelay(100); diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 8453115e..6bf079c6 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -3367,7 +3367,21 @@ void Graphics::textboxtranslate(const TextboxTranslate translate, const TextboxF textboxes[m].updatetext(); } -void Graphics::textboxcommsrelay(void) +static void commsrelay_textbox(textboxclass* THIS) +{ + THIS->lines.clear(); + + if (THIS->original.lines.empty()) + { + return; + } + THIS->lines.push_back(loc::gettext(THIS->original.lines[0].c_str())); + THIS->wrap(11); + THIS->resize(); + THIS->xp = 224 - THIS->w; +} + +void Graphics::textboxcommsrelay(const char* text) { // Special treatment for the gamestate textboxes in Comms Relay if (!INBOUNDS_VEC(m, textboxes)) @@ -3376,8 +3390,8 @@ void Graphics::textboxcommsrelay(void) return; } textboxprintflags(PR_FONT_INTERFACE); - textboxwrap(11); - textboxes[m].xp = 224 - textboxes[m].w; + textboxes[m].original.lines.push_back(text); + textboxtranslate(TEXTTRANSLATE_FUNCTION, commsrelay_textbox); } int Graphics::crewcolour(const int t) diff --git a/desktop_version/src/Graphics.h b/desktop_version/src/Graphics.h index b7187396..f000de40 100644 --- a/desktop_version/src/Graphics.h +++ b/desktop_version/src/Graphics.h @@ -123,7 +123,7 @@ public: void textboxtranslate(TextboxTranslate translate, TextboxFunction function); - void textboxcommsrelay(void); + void textboxcommsrelay(const char* text); void textboxapplyposition(void);