2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project 64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
|
2015-02-26 10:57:51 +00:00
|
|
|
class CCheats
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
CCheats ( const CN64Rom * Rom = NULL );
|
|
|
|
~CCheats ( void );
|
|
|
|
|
|
|
|
bool IsCheatMessage ( MSG * msg );
|
|
|
|
void ApplyCheats ( CMipsMemory * MMU );
|
|
|
|
void ApplyGSButton ( CMipsMemory * MMU );
|
2015-03-12 06:58:41 +00:00
|
|
|
void LoadCheats ( bool DisableSelected, CPlugins * Plugins );
|
2015-02-26 10:57:51 +00:00
|
|
|
void SelectCheats ( HWND hParent, bool BlockExecution );
|
|
|
|
inline bool CheatsSlectionChanged ( void ) const { return m_CheatSelectionChanged; }
|
|
|
|
|
|
|
|
private:
|
2015-05-04 00:08:53 +00:00
|
|
|
struct GAMESHARK_CODE {
|
2008-09-18 03:15:49 +00:00
|
|
|
DWORD Command;
|
|
|
|
WORD Value;
|
2015-05-04 00:08:53 +00:00
|
|
|
};
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
typedef std::vector<GAMESHARK_CODE> CODES;
|
|
|
|
typedef std::vector<CODES> CODES_ARRAY;
|
|
|
|
|
2008-11-14 20:51:06 +00:00
|
|
|
enum { MaxCheats = 50000 };
|
2015-03-12 06:58:41 +00:00
|
|
|
void LoadPermCheats ( CPlugins * Plugins );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-01-27 05:07:44 +00:00
|
|
|
static int CALLBACK CheatAddProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
|
|
|
|
static int CALLBACK CheatListProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
|
|
|
|
static int CALLBACK ManageCheatsProc ( HWND hDlg,DWORD uMsg,DWORD wParam, DWORD lParam );
|
|
|
|
static int CALLBACK CheatsCodeExProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam);
|
|
|
|
static int CALLBACK CheatsCodeQuantProc ( HWND hDlg, DWORD uMsg, DWORD wParam, DWORD lParam);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
//information about the gui for selecting cheats
|
2015-01-27 05:07:44 +00:00
|
|
|
HWND m_Window, m_hSelectCheat, m_AddCheat, m_hCheatTree, m_hSelectedItem;
|
2015-02-26 10:57:51 +00:00
|
|
|
const CN64Rom * m_Rom;
|
2008-09-18 03:15:49 +00:00
|
|
|
void * const m_rcList, * const m_rcAdd;
|
|
|
|
int m_MinSizeDlg, m_MaxSizeDlg;
|
|
|
|
int m_EditCheat;
|
|
|
|
bool m_DeleteingEntries;
|
|
|
|
CODES_ARRAY m_Codes;
|
|
|
|
bool m_CheatSelectionChanged;
|
|
|
|
|
|
|
|
//Information about the current cheat we are editing
|
|
|
|
stdstr m_EditName;
|
|
|
|
stdstr m_EditCode;
|
|
|
|
stdstr m_EditOptions;
|
|
|
|
stdstr m_EditNotes;
|
|
|
|
|
|
|
|
enum Dialog_State { CONTRACTED, EXPANDED } m_DialogState;
|
|
|
|
enum TV_CHECK_STATE { TV_STATE_UNKNOWN, TV_STATE_CLEAR, TV_STATE_CHECKED, TV_STATE_INDETERMINATE };
|
|
|
|
enum { MaxGSEntries = 100, IDC_MYTREE = 0x500 };
|
|
|
|
|
|
|
|
bool LoadCode ( int CheatNo, LPCSTR CheatString );
|
2015-04-28 22:19:02 +00:00
|
|
|
void AddCodeLayers ( int CheatNumber, const stdstr &CheatName, HWND hParent, bool CheatActive );
|
2008-09-18 03:15:49 +00:00
|
|
|
//Reload the cheats from the ini file to the select gui
|
2015-04-28 22:19:02 +00:00
|
|
|
void RefreshCheatManager ();
|
|
|
|
void ChangeChildrenStatus ( HWND hParent, bool Checked );
|
|
|
|
void CheckParentStatus ( HWND hParent );
|
2015-01-27 05:07:44 +00:00
|
|
|
static stdstr ReadCodeString ( HWND hDlg, bool &validcodes, bool &validoption, bool &nooptions, int &codeformat );
|
|
|
|
static stdstr ReadOptionsString( HWND hDlg, bool &validcodes, bool &validoptions, bool &nooptions, int &codeformat );
|
2015-05-02 22:14:19 +00:00
|
|
|
int ApplyCheatEntry (CMipsMemory * MMU,const CODES & CodeEntry, int CurrentEntry, bool Execute );
|
2015-01-27 05:07:44 +00:00
|
|
|
void RecordCheatValues ( HWND hDlg );
|
|
|
|
bool CheatChanged ( HWND hDlg );
|
2008-09-18 03:15:49 +00:00
|
|
|
bool IsValid16BitCode ( LPCSTR CheatString ) const;
|
2010-05-14 23:28:15 +00:00
|
|
|
void DeleteCheat(int Index);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
//Get Information about the Cheat
|
|
|
|
stdstr GetCheatName ( int CheatNo, bool AddExtension ) const;
|
|
|
|
static bool CheatUsesCodeExtensions ( const stdstr &LineEntry );
|
|
|
|
|
|
|
|
//Working with treeview
|
2015-01-27 05:07:44 +00:00
|
|
|
static bool TV_SetCheckState(HWND hwndTreeView, HWND hItem, TV_CHECK_STATE state);
|
|
|
|
static int TV_GetCheckState(HWND hwndTreeView, HWND hItem);
|
2008-09-18 03:15:49 +00:00
|
|
|
static DWORD AsciiToHex ( const char * HexValue );
|
2015-04-20 19:41:25 +00:00
|
|
|
static void MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, const wchar_t * ShortCut );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
//UI Functions
|
2015-01-27 05:07:44 +00:00
|
|
|
static stdstr GetDlgItemStr (HWND hDlg, int nIDDlgItem);
|
2015-01-31 19:27:27 +00:00
|
|
|
};
|