remember which windows are opened
This commit is contained in:
parent
e42829ea81
commit
12b207d915
|
@ -99,7 +99,7 @@ DefaultList<bool> DefaultBools =
|
||||||
{"3D.Soft.Threaded", true},
|
{"3D.Soft.Threaded", true},
|
||||||
{"3D.GL.HiresCoordinates", true},
|
{"3D.GL.HiresCoordinates", true},
|
||||||
{"LimitFPS", true},
|
{"LimitFPS", true},
|
||||||
{"Window*.ShowOSD", true},
|
{"Instance*.Window*.ShowOSD", true},
|
||||||
{"Emu.DirectBoot", true},
|
{"Emu.DirectBoot", true},
|
||||||
{"Instance*.DS.Battery.LevelOkay", true},
|
{"Instance*.DS.Battery.LevelOkay", true},
|
||||||
{"Instance*.DSi.Battery.Charging", true},
|
{"Instance*.DSi.Battery.Charging", true},
|
||||||
|
|
|
@ -137,6 +137,16 @@ EmuInstance::EmuInstance(int inst) : deleting(false),
|
||||||
|
|
||||||
emuThread->start();
|
emuThread->start();
|
||||||
emuThread->emuPause();
|
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()
|
EmuInstance::~EmuInstance()
|
||||||
|
@ -173,7 +183,7 @@ std::string EmuInstance::instanceFileSuffix()
|
||||||
return suffix;
|
return suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmuInstance::createWindow()
|
void EmuInstance::createWindow(int id)
|
||||||
{
|
{
|
||||||
if (numWindows >= kMaxWindows)
|
if (numWindows >= kMaxWindows)
|
||||||
{
|
{
|
||||||
|
@ -181,16 +191,20 @@ void EmuInstance::createWindow()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = -1;
|
if (id == -1)
|
||||||
for (int i = 0; i < kMaxWindows; i++)
|
|
||||||
{
|
{
|
||||||
if (windowList[i]) continue;
|
for (int i = 0; i < kMaxWindows; i++)
|
||||||
id = i;
|
{
|
||||||
break;
|
if (windowList[i]) continue;
|
||||||
|
id = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (id == -1)
|
if (id == -1)
|
||||||
return;
|
return;
|
||||||
|
if (windowList[id])
|
||||||
|
return;
|
||||||
|
|
||||||
MainWindow* win = new MainWindow(id, this, topWindow);
|
MainWindow* win = new MainWindow(id, this, topWindow);
|
||||||
if (!topWindow) topWindow = win;
|
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)
|
void EmuInstance::broadcastCommand(int cmd, QVariant param)
|
||||||
{
|
{
|
||||||
|
|
|
@ -91,6 +91,7 @@ public:
|
||||||
MainWindow* getWindow(int id) { return windowList[id]; }
|
MainWindow* getWindow(int id) { return windowList[id]; }
|
||||||
|
|
||||||
void doOnAllWindows(std::function<void(MainWindow*)> func, int exclude = -1);
|
void doOnAllWindows(std::function<void(MainWindow*)> func, int exclude = -1);
|
||||||
|
void saveEnabledWindows();
|
||||||
|
|
||||||
Config::Table& getGlobalConfig() { return globalCfg; }
|
Config::Table& getGlobalConfig() { return globalCfg; }
|
||||||
Config::Table& getLocalConfig() { return localCfg; }
|
Config::Table& getLocalConfig() { return localCfg; }
|
||||||
|
@ -100,7 +101,7 @@ public:
|
||||||
|
|
||||||
std::string instanceFileSuffix();
|
std::string instanceFileSuffix();
|
||||||
|
|
||||||
void createWindow();
|
void createWindow(int id = -1);
|
||||||
void deleteWindow(int id, bool close);
|
void deleteWindow(int id, bool close);
|
||||||
void deleteAllWindows();
|
void deleteAllWindows();
|
||||||
|
|
||||||
|
|
|
@ -234,7 +234,8 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
||||||
globalCfg(inst->globalCfg),
|
globalCfg(inst->globalCfg),
|
||||||
localCfg(inst->localCfg),
|
localCfg(inst->localCfg),
|
||||||
windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0")),
|
windowCfg(localCfg.GetTable("Window"+std::to_string(id), "Window0")),
|
||||||
emuThread(inst->getEmuThread())
|
emuThread(inst->getEmuThread()),
|
||||||
|
enabledSaved(false)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if (!parent)
|
if (!parent)
|
||||||
|
@ -807,8 +808,20 @@ void MainWindow::osdAddMessage(unsigned int color, const char* msg)
|
||||||
panel->osdAddMessage(color, msg);
|
panel->osdAddMessage(color, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::saveEnabled(bool enabled)
|
||||||
|
{
|
||||||
|
if (enabledSaved) return;
|
||||||
|
windowCfg.SetBool("Enabled", enabled);
|
||||||
|
enabledSaved = true;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::closeEvent(QCloseEvent* event)
|
void MainWindow::closeEvent(QCloseEvent* event)
|
||||||
{
|
{
|
||||||
|
if (windowID == 0)
|
||||||
|
emuInstance->saveEnabledWindows();
|
||||||
|
else
|
||||||
|
saveEnabled(false);
|
||||||
|
|
||||||
QByteArray geom = saveGeometry();
|
QByteArray geom = saveGeometry();
|
||||||
QByteArray enc = geom.toBase64(QByteArray::Base64Encoding);
|
QByteArray enc = geom.toBase64(QByteArray::Base64Encoding);
|
||||||
windowCfg.SetString("Geometry", enc.toStdString());
|
windowCfg.SetString("Geometry", enc.toStdString());
|
||||||
|
|
|
@ -114,6 +114,8 @@ public:
|
||||||
|
|
||||||
bool winHasMenu() { return hasMenu; }
|
bool winHasMenu() { return hasMenu; }
|
||||||
|
|
||||||
|
void saveEnabled(bool enabled);
|
||||||
|
|
||||||
void toggleFullscreen();
|
void toggleFullscreen();
|
||||||
|
|
||||||
bool hasOpenGL() { return hasOGL; }
|
bool hasOpenGL() { return hasOGL; }
|
||||||
|
@ -260,6 +262,7 @@ private:
|
||||||
bool pausedManually;
|
bool pausedManually;
|
||||||
|
|
||||||
int windowID;
|
int windowID;
|
||||||
|
bool enabledSaved;
|
||||||
|
|
||||||
EmuInstance* emuInstance;
|
EmuInstance* emuInstance;
|
||||||
EmuThread* emuThread;
|
EmuThread* emuThread;
|
||||||
|
|
Loading…
Reference in New Issue