mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-06-03 12:27:21 +12:00
Merge pull request #388 from OFFTKP/cheatpicker
Add cheat picker window
This commit is contained in:
commit
407411cc0b
9 changed files with 473 additions and 25 deletions
|
@ -24,6 +24,7 @@ class Cheats {
|
|||
|
||||
Cheats(Memory& mem, HIDService& hid);
|
||||
u32 addCheat(const Cheat& cheat);
|
||||
u32 addCheat(const u8* data, size_t size);
|
||||
void removeCheat(u32 id);
|
||||
void enableCheat(u32 id);
|
||||
void disableCheat(u32 id);
|
||||
|
@ -32,6 +33,7 @@ class Cheats {
|
|||
|
||||
void clear();
|
||||
bool haveCheats() const { return cheatsLoaded; }
|
||||
static constexpr u32 badCheatHandle = 0xFFFFFFFF;
|
||||
|
||||
private:
|
||||
ActionReplay ar; // An ActionReplay cheat machine for executing CTRPF codes
|
||||
|
|
26
include/panda_qt/cheats_window.hpp
Normal file
26
include/panda_qt/cheats_window.hpp
Normal file
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include <QAction>
|
||||
#include <QWidget>
|
||||
#include <filesystem>
|
||||
#include <memory>
|
||||
|
||||
#include "emulator.hpp"
|
||||
|
||||
class QListWidget;
|
||||
|
||||
class CheatsWindow final : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CheatsWindow(Emulator* emu, const std::filesystem::path& path, QWidget* parent = nullptr);
|
||||
~CheatsWindow() = default;
|
||||
|
||||
private:
|
||||
void addEntry();
|
||||
void removeClicked();
|
||||
|
||||
QListWidget* cheatList;
|
||||
std::filesystem::path cheatPath;
|
||||
Emulator* emu;
|
||||
};
|
|
@ -5,6 +5,7 @@
|
|||
#include <QtWidgets>
|
||||
#include <atomic>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
@ -12,16 +13,36 @@
|
|||
#include "emulator.hpp"
|
||||
#include "panda_qt/about_window.hpp"
|
||||
#include "panda_qt/config_window.hpp"
|
||||
#include "panda_qt/cheats_window.hpp"
|
||||
#include "panda_qt/screen.hpp"
|
||||
#include "panda_qt/text_editor.hpp"
|
||||
#include "services/hid.hpp"
|
||||
|
||||
struct CheatMessage {
|
||||
u32 handle;
|
||||
std::vector<uint8_t> cheat;
|
||||
std::function<void(u32)> callback;
|
||||
};
|
||||
|
||||
class MainWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
// Types of messages we might send from the GUI thread to the emulator thread
|
||||
enum class MessageType { LoadROM, Reset, Pause, Resume, TogglePause, DumpRomFS, PressKey, ReleaseKey, LoadLuaScript };
|
||||
enum class MessageType {
|
||||
LoadROM,
|
||||
Reset,
|
||||
Pause,
|
||||
Resume,
|
||||
TogglePause,
|
||||
DumpRomFS,
|
||||
PressKey,
|
||||
ReleaseKey,
|
||||
SetCirclePadX,
|
||||
SetCirclePadY,
|
||||
LoadLuaScript,
|
||||
EditCheat,
|
||||
};
|
||||
|
||||
// Tagged union representing our message queue messages
|
||||
struct EmulatorMessage {
|
||||
|
@ -36,9 +57,17 @@ class MainWindow : public QMainWindow {
|
|||
u32 key;
|
||||
} key;
|
||||
|
||||
struct {
|
||||
s16 value;
|
||||
} circlepad;
|
||||
|
||||
struct {
|
||||
std::string* str;
|
||||
} string;
|
||||
|
||||
struct {
|
||||
CheatMessage* c;
|
||||
} cheat;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -54,6 +83,7 @@ class MainWindow : public QMainWindow {
|
|||
ScreenWidget screen;
|
||||
AboutWindow* aboutWindow;
|
||||
ConfigWindow* configWindow;
|
||||
CheatsWindow* cheatsEditor;
|
||||
TextEditorWindow* luaEditor;
|
||||
QMenuBar* menuBar = nullptr;
|
||||
|
||||
|
@ -63,6 +93,7 @@ class MainWindow : public QMainWindow {
|
|||
void selectROM();
|
||||
void dumpRomFS();
|
||||
void openLuaEditor();
|
||||
void openCheatsEditor();
|
||||
void showAboutMenu();
|
||||
void sendMessage(const EmulatorMessage& message);
|
||||
void dispatchMessage(const EmulatorMessage& message);
|
||||
|
@ -78,4 +109,5 @@ class MainWindow : public QMainWindow {
|
|||
void keyPressEvent(QKeyEvent* event) override;
|
||||
void keyReleaseEvent(QKeyEvent* event) override;
|
||||
void loadLuaScript(const std::string& code);
|
||||
void editCheat(u32 handle, const std::vector<uint8_t>& cheat, const std::function<void(u32)>& callback);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue