From 6d3ea6a485930c027488ea0f376a12e77aead4bd Mon Sep 17 00:00:00 2001 From: Arisotura Date: Thu, 24 Oct 2024 13:49:43 +0200 Subject: [PATCH] fix bug with the GBA addon menu (and make it a proper list so we don't have to hardcode the length all over) --- src/frontend/qt_sdl/Window.cpp | 27 +++++++++++++++------------ src/frontend/qt_sdl/Window.h | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index c267eb85..ecf7f771 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -311,14 +311,17 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : { QMenu* submenu = menu->addMenu("Insert add-on cart"); + QAction* act; - actInsertGBAAddon[0] = submenu->addAction("Memory expansion"); - actInsertGBAAddon[0]->setData(QVariant(GBAAddon_RAMExpansion)); - connect(actInsertGBAAddon[0], &QAction::triggered, this, &MainWindow::onInsertGBAAddon); + act = submenu->addAction("Memory expansion"); + act->setData(QVariant(GBAAddon_RAMExpansion)); + connect(act, &QAction::triggered, this, &MainWindow::onInsertGBAAddon); + actInsertGBAAddon.append(act); - actInsertGBAAddon[1] = submenu->addAction("Rumble Pak"); - actInsertGBAAddon[1]->setData(QVariant(GBAAddon_RumblePak)); - connect(actInsertGBAAddon[1], &QAction::triggered, this, &MainWindow::onInsertGBAAddon); + act = submenu->addAction("Rumble Pak"); + act->setData(QVariant(GBAAddon_RumblePak)); + connect(act, &QAction::triggered, this, &MainWindow::onInsertGBAAddon); + actInsertGBAAddon.append(act); } actEjectGBACart = menu->addAction("Eject cart"); @@ -673,8 +676,8 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : if (globalCfg.GetInt("Emu.ConsoleType") == 1) { actInsertGBACart->setEnabled(false); - for (int i = 0; i < 1; i++) - actInsertGBAAddon[i]->setEnabled(false); + for (auto act : actInsertGBAAddon) + act->setEnabled(false); } for (int i = 0; i < 9; i++) @@ -1700,15 +1703,15 @@ void MainWindow::onEmuSettingsDialogFinished(int res) if (globalCfg.GetInt("Emu.ConsoleType") == 1) { actInsertGBACart->setEnabled(false); - for (int i = 0; i < 1; i++) - actInsertGBAAddon[i]->setEnabled(false); + for (auto act : actInsertGBAAddon) + act->setEnabled(false); actEjectGBACart->setEnabled(false); } else { actInsertGBACart->setEnabled(true); - for (int i = 0; i < 1; i++) - actInsertGBAAddon[i]->setEnabled(true); + for (auto act : actInsertGBAAddon) + act->setEnabled(true); actEjectGBACart->setEnabled(emuInstance->gbaCartInserted()); } diff --git a/src/frontend/qt_sdl/Window.h b/src/frontend/qt_sdl/Window.h index 30d97b17..9125f76a 100644 --- a/src/frontend/qt_sdl/Window.h +++ b/src/frontend/qt_sdl/Window.h @@ -269,7 +269,7 @@ public: QAction* actEjectCart; QAction* actCurrentGBACart; QAction* actInsertGBACart; - QAction* actInsertGBAAddon[2]; + QList actInsertGBAAddon; QAction* actEjectGBACart; QAction* actImportSavefile; QAction* actSaveState[9];