mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 13:27:41 -07:00
properly sync up menus between windows of a same instance
This commit is contained in:
parent
94955aee81
commit
d79d45a117
@ -240,6 +240,17 @@ void EmuInstance::deleteAllWindows()
|
|||||||
deleteWindow(i, true);
|
deleteWindow(i, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EmuInstance::doOnAllWindows(std::function<void(MainWindow*)> func, int exclude)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < kMaxWindows; i++)
|
||||||
|
{
|
||||||
|
if (i == exclude) continue;
|
||||||
|
if (!windowList[i]) continue;
|
||||||
|
|
||||||
|
func(windowList[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EmuInstance::broadcastCommand(int cmd, QVariant param)
|
void EmuInstance::broadcastCommand(int cmd, QVariant param)
|
||||||
{
|
{
|
||||||
|
@ -89,6 +89,8 @@ public:
|
|||||||
MainWindow* getMainWindow() { return mainWindow; }
|
MainWindow* getMainWindow() { return mainWindow; }
|
||||||
MainWindow* getWindow(int id) { return windowList[id]; }
|
MainWindow* getWindow(int id) { return windowList[id]; }
|
||||||
|
|
||||||
|
void doOnAllWindows(std::function<void(MainWindow*)> func, int exclude = -1);
|
||||||
|
|
||||||
Config::Table& getGlobalConfig() { return globalCfg; }
|
Config::Table& getGlobalConfig() { return globalCfg; }
|
||||||
Config::Table& getLocalConfig() { return localCfg; }
|
Config::Table& getLocalConfig() { return localCfg; }
|
||||||
|
|
||||||
|
@ -781,6 +781,9 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) :
|
|||||||
actPreferences->setEnabled(false);
|
actPreferences->setEnabled(false);
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (emuThread->emuIsActive())
|
||||||
|
onEmuStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(qApp, &QApplication::applicationStateChanged, this, &MainWindow::onAppStateChanged);
|
QObject::connect(qApp, &QApplication::applicationStateChanged, this, &MainWindow::onAppStateChanged);
|
||||||
@ -1226,21 +1229,34 @@ QStringList MainWindow::pickROM(bool gba)
|
|||||||
void MainWindow::updateCartInserted(bool gba)
|
void MainWindow::updateCartInserted(bool gba)
|
||||||
{
|
{
|
||||||
bool inserted;
|
bool inserted;
|
||||||
|
QString label;
|
||||||
if (gba)
|
if (gba)
|
||||||
{
|
{
|
||||||
inserted = emuInstance->gbaCartInserted() && (globalCfg.GetInt("Emu.ConsoleType") == 0);
|
inserted = emuInstance->gbaCartInserted() && (emuInstance->getConsoleType() == 0);
|
||||||
actCurrentGBACart->setText("GBA slot: " + emuInstance->gbaCartLabel());
|
label = "GBA slot: " + emuInstance->gbaCartLabel();
|
||||||
actEjectGBACart->setEnabled(inserted);
|
|
||||||
|
emuInstance->doOnAllWindows([=](MainWindow* win)
|
||||||
|
{
|
||||||
|
if (!win->hasMenu) return;
|
||||||
|
win->actCurrentGBACart->setText(label);
|
||||||
|
win->actEjectGBACart->setEnabled(inserted);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
inserted = emuInstance->cartInserted();
|
inserted = emuInstance->cartInserted();
|
||||||
actCurrentCart->setText("DS slot: " + emuInstance->cartLabel());
|
label = "DS slot: " + emuInstance->cartLabel();
|
||||||
actEjectCart->setEnabled(inserted);
|
|
||||||
actImportSavefile->setEnabled(inserted);
|
emuInstance->doOnAllWindows([=](MainWindow* win)
|
||||||
actSetupCheats->setEnabled(inserted);
|
{
|
||||||
actROMInfo->setEnabled(inserted);
|
if (!win->hasMenu) return;
|
||||||
actRAMInfo->setEnabled(inserted);
|
win->actCurrentCart->setText(label);
|
||||||
|
win->actEjectCart->setEnabled(inserted);
|
||||||
|
win->actImportSavefile->setEnabled(inserted);
|
||||||
|
win->actSetupCheats->setEnabled(inserted);
|
||||||
|
win->actROMInfo->setEnabled(inserted);
|
||||||
|
win->actRAMInfo->setEnabled(inserted);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user