From 992acd9e96edd1366991f10888225e97767d3d12 Mon Sep 17 00:00:00 2001 From: Adam Sturge Date: Sun, 7 Feb 2016 20:56:40 -0800 Subject: [PATCH] Added code to sort by comparison type. Added code to compare based on comparison type selected --- BizHawk.Client.Common/tools/Cheat.cs | 48 ++++++++++++++++++- BizHawk.Client.Common/tools/CheatList.cs | 20 ++++++++ .../tools/Cheats/Cheats.Designer.cs | 6 +-- 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/BizHawk.Client.Common/tools/Cheat.cs b/BizHawk.Client.Common/tools/Cheat.cs index 4cee5a343b..fb37a8fd08 100644 --- a/BizHawk.Client.Common/tools/Cheat.cs +++ b/BizHawk.Client.Common/tools/Cheat.cs @@ -253,10 +253,54 @@ namespace BizHawk.Client.Common { if (_compare.HasValue) { - if (_compare.Value == _watch.ValueNoFreeze) // NOTE : THIS IS THE PLACE TO ADD DIFFERENT COMPARISON TYPES + switch (_comparisonType) { - _watch.Poke(GetStringForPulse(_val)); + case Cheat.COMPARISONTYPE.EQUAL: + if (_compare.Value == _watch.ValueNoFreeze) + { + _watch.Poke(GetStringForPulse(_val)); + } + break; + case Cheat.COMPARISONTYPE.GREATER_THAN: + if (_compare.Value > _watch.ValueNoFreeze) + { + _watch.Poke(GetStringForPulse(_val)); + } + break; + case Cheat.COMPARISONTYPE.GREATER_THAN_OR_EQUAL: + if (_compare.Value >= _watch.ValueNoFreeze) + { + _watch.Poke(GetStringForPulse(_val)); + } + break; + case Cheat.COMPARISONTYPE.LESS_THAN: + if (_compare.Value < _watch.ValueNoFreeze) + { + _watch.Poke(GetStringForPulse(_val)); + } + break; + case Cheat.COMPARISONTYPE.LESS_THAN_OR_EQUAL: + if (_compare.Value <= _watch.ValueNoFreeze) + { + _watch.Poke(GetStringForPulse(_val)); + } + break; + case Cheat.COMPARISONTYPE.NOT_EQUAL: + if (_compare.Value != _watch.ValueNoFreeze) + { + _watch.Poke(GetStringForPulse(_val)); + } + break; + default : + if (_compare.Value == _watch.ValueNoFreeze) + { + _watch.Poke(GetStringForPulse(_val)); + } + break; + } + + } else { diff --git a/BizHawk.Client.Common/tools/CheatList.cs b/BizHawk.Client.Common/tools/CheatList.cs index 626fc91c77..114c9d644f 100644 --- a/BizHawk.Client.Common/tools/CheatList.cs +++ b/BizHawk.Client.Common/tools/CheatList.cs @@ -673,6 +673,25 @@ namespace BizHawk.Client.Common .ToList(); } + break; + case COMPARISONTYPE: + if (reverse) + { + _cheatList = _cheatList + .OrderByDescending(x => x.ComparisonType) + .ThenBy(x => x.Name) + .ThenBy(x => x.Address ?? 0) + .ToList(); + } + else + { + _cheatList = _cheatList + .OrderBy(x => x.ComparisonType) + .ThenBy(x => x.Name) + .ThenBy(x => x.Address ?? 0) + .ToList(); + } + break; } } @@ -706,5 +725,6 @@ namespace BizHawk.Client.Common public const string SIZE = "SizeColumn"; public const string ENDIAN = "EndianColumn"; public const string TYPE = "DisplayTypeColumn"; + private const string COMPARISONTYPE = "ComparisonTypeColumn"; } } diff --git a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs index 8170360f19..a16911fb78 100644 --- a/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Cheats/Cheats.Designer.cs @@ -111,10 +111,10 @@ this.CheatListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.CheatName, this.Address, - this.Value, - this.ComparisonType, + this.Value, this.Compare, - this.On, + this.ComparisonType, + this.On, this.Domain}); this.CheatListView.ContextMenuStrip = this.CheatsContextMenu; this.CheatListView.FullRowSelect = true;