wavelength 1.0.0
Loading...
Searching...
No Matches
cheatsmanager.h
Go to the documentation of this file.
1#pragma once
2
3#include <deque>
4#include <vector>
5
6#include "app/msgsink.h"
8#include "script/dataarray.h"
9
16class CheatsManager : public MsgSink {
17public:
24 ~CheatsManager() override = default;
25
27 static constexpr int kMaxHistory = 16;
28
30 static constexpr int kMaxCheatButtons = 16;
31
33 enum Combo {
37 };
38
40 struct LongCheat {
41 std::vector<int> mButtons;
44 };
45
51
59
68 void RunAction(DataArray *pAction, int nPad);
69
82
91 bool DispatchPriv(Message *pMsg) override;
92
100 static int IsCheatEntered();
101
109 static void Init();
110
117 static void Terminate();
118
119private:
128 static void TestCmd(DataArray *pCommand, void *pUserData);
129
140 static void LoadLongCheats(DataArray *pCheats);
141
143 int GetCheatEntered() const {
144 return mCheatEntered;
145 }
146
147 std::vector<LongCheat> mLongCheats;
148 std::vector<ComboCheat> mComboCheats[kComboCount];
149 std::deque<int> mHistory;
150 int mReserved60; // +0x60, cleared and never read.
151 float mLastPressMs;
152 int mCheatEntered;
153};
static void Init()
Create the one instance, listen to the controllers, load the long-cheats section, and register the te...
static constexpr int kMaxCheatButtons
Buttons one long cheat may have.
Definition cheatsmanager.h:30
CheatsManager()
Construct a manager with no cheat.
bool HandleButton(JoypadInputMsg *pMsg)
Add a press to the history and run every cheat it completes.
Combo
Combinations that select a table of mComboCheats.
Definition cheatsmanager.h:33
@ kComboCount
Definition cheatsmanager.h:36
@ kComboRight
Definition cheatsmanager.h:35
@ kComboLeft
Definition cheatsmanager.h:34
static constexpr int kMaxHistory
Presses mHistory retains.
Definition cheatsmanager.h:27
static void Terminate()
Stop listening to the controllers and delete the one instance.
static int IsCheatEntered()
Report whether a cheat that marks the game was entered.
void RunAction(DataArray *pAction, int nPad)
Run a cheat's script command, first storing the controller in its controller entry.
bool DispatchPriv(Message *pMsg) override
Handle controller button messages.
~CheatsManager() override=default
Destroy the object.
Reference-counted array of script data nodes.
Definition dataarray.h:20
Message the controller poll sends when a button is pressed or released.
Definition joypadinputmsg.h:23
Base of every event the game passes between a MsgSource and a MsgSink.
Definition message.h:40
Receiver of engine messages.
Definition msgsink.h:21
A press made while a combination is held that runs a script command.
Definition cheatsmanager.h:47
int mButton
Definition cheatsmanager.h:48
DataArray * mAction
Definition cheatsmanager.h:49
A sequence of presses that runs a script command.
Definition cheatsmanager.h:40
DataArray * mAction
Definition cheatsmanager.h:42
std::vector< int > mButtons
Definition cheatsmanager.h:41
int mMarksEntered
Definition cheatsmanager.h:43