From e2caffcb04150b4b4b3c1de8d9ca6ceb29bba3ab Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Fri, 18 Mar 2011 18:13:24 +0000 Subject: [PATCH] Ram Watch - refactor some code --- BizHawk.MultiClient/Config.cs | 10 +++---- BizHawk.MultiClient/tools/RamSearch.cs | 11 ++++--- .../tools/RamWatch.Designer.cs | 8 +++++ BizHawk.MultiClient/tools/RamWatch.cs | 30 ++++++++++++++----- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs index a4928d08c4..816c5cff1a 100644 --- a/BizHawk.MultiClient/Config.cs +++ b/BizHawk.MultiClient/Config.cs @@ -58,11 +58,11 @@ public bool RamWatchShowChangeColumn = true; public bool RamWatchShowPrevColumn = false; public bool RamWatchShowChangeFromPrev = true; - public int RamWatchAddressWidth = 59; - public int RamWatchValueWidth = 59; - public int RamWatchPrevWidth = 59; - public int RamWatchChangeWidth = 54; - public int RamWatchNotesWidth = 130; + public int RamWatchAddressWidth = -1; + public int RamWatchValueWidth = -1; + public int RamWatchPrevWidth = -1; + public int RamWatchChangeWidth = -1; + public int RamWatchNotesWidth = -1; // RamSearch Settings public bool AutoLoadRamSearch = false; diff --git a/BizHawk.MultiClient/tools/RamSearch.cs b/BizHawk.MultiClient/tools/RamSearch.cs index f962d2499d..7b9f72775e 100644 --- a/BizHawk.MultiClient/tools/RamSearch.cs +++ b/BizHawk.MultiClient/tools/RamSearch.cs @@ -72,6 +72,13 @@ namespace BizHawk.MultiClient } private void RamSearch_Load(object sender, EventArgs e) + { + LoadConfigSettings(); + StartNewSearch(); + SetMemoryDomainMenu(); + } + + private void LoadConfigSettings() { defaultWidth = this.Size.Width; //Save these first so that the user can restore to its original size defaultHeight = this.Size.Height; @@ -87,8 +94,6 @@ namespace BizHawk.MultiClient littleEndianToolStripMenuItem.Checked = true; } - StartNewSearch(); - if (Global.Config.RamSearchWndx >= 0 && Global.Config.RamSearchWndy >= 0) this.Location = new Point(Global.Config.RamSearchWndx, Global.Config.RamSearchWndy); @@ -96,8 +101,6 @@ namespace BizHawk.MultiClient { this.Size = new System.Drawing.Size(Global.Config.RamSearchWidth, Global.Config.RamSearchHeight); } - - SetMemoryDomainMenu(); } private void SetMemoryDomainMenu() diff --git a/BizHawk.MultiClient/tools/RamWatch.Designer.cs b/BizHawk.MultiClient/tools/RamWatch.Designer.cs index a5c4760a6c..615027ef63 100644 --- a/BizHawk.MultiClient/tools/RamWatch.Designer.cs +++ b/BizHawk.MultiClient/tools/RamWatch.Designer.cs @@ -100,6 +100,7 @@ this.freezeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.freezeAddressToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.FreezetoolStripButton2 = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); this.menuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); @@ -323,6 +324,7 @@ this.showChangeCountsToolStripMenuItem, this.showPreviousValueToolStripMenuItem, this.prevValueShowsChangeAmountToolStripMenuItem, + this.toolStripSeparator7, this.restoreWindowSizeToolStripMenuItem}); this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20); @@ -726,6 +728,11 @@ this.FreezetoolStripButton2.Text = "Freeze"; this.FreezetoolStripButton2.Click += new System.EventHandler(this.FreezetoolStripButton2_Click); // + // toolStripSeparator7 + // + this.toolStripSeparator7.Name = "toolStripSeparator7"; + this.toolStripSeparator7.Size = new System.Drawing.Size(188, 6); + // // RamWatch // this.AllowDrop = true; @@ -827,5 +834,6 @@ private System.Windows.Forms.ToolStripMenuItem freezeToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem freezeAddressToolStripMenuItem; private System.Windows.Forms.ToolStripButton FreezetoolStripButton2; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index 0271e3f56a..7200f7b028 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -21,10 +21,16 @@ namespace BizHawk.MultiClient //Ability to watch in different memory domains //.wch format includes platform and domain type //address num digits based on domain size - //Refactor column width settings like Cheats, default valeu = -1, and check for negative values - //Refactor restore window size by saving widths in constructor and use them to restore + //Restore window size should restore column order as well + int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired int defaultHeight; + int defaultAddressWidth; + int defaultValueWidth; + int defaultPrevWidth; + int defaultChangeWidth; + int NotesWidth; + List watchList = new List(); string currentWatchFile = ""; bool changes = false; @@ -66,6 +72,11 @@ namespace BizHawk.MultiClient { defaultWidth = Size.Width; //Save these first so that the user can restore to its original size defaultHeight = Size.Height; + defaultAddressWidth = WatchListView.Columns[0].Width; + defaultValueWidth = WatchListView.Columns[1].Width; + defaultPrevWidth = WatchListView.Columns[2].Width; + defaultChangeWidth = WatchListView.Columns[3].Width; + NotesWidth = WatchListView.Columns[4].Width; if (Global.Config.RamWatchWndx >= 0 && Global.Config.RamWatchWndy >= 0) Location = new Point(Global.Config.RamWatchWndx, Global.Config.RamWatchWndy); @@ -76,11 +87,16 @@ namespace BizHawk.MultiClient } SetPrevColumn(Global.Config.RamWatchShowPrevColumn); SetChangesColumn(Global.Config.RamWatchShowChangeColumn); - WatchListView.Columns[0].Width = Global.Config.RamWatchAddressWidth; - WatchListView.Columns[1].Width = Global.Config.RamWatchValueWidth; - WatchListView.Columns[2].Width = Global.Config.RamWatchPrevWidth; - WatchListView.Columns[3].Width = Global.Config.RamWatchChangeWidth; - WatchListView.Columns[4].Width = Global.Config.RamWatchNotesWidth; + if (Global.Config.RamWatchAddressWidth > 0) + WatchListView.Columns[0].Width = Global.Config.RamWatchAddressWidth; + if (Global.Config.RamWatchValueWidth > 0) + WatchListView.Columns[1].Width = Global.Config.RamWatchValueWidth; + if (Global.Config.RamWatchPrevWidth > 0) + WatchListView.Columns[2].Width = Global.Config.RamWatchPrevWidth; + if (Global.Config.RamWatchChangeWidth > 0) + WatchListView.Columns[3].Width = Global.Config.RamWatchChangeWidth; + if (Global.Config.RamWatchNotesWidth > 0) + WatchListView.Columns[4].Width = Global.Config.RamWatchNotesWidth; } public void SaveConfigSettings()