check for ui initialization without game-only global var

This commit is contained in:
2024-06-12 12:51:03 -06:00
parent a45b34ec42
commit fa3d092dc9
3 changed files with 6 additions and 3 deletions

View File

@@ -460,11 +460,14 @@ void cDialog::recalcRect(){
winRect.bottom *= ui_scale(); winRect.bottom *= ui_scale();
} }
bool cDialog::initCalled = false;
void cDialog::init(){ void cDialog::init(){
cButton::init(); cButton::init();
cLed::init(); cLed::init();
cPict::init(); cPict::init();
cScrollbar::init(); cScrollbar::init();
initCalled = true;
} }
cDialog::~cDialog(){ cDialog::~cDialog(){

View File

@@ -69,10 +69,12 @@ class cDialog {
template<typename Iter> void handleTabOrder(std::string& itemHit, Iter begin, Iter end); template<typename Iter> void handleTabOrder(std::string& itemHit, Iter begin, Iter end);
std::vector<std::pair<std::string,cTextField*>> tabOrder; std::vector<std::pair<std::string,cTextField*>> tabOrder;
static cDialog* topWindow; // Tracks the frontmost dialog. static cDialog* topWindow; // Tracks the frontmost dialog.
static bool initCalled;
public: public:
static void (*redraw_everything)(); static void (*redraw_everything)();
/// Performs essential startup initialization. Generally should not be called directly. /// Performs essential startup initialization. Generally should not be called directly.
static void init(); static void init();
static bool wasInitCalled() { return initCalled; };
/// The light background pattern used by the scenario editor dialogs. /// The light background pattern used by the scenario editor dialogs.
static const short BG_LIGHT, BG_DARK; ///< The dark background pattern used by the game dialogs. static const short BG_LIGHT, BG_DARK; ///< The dark background pattern used by the game dialogs.
/// The default background pattern for newly created dialogs. /// The default background pattern for newly created dialogs.

View File

@@ -75,11 +75,9 @@ void cStrDlog::show(){
dlg.run(); dlg.run();
} }
extern bool finished_init;
static void giveError(pic_num_t pic, std::string title, std::string str1, std::string str2, cDialog* parent) { static void giveError(pic_num_t pic, std::string title, std::string str1, std::string str2, cDialog* parent) {
// If giveError() is called before UI is initialized, print to console // If giveError() is called before UI is initialized, print to console
if (!finished_init) { if (!cDialog::wasInitCalled()) {
std::cout << title << std::endl << str1 << std::endl << str2 << std::endl; std::cout << title << std::endl << str1 << std::endl << str2 << std::endl;
return; return;
} }