remember which windows are opened
Some checks are pending
macOS / ${{ matrix.arch }} (arm64) (push) Waiting to run
macOS / ${{ matrix.arch }} (x86_64) (push) Waiting to run
macOS / Universal binary (push) Blocked by required conditions
Ubuntu / x86_64 (push) Waiting to run
Ubuntu / aarch64 (push) Waiting to run
Windows / build (push) Waiting to run

This commit is contained in:
Arisotura 2024-10-27 18:49:17 +01:00
parent e42829ea81
commit 12b207d915
5 changed files with 48 additions and 9 deletions

View File

@ -99,7 +99,7 @@ DefaultList<bool> 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},

View File

@ -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;
if (id == -1)
{
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<void(MainWindow*)> func, int excl
}
}
void EmuInstance::saveEnabledWindows()
{
doOnAllWindows([=](MainWindow* win)
{
win->saveEnabled(true);
});
}
void EmuInstance::broadcastCommand(int cmd, QVariant param)
{

View File

@ -91,6 +91,7 @@ public:
MainWindow* getWindow(int id) { return windowList[id]; }
void doOnAllWindows(std::function<void(MainWindow*)> 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();

View File

@ -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());

View File

@ -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;