Debugger: Added "View in ..." shortcuts to label list

This commit is contained in:
Sour 2018-08-26 19:25:27 -04:00
parent 47249556d2
commit 7e91e632cc
7 changed files with 99 additions and 21 deletions

View file

@ -153,6 +153,10 @@ namespace Mesen.GUI.Config
public XmlKeys LabelList_AddToWatch = Keys.None;
[ShortcutName("Label List: Find Occurrences")]
public XmlKeys LabelList_FindOccurrences = Keys.None;
[ShortcutName("Label List: View in CPU Memory")]
public XmlKeys LabelList_ViewInCpuMemory = Keys.None;
[ShortcutName("Label List: View in [memory type]")]
public XmlKeys LabelList_ViewInMemoryType = Keys.None;
[ShortcutName("Breakpoint List: Add Breakpoint")]
public XmlKeys BreakpointList_Add = Keys.Insert;

View file

@ -374,7 +374,7 @@ namespace Mesen.GUI.Debugger.Controls
private void mnuEditInMemoryViewer_Click(object sender, EventArgs e)
{
if(UpdateContextMenu(_lastLocation)) {
DebugWindowManager.OpenMemoryViewer(_lastClickedAddress, false);
DebugWindowManager.OpenMemoryViewer(_lastClickedAddress, DebugMemoryType.CpuMemory);
}
}

View file

@ -33,6 +33,9 @@
this.mnuEdit = new System.Windows.Forms.ToolStripMenuItem();
this.mnuDelete = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
this.mnuViewInCpuMemory = new System.Windows.Forms.ToolStripMenuItem();
this.mnuViewInMemoryType = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripSeparator();
this.mnuAddBreakpoint = new System.Windows.Forms.ToolStripMenuItem();
this.mnuAddToWatch = new System.Windows.Forms.ToolStripMenuItem();
this.mnuFindOccurrences = new System.Windows.Forms.ToolStripMenuItem();
@ -53,19 +56,22 @@
this.mnuEdit,
this.mnuDelete,
this.toolStripMenuItem1,
this.mnuViewInCpuMemory,
this.mnuViewInMemoryType,
this.toolStripMenuItem3,
this.mnuAddBreakpoint,
this.mnuAddToWatch,
this.mnuFindOccurrences,
this.toolStripMenuItem2,
this.mnuShowComments});
this.contextMenu.Name = "contextMenu";
this.contextMenu.Size = new System.Drawing.Size(167, 170);
this.contextMenu.Size = new System.Drawing.Size(187, 242);
//
// mnuAdd
//
this.mnuAdd.Image = global::Mesen.GUI.Properties.Resources.Add;
this.mnuAdd.Name = "mnuAdd";
this.mnuAdd.Size = new System.Drawing.Size(166, 22);
this.mnuAdd.Size = new System.Drawing.Size(186, 22);
this.mnuAdd.Text = "Add";
this.mnuAdd.Click += new System.EventHandler(this.mnuAdd_Click);
//
@ -73,7 +79,7 @@
//
this.mnuEdit.Image = global::Mesen.GUI.Properties.Resources.EditLabel;
this.mnuEdit.Name = "mnuEdit";
this.mnuEdit.Size = new System.Drawing.Size(166, 22);
this.mnuEdit.Size = new System.Drawing.Size(186, 22);
this.mnuEdit.Text = "Edit";
this.mnuEdit.Click += new System.EventHandler(this.mnuEdit_Click);
//
@ -81,20 +87,41 @@
//
this.mnuDelete.Image = global::Mesen.GUI.Properties.Resources.Close;
this.mnuDelete.Name = "mnuDelete";
this.mnuDelete.Size = new System.Drawing.Size(166, 22);
this.mnuDelete.Size = new System.Drawing.Size(186, 22);
this.mnuDelete.Text = "Delete";
this.mnuDelete.Click += new System.EventHandler(this.mnuDelete_Click);
//
// toolStripMenuItem1
//
this.toolStripMenuItem1.Name = "toolStripMenuItem1";
this.toolStripMenuItem1.Size = new System.Drawing.Size(163, 6);
this.toolStripMenuItem1.Size = new System.Drawing.Size(183, 6);
//
// mnuViewInCpuMemory
//
this.mnuViewInCpuMemory.Image = global::Mesen.GUI.Properties.Resources.Chip;
this.mnuViewInCpuMemory.Name = "mnuViewInCpuMemory";
this.mnuViewInCpuMemory.Size = new System.Drawing.Size(186, 22);
this.mnuViewInCpuMemory.Text = "View in CPU memory";
this.mnuViewInCpuMemory.Click += new System.EventHandler(this.mnuViewInCpuMemory_Click);
//
// mnuViewInMemoryType
//
this.mnuViewInMemoryType.Image = global::Mesen.GUI.Properties.Resources.CheatCode;
this.mnuViewInMemoryType.Name = "mnuViewInMemoryType";
this.mnuViewInMemoryType.Size = new System.Drawing.Size(186, 22);
this.mnuViewInMemoryType.Text = "View in {0} memory";
this.mnuViewInMemoryType.Click += new System.EventHandler(this.mnuViewInMemoryType_Click);
//
// toolStripMenuItem3
//
this.toolStripMenuItem3.Name = "toolStripMenuItem3";
this.toolStripMenuItem3.Size = new System.Drawing.Size(183, 6);
//
// mnuAddBreakpoint
//
this.mnuAddBreakpoint.Image = global::Mesen.GUI.Properties.Resources.Breakpoint;
this.mnuAddBreakpoint.Name = "mnuAddBreakpoint";
this.mnuAddBreakpoint.Size = new System.Drawing.Size(166, 22);
this.mnuAddBreakpoint.Size = new System.Drawing.Size(186, 22);
this.mnuAddBreakpoint.Text = "Add breakpoint";
this.mnuAddBreakpoint.Click += new System.EventHandler(this.mnuAddBreakpoint_Click);
//
@ -102,7 +129,7 @@
//
this.mnuAddToWatch.Image = global::Mesen.GUI.Properties.Resources.Add;
this.mnuAddToWatch.Name = "mnuAddToWatch";
this.mnuAddToWatch.Size = new System.Drawing.Size(166, 22);
this.mnuAddToWatch.Size = new System.Drawing.Size(186, 22);
this.mnuAddToWatch.Text = "Add to watch";
this.mnuAddToWatch.Click += new System.EventHandler(this.mnuAddToWatch_Click);
//
@ -110,20 +137,20 @@
//
this.mnuFindOccurrences.Image = global::Mesen.GUI.Properties.Resources.Find;
this.mnuFindOccurrences.Name = "mnuFindOccurrences";
this.mnuFindOccurrences.Size = new System.Drawing.Size(166, 22);
this.mnuFindOccurrences.Size = new System.Drawing.Size(186, 22);
this.mnuFindOccurrences.Text = "Find Occurrences";
this.mnuFindOccurrences.Click += new System.EventHandler(this.mnuFindOccurrences_Click);
//
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
this.toolStripMenuItem2.Size = new System.Drawing.Size(163, 6);
this.toolStripMenuItem2.Size = new System.Drawing.Size(183, 6);
//
// mnuShowComments
//
this.mnuShowComments.CheckOnClick = true;
this.mnuShowComments.Name = "mnuShowComments";
this.mnuShowComments.Size = new System.Drawing.Size(166, 22);
this.mnuShowComments.Size = new System.Drawing.Size(186, 22);
this.mnuShowComments.Text = "Show Comments";
this.mnuShowComments.Click += new System.EventHandler(this.mnuShowComments_Click);
//
@ -199,5 +226,8 @@
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
private System.Windows.Forms.ColumnHeader colComment;
private System.Windows.Forms.ToolStripMenuItem mnuShowComments;
private System.Windows.Forms.ToolStripMenuItem mnuViewInCpuMemory;
private System.Windows.Forms.ToolStripMenuItem mnuViewInMemoryType;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem3;
}
}

View file

@ -45,6 +45,9 @@ namespace Mesen.GUI.Debugger.Controls
mnuAddToWatch.InitShortcut(this, nameof(DebuggerShortcutsConfig.LabelList_AddToWatch));
mnuAddBreakpoint.InitShortcut(this, nameof(DebuggerShortcutsConfig.LabelList_AddBreakpoint));
mnuFindOccurrences.InitShortcut(this, nameof(DebuggerShortcutsConfig.LabelList_FindOccurrences));
mnuViewInCpuMemory.InitShortcut(this, nameof(DebuggerShortcutsConfig.LabelList_ViewInCpuMemory));
mnuViewInMemoryType.InitShortcut(this, nameof(DebuggerShortcutsConfig.LabelList_ViewInMemoryType));
}
public static void EditLabel(UInt32 address, AddressType type)
@ -187,6 +190,30 @@ namespace Mesen.GUI.Debugger.Controls
mnuFindOccurrences.Enabled = lstLabels.SelectedIndices.Count == 1;
mnuAddToWatch.Enabled = lstLabels.SelectedIndices.Count == 1;
mnuAddBreakpoint.Enabled = lstLabels.SelectedIndices.Count == 1;
if(lstLabels.SelectedIndices.Count == 1) {
ListViewItem item = GetSelectedItem();
bool availableInCpuMemory = (int)item.Tag >= 0;
mnuViewInCpuMemory.Enabled = availableInCpuMemory;
CodeLabel label = (CodeLabel)item.SubItems[1].Tag;
if(label.AddressType != AddressType.Register && label.AddressType != AddressType.InternalRam) {
string memoryType = "";
switch(label.AddressType) {
case AddressType.PrgRom: memoryType = "PRG ROM"; break;
case AddressType.SaveRam: memoryType = "Save RAM"; break;
case AddressType.WorkRam: memoryType = "Work RAM"; break;
}
mnuViewInMemoryType.Text = "View in " + memoryType;
mnuViewInMemoryType.Enabled = true;
} else {
mnuViewInMemoryType.Enabled = false;
}
} else {
mnuViewInCpuMemory.Enabled = false;
mnuViewInMemoryType.Enabled = false;
}
}
private void mnuDelete_Click(object sender, EventArgs e)
@ -311,5 +338,25 @@ namespace Mesen.GUI.Debugger.Controls
}
}
}
private void mnuViewInCpuMemory_Click(object sender, EventArgs e)
{
if(lstLabels.SelectedIndices.Count == 1) {
ListViewItem item = GetSelectedItem();
int address = (int)item.Tag;
if(address >= 0) {
DebugWindowManager.OpenMemoryViewer(address, DebugMemoryType.CpuMemory);
}
}
}
private void mnuViewInMemoryType_Click(object sender, EventArgs e)
{
if(lstLabels.SelectedIndices.Count == 1) {
ListViewItem item = GetSelectedItem();
CodeLabel label = (CodeLabel)item.SubItems[1].Tag;
DebugWindowManager.OpenMemoryViewer((int)label.Address, label.AddressType.ToMemoryType());
}
}
}
}

View file

@ -47,7 +47,7 @@ namespace Mesen.GUI.Debugger
frm.Show();
}
public static void OpenMemoryViewer(int address, bool usePrgRom)
public static void OpenMemoryViewer(int address, DebugMemoryType memoryType)
{
frmMemoryViewer frm = GetMemoryViewer();
if(frm == null) {
@ -56,7 +56,7 @@ namespace Mesen.GUI.Debugger
_openedWindows.Add(frm);
}
frm.Show();
frm.ShowAddress(address, usePrgRom);
frm.ShowAddress(address, memoryType);
}
public static frmScript OpenScriptWindow(bool forceBlank)

View file

@ -101,6 +101,8 @@ namespace Mesen.GUI.Debugger
GetMember(nameof(DebuggerShortcutsConfig.LabelList_AddBreakpoint)),
GetMember(nameof(DebuggerShortcutsConfig.LabelList_AddToWatch)),
GetMember(nameof(DebuggerShortcutsConfig.LabelList_FindOccurrences)),
GetMember(nameof(DebuggerShortcutsConfig.LabelList_ViewInCpuMemory)),
GetMember(nameof(DebuggerShortcutsConfig.LabelList_ViewInMemoryType)),
GetMember(nameof(DebuggerShortcutsConfig.BreakpointList_Add)),
GetMember(nameof(DebuggerShortcutsConfig.BreakpointList_Edit)),
GetMember(nameof(DebuggerShortcutsConfig.BreakpointList_GoToLocation)),

View file

@ -190,16 +190,11 @@ namespace Mesen.GUI.Debugger
}
}
public void ShowAddress(int address, bool usePrgRom)
public void ShowAddress(int address, DebugMemoryType memoryType)
{
tabMain.SelectedTab = tpgMemoryViewer;
if(usePrgRom) {
cboMemoryType.SetEnumValue(DebugMemoryType.PrgRom);
ctrlHexViewer.GoToAddress(address);
} else {
cboMemoryType.SetEnumValue(DebugMemoryType.CpuMemory);
ctrlHexViewer.GoToAddress(address);
}
cboMemoryType.SetEnumValue(memoryType);
ctrlHexViewer.GoToAddress(address);
}
private void InitTblMappings()