From 135934289ec0114bff256f006cacabb18ec9b0aa Mon Sep 17 00:00:00 2001 From: Dav999 Date: Mon, 28 Aug 2023 03:19:57 +0200 Subject: [PATCH] Fix setfont() changing font of fading out text boxes Closes #925. My fix here is to delay the font change until all fading-out textboxes have disappeared. See it as adding a sort of `untilbars` or `untilfade` for text box fadeout, into setfont. This doesn't prevent every possible way to change the font of an existing textbox, but you would need to use internal scripting to still do it (and basically be doing it on purpose) - the problem in simplified scripting when you simply do textbox-setfont-textbox is gone. --- desktop_version/src/Script.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index d32a112c..297cd486 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -2416,13 +2416,29 @@ void scriptclass::run(void) } else if (words[0] == "setfont") { - if (words[1] == "") + // If any textbox is currently fading out, wait for that first + bool blocked = false; + for (size_t i = 0; i < graphics.textboxes.size(); i++) { - font::set_level_font(cl.level_font_name.c_str()); + if (graphics.textboxes[i].tm == 2) + { + scriptdelay = 1; + position--; + blocked = true; + break; + } } - else + + if (!blocked) { - font::set_level_font(raw_words[1].c_str()); + if (words[1] == "") + { + font::set_level_font(cl.level_font_name.c_str()); + } + else + { + font::set_level_font(raw_words[1].c_str()); + } } }