From eaa212fef7eefac96aeaad640c6a52120160d1d1 Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 11 Sep 2012 00:17:54 +0000 Subject: [PATCH] Hex Editor - fix 6 digit domains (note that 8 digit will still fail should we have any) --- .../tools/HexEditor.Designer.cs | 34 +++++++++---------- BizHawk.MultiClient/tools/HexEditor.cs | 26 ++++++++------ 2 files changed, 33 insertions(+), 27 deletions(-) diff --git a/BizHawk.MultiClient/tools/HexEditor.Designer.cs b/BizHawk.MultiClient/tools/HexEditor.Designer.cs index a8c6659543..ca09a42d0b 100644 --- a/BizHawk.MultiClient/tools/HexEditor.Designer.cs +++ b/BizHawk.MultiClient/tools/HexEditor.Designer.cs @@ -32,8 +32,9 @@ System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HexEditor)); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.dumpToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.saveAsBinaryToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.dumpToFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -83,7 +84,6 @@ this.vScrollBar1 = new System.Windows.Forms.VScrollBar(); this.AddressesLabel = new System.Windows.Forms.Label(); this.Header = new System.Windows.Forms.Label(); - this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip1.SuspendLayout(); this.ViewerContextMenuStrip.SuspendLayout(); this.MemoryViewerBox.SuspendLayout(); @@ -115,12 +115,14 @@ this.fileToolStripMenuItem.Text = "&File"; this.fileToolStripMenuItem.DropDownOpened += new System.EventHandler(this.fileToolStripMenuItem_DropDownOpened); // - // dumpToFileToolStripMenuItem + // saveToolStripMenuItem // - this.dumpToFileToolStripMenuItem.Name = "dumpToFileToolStripMenuItem"; - this.dumpToFileToolStripMenuItem.Size = new System.Drawing.Size(229, 22); - this.dumpToFileToolStripMenuItem.Text = "Save as text..."; - this.dumpToFileToolStripMenuItem.Click += new System.EventHandler(this.dumpToFileToolStripMenuItem_Click); + this.saveToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.SaveAs; + this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; + this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); + this.saveToolStripMenuItem.Size = new System.Drawing.Size(229, 22); + this.saveToolStripMenuItem.Text = "Save"; + this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); // // saveAsBinaryToolStripMenuItem // @@ -131,6 +133,13 @@ this.saveAsBinaryToolStripMenuItem.Text = "Save as binary..."; this.saveAsBinaryToolStripMenuItem.Click += new System.EventHandler(this.saveAsBinaryToolStripMenuItem_Click); // + // dumpToFileToolStripMenuItem + // + this.dumpToFileToolStripMenuItem.Name = "dumpToFileToolStripMenuItem"; + this.dumpToFileToolStripMenuItem.Size = new System.Drawing.Size(229, 22); + this.dumpToFileToolStripMenuItem.Text = "Save as text..."; + this.dumpToFileToolStripMenuItem.Click += new System.EventHandler(this.dumpToFileToolStripMenuItem_Click); + // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; @@ -532,7 +541,7 @@ // this.AddressesLabel.AutoSize = true; this.AddressesLabel.ContextMenuStrip = this.ViewerContextMenuStrip; - this.AddressesLabel.Location = new System.Drawing.Point(48, 30); + this.AddressesLabel.Location = new System.Drawing.Point(55, 30); this.AddressesLabel.Name = "AddressesLabel"; this.AddressesLabel.Size = new System.Drawing.Size(31, 13); this.AddressesLabel.TabIndex = 0; @@ -551,15 +560,6 @@ this.Header.TabIndex = 2; this.Header.Text = "label1"; // - // saveToolStripMenuItem - // - this.saveToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.SaveAs; - this.saveToolStripMenuItem.Name = "saveToolStripMenuItem"; - this.saveToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.S))); - this.saveToolStripMenuItem.Size = new System.Drawing.Size(229, 22); - this.saveToolStripMenuItem.Text = "Save"; - this.saveToolStripMenuItem.Click += new System.EventHandler(this.saveToolStripMenuItem_Click); - // // HexEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/BizHawk.MultiClient/tools/HexEditor.cs b/BizHawk.MultiClient/tools/HexEditor.cs index 67111af342..03eb1d1a78 100644 --- a/BizHawk.MultiClient/tools/HexEditor.cs +++ b/BizHawk.MultiClient/tools/HexEditor.cs @@ -22,8 +22,8 @@ namespace BizHawk.MultiClient List domainMenuItems = new List(); int RowsVisible = 0; int NumDigits = 4; - string NumDigitsStr = "{0:X4} "; - string DigitFormatString = "{0:X2} "; + string NumDigitsStr = "{0:X4}"; + string DigitFormatString = "{0:X2}"; char[] nibbles = { 'G', 'G', 'G', 'G' , 'G', 'G', 'G', 'G'}; //G = off 0-9 & A-F are acceptable values int addressHighlighted = -1; List SecondaryHighlightedAddresses = new List(); @@ -150,8 +150,14 @@ namespace BizHawk.MultiClient addr = (row << 4); if (addr >= Domain.Size) break; - addrStr.AppendFormat(NumDigitsStr, addr); + + if (NumDigits == 4) + { + addrStr.Append(" "); //Hack to line things up better between 4 and 6 + } + addrStr.Append(String.Format("{0:X" + NumDigits + "}", addr)); addrStr.Append('\n'); + } return addrStr.ToString(); @@ -1061,7 +1067,7 @@ namespace BizHawk.MultiClient } int column = (x /*- 43*/) / (fontWidth * colWidth); - int start = GetTextOffset() - - 50; + int start = GetTextOffset() - 50; if (x > start) { column = (x - start) / (fontWidth / DataSize); @@ -1161,11 +1167,11 @@ namespace BizHawk.MultiClient { default: case 1: - return new Point(((address % 16) * (fontWidth * 3)) + 50, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30); + return new Point(((address % 16) * (fontWidth * 3)) + 57, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30); case 2: - return new Point((((address % 16) / DataSize) * (fontWidth * 5)) + 50, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30); + return new Point((((address % 16) / DataSize) * (fontWidth * 5)) + 57, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30); case 4: - return new Point((((address % 16) / DataSize) * (fontWidth * 9)) + 50, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30); + return new Point((((address % 16) / DataSize) * (fontWidth * 9)) + 57, (((address / 16) - vScrollBar1.Value) * fontHeight) + 30); } } @@ -1176,13 +1182,13 @@ namespace BizHawk.MultiClient { default: case 1: - start = (16 * (fontWidth * 3)) + 50; + start = (16 * (fontWidth * 3)) + 57; break; case 2: - start = ((16 / DataSize) * (fontWidth * 5)) + 50; + start = ((16 / DataSize) * (fontWidth * 5)) + 57; break; case 4: - start = ((16 / DataSize) * (fontWidth * 9)) + 50; + start = ((16 / DataSize) * (fontWidth * 9)) + 57; break; } start += (fontWidth * 4);