diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index edb6c559e3..c4c003fbbc 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -1972,25 +1972,36 @@ bool EmuInstance::gbaCartInserted() return gbaCartType != -1; } +QString EmuInstance::gbaAddonName(int addon) +{ + switch (addon) + { + case GBAAddon_RumblePak: + return "Rumble Pak"; + case GBAAddon_RAMExpansion: + return "Memory expansion"; + } + + return "???"; +} + QString EmuInstance::gbaCartLabel() { if (consoleType == 1) return "none (DSi)"; - switch (gbaCartType) + if (gbaCartType == 0) { - case 0: - { - QString ret = QString::fromStdString(baseGBAROMName); - - int maxlen = 32; - if (ret.length() > maxlen) - ret = ret.left(maxlen-6) + "..." + ret.right(3); + QString ret = QString::fromStdString(baseGBAROMName); - return ret; - } + int maxlen = 32; + if (ret.length() > maxlen) + ret = ret.left(maxlen-6) + "..." + ret.right(3); - case GBAAddon_RAMExpansion: - return "Memory expansion"; + return ret; + } + else if (gbaCartType != -1) + { + return gbaAddonName(gbaCartType); } return "(none)"; diff --git a/src/frontend/qt_sdl/EmuInstance.h b/src/frontend/qt_sdl/EmuInstance.h index 04290f5664..9e0659e0ec 100644 --- a/src/frontend/qt_sdl/EmuInstance.h +++ b/src/frontend/qt_sdl/EmuInstance.h @@ -186,6 +186,7 @@ class EmuInstance void loadGBAAddon(int type); void ejectGBACart(); bool gbaCartInserted(); + QString gbaAddonName(int addon); QString gbaCartLabel(); void audioInit(); diff --git a/src/frontend/qt_sdl/EmuThread.cpp b/src/frontend/qt_sdl/EmuThread.cpp index 7c3e1a9176..c3668fe3e1 100644 --- a/src/frontend/qt_sdl/EmuThread.cpp +++ b/src/frontend/qt_sdl/EmuThread.cpp @@ -623,7 +623,7 @@ void EmuThread::handleMessages() break; case msg_EjectGBACart: - emuInstance->ejectCart(); + emuInstance->ejectGBACart(); break; } diff --git a/src/frontend/qt_sdl/Window.cpp b/src/frontend/qt_sdl/Window.cpp index ecf7f77136..ce900cbb82 100644 --- a/src/frontend/qt_sdl/Window.cpp +++ b/src/frontend/qt_sdl/Window.cpp @@ -313,15 +313,15 @@ MainWindow::MainWindow(int id, EmuInstance* inst, QWidget* parent) : QMenu* submenu = menu->addMenu("Insert add-on cart"); QAction* act; - act = submenu->addAction("Memory expansion"); - act->setData(QVariant(GBAAddon_RAMExpansion)); - connect(act, &QAction::triggered, this, &MainWindow::onInsertGBAAddon); - actInsertGBAAddon.append(act); - - act = submenu->addAction("Rumble Pak"); - act->setData(QVariant(GBAAddon_RumblePak)); - connect(act, &QAction::triggered, this, &MainWindow::onInsertGBAAddon); - actInsertGBAAddon.append(act); + int addons[] = {GBAAddon_RAMExpansion, GBAAddon_RumblePak, -1}; + for (int i = 0; addons[i] != -1; i++) + { + int addon = addons[i]; + act = submenu->addAction(emuInstance->gbaAddonName(addon)); + act->setData(QVariant(addon)); + connect(act, &QAction::triggered, this, &MainWindow::onInsertGBAAddon); + actInsertGBAAddon.append(act); + } } actEjectGBACart = menu->addAction("Eject cart");