From b8966c4566ddc53a78c318127b6810366c02b8d8 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Thu, 24 Feb 2011 16:17:46 +0000 Subject: [PATCH] Ram Watch - option to show a Previous value column (off by default) --- .../tools/RamWatch.Designer.cs | 73 +++++++++++------- BizHawk.MultiClient/tools/RamWatch.cs | 74 ++++++++++++++++--- 2 files changed, 111 insertions(+), 36 deletions(-) diff --git a/BizHawk.MultiClient/tools/RamWatch.Designer.cs b/BizHawk.MultiClient/tools/RamWatch.Designer.cs index d8dc61dff3..daf0569ae3 100644 --- a/BizHawk.MultiClient/tools/RamWatch.Designer.cs +++ b/BizHawk.MultiClient/tools/RamWatch.Designer.cs @@ -55,9 +55,13 @@ this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); this.moveUpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.moveDownToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showChangeCountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.WatchListView = new BizHawk.VirtualListView(); this.Address = new System.Windows.Forms.ColumnHeader(); this.Value = new System.Windows.Forms.ColumnHeader(); + this.Prev = new System.Windows.Forms.ColumnHeader(); this.ChangeCounts = new System.Windows.Forms.ColumnHeader(); this.Notes = new System.Windows.Forms.ColumnHeader(); this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); @@ -86,9 +90,7 @@ this.MoveDownStripButton1 = new System.Windows.Forms.ToolStripButton(); this.WatchCountLabel = new System.Windows.Forms.Label(); this.MessageLabel = new System.Windows.Forms.Label(); - this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.showChangeCountsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.showPreviousValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.contextMenuStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout(); @@ -305,6 +307,32 @@ this.moveDownToolStripMenuItem.Text = "Move &Down"; this.moveDownToolStripMenuItem.Click += new System.EventHandler(this.moveDownToolStripMenuItem_Click); // + // optionsToolStripMenuItem + // + this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.showChangeCountsToolStripMenuItem, + this.showPreviousValueToolStripMenuItem, + this.restoreWindowSizeToolStripMenuItem}); + this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; + this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20); + this.optionsToolStripMenuItem.Text = "&Options"; + // + // showChangeCountsToolStripMenuItem + // + this.showChangeCountsToolStripMenuItem.Checked = true; + this.showChangeCountsToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; + this.showChangeCountsToolStripMenuItem.Name = "showChangeCountsToolStripMenuItem"; + this.showChangeCountsToolStripMenuItem.Size = new System.Drawing.Size(188, 22); + this.showChangeCountsToolStripMenuItem.Text = "Show Change Counts"; + this.showChangeCountsToolStripMenuItem.Click += new System.EventHandler(this.showChangeCountsToolStripMenuItem_Click); + // + // restoreWindowSizeToolStripMenuItem + // + this.restoreWindowSizeToolStripMenuItem.Name = "restoreWindowSizeToolStripMenuItem"; + this.restoreWindowSizeToolStripMenuItem.Size = new System.Drawing.Size(188, 22); + this.restoreWindowSizeToolStripMenuItem.Text = "Restore Window Size"; + this.restoreWindowSizeToolStripMenuItem.Click += new System.EventHandler(this.restoreWindowSizeToolStripMenuItem_Click); + // // WatchListView // this.WatchListView.AllowColumnReorder = true; @@ -315,6 +343,7 @@ this.WatchListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.Address, this.Value, + this.Prev, this.ChangeCounts, this.Notes}); this.WatchListView.ContextMenuStrip = this.contextMenuStrip1; @@ -342,6 +371,12 @@ this.Value.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; this.Value.Width = 59; // + // Prev + // + this.Prev.Text = "Prev"; + this.Prev.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.Prev.Width = 0; + // // ChangeCounts // this.ChangeCounts.Text = "Changes"; @@ -351,7 +386,7 @@ // Notes // this.Notes.Text = "Notes"; - this.Notes.Width = 190; + this.Notes.Width = 160; // // contextMenuStrip1 // @@ -600,30 +635,12 @@ this.MessageLabel.TabIndex = 5; this.MessageLabel.Text = " "; // - // optionsToolStripMenuItem + // showPreviousValueToolStripMenuItem // - this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.showChangeCountsToolStripMenuItem, - this.restoreWindowSizeToolStripMenuItem}); - this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem"; - this.optionsToolStripMenuItem.Size = new System.Drawing.Size(56, 20); - this.optionsToolStripMenuItem.Text = "&Options"; - // - // showChangeCountsToolStripMenuItem - // - this.showChangeCountsToolStripMenuItem.Checked = true; - this.showChangeCountsToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; - this.showChangeCountsToolStripMenuItem.Name = "showChangeCountsToolStripMenuItem"; - this.showChangeCountsToolStripMenuItem.Size = new System.Drawing.Size(188, 22); - this.showChangeCountsToolStripMenuItem.Text = "Show Change Counts"; - this.showChangeCountsToolStripMenuItem.Click += new System.EventHandler(this.showChangeCountsToolStripMenuItem_Click); - // - // restoreWindowSizeToolStripMenuItem - // - this.restoreWindowSizeToolStripMenuItem.Name = "restoreWindowSizeToolStripMenuItem"; - this.restoreWindowSizeToolStripMenuItem.Size = new System.Drawing.Size(188, 22); - this.restoreWindowSizeToolStripMenuItem.Text = "Restore Window Size"; - this.restoreWindowSizeToolStripMenuItem.Click += new System.EventHandler(this.restoreWindowSizeToolStripMenuItem_Click); + this.showPreviousValueToolStripMenuItem.Name = "showPreviousValueToolStripMenuItem"; + this.showPreviousValueToolStripMenuItem.Size = new System.Drawing.Size(188, 22); + this.showPreviousValueToolStripMenuItem.Text = "Show Previous Value"; + this.showPreviousValueToolStripMenuItem.Click += new System.EventHandler(this.showPreviousValueToolStripMenuItem_Click); // // RamWatch // @@ -680,6 +697,7 @@ private System.Windows.Forms.ToolStrip toolStrip1; private System.Windows.Forms.ColumnHeader Address; private System.Windows.Forms.ColumnHeader Value; + private System.Windows.Forms.ColumnHeader Prev; private System.Windows.Forms.ColumnHeader ChangeCounts; private System.Windows.Forms.ColumnHeader Notes; private System.Windows.Forms.Label WatchCountLabel; @@ -717,5 +735,6 @@ private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem showChangeCountsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem restoreWindowSizeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem showPreviousValueToolStripMenuItem; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/RamWatch.cs b/BizHawk.MultiClient/tools/RamWatch.cs index ca0f8b0a06..96c4b186a0 100644 --- a/BizHawk.MultiClient/tools/RamWatch.cs +++ b/BizHawk.MultiClient/tools/RamWatch.cs @@ -20,9 +20,9 @@ namespace BizHawk.MultiClient //On Movie UP/Down set highlighted items to be what the user had selected (in their new position) //DisplayWatches needs to do value display properly like updatevalues, or just run update values //Ability to watch in different memory domains - //IDEAS: - //Option to show previous value - //Option to show change from previous value + //Save column showing in config + //Save column widths in config + //Option for Prev to show change (+2 or -2) etc int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired int defaultHeight; @@ -87,14 +87,14 @@ namespace BizHawk.MultiClient void WatchListView_QueryItemText(int index, int column, out string text) { text = ""; - if (column == 0) + if (column == 0) //Address { if (watchList[index].type == atype.SEPARATOR) text = ""; else text = String.Format("{0:X}", watchList[index].address); } - if (column == 1) + if (column == 1) //Value { if (watchList[index].type == atype.SEPARATOR) text = ""; @@ -125,11 +125,42 @@ namespace BizHawk.MultiClient } } } - if (column == 2) + if (column == 2) //Prev + { + if (watchList[index].type == atype.SEPARATOR) + text = ""; + else + { + switch (watchList[index].signed) + { + case asigned.HEX: + switch (watchList[index].type) + { + case atype.BYTE: + text = String.Format("{0:X2}", watchList[index].prev); + break; + case atype.WORD: + text = String.Format("{0:X4}", watchList[index].prev); + break; + case atype.DWORD: + text = String.Format("{0:X8}", watchList[index].prev); + break; + } + break; + case asigned.SIGNED: + text = ((sbyte)watchList[index].prev).ToString(); + break; + case asigned.UNSIGNED: + text = watchList[index].prev.ToString(); + break; + } + } + } + if (column == 3) //Change Counts { text = watchList[index].changecount.ToString(); } - if (column == 3) + if (column == 4) //Notes { if (watchList[index].type == atype.SEPARATOR) text = ""; @@ -675,6 +706,17 @@ namespace BizHawk.MultiClient private void restoreWindowSizeToolStripMenuItem_Click(object sender, EventArgs e) { this.Size = new System.Drawing.Size(defaultWidth, defaultHeight); + WatchListView.Columns[0].Width = 59; //Address + WatchListView.Columns[1].Width = 59; //Value + if (showPreviousValueToolStripMenuItem.Checked) + WatchListView.Columns[2].Width = 59; //Prev + else + WatchListView.Columns[2].Width = 0; + if (showChangeCountsToolStripMenuItem.Checked) + WatchListView.Columns[3].Width = 54; //Change counts + else + WatchListView.Columns[3].Width = 0; + WatchListView.Columns[4].Width = 150; //Notes } private void newToolStripButton_Click(object sender, EventArgs e) @@ -902,12 +944,26 @@ namespace BizHawk.MultiClient if (showChangeCountsToolStripMenuItem.Checked) { showChangeCountsToolStripMenuItem.Checked = false; - WatchListView.Columns[2].Width = 0; + WatchListView.Columns[3].Width = 0; } else { showChangeCountsToolStripMenuItem.Checked = true; - WatchListView.Columns[2].Width = 60; + WatchListView.Columns[3].Width = 60; + } + } + + private void showPreviousValueToolStripMenuItem_Click(object sender, EventArgs e) + { + if (showPreviousValueToolStripMenuItem.Checked) + { + showPreviousValueToolStripMenuItem.Checked = false; + WatchListView.Columns[2].Width = 0; + } + else + { + showPreviousValueToolStripMenuItem.Checked = true; + WatchListView.Columns[2].Width = 59; } } }