all repos — mgba @ 5b710a59fa407f8bba20100c008510f717597746

mGBA Game Boy Advance Emulator

Qt: Clean up cheats
Jeffrey Pfau jeffrey@endrift.com
Mon, 05 Sep 2016 10:01:12 -0700
commit

5b710a59fa407f8bba20100c008510f717597746

parent

69244f053af7f9f79c0cb9af3e2ab8e0aa3ecee4

3 files changed, 91 insertions(+), 73 deletions(-)

jump to
M src/gb/cheats.hsrc/gb/cheats.h

@@ -11,7 +11,7 @@

#include "core/cheats.h" #include "util/vector.h" -enum GBACheatType { +enum GBCheatType { GB_CHEAT_AUTODETECT, GB_CHEAT_GAMESHARK, GB_CHEAT_GAME_GENIE,
M src/platform/qt/CheatsView.cppsrc/platform/qt/CheatsView.cpp

@@ -9,11 +9,15 @@ #include "GBAApp.h"

#include "GameController.h" #include <QClipboard> +#include <QPushButton> extern "C" { #include "core/cheats.h" #ifdef M_CORE_GBA #include "gba/cheats.h" +#endif +#ifdef M_CORE_GB +#include "gb/cheats.h" #endif }

@@ -33,24 +37,63 @@ connect(m_ui.load, SIGNAL(clicked()), this, SLOT(load()));

connect(m_ui.save, SIGNAL(clicked()), this, SLOT(save())); connect(m_ui.addSet, SIGNAL(clicked()), this, SLOT(addSet())); connect(m_ui.remove, SIGNAL(clicked()), this, SLOT(removeSet())); - connect(controller, SIGNAL(gameStopped(mCoreThread*)), &m_model, SLOT(invalidated())); + connect(controller, SIGNAL(gameStopped(mCoreThread*)), this, SLOT(close())); connect(controller, SIGNAL(stateLoaded(mCoreThread*)), &m_model, SLOT(invalidated())); - connect(m_ui.add, &QPushButton::clicked, [this]() { - enterCheat(GBA_CHEAT_AUTODETECT); - }); + QPushButton* add; + switch (controller->platform()) { +#ifdef M_CORE_GBA + case PLATFORM_GBA: + connect(m_ui.add, &QPushButton::clicked, [this]() { + enterCheat(GBA_CHEAT_AUTODETECT); + }); + + add = new QPushButton("Add GameShark"); + m_ui.gridLayout->addWidget(add, m_ui.gridLayout->rowCount(), 2, 1, 2); + connect(add, &QPushButton::clicked, [this]() { + enterCheat(GBA_CHEAT_GAMESHARK); + }); + + add = new QPushButton("Add Pro Action Replay"); + m_ui.gridLayout->addWidget(add, m_ui.gridLayout->rowCount(), 2, 1, 2); + connect(add, &QPushButton::clicked, [this]() { + enterCheat(GBA_CHEAT_PRO_ACTION_REPLAY); + }); + + add = new QPushButton("Add CodeBreaker"); + m_ui.gridLayout->addWidget(add, m_ui.gridLayout->rowCount(), 2, 1, 2); + connect(add, &QPushButton::clicked, [this]() { + enterCheat(GBA_CHEAT_CODEBREAKER); + }); + break; +#endif +#ifdef M_CORE_GB + case PLATFORM_GB: + connect(m_ui.add, &QPushButton::clicked, [this]() { + enterCheat(GB_CHEAT_AUTODETECT); + }); - connect(m_ui.addGSA, &QPushButton::clicked, [this]() { - enterCheat(GBA_CHEAT_GAMESHARK); - }); + add = new QPushButton("Add GameShark"); + m_ui.gridLayout->addWidget(add, m_ui.gridLayout->rowCount(), 2, 1, 2); + connect(add, &QPushButton::clicked, [this]() { + enterCheat(GB_CHEAT_GAMESHARK); + }); - connect(m_ui.addPAR, &QPushButton::clicked, [this]() { - enterCheat(GBA_CHEAT_PRO_ACTION_REPLAY); - }); + add = new QPushButton("Add GameGenie"); + m_ui.gridLayout->addWidget(add, m_ui.gridLayout->rowCount(), 2, 1, 2); + connect(add, &QPushButton::clicked, [this]() { + enterCheat(GB_CHEAT_GAME_GENIE); + }); + break; +#endif + default: + break; + } - connect(m_ui.addCB, &QPushButton::clicked, [this]() { - enterCheat(GBA_CHEAT_CODEBREAKER); - }); + // Stretch the cheat list back into place + int index = m_ui.gridLayout->indexOf(m_ui.cheatList); + m_ui.gridLayout->takeAt(index); + m_ui.gridLayout->addWidget(m_ui.cheatList, 0, 0, -1, 1); } bool CheatsView::eventFilter(QObject* object, QEvent* event) {
M src/platform/qt/CheatsView.uisrc/platform/qt/CheatsView.ui

@@ -14,70 +14,70 @@ <property name="windowTitle">

<string>Cheats</string> </property> <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="1" colspan="2"> + <item row="2" column="2" colspan="2"> <widget class="QPushButton" name="remove"> <property name="text"> <string>Remove</string> </property> </widget> </item> - <item row="0" column="1" colspan="2"> - <widget class="QPushButton" name="addSet"> - <property name="text"> - <string>Add New Set</string> + <item row="3" column="2" colspan="2"> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> </widget> </item> - <item row="7" column="1" colspan="2"> - <widget class="QPushButton" name="addGSA"> + <item row="1" column="3"> + <widget class="QPushButton" name="save"> <property name="text"> - <string>Add GameShark</string> + <string>Save</string> </property> </widget> </item> - <item row="8" column="1" colspan="2"> - <widget class="QPushButton" name="addPAR"> + <item row="1" column="2"> + <widget class="QPushButton" name="load"> <property name="text"> - <string>Add Pro Action Replay</string> + <string>Load</string> </property> </widget> </item> - <item row="9" column="1" colspan="2"> - <widget class="QPushButton" name="addCB"> - <property name="text"> - <string>Add CodeBreaker</string> + <item row="4" column="2" rowspan="2" colspan="2"> + <widget class="QPlainTextEdit" name="codeEntry"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Maximum" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>180</width> + <height>16777215</height> + </size> + </property> + <property name="font"> + <font> + <family>Courier New</family> + </font> </property> </widget> </item> - <item row="1" column="1"> - <widget class="QPushButton" name="load"> + <item row="0" column="2" colspan="2"> + <widget class="QPushButton" name="addSet"> <property name="text"> - <string>Load</string> + <string>Add New Set</string> </property> </widget> </item> - <item row="6" column="1" colspan="2"> + <item row="6" column="2" colspan="2"> <widget class="QPushButton" name="add"> <property name="text"> <string>Add</string> </property> </widget> </item> - <item row="1" column="2"> - <widget class="QPushButton" name="save"> - <property name="text"> - <string>Save</string> - </property> - </widget> - </item> - <item row="3" column="1" colspan="2"> - <widget class="Line" name="line"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - </widget> - </item> - <item row="0" column="0" rowspan="10"> + <item row="0" column="0" rowspan="7" colspan="2"> <widget class="QTreeView" name="cheatList"> <property name="sizePolicy"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">

@@ -96,40 +96,15 @@ <bool>true</bool>

</property> </widget> </item> - <item row="4" column="1" rowspan="2" colspan="2"> - <widget class="QPlainTextEdit" name="codeEntry"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Maximum" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="maximumSize"> - <size> - <width>180</width> - <height>16777215</height> - </size> - </property> - <property name="font"> - <font> - <family>Courier New</family> - </font> - </property> - </widget> - </item> </layout> </widget> <tabstops> - <tabstop>cheatList</tabstop> <tabstop>addSet</tabstop> <tabstop>load</tabstop> <tabstop>save</tabstop> <tabstop>remove</tabstop> <tabstop>codeEntry</tabstop> <tabstop>add</tabstop> - <tabstop>addGSA</tabstop> - <tabstop>addPAR</tabstop> - <tabstop>addCB</tabstop> </tabstops> <resources/> <connections/>