From 376ffd3ba43bd86a38396fb70249ad78cd2d4b8c Mon Sep 17 00:00:00 2001 From: brandman211 Date: Sat, 9 Jun 2012 21:43:02 +0000 Subject: [PATCH] -Refactored what zeromus wanted me to and nothing more. -The number of watches in Ram Watch is now updated in UpdateValues instead of LoadWatchFile, meaning that it's updated every time items are added / removed. --Also noticed that separators count as watches. Filter these out and exclude them from the count, adelikat? --- BizHawk.MultiClient/tools/RamWatch.cs | 4 +- BizHawk.MultiClient/tools/Watch.cs | 98 ++++++--------------------- 2 files changed, 22 insertions(+), 80 deletions(-) diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index a7c735b183..c737cea949 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -88,8 +88,7 @@ namespace BizHawk.MultiClient WatchListView.BlazingFast = true; WatchListView.Refresh(); WatchListView.BlazingFast = false; - - + WatchCountLabel.Text = watchList.Count.ToString() + " watches"; } public void AddWatch(Watch w) @@ -307,7 +306,6 @@ namespace BizHawk.MultiClient } changes = false; MessageLabel.Text = Path.GetFileNameWithoutExtension(path); - WatchCountLabel.Text = watchList.Count.ToString() + " watches"; Global.Config.RecentWatches.Add(path); SetMemoryDomain(WatchCommon.GetDomainPos(domain)); return true; diff --git a/BizHawk.MultiClient/tools/Watch.cs b/BizHawk.MultiClient/tools/Watch.cs index 13e4ceb8e4..3d3484e00b 100644 --- a/BizHawk.MultiClient/tools/Watch.cs +++ b/BizHawk.MultiClient/tools/Watch.cs @@ -338,6 +338,22 @@ namespace BizHawk.MultiClient return ValToString(lastsearch); } + private int ComparePrevious(Watch Other, string previous) + { + switch (previous) + { + case "Last Search": + return CompareLastSearch(Other); + case "Original": + return CompareOriginal(Other); + default: + case "Last Frame": + return ComparePrev(Other); + case "Last Change": + return CompareLastChange(Other); + } + } + private int CompareAddress(Watch Other) { if (this.address < Other.address) @@ -479,22 +495,7 @@ namespace BizHawk.MultiClient compare = CompareChanges(Other); if (compare == 0) { - switch (previous) - { - case "Last Search": - compare = CompareLastSearch(Other); - break; - case "Original": - compare = CompareOriginal(Other); - break; - default: - case "Last Frame": - compare = ComparePrev(Other); - break; - case "Last Change": - compare = CompareLastChange(Other); - break; - } + compare = ComparePrevious(Other, previous); if (compare == 0) compare = CompareNotes(Other); } @@ -513,22 +514,7 @@ namespace BizHawk.MultiClient compare = CompareChanges(Other); if (compare == 0) { - switch (previous) - { - case "Last Search": - compare = CompareLastSearch(Other); - break; - case "Original": - compare = CompareOriginal(Other); - break; - default: - case "Last Frame": - compare = ComparePrev(Other); - break; - case "Last Change": - compare = CompareLastChange(Other); - break; - } + compare = ComparePrevious(Other, previous); if (compare == 0) compare = CompareNotes(Other); } @@ -538,22 +524,7 @@ namespace BizHawk.MultiClient else if (parameter == "Prev") { - switch (previous) - { - case "Last Search": - compare = CompareLastSearch(Other); - break; - case "Original": - compare = CompareOriginal(Other); - break; - default: - case "Last Frame": - compare = ComparePrev(Other); - break; - case "Last Change": - compare = CompareLastChange(Other); - break; - } + compare = ComparePrevious(Other, previous); if (compare == 0) { compare = CompareAddress(Other); @@ -581,22 +552,7 @@ namespace BizHawk.MultiClient compare = CompareValue(Other); if (compare == 0) { - switch (previous) - { - case "Last Search": - compare = CompareLastSearch(Other); - break; - case "Original": - compare = CompareOriginal(Other); - break; - default: - case "Last Frame": - compare = ComparePrev(Other); - break; - case "Last Change": - compare = CompareLastChange(Other); - break; - } + compare = ComparePrevious(Other, previous); if (compare == 0) compare = CompareNotes(Other); } @@ -617,19 +573,7 @@ namespace BizHawk.MultiClient { compare = CompareChanges(Other); if (compare == 0) - switch (previous) - { - case "Last Search": - compare = CompareLastSearch(Other); - break; - case "Original": - compare = CompareOriginal(Other); - break; - case "Last Frame": - default: - compare = ComparePrev(Other); - break; - } + compare = ComparePrevious(Other, previous); } } }