Have cheats to record in project64.cfg
This commit is contained in:
parent
bf269454dd
commit
352dcff301
|
@ -163,6 +163,7 @@ public enum SettingsID
|
|||
Game_Transferpak_ROM,
|
||||
Game_Transferpak_Sav,
|
||||
Game_LoadSaveAtStart,
|
||||
Game_OverClockModifier,
|
||||
Game_FullSpeed,
|
||||
Game_UnalignedDMA,
|
||||
|
||||
|
@ -316,13 +317,19 @@ public enum SettingsID
|
|||
Logging_LogUnknown,
|
||||
|
||||
//Cheats
|
||||
Cheat_Modified,
|
||||
Cheat_Entry,
|
||||
Cheat_Active,
|
||||
Cheat_Extension,
|
||||
Cheat_Notes,
|
||||
Cheat_Options,
|
||||
Cheat_Range,
|
||||
Cheat_RangeNotes,
|
||||
Cheat_UserEntry,
|
||||
Cheat_UserNotes,
|
||||
Cheat_UserOptions,
|
||||
Cheat_UserRange,
|
||||
Cheat_UserRangeNotes,
|
||||
Cheat_Active,
|
||||
Cheat_Extension,
|
||||
|
||||
//Enhancement
|
||||
Enhancement_Name,
|
||||
|
|
|
@ -430,13 +430,19 @@ void CSettings::AddHowToHandleSetting(const char * BaseDirectory)
|
|||
AddHandler(Logging_LogUnknown, new CSettingTypeApplication("Logging", "Log Rom Header", false));
|
||||
|
||||
// cheats
|
||||
AddHandler(Cheat_Entry, new CSettingTypeCheats(""));
|
||||
AddHandler(Cheat_Active, new CSettingTypeGameIndex("Cheat", "", (uint32_t)false));
|
||||
AddHandler(Cheat_Modified, new CSettingTypeGame("CheatModified",false));
|
||||
AddHandler(Cheat_Entry, new CSettingTypeCheats("", Cheat_UserEntry));
|
||||
AddHandler(Cheat_Notes, new CSettingTypeCheats("_N", Cheat_UserNotes));
|
||||
AddHandler(Cheat_Options, new CSettingTypeCheats("_O", Cheat_UserOptions));
|
||||
AddHandler(Cheat_Range, new CSettingTypeCheats("_R", Cheat_UserRange));
|
||||
AddHandler(Cheat_RangeNotes, new CSettingTypeCheats("_RN", Cheat_UserRangeNotes));
|
||||
AddHandler(Cheat_UserEntry, new CSettingTypeGameIndex("Cheat", "", ""));
|
||||
AddHandler(Cheat_UserNotes, new CSettingTypeGameIndex("Cheat", "_N", ""));
|
||||
AddHandler(Cheat_UserOptions, new CSettingTypeGameIndex("Cheat", "_O", ""));
|
||||
AddHandler(Cheat_UserRange, new CSettingTypeGameIndex("Cheat", "_R", ""));
|
||||
AddHandler(Cheat_UserRangeNotes, new CSettingTypeGameIndex("Cheat", "_RN", ""));
|
||||
AddHandler(Cheat_Active, new CSettingTypeGameIndex("Cheat", "Active", false));
|
||||
AddHandler(Cheat_Extension, new CSettingTypeGameIndex("Cheat", ".exten", "??? - Not Set"));
|
||||
AddHandler(Cheat_Notes, new CSettingTypeCheats("_N"));
|
||||
AddHandler(Cheat_Options, new CSettingTypeCheats("_O"));
|
||||
AddHandler(Cheat_Range, new CSettingTypeCheats("_R"));
|
||||
AddHandler(Cheat_RangeNotes, new CSettingTypeCheats("_RN"));
|
||||
|
||||
// Enhancement
|
||||
AddHandler(Enhancement_Name, new CSettingTypeEnhancements(""));
|
||||
|
|
|
@ -236,7 +236,7 @@ void CSettingTypeApplication::Save(uint32_t Index, bool Value)
|
|||
bool indexed = g_Settings->IndexBasedSetting(m_DefaultSetting);
|
||||
|
||||
if (m_DefaultSetting != Default_None &&
|
||||
((m_DefaultSetting == Default_Constant && (bool)m_DefaultValue == Value) ||
|
||||
((m_DefaultSetting == Default_Constant && m_DefaultValue == (uint32_t)Value) ||
|
||||
(m_DefaultSetting != Default_Constant && (indexed ? g_Settings->LoadBoolIndex(m_DefaultSetting, Index) : g_Settings->LoadBool(m_DefaultSetting)) == Value)))
|
||||
{
|
||||
m_SettingsIniFile->SaveString(SectionName(), m_KeyNameIdex.c_str(), NULL);
|
||||
|
|
|
@ -10,12 +10,15 @@
|
|||
****************************************************************************/
|
||||
#include "stdafx.h"
|
||||
#include "SettingsType-Cheats.h"
|
||||
#include <Project64-core\N64System\CheatClass.h>
|
||||
|
||||
CIniFile * CSettingTypeCheats::m_CheatIniFile = NULL;
|
||||
std::string * CSettingTypeCheats::m_SectionIdent = NULL;
|
||||
bool CSettingTypeCheats::m_CheatsModified = false;
|
||||
|
||||
CSettingTypeCheats::CSettingTypeCheats(const char * PostFix ) :
|
||||
m_PostFix(PostFix)
|
||||
CSettingTypeCheats::CSettingTypeCheats(const char * PostFix, SettingID UserSetting) :
|
||||
m_PostFix(PostFix),
|
||||
m_UserSetting(UserSetting)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -60,6 +63,7 @@ void CSettingTypeCheats::FlushChanges( void )
|
|||
void CSettingTypeCheats::GameChanged ( void * /*Data */ )
|
||||
{
|
||||
*m_SectionIdent = g_Settings->LoadStringVal(Game_IniKey);
|
||||
m_CheatsModified = g_Settings->LoadBool(Cheat_Modified);
|
||||
}
|
||||
|
||||
bool CSettingTypeCheats::IsSettingSet(void) const
|
||||
|
@ -82,6 +86,10 @@ bool CSettingTypeCheats::Load (uint32_t /*Index*/, uint32_t & /*Value*/ ) const
|
|||
|
||||
bool CSettingTypeCheats::Load (uint32_t Index, std::string & Value ) const
|
||||
{
|
||||
if (m_CheatsModified)
|
||||
{
|
||||
return g_Settings->LoadStringIndex(m_UserSetting, Index, Value);
|
||||
}
|
||||
if (m_CheatIniFile == NULL)
|
||||
{
|
||||
return false;
|
||||
|
@ -119,22 +127,62 @@ void CSettingTypeCheats::Save (uint32_t /*Index*/, uint32_t /*Value*/ )
|
|||
|
||||
void CSettingTypeCheats::Save (uint32_t Index, const std::string & Value )
|
||||
{
|
||||
if (m_CheatIniFile == NULL) { return; }
|
||||
|
||||
stdstr_f Key("Cheat%d%s",Index,m_PostFix);
|
||||
m_CheatIniFile->SaveString(m_SectionIdent->c_str(),Key.c_str(),Value.c_str());
|
||||
if (!m_CheatsModified)
|
||||
{
|
||||
CopyCheats();
|
||||
m_CheatsModified = true;
|
||||
g_Settings->SaveBool(Cheat_Modified, true);
|
||||
}
|
||||
g_Settings->SaveStringIndex(m_UserSetting, Index, Value.c_str());
|
||||
}
|
||||
|
||||
void CSettingTypeCheats::Save (uint32_t Index, const char * Value )
|
||||
{
|
||||
if (m_CheatIniFile == NULL) { return; }
|
||||
|
||||
stdstr_f Key("Cheat%d%s",Index,m_PostFix);
|
||||
m_CheatIniFile->SaveString(m_SectionIdent->c_str(),Key.c_str(),Value);
|
||||
if (!m_CheatsModified)
|
||||
{
|
||||
CopyCheats();
|
||||
m_CheatsModified = true;
|
||||
g_Settings->SaveBool(Cheat_Modified, true);
|
||||
}
|
||||
g_Settings->SaveStringIndex(m_UserSetting, Index, Value);
|
||||
}
|
||||
|
||||
void CSettingTypeCheats::Delete (uint32_t Index )
|
||||
{
|
||||
stdstr_f Key("Cheat%d%s",Index,m_PostFix);
|
||||
m_CheatIniFile->SaveString(m_SectionIdent->c_str(),Key.c_str(),NULL);
|
||||
if (!m_CheatsModified)
|
||||
{
|
||||
CopyCheats();
|
||||
m_CheatsModified = true;
|
||||
g_Settings->SaveBool(Cheat_Modified, true);
|
||||
}
|
||||
g_Settings->DeleteSettingIndex(m_UserSetting, Index);
|
||||
}
|
||||
|
||||
void CSettingTypeCheats::CopyCheats(void)
|
||||
{
|
||||
for (int i = 0; i < CCheats::MaxCheats; i++)
|
||||
{
|
||||
std::string Value;
|
||||
if (!g_Settings->LoadStringIndex(Cheat_Entry, i, Value))
|
||||
{
|
||||
break;
|
||||
}
|
||||
g_Settings->SaveStringIndex(Cheat_UserEntry, i, Value);
|
||||
if (g_Settings->LoadStringIndex(Cheat_Notes, i, Value))
|
||||
{
|
||||
g_Settings->SaveStringIndex(Cheat_UserNotes, i, Value);
|
||||
}
|
||||
if (g_Settings->LoadStringIndex(Cheat_Options, i, Value))
|
||||
{
|
||||
g_Settings->SaveStringIndex(Cheat_UserOptions, i, Value);
|
||||
}
|
||||
if (g_Settings->LoadStringIndex(Cheat_Range, i, Value))
|
||||
{
|
||||
g_Settings->SaveStringIndex(Cheat_UserRange, i, Value);
|
||||
}
|
||||
if (g_Settings->LoadStringIndex(Cheat_RangeNotes, i, Value))
|
||||
{
|
||||
g_Settings->SaveStringIndex(Cheat_UserRangeNotes, i, Value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,7 @@ class CSettingTypeCheats :
|
|||
public CSettingType
|
||||
{
|
||||
public:
|
||||
CSettingTypeCheats(const char * PostFix );
|
||||
CSettingTypeCheats(const char * PostFix, SettingID UserSetting);
|
||||
~CSettingTypeCheats();
|
||||
|
||||
virtual bool IndexBasedSetting ( void ) const { return true; }
|
||||
|
@ -49,13 +49,18 @@ public:
|
|||
static void FlushChanges ( void );
|
||||
|
||||
protected:
|
||||
static void GameChanged(void * /*Data */);
|
||||
|
||||
static CIniFile * m_CheatIniFile;
|
||||
static std::string * m_SectionIdent;
|
||||
static bool m_CheatsModified;
|
||||
const char * const m_PostFix;
|
||||
static void GameChanged ( void * /*Data */ );
|
||||
SettingID m_UserSetting;
|
||||
|
||||
private:
|
||||
CSettingTypeCheats(void); // Disable default constructor
|
||||
CSettingTypeCheats(const CSettingTypeCheats&); // Disable copy constructor
|
||||
CSettingTypeCheats& operator=(const CSettingTypeCheats&); // Disable assignment
|
||||
|
||||
void CopyCheats(void);
|
||||
};
|
||||
|
|
|
@ -14,7 +14,12 @@
|
|||
|
||||
bool CSettingTypeGame::m_RdbEditor = false;
|
||||
bool CSettingTypeGame::m_EraseDefaults = true;
|
||||
stdstr * CSettingTypeGame::m_SectionIdent = NULL;
|
||||
std::string * CSettingTypeGame::m_SectionIdent = NULL;
|
||||
|
||||
CSettingTypeGame::CSettingTypeGame(const char * Name, bool DefaultValue) :
|
||||
CSettingTypeApplication("", Name, DefaultValue)
|
||||
{
|
||||
}
|
||||
|
||||
CSettingTypeGame::CSettingTypeGame(const char * Name, const char * DefaultValue) :
|
||||
CSettingTypeApplication("", Name, DefaultValue)
|
||||
|
|
|
@ -13,17 +13,9 @@
|
|||
class CSettingTypeGame :
|
||||
public CSettingTypeApplication
|
||||
{
|
||||
protected:
|
||||
static bool m_RdbEditor;
|
||||
static bool m_EraseDefaults;
|
||||
static stdstr * m_SectionIdent;
|
||||
|
||||
static void UpdateSettings ( void * /*Data */ );
|
||||
|
||||
virtual const char * SectionName ( void ) const;
|
||||
|
||||
public:
|
||||
CSettingTypeGame(const char * Name, const char * DefaultValue );
|
||||
CSettingTypeGame(const char * Name, bool DefaultValue);
|
||||
CSettingTypeGame(const char * Name, const char * DefaultValue);
|
||||
CSettingTypeGame(const char * Name, uint32_t DefaultValue );
|
||||
CSettingTypeGame(const char * Name, SettingID DefaultSetting );
|
||||
virtual ~CSettingTypeGame();
|
||||
|
@ -53,6 +45,15 @@ public:
|
|||
// Delete the setting
|
||||
virtual void Delete (uint32_t Index );
|
||||
|
||||
protected:
|
||||
static bool m_RdbEditor;
|
||||
static bool m_EraseDefaults;
|
||||
static std::string * m_SectionIdent;
|
||||
|
||||
static void UpdateSettings(void * /*Data */);
|
||||
|
||||
virtual const char * SectionName(void) const;
|
||||
|
||||
private:
|
||||
CSettingTypeGame(void); // Disable default constructor
|
||||
CSettingTypeGame(const CSettingTypeGame&); // Disable copy constructor
|
||||
|
|
|
@ -27,6 +27,13 @@ CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char *
|
|||
{
|
||||
}
|
||||
|
||||
CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, bool DefaultValue) :
|
||||
CSettingTypeGame("", DefaultValue),
|
||||
m_PreIndex(PreIndex),
|
||||
m_PostIndex(PostIndex)
|
||||
{
|
||||
}
|
||||
|
||||
CSettingTypeGameIndex::CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue ) :
|
||||
CSettingTypeGame("", DefaultValue),
|
||||
m_PreIndex(PreIndex),
|
||||
|
|
|
@ -13,12 +13,11 @@
|
|||
class CSettingTypeGameIndex :
|
||||
public CSettingTypeGame
|
||||
{
|
||||
stdstr m_PreIndex, m_PostIndex;
|
||||
|
||||
public:
|
||||
CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, const char * DefaultValue );
|
||||
CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, uint32_t DefaultValue );
|
||||
CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting );
|
||||
CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, bool DefaultSetting);
|
||||
CSettingTypeGameIndex(const char * PreIndex, const char * PostIndex, SettingID DefaultSetting);
|
||||
~CSettingTypeGameIndex();
|
||||
|
||||
virtual bool IndexBasedSetting ( void ) const { return true; }
|
||||
|
@ -47,4 +46,6 @@ private:
|
|||
CSettingTypeGameIndex(void); // Disable default constructor
|
||||
CSettingTypeGameIndex(const CSettingTypeGameIndex&); // Disable copy constructor
|
||||
CSettingTypeGameIndex& operator=(const CSettingTypeGameIndex&); // Disable assignment
|
||||
|
||||
std::string m_PreIndex, m_PostIndex;
|
||||
};
|
||||
|
|
|
@ -322,13 +322,19 @@ enum SettingID
|
|||
Logging_LogUnknown,
|
||||
|
||||
//Cheats
|
||||
Cheat_Modified,
|
||||
Cheat_Entry,
|
||||
Cheat_Active,
|
||||
Cheat_Extension,
|
||||
Cheat_Notes,
|
||||
Cheat_Options,
|
||||
Cheat_Range,
|
||||
Cheat_RangeNotes,
|
||||
Cheat_UserEntry,
|
||||
Cheat_UserNotes,
|
||||
Cheat_UserOptions,
|
||||
Cheat_UserRange,
|
||||
Cheat_UserRangeNotes,
|
||||
Cheat_Active,
|
||||
Cheat_Extension,
|
||||
|
||||
//Enhancement
|
||||
Enhancement_Name,
|
||||
|
|
Loading…
Reference in New Issue