diff --git a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs index 4e8ccece..0b63f79d 100644 --- a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs +++ b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.Designer.cs @@ -35,6 +35,8 @@ this.mnuShowLineNotes = new System.Windows.Forms.ToolStripMenuItem(); this.mnuShowCodeNotes = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator(); + this.mnuEditLabel = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator(); this.mnuGoToLocation = new System.Windows.Forms.ToolStripMenuItem(); this.mnuAddToWatch = new System.Windows.Forms.ToolStripMenuItem(); this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem(); @@ -75,6 +77,8 @@ this.mnuShowLineNotes, this.mnuShowCodeNotes, this.toolStripMenuItem2, + this.mnuEditLabel, + this.toolStripMenuItem4, this.mnuGoToLocation, this.mnuAddToWatch, this.mnuFindOccurrences, @@ -82,7 +86,7 @@ this.mnuNavigateBackward, this.mnuNavigateForward}); this.contextMenuCode.Name = "contextMenuWatch"; - this.contextMenuCode.Size = new System.Drawing.Size(259, 220); + this.contextMenuCode.Size = new System.Drawing.Size(259, 270); this.contextMenuCode.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuCode_Opening); // // mnuShowNextStatement @@ -129,6 +133,18 @@ this.toolStripMenuItem2.Name = "toolStripMenuItem2"; this.toolStripMenuItem2.Size = new System.Drawing.Size(255, 6); // + // mnuEditLabel + // + this.mnuEditLabel.Name = "mnuEditLabel"; + this.mnuEditLabel.Size = new System.Drawing.Size(258, 22); + this.mnuEditLabel.Text = "Edit Label"; + this.mnuEditLabel.Click += new System.EventHandler(this.mnuEditLabel_Click); + // + // toolStripMenuItem4 + // + this.toolStripMenuItem4.Name = "toolStripMenuItem4"; + this.toolStripMenuItem4.Size = new System.Drawing.Size(255, 6); + // // mnuGoToLocation // this.mnuGoToLocation.Name = "mnuGoToLocation"; @@ -377,5 +393,7 @@ private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3; private System.Windows.Forms.ToolStripMenuItem mnuNavigateForward; private System.Windows.Forms.ToolStripMenuItem mnuNavigateBackward; + private System.Windows.Forms.ToolStripMenuItem mnuEditLabel; + private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4; } } diff --git a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs index 65160297..4ed1b850 100644 --- a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs +++ b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs @@ -290,15 +290,18 @@ namespace Mesen.GUI.Debugger AddWatch(); } } - + mnuGoToLocation.Enabled = true; - mnuGoToLocation.Text = "Go to Location (" + word + ")"; + mnuGoToLocation.Text = $"Go to Location ({word})"; mnuAddToWatch.Enabled = true; - mnuAddToWatch.Text = "Add to Watch (" + word + ")"; + mnuAddToWatch.Text = $"Add to Watch ({word})"; mnuFindOccurrences.Enabled = true; - mnuFindOccurrences.Text = "Find Occurrences (" + word + ")"; + mnuFindOccurrences.Text = $"Find Occurrences ({word})"; + + mnuEditLabel.Enabled = true; + mnuEditLabel.Text = $"Edit Label ({word})"; } else { mnuGoToLocation.Enabled = false; mnuGoToLocation.Text = "Go to Location"; @@ -306,6 +309,23 @@ namespace Mesen.GUI.Debugger mnuAddToWatch.Text = "Add to Watch"; mnuFindOccurrences.Enabled = false; mnuFindOccurrences.Text = "Find Occurrences"; + mnuEditLabel.Enabled = false; + mnuEditLabel.Text = "Edit Label"; + + if(e.Location.X < this.ctrlCodeViewer.CodeMargin && ctrlCodeViewer.CurrentLine >= 0) { + _lastClickedAddress = (UInt32)ctrlCodeViewer.CurrentLine; + + string address = $"${_lastClickedAddress.ToString("X4")}"; + _newWatchValue = $"[{address}]"; + _lastWord = address; + + mnuAddToWatch.Enabled = true; + mnuAddToWatch.Text = $"Add to Watch ({address})"; + mnuFindOccurrences.Enabled = true; + mnuFindOccurrences.Text = $"Find Occurrences ({address})"; + mnuEditLabel.Enabled = true; + mnuEditLabel.Text = $"Edit Label ({address})"; + } } } @@ -480,6 +500,15 @@ namespace Mesen.GUI.Debugger UpdateConfig(); } + private void mnuEditLabel_Click(object sender, EventArgs e) + { + AddressTypeInfo info = new AddressTypeInfo(); + InteropEmu.DebugGetAbsoluteAddressAndType(_lastClickedAddress, ref info); + if(info.Address >= 0) { + ctrlLabelList.EditLabel((UInt32)info.Address, info.Type); + } + } + private void mnuNavigateForward_Click(object sender, EventArgs e) { this.ctrlCodeViewer.NavigateForward();