Cheats: Fixed cheats not being saved properly when switching games with the cheat window opened, etc.
+ Compilation error fix on some compilers
This commit is contained in:
parent
2ed4f3603b
commit
52c61f00f9
5 changed files with 16 additions and 3 deletions
|
@ -39,7 +39,10 @@ void CheatManager::SetCheats(uint32_t codes[], uint32_t length)
|
|||
vector<CheatCode> cheats;
|
||||
cheats.reserve(length);
|
||||
for(uint32_t i = 0; i < length; i++) {
|
||||
cheats.push_back({ codes[i] >> 8, codes[i] & 0xFF });
|
||||
CheatCode code;
|
||||
code.Address = codes[i] >> 8;
|
||||
code.Value = codes[i] & 0xFF;
|
||||
cheats.push_back(code);
|
||||
}
|
||||
SetCheats(cheats);
|
||||
}
|
||||
|
|
|
@ -203,6 +203,8 @@ void Console::Stop(bool sendNotification)
|
|||
_saveStateManager->SaveRecentGame(romInfo.RomFile.GetFileName(), romInfo.RomFile, romInfo.PatchFile);
|
||||
}
|
||||
|
||||
_notificationManager->SendNotification(ConsoleNotificationType::BeforeGameUnload);
|
||||
|
||||
if(sendNotification) {
|
||||
_notificationManager->SendNotification(ConsoleNotificationType::BeforeEmulationStop);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,8 @@ enum class ConsoleNotificationType
|
|||
BeforeEmulationStop = 12,
|
||||
ViewerRefresh = 13,
|
||||
EventViewerRefresh = 14,
|
||||
MissingFirmware = 15
|
||||
MissingFirmware = 15,
|
||||
BeforeGameUnload = 16,
|
||||
};
|
||||
|
||||
class INotificationListener
|
||||
|
|
|
@ -61,6 +61,10 @@ namespace Mesen.GUI.Forms
|
|||
private void OnNotification(NotificationEventArgs e)
|
||||
{
|
||||
switch(e.NotificationType) {
|
||||
case ConsoleNotificationType.BeforeGameUnload:
|
||||
(new CheatCodes() { Cheats = _cheats }).Save();
|
||||
break;
|
||||
|
||||
case ConsoleNotificationType.GameLoaded:
|
||||
this.BeginInvoke((Action)(() => {
|
||||
InitCheatList();
|
||||
|
@ -69,6 +73,8 @@ namespace Mesen.GUI.Forms
|
|||
|
||||
case ConsoleNotificationType.BeforeEmulationStop:
|
||||
this.Invoke((Action)(() => {
|
||||
//Close and save saves
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}));
|
||||
break;
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace Mesen.GUI
|
|||
BeforeEmulationStop = 12,
|
||||
ViewerRefresh = 13,
|
||||
EventViewerRefresh = 14,
|
||||
MissingFirmware = 15
|
||||
MissingFirmware = 15,
|
||||
BeforeGameUnload = 16,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue