From 4aae8a1311bf0c47e6da1431cf078019964302c3 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 5 Nov 2013 19:33:06 +0000 Subject: [PATCH] Cheats - implement editing (oops, it was released without it!), fix value display (was showing the actual ram value, not the cheat's override value), don't flag changes if erroneously adding an existing cheat. --- BizHawk.Client.Common/tools/Cheat.cs | 16 +++++++++++++++- BizHawk.Client.Common/tools/CheatList.cs | 4 +++- BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs | 6 +++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/BizHawk.Client.Common/tools/Cheat.cs b/BizHawk.Client.Common/tools/Cheat.cs index 538b4a9601..315ecf8040 100644 --- a/BizHawk.Client.Common/tools/Cheat.cs +++ b/BizHawk.Client.Common/tools/Cheat.cs @@ -121,7 +121,21 @@ namespace BizHawk.Client.Common public string ValueStr { - get { return _watch.ValueString; } + get + { + switch (_watch.Size) + { + default: + case Watch.WatchSize.Separator: + return String.Empty; + case Watch.WatchSize.Byte: + return (_watch as ByteWatch).FormatValue((byte)_val); + case Watch.WatchSize.Word: + return (_watch as WordWatch).FormatValue((ushort)_val); + case Watch.WatchSize.DWord: + return (_watch as DWordWatch).FormatValue((uint)_val); + } + } } public string CompareStr diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index fc53ec333a..a56c8de21c 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -106,6 +106,7 @@ namespace BizHawk.Client.Common if (cheat.IsSeparator) { _cheatList.Add(cheat); + Changes = true; } else { @@ -117,10 +118,11 @@ namespace BizHawk.Client.Common else { _cheatList.Add(cheat); + Changes = true; } } - Changes = true; + } public void Insert(int index, Cheat c) diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index fcdd397a57..01a862384b 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -229,7 +229,11 @@ namespace BizHawk.Client.EmuHawk private void EditCheat() { - MessageBox.Show("Edit clicked"); + var cheat = CheatEditor.Cheat; + Global.CheatList.Remove(Global.CheatList.FirstOrDefault(x => x.Domain == cheat.Domain && x.Address == cheat.Address)); + Global.CheatList.Add(cheat); + UpdateListView(); + UpdateMessageLabel(); } public void SaveConfigSettings()