mirror of https://github.com/mgba-emu/mgba.git
Qt: Clean up cheats
This commit is contained in:
parent
69244f053a
commit
5b710a59fa
|
@ -11,7 +11,7 @@
|
||||||
#include "core/cheats.h"
|
#include "core/cheats.h"
|
||||||
#include "util/vector.h"
|
#include "util/vector.h"
|
||||||
|
|
||||||
enum GBACheatType {
|
enum GBCheatType {
|
||||||
GB_CHEAT_AUTODETECT,
|
GB_CHEAT_AUTODETECT,
|
||||||
GB_CHEAT_GAMESHARK,
|
GB_CHEAT_GAMESHARK,
|
||||||
GB_CHEAT_GAME_GENIE,
|
GB_CHEAT_GAME_GENIE,
|
||||||
|
|
|
@ -9,12 +9,16 @@
|
||||||
#include "GameController.h"
|
#include "GameController.h"
|
||||||
|
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "core/cheats.h"
|
#include "core/cheats.h"
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
#include "gba/cheats.h"
|
#include "gba/cheats.h"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef M_CORE_GB
|
||||||
|
#include "gb/cheats.h"
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
|
@ -33,24 +37,63 @@ CheatsView::CheatsView(GameController* controller, QWidget* parent)
|
||||||
connect(m_ui.save, SIGNAL(clicked()), this, SLOT(save()));
|
connect(m_ui.save, SIGNAL(clicked()), this, SLOT(save()));
|
||||||
connect(m_ui.addSet, SIGNAL(clicked()), this, SLOT(addSet()));
|
connect(m_ui.addSet, SIGNAL(clicked()), this, SLOT(addSet()));
|
||||||
connect(m_ui.remove, SIGNAL(clicked()), this, SLOT(removeSet()));
|
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(controller, SIGNAL(stateLoaded(mCoreThread*)), &m_model, SLOT(invalidated()));
|
||||||
|
|
||||||
connect(m_ui.add, &QPushButton::clicked, [this]() {
|
QPushButton* add;
|
||||||
enterCheat(GBA_CHEAT_AUTODETECT);
|
switch (controller->platform()) {
|
||||||
});
|
#ifdef M_CORE_GBA
|
||||||
|
case PLATFORM_GBA:
|
||||||
|
connect(m_ui.add, &QPushButton::clicked, [this]() {
|
||||||
|
enterCheat(GBA_CHEAT_AUTODETECT);
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_ui.addGSA, &QPushButton::clicked, [this]() {
|
add = new QPushButton("Add GameShark");
|
||||||
enterCheat(GBA_CHEAT_GAMESHARK);
|
m_ui.gridLayout->addWidget(add, m_ui.gridLayout->rowCount(), 2, 1, 2);
|
||||||
});
|
connect(add, &QPushButton::clicked, [this]() {
|
||||||
|
enterCheat(GBA_CHEAT_GAMESHARK);
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_ui.addPAR, &QPushButton::clicked, [this]() {
|
add = new QPushButton("Add Pro Action Replay");
|
||||||
enterCheat(GBA_CHEAT_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);
|
||||||
|
});
|
||||||
|
|
||||||
connect(m_ui.addCB, &QPushButton::clicked, [this]() {
|
add = new QPushButton("Add CodeBreaker");
|
||||||
enterCheat(GBA_CHEAT_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);
|
||||||
|
});
|
||||||
|
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
bool CheatsView::eventFilter(QObject* object, QEvent* event) {
|
||||||
|
|
|
@ -14,89 +14,35 @@
|
||||||
<string>Cheats</string>
|
<string>Cheats</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="2" column="1" colspan="2">
|
<item row="2" column="2" colspan="2">
|
||||||
<widget class="QPushButton" name="remove">
|
<widget class="QPushButton" name="remove">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Remove</string>
|
<string>Remove</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1" colspan="2">
|
<item row="3" column="2" colspan="2">
|
||||||
<widget class="QPushButton" name="addSet">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add New Set</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="7" column="1" colspan="2">
|
|
||||||
<widget class="QPushButton" name="addGSA">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add GameShark</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="8" column="1" colspan="2">
|
|
||||||
<widget class="QPushButton" name="addPAR">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add Pro Action Replay</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="9" column="1" colspan="2">
|
|
||||||
<widget class="QPushButton" name="addCB">
|
|
||||||
<property name="text">
|
|
||||||
<string>Add CodeBreaker</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QPushButton" name="load">
|
|
||||||
<property name="text">
|
|
||||||
<string>Load</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="1" 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">
|
<widget class="Line" name="line">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0" rowspan="10">
|
<item row="1" column="3">
|
||||||
<widget class="QTreeView" name="cheatList">
|
<widget class="QPushButton" name="save">
|
||||||
<property name="sizePolicy">
|
<property name="text">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
<string>Save</string>
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="defaultDropAction">
|
|
||||||
<enum>Qt::MoveAction</enum>
|
|
||||||
</property>
|
|
||||||
<property name="selectionMode">
|
|
||||||
<enum>QAbstractItemView::ExtendedSelection</enum>
|
|
||||||
</property>
|
|
||||||
<property name="headerHidden">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1" rowspan="2" colspan="2">
|
<item row="1" column="2">
|
||||||
|
<widget class="QPushButton" name="load">
|
||||||
|
<property name="text">
|
||||||
|
<string>Load</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="2" rowspan="2" colspan="2">
|
||||||
<widget class="QPlainTextEdit" name="codeEntry">
|
<widget class="QPlainTextEdit" name="codeEntry">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
|
<sizepolicy hsizetype="Maximum" vsizetype="Expanding">
|
||||||
|
@ -117,19 +63,48 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="2" colspan="2">
|
||||||
|
<widget class="QPushButton" name="addSet">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add New Set</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="2" colspan="2">
|
||||||
|
<widget class="QPushButton" name="add">
|
||||||
|
<property name="text">
|
||||||
|
<string>Add</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" rowspan="7" colspan="2">
|
||||||
|
<widget class="QTreeView" name="cheatList">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="defaultDropAction">
|
||||||
|
<enum>Qt::MoveAction</enum>
|
||||||
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::ExtendedSelection</enum>
|
||||||
|
</property>
|
||||||
|
<property name="headerHidden">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>cheatList</tabstop>
|
|
||||||
<tabstop>addSet</tabstop>
|
<tabstop>addSet</tabstop>
|
||||||
<tabstop>load</tabstop>
|
<tabstop>load</tabstop>
|
||||||
<tabstop>save</tabstop>
|
<tabstop>save</tabstop>
|
||||||
<tabstop>remove</tabstop>
|
<tabstop>remove</tabstop>
|
||||||
<tabstop>codeEntry</tabstop>
|
<tabstop>codeEntry</tabstop>
|
||||||
<tabstop>add</tabstop>
|
<tabstop>add</tabstop>
|
||||||
<tabstop>addGSA</tabstop>
|
|
||||||
<tabstop>addPAR</tabstop>
|
|
||||||
<tabstop>addCB</tabstop>
|
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
Loading…
Reference in New Issue