From 0e934d5454b202aa6669452c49ee28a914003cc4 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 14 Oct 2013 02:26:06 +0000 Subject: [PATCH] More fixes to the cheats system --- BizHawk.MultiClient/tools/Cheats/Cheat.cs | 2 ++ BizHawk.MultiClient/tools/Cheats/CheatList.cs | 23 +++++++++++-------- .../tools/HexEditor/HexEditor.cs | 8 +++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/BizHawk.MultiClient/tools/Cheats/Cheat.cs b/BizHawk.MultiClient/tools/Cheats/Cheat.cs index 46d6c4b097..c085ebdfbf 100644 --- a/BizHawk.MultiClient/tools/Cheats/Cheat.cs +++ b/BizHawk.MultiClient/tools/Cheats/Cheat.cs @@ -217,6 +217,7 @@ namespace BizHawk.MultiClient if (!IsSeparator) { _val++; + Pulse(); } } @@ -225,6 +226,7 @@ namespace BizHawk.MultiClient if (!IsSeparator) { _val--; + Pulse(); } } diff --git a/BizHawk.MultiClient/tools/Cheats/CheatList.cs b/BizHawk.MultiClient/tools/Cheats/CheatList.cs index 680f9eb43f..595004ecd0 100644 --- a/BizHawk.MultiClient/tools/Cheats/CheatList.cs +++ b/BizHawk.MultiClient/tools/Cheats/CheatList.cs @@ -94,25 +94,30 @@ namespace BizHawk.MultiClient { if (_cheatList.Any(x => x.Domain == c.Domain && x.Address == c.Address)) { - var cheat = _cheatList.FirstOrDefault(x => x.Domain == c.Domain && x.Address == c.Address); - cheat.Enable(); + _cheatList.FirstOrDefault(x => x.Domain == c.Domain && x.Address == c.Address).Enable(); } else { - _changes = true; _cheatList.Add(c); - ToolHelpers.UpdateCheatRelatedTools(); } + + _changes = true; + ToolHelpers.UpdateCheatRelatedTools(); } public void Insert(int index, Cheat c) { - if (!_cheatList.Any(x => x.Domain == c.Domain && x.Address == c.Address)) + if (_cheatList.Any(x => x.Domain == c.Domain && x.Address == c.Address)) { - _changes = true; - _cheatList.Insert(index, c); - ToolHelpers.UpdateCheatRelatedTools(); + _cheatList.FirstOrDefault(x => x.Domain == c.Domain && x.Address == c.Address).Enable(); } + else + { + _cheatList.Insert(index, c); + } + + _changes = true; + ToolHelpers.UpdateCheatRelatedTools(); } public void Remove(Cheat c) @@ -545,7 +550,7 @@ namespace BizHawk.MultiClient sb .Append(cheat.AddressStr).Append('\t') .Append(cheat.ValueStr).Append('\t') - .Append(cheat.Compare.HasValue ? cheat.Compare.Value : 'N').Append('\t') + .Append(cheat.Compare.HasValue ? cheat.Compare.Value.ToString() : "N").Append('\t') .Append(cheat.Domain != null ? cheat.Domain.Name : String.Empty).Append('\t') .Append(cheat.Enabled ? '1' : '0').Append('\t') .Append(cheat.Name).Append('\t') diff --git a/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs b/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs index 289b115dfa..3d611be67f 100644 --- a/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs +++ b/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs @@ -1692,8 +1692,8 @@ namespace BizHawk.MultiClient { if (Global.CheatList.IsActive(Domain, address)) { - var cheat = Global.CheatList.FirstOrDefault(x => x.Domain == Domain && x.Address == address); - cheat.Increment(); + Global.CheatList.FirstOrDefault(x => x.Domain == Domain && x.Address == address).Increment(); + Global.CheatList.FlagChanges(); } else { @@ -1730,8 +1730,8 @@ namespace BizHawk.MultiClient { if (Global.CheatList.IsActive(Domain, address)) { - var cheat = Global.CheatList.FirstOrDefault(x => x.Domain == Domain && x.Address == address); - cheat.Decrement(); + Global.CheatList.FirstOrDefault(x => x.Domain == Domain && x.Address == address).Decrement(); + Global.CheatList.FlagChanges(); } else {