Implement CW cheat refresh rate.

This commit is contained in:
Luna 2015-01-27 00:50:50 +01:00
parent 1079c21e38
commit b954145241
4 changed files with 13 additions and 3 deletions

View File

@ -293,6 +293,8 @@ static ConfigSetting generalSettings[] = {
ReportedConfigSetting("NumWorkerThreads", &g_Config.iNumWorkerThreads, &DefaultNumWorkers, true, true),
ConfigSetting("EnableAutoLoad", &g_Config.bEnableAutoLoad, false, true, true),
ReportedConfigSetting("EnableCheats", &g_Config.bEnableCheats, false, true, true),
ConfigSetting("CwCheatRefreshRate", &g_Config.iCwCheatRefreshRate, 77, true, true),
ConfigSetting("ScreenshotsAsPNG", &g_Config.bScreenshotsAsPNG, false, true, true),
ConfigSetting("StateSlot", &g_Config.iCurrentStateSlot, 0, true, true),
ConfigSetting("RewindFlipFrequency", &g_Config.iRewindFlipFrequency, 0, true, true),

View File

@ -182,6 +182,7 @@ public:
bool bEnableAutoLoad;
bool bEnableCheats;
bool bReloadCheats;
int iCwCheatRefreshRate;
bool bDisableStencilTest;
bool bAlwaysDepthWrite;
bool bDepthRangeHack;

View File

@ -56,8 +56,10 @@ void __CheatInit() {
__CheatStart();
}
int refresh = g_Config.iCwCheatRefreshRate;
// Only check once a second for cheats to be enabled.
CoreTiming::ScheduleEvent(msToCycles(cheatsEnabled ? 77 : 1000), CheatEvent, 0);
CoreTiming::ScheduleEvent(msToCycles(cheatsEnabled ? refresh : 1000), CheatEvent, 0);
}
void __CheatShutdown() {
@ -73,11 +75,13 @@ void __CheatDoState(PointerWrap &p) {
p.Do(CheatEvent);
CoreTiming::RestoreRegisterEvent(CheatEvent, "CheatEvent", &hleCheat);
int refresh = g_Config.iCwCheatRefreshRate;
if (s < 2) {
// Before this we didn't have a checkpoint, so reset didn't work.
// Let's just force one in.
CoreTiming::RemoveEvent(CheatEvent);
CoreTiming::ScheduleEvent(msToCycles(cheatsEnabled ? 77 : 1000), CheatEvent, 0);
CoreTiming::ScheduleEvent(msToCycles(cheatsEnabled ? refresh : 1000), CheatEvent, 0);
}
}
@ -91,8 +95,10 @@ void hleCheat(u64 userdata, int cyclesLate) {
}
}
int refresh = g_Config.iCwCheatRefreshRate;
// Only check once a second for cheats to be enabled.
CoreTiming::ScheduleEvent(msToCycles(cheatsEnabled ? 77 : 1000), CheatEvent, 0);
CoreTiming::ScheduleEvent(msToCycles(cheatsEnabled ? refresh : 1000), CheatEvent, 0);
if (!cheatEngine || !cheatsEnabled)
return;

View File

@ -76,6 +76,7 @@ void CwCheatScreen::CreateViews() {
leftColumn->Add(new Choice(k->T("Edit Cheat File")))->OnClick.Handle(this, &CwCheatScreen::OnEditCheatFile);
#endif
leftColumn->Add(new Choice(k->T("Enable/Disable All")))->OnClick.Handle(this, &CwCheatScreen::OnEnableAll);
leftColumn->Add(new PopupSliderChoice(&g_Config.iCwCheatRefreshRate, 1, 1000, k->T("Refresh Rate"), 1, screenManager()));
ScrollView *rightScroll = new ScrollView(ORIENT_VERTICAL, new LinearLayoutParams(0.5f));
rightScroll->SetScrollToTop(false);