mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 05:17:40 -07:00
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
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:
parent
e42829ea81
commit
12b207d915
@ -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},
|
||||
|
@ -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<void(MainWindow*)> func, int excl
|
||||
}
|
||||
}
|
||||
|
||||
void EmuInstance::saveEnabledWindows()
|
||||
{
|
||||
doOnAllWindows([=](MainWindow* win)
|
||||
{
|
||||
win->saveEnabled(true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void EmuInstance::broadcastCommand(int cmd, QVariant param)
|
||||
{
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user