When adding a cheat, if it already exists, update the existing instead of doing nothing!

This commit is contained in:
adelikat 2013-11-05 19:53:49 +00:00
parent 76de0c4bdd
commit 92f8f9982c
2 changed files with 15 additions and 3 deletions

View File

@ -199,6 +199,11 @@ namespace BizHawk.Client.Common
return false; return false;
} }
public bool HasCheat(Cheat cheat)
{
return _cheatList.FirstOrDefault(x => x.Domain == cheat.Domain && x.Address == cheat.Address) != null;
}
public void SaveOnClose() public void SaveOnClose()
{ {
if (Global.Config.CheatsAutoSaveOnClose) if (Global.Config.CheatsAutoSaveOnClose)

View File

@ -221,11 +221,18 @@ namespace BizHawk.Client.EmuHawk
} }
private void AddCheat() private void AddCheat()
{
if (Global.CheatList.HasCheat(CheatEditor.Cheat))
{
EditCheat();
}
else
{ {
Global.CheatList.Add(CheatEditor.Cheat); Global.CheatList.Add(CheatEditor.Cheat);
UpdateListView(); UpdateListView();
UpdateMessageLabel(); UpdateMessageLabel();
} }
}
private void EditCheat() private void EditCheat()
{ {