From 6cc07bffb9e92099f4e9ca4f8926daa49afcc6fa Mon Sep 17 00:00:00 2001 From: ALONSO Laurent Date: Thu, 16 Dec 2021 14:20:13 +0100 Subject: [PATCH] minimap[osx]: try to avoid "updating" the minimap when a dialog is opened... --- src/dialogxml/dialogs/dialog.cpp | 4 ++++ src/dialogxml/dialogs/dialog.hpp | 5 +++++ src/game/boe.infodlg.cpp | 4 +--- src/game/boe.minimap.cpp | 6 ++++++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/dialogxml/dialogs/dialog.cpp b/src/dialogxml/dialogs/dialog.cpp index 19416ac0..e311b69b 100644 --- a/src/dialogxml/dialogs/dialog.cpp +++ b/src/dialogxml/dialogs/dialog.cpp @@ -34,6 +34,7 @@ extern sf::RenderWindow mainPtr; const short cDialog::BG_DARK = 5, cDialog::BG_LIGHT = 16; short cDialog::defaultBackground = cDialog::BG_DARK; cDialog* cDialog::topWindow = nullptr; +bool cDialog::inDialog = false; std::string cDialog::generateRandomString(){ // Not bothering to seed, because it doesn't actually matter if it's truly random. @@ -493,6 +494,8 @@ bool cDialog::sendInput(cKey key) { void cDialog::run(std::function onopen){ cDialog* formerTop = topWindow; + bool formerInDialog = inDialog; + inDialog = true; // TODO: The introduction of the static topWindow means I may be able to use this instead of parent->win; do I still need parent? sf::RenderWindow* parentWin = &(parent ? parent->win : mainPtr); auto parentPos = parentWin->getPosition(); @@ -554,6 +557,7 @@ void cDialog::run(std::function onopen){ set_cursor(former_curs); topWindow = formerTop; makeFrontWindow(*parentWin); + inDialog = formerInDialog; } // This method is a main event event loop of the dialog. diff --git a/src/dialogxml/dialogs/dialog.hpp b/src/dialogxml/dialogs/dialog.hpp index c35f8844..8dd3df4a 100644 --- a/src/dialogxml/dialogs/dialog.hpp +++ b/src/dialogxml/dialogs/dialog.hpp @@ -49,6 +49,7 @@ class cDialog { template void handleTabOrder(std::string& itemHit, Iter begin, Iter end); std::vector> tabOrder; static cDialog* topWindow; // Tracks the frontmost dialog. + static bool inDialog; public: /// Performs essential startup initialization. Generally should not be called directly. static void init(); @@ -211,6 +212,10 @@ public: } return p; } + /// checks if a dialog is actually running + static bool checkIfDialogIsRunning() { + return inDialog; + } cDialog& operator=(cDialog& other) = delete; cDialog(cDialog& other) = delete; private: diff --git a/src/game/boe.infodlg.cpp b/src/game/boe.infodlg.cpp index 7af4a531..399f77fc 100644 --- a/src/game/boe.infodlg.cpp +++ b/src/game/boe.infodlg.cpp @@ -694,9 +694,7 @@ void cStringRecorder::operator()(cDialog& me) { break; case NOTE_TOWN: str1 = univ.town->get_special_string(label1); - if (label2>=univ.town->spec_strs.size()) - add_string_to_buf("cStringRecorder()[town]: empty label 2."); - else + if (label2spec_strs.size()) str2 = univ.town->spec_strs[label2]; break; case NOTE_OUT: diff --git a/src/game/boe.minimap.cpp b/src/game/boe.minimap.cpp index 6e800265..3e05d27f 100644 --- a/src/game/boe.minimap.cpp +++ b/src/game/boe.minimap.cpp @@ -10,6 +10,7 @@ #include #include "cursors.hpp" +#include "dialog.hpp" #include "gfxsheets.hpp" #include "pict.hpp" #include "prefs.hpp" @@ -108,6 +109,11 @@ void set_visible(bool vis) } void draw(bool need_refresh) { +#ifdef __APPLE__ + // can not be updated when a dialog is running + if (cDialog::checkIfDialogIsRunning()) + return; +#endif if (changed) { need_refresh=true; changed = false;