From 5402f1ff9e622c5cc8bcdca709bc9b79cb8e4c4c Mon Sep 17 00:00:00 2001 From: zeromus Date: Tue, 4 Aug 2015 22:25:58 -0500 Subject: [PATCH] dont reorder cheats list when editing cheats --- BizHawk.Client.Common/tools/CheatList.cs | 12 ++++++++++++ BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index 74f28a0c2b..ac029dddaf 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -164,6 +164,18 @@ namespace BizHawk.Client.Common Changes = true; } + public bool Exchange(Cheat oldCheat, Cheat newCheat) + { + int index = _cheatList.IndexOf(oldCheat); + if (index == -1) + return false; + + _cheatList[index] = newCheat; + Changes = true; + + return true; + } + public bool Remove(Cheat c) { var result = _cheatList.Remove(c); diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs index 5103fa18c2..c05f14fe22 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.cs @@ -178,8 +178,9 @@ namespace BizHawk.Client.EmuHawk private void EditCheat() { - Global.CheatList.Remove(CheatEditor.OriginalCheat); - AddCheat(); + Global.CheatList.Exchange(CheatEditor.OriginalCheat, CheatEditor.Cheat); + UpdateDialog(); + UpdateMessageLabel(); } public void SaveConfigSettings()