diff --git a/src/frontend/qt_sdl/Config.cpp b/src/frontend/qt_sdl/Config.cpp index 3f570302..02be5b65 100644 --- a/src/frontend/qt_sdl/Config.cpp +++ b/src/frontend/qt_sdl/Config.cpp @@ -99,7 +99,7 @@ DefaultList DefaultBools = {"3D.Soft.Threaded", true}, {"3D.GL.HiresCoordinates", true}, {"LimitFPS", true}, - {"Window*.ShowOSD", true}, + {"Instance*.Window*.ShowOSD", true}, {"Emu.DirectBoot", true}, {"Instance*.DS.Battery.LevelOkay", true}, {"Instance*.DSi.Battery.Charging", true}, diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index 12afb12b..90116692 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -137,6 +137,16 @@ EmuInstance::EmuInstance(int inst) : deleting(false), emuThread->start(); emuThread->emuPause(); + + // if any extra windows were saved as enabled, open them + for (int i = 1; i < kMaxWindows; i++) + { + //Config::Table tbl = localCfg.GetTable("Window"+std::to_string(i), "Window0"); + std::string key = "Window" + std::to_string(i) + ".Enabled"; + bool enable = localCfg.GetBool(key); + if (enable) + createWindow(i); + } } EmuInstance::~EmuInstance() @@ -173,7 +183,7 @@ std::string EmuInstance::instanceFileSuffix() return suffix; } -void EmuInstance::createWindow() +void EmuInstance::createWindow(int id) { if (numWindows >= kMaxWindows) { @@ -181,16 +191,20 @@ void EmuInstance::createWindow() return; } - int id = -1; - for (int i = 0; i < kMaxWindows; i++) + if (id == -1) { - if (windowList[i]) continue; - id = i; - break; + for (int i = 0; i < kMaxWindows; i++) + { + if (windowList[i]) continue; + id = i; + break; + } } if (id == -1) return; + if (windowList[id]) + return; MainWindow* win = new MainWindow(id, this, topWindow); if (!topWindow) topWindow = win; @@ -265,6 +279,14 @@ void EmuInstance::doOnAllWindows(std::function func, int excl } } +void EmuInstance::saveEnabledWindows() +{ + doOnAllWindows([=](MainWindow* win) + { + win->saveEnabled(true); + }); +} + void EmuInstance::broadcastCommand(int cmd, QVariant param) { diff --git a/src/frontend/qt_sdl/EmuInstance.h b/src/frontend/qt_sdl/EmuInstance.h index 0122b0d9..658247f0 100644 --- a/src/frontend/qt_sdl/EmuInstance.h +++ b/src/frontend/qt_sdl/EmuInstance.h @@ -91,6 +91,7 @@ public: MainWindow* getWindow(int id) { return windowList[id]; } void doOnAllWindows(std::function func, int exclude = -1); + void saveEnabledWindows(); Config::Table& getGlobalConfig() { return globalCfg; } Config::Table& getLocalConfig() { return localCfg; } @@ -100,7 +101,7 @@ public: std::string instanceFileSuffix(); - void createWindow(); + void createWindow(int id = -1); void deleteWindow(int id, bool close); void deleteAllWindows(); diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index b09f8354..2354fa20 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -234,7 +234,8 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : globalCfg(inst->globalCfg), localCfg(inst->localCfg), windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0")), - emuThread(inst->getEmuThread()) + emuThread(inst->getEmuThread()), + enabledSaved(false) { #ifndef _WIN32 if (!parent) @@ -807,8 +808,20 @@ void MainWindow::osdAddMessage(unsigned int color, const char* msg) panel->osdAddMessage(color, msg); } +void MainWindow::saveEnabled(bool enabled) +{ + if (enabledSaved) return; + windowCfg.SetBool("Enabled", enabled); + enabledSaved = true; +} + void MainWindow::closeEvent(QCloseEvent* event) { + if (windowID == 0) + emuInstance->saveEnabledWindows(); + else + saveEnabled(false); + QByteArray geom = saveGeometry(); QByteArray enc = geom.toBase64(QByteArray::Base64Encoding); windowCfg.SetString("Geometry", enc.toStdString()); diff --git a/src/frontend/qt_sdl/Window.h b/src/frontend/qt_sdl/Window.h index 64f17841..121115c0 100644 --- a/src/frontend/qt_sdl/Window.h +++ b/src/frontend/qt_sdl/Window.h @@ -114,6 +114,8 @@ public: bool winHasMenu() { return hasMenu; } + void saveEnabled(bool enabled); + void toggleFullscreen(); bool hasOpenGL() { return hasOGL; } @@ -260,6 +262,7 @@ private: bool pausedManually; int windowID; + bool enabledSaved; EmuInstance* emuInstance; EmuThread* emuThread;