diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index 4e51233469..ab1d38a55b 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -106,23 +106,19 @@ namespace BizHawk.Client.Common if (cheat.IsSeparator) { _cheatList.Add(cheat); - Changes = true; + } else { cheat.Changed += CheatChanged; - if (_cheatList.Any(x => x.Domain == cheat.Domain && x.Address == cheat.Address)) + if (HasCheat(cheat)) { - _cheatList.FirstOrDefault(x => x.Domain == cheat.Domain && x.Address == cheat.Address).Enable(); - } - else - { - _cheatList.Add(cheat); - Changes = true; + _cheatList.Remove(Global.CheatList.FirstOrDefault(x => x.Domain == cheat.Domain && x.Address == cheat.Address)); } + _cheatList.Add(cheat); } - + Changes = true; } public void Insert(int index, Cheat c) @@ -201,7 +197,7 @@ namespace BizHawk.Client.Common public bool HasCheat(Cheat cheat) { - return _cheatList.FirstOrDefault(x => x.Domain == cheat.Domain && x.Address == cheat.Address) != null; + return _cheatList.Any(x => x.Domain == cheat.Domain && x.Address == cheat.Address); } public void SaveOnClose() diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs b/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs index 7a91835be4..791e765f82 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/CheatEdit.cs @@ -71,6 +71,10 @@ namespace BizHawk.Client.EmuHawk BigEndianCheckBox.Checked = _cheat.BigEndian.Value; CheckFormState(); + if (!_cheat.Compare.HasValue) + { + CompareBox.Text = String.Empty; //Necessary hack until WatchValueBox.ToRawInt() becomes nullable + } _loading = false; } diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index 69b020e9db..7e1bb645c7 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -205,7 +205,7 @@ namespace BizHawk.Client.EmuHawk LoadConfigSettings(); ToggleGameGenieButton(); CheatEditor.SetAddEvent(AddCheat); - CheatEditor.SetEditEvent(EditCheat); + CheatEditor.SetEditEvent(AddCheat); //CheatList.Add is already an upsert, so there is nothing different to handle here UpdateValues(); } @@ -222,23 +222,7 @@ namespace BizHawk.Client.EmuHawk private void AddCheat() { - if (Global.CheatList.HasCheat(CheatEditor.Cheat)) - { - EditCheat(); - } - else - { - Global.CheatList.Add(CheatEditor.Cheat); - UpdateListView(); - UpdateMessageLabel(); - } - } - - private void EditCheat() - { - var cheat = CheatEditor.Cheat; - Global.CheatList.Remove(Global.CheatList.FirstOrDefault(x => x.Domain == cheat.Domain && x.Address == cheat.Address)); - Global.CheatList.Add(cheat); + Global.CheatList.Add(CheatEditor.Cheat); UpdateListView(); UpdateMessageLabel(); }