diff --git a/BizHawk.MultiClient/tools/HexEditor.Designer.cs b/BizHawk.MultiClient/tools/HexEditor.Designer.cs index 6a503f0d05..a007f883a0 100644 --- a/BizHawk.MultiClient/tools/HexEditor.Designer.cs +++ b/BizHawk.MultiClient/tools/HexEditor.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HexEditor)); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -46,8 +47,13 @@ this.restoreWindowSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AddressBox = new System.Windows.Forms.TextBox(); + this.ViewerContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components); + this.pokeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.freezeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.addToRamWatchToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.MemoryViewer = new BizHawk.MultiClient.MemoryViewer(); this.menuStrip1.SuspendLayout(); + this.ViewerContextMenuStrip.SuspendLayout(); this.SuspendLayout(); // // menuStrip1 @@ -185,12 +191,43 @@ this.AddressBox.Size = new System.Drawing.Size(57, 20); this.AddressBox.TabIndex = 2; // + // ViewerContextMenuStrip + // + this.ViewerContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.pokeToolStripMenuItem, + this.freezeToolStripMenuItem, + this.addToRamWatchToolStripMenuItem}); + this.ViewerContextMenuStrip.Name = "ViewerContextMenuStrip"; + this.ViewerContextMenuStrip.Size = new System.Drawing.Size(176, 92); + // + // pokeToolStripMenuItem + // + this.pokeToolStripMenuItem.Name = "pokeToolStripMenuItem"; + this.pokeToolStripMenuItem.Size = new System.Drawing.Size(175, 22); + this.pokeToolStripMenuItem.Text = "&Poke"; + this.pokeToolStripMenuItem.Click += new System.EventHandler(this.pokeToolStripMenuItem_Click); + // + // freezeToolStripMenuItem + // + this.freezeToolStripMenuItem.Enabled = false; + this.freezeToolStripMenuItem.Name = "freezeToolStripMenuItem"; + this.freezeToolStripMenuItem.Size = new System.Drawing.Size(175, 22); + this.freezeToolStripMenuItem.Text = "&Freeze"; + // + // addToRamWatchToolStripMenuItem + // + this.addToRamWatchToolStripMenuItem.Name = "addToRamWatchToolStripMenuItem"; + this.addToRamWatchToolStripMenuItem.Size = new System.Drawing.Size(175, 22); + this.addToRamWatchToolStripMenuItem.Text = "&Add to Ram Watch"; + this.addToRamWatchToolStripMenuItem.Click += new System.EventHandler(this.addToRamWatchToolStripMenuItem_Click); + // // MemoryViewer // this.MemoryViewer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.MemoryViewer.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.MemoryViewer.ContextMenuStrip = this.ViewerContextMenuStrip; this.MemoryViewer.Location = new System.Drawing.Point(12, 37); this.MemoryViewer.Name = "MemoryViewer"; this.MemoryViewer.Size = new System.Drawing.Size(458, 295); @@ -215,6 +252,7 @@ this.Resize += new System.EventHandler(this.HexEditor_Resize); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); + this.ViewerContextMenuStrip.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); @@ -240,5 +278,9 @@ private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem enToolStripMenuItem; private System.Windows.Forms.TextBox AddressBox; + private System.Windows.Forms.ContextMenuStrip ViewerContextMenuStrip; + private System.Windows.Forms.ToolStripMenuItem pokeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem freezeToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem addToRamWatchToolStripMenuItem; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/HexEditor.cs b/BizHawk.MultiClient/tools/HexEditor.cs index f900816f87..a8ae9765de 100644 --- a/BizHawk.MultiClient/tools/HexEditor.cs +++ b/BizHawk.MultiClient/tools/HexEditor.cs @@ -6,6 +6,7 @@ using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; +using System.Globalization; namespace BizHawk.MultiClient { @@ -15,7 +16,6 @@ namespace BizHawk.MultiClient //Find text box - autohighlights matches, and shows total matches //Implement Goto address //Users can customize background, & text colors - //Context menu - Poke, Freeze/Unfreeze, Watch //Tool strip //Double click sends all highlighted to Ram Watch not just currently pointed //Add to Ram Watch menu item, enabled conditionally on if any address is highlighted @@ -190,7 +190,7 @@ namespace BizHawk.MultiClient } - private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e) + private void AddToRamWatch() { //Add to RAM Watch int address = MemoryViewer.GetPointedAddress(); @@ -230,6 +230,38 @@ namespace BizHawk.MultiClient } } + private void MemoryViewer_MouseDoubleClick(object sender, MouseEventArgs e) + { + AddToRamWatch(); + } + + private void pokeToolStripMenuItem_Click(object sender, EventArgs e) + { + int p = MemoryViewer.GetPointedAddress(); + if (p >= 0) + { + InputPrompt i = new InputPrompt(); + i.Text = "Poke " + String.Format("{0:X}", p); + i.SetMessage("Enter a hexadecimal value"); + i.ShowDialog(); + + if (i.UserOK) + { + if (InputValidate.IsValidHexNumber(i.UserText)) + { + int value = int.Parse(i.UserText, NumberStyles.HexNumber); + MemoryViewer.HighlightPointed(); + MemoryViewer.PokeHighlighted(value); + } + } + } + } + + private void addToRamWatchToolStripMenuItem_Click(object sender, EventArgs e) + { + AddToRamWatch(); + } + } } diff --git a/BizHawk.MultiClient/tools/HexEditor.resx b/BizHawk.MultiClient/tools/HexEditor.resx index 63ec1f833f..ae0a30281e 100644 --- a/BizHawk.MultiClient/tools/HexEditor.resx +++ b/BizHawk.MultiClient/tools/HexEditor.resx @@ -120,6 +120,9 @@ 17, 17 + + 126, 17 + diff --git a/BizHawk.MultiClient/tools/InputPrompt.Designer.cs b/BizHawk.MultiClient/tools/InputPrompt.Designer.cs index fd5878ef83..3d1de67003 100644 --- a/BizHawk.MultiClient/tools/InputPrompt.Designer.cs +++ b/BizHawk.MultiClient/tools/InputPrompt.Designer.cs @@ -69,6 +69,7 @@ this.Cancel.TabIndex = 3; this.Cancel.Text = "&Cancel"; this.Cancel.UseVisualStyleBackColor = true; + this.Cancel.Click += new System.EventHandler(this.Cancel_Click); // // InputPrompt // diff --git a/BizHawk.MultiClient/tools/InputPrompt.cs b/BizHawk.MultiClient/tools/InputPrompt.cs index 36762fab4c..2bc9301c2f 100644 --- a/BizHawk.MultiClient/tools/InputPrompt.cs +++ b/BizHawk.MultiClient/tools/InputPrompt.cs @@ -22,14 +22,25 @@ namespace BizHawk.MultiClient InitializeComponent(); } + public void SetMessage(string message) + { + PromptLabel.Text = message; + } + private void InputPrompt_Load(object sender, EventArgs e) { - this.Close(); + } private void OK_Click(object sender, EventArgs e) { UserOK = true; + UserText = PromptBox.Text; + this.Close(); + } + + private void Cancel_Click(object sender, EventArgs e) + { this.Close(); } } diff --git a/BizHawk.MultiClient/tools/MemoryViewer.cs b/BizHawk.MultiClient/tools/MemoryViewer.cs index 5cd8809714..028e5eff72 100644 --- a/BizHawk.MultiClient/tools/MemoryViewer.cs +++ b/BizHawk.MultiClient/tools/MemoryViewer.cs @@ -11,6 +11,10 @@ namespace BizHawk.MultiClient public class MemoryViewer : Panel { //TODO: highlighting and address determining for 2 & 4 byte viewing + //2 & 4 byte typign in + //show nibbles instead of highlighted address + //double check that typign into last column moves to the next + //If moving to an offscreen address, increment scrollbar public VScrollBar vScrollBar1; public Label info; @@ -298,9 +302,8 @@ namespace BizHawk.MultiClient SetAddressOver(e.X, e.Y); } - private void MemoryViewer_MouseClick(object sender, MouseEventArgs e) + public void HighlightPointed() { - SetAddressOver(e.X, e.Y); if (addressOver >= 0) { addressHighlighted = addressOver; @@ -312,6 +315,12 @@ namespace BizHawk.MultiClient this.Refresh(); } + private void MemoryViewer_MouseClick(object sender, MouseEventArgs e) + { + SetAddressOver(e.X, e.Y); + HighlightPointed(); + } + public int GetPointedAddress() { if (addressOver >= 0) @@ -337,5 +346,12 @@ namespace BizHawk.MultiClient else return false; } + + public void PokeHighlighted(int value) + { + //TODO: 2 byte & 4 byte + if (addressHighlighted >= 0) + Domain.PokeByte(addressHighlighted, (byte)value); + } } }