mirror of
https://github.com/SourMesen/Mesen.git
synced 2025-04-02 10:52:48 -04:00
Debugger: Added tooltip with label information in memory viewer
This commit is contained in:
parent
3defa304c6
commit
2a5e2f05e9
7 changed files with 131 additions and 28 deletions
|
@ -124,6 +124,7 @@ namespace Mesen.GUI.Config
|
|||
public int RamColumnCount = 2;
|
||||
public float RamFontSize = BaseControl.DefaultFontSize;
|
||||
public bool RamShowCharacters = true;
|
||||
public bool RamShowLabelInfo = true;
|
||||
public bool RamHighlightExecution = true;
|
||||
public bool RamHighlightWrites = true;
|
||||
public bool RamHighlightReads = true;
|
||||
|
|
|
@ -243,6 +243,7 @@
|
|||
//
|
||||
// ctrlHexBox
|
||||
//
|
||||
this.ctrlHexBox.ByteColorProvider = null;
|
||||
this.ctrlHexBox.ColumnInfoVisible = true;
|
||||
this.ctrlHexBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ctrlHexBox.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
|
@ -257,6 +258,8 @@
|
|||
this.ctrlHexBox.TabIndex = 2;
|
||||
this.ctrlHexBox.UseFixedBytesPerLine = true;
|
||||
this.ctrlHexBox.VScrollBarVisible = true;
|
||||
this.ctrlHexBox.MouseLeave += new System.EventHandler(this.ctrlHexBox_MouseLeave);
|
||||
this.ctrlHexBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ctrlHexBox_MouseMove);
|
||||
//
|
||||
// ctrlHexViewer
|
||||
//
|
||||
|
|
|
@ -334,5 +334,18 @@ namespace Mesen.GUI.Debugger.Controls
|
|||
get { return this.ctrlHexBox.ReadOnly; }
|
||||
set { this.ctrlHexBox.ReadOnly = value; }
|
||||
}
|
||||
|
||||
public delegate void ByteMouseHoverHandler(int address);
|
||||
public event ByteMouseHoverHandler ByteMouseHover;
|
||||
private void ctrlHexBox_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
BytePositionInfo bpi = ctrlHexBox.GetHexBytePositionInfo(e.Location);
|
||||
ByteMouseHover?.Invoke((int)bpi.Index);
|
||||
}
|
||||
|
||||
private void ctrlHexBox_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
ByteMouseHover?.Invoke(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Be.Windows.Forms
|
|||
/// <summary>
|
||||
/// Represents a position in the HexBox control
|
||||
/// </summary>
|
||||
struct BytePositionInfo
|
||||
internal struct BytePositionInfo
|
||||
{
|
||||
public BytePositionInfo(long index, int characterPosition)
|
||||
{
|
||||
|
|
|
@ -1868,7 +1868,7 @@ namespace Be.Windows.Forms
|
|||
}
|
||||
}
|
||||
|
||||
BytePositionInfo GetHexBytePositionInfo(Point p)
|
||||
internal BytePositionInfo GetHexBytePositionInfo(Point p)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("GetHexBytePositionInfo()", "HexBox");
|
||||
|
||||
|
|
63
GUI.NET/Debugger/frmMemoryViewer.Designer.cs
generated
63
GUI.NET/Debugger/frmMemoryViewer.Designer.cs
generated
|
@ -70,14 +70,16 @@
|
|||
this.mnuHideWrittenBytes = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuHideExecutedBytes = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem5 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuRefresh = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuConfigureColors = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.fontSizeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuIncreaseFontSize = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuDecreaseFontSize = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuResetFontSize = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuRefresh = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mnuAutoRefresh = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuShowCharacters = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuShowLabelInfoOnMouseOver = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuFind = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mnuFindNext = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -94,7 +96,6 @@
|
|||
this.tpgProfiler = new System.Windows.Forms.TabPage();
|
||||
this.ctrlProfiler = new Mesen.GUI.Debugger.Controls.ctrlProfiler();
|
||||
this.tmrRefresh = new System.Windows.Forms.Timer(this.components);
|
||||
this.mnuConfigureColors = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.flowLayoutPanel1.SuspendLayout();
|
||||
this.menuStrip1.SuspendLayout();
|
||||
this.toolStrip1.SuspendLayout();
|
||||
|
@ -115,6 +116,7 @@
|
|||
this.ctrlHexViewer.RequiredWidthChanged += new System.EventHandler(this.ctrlHexViewer_RequiredWidthChanged);
|
||||
this.ctrlHexViewer.InitializeContextMenu += new System.EventHandler(this.ctrlHexViewer_InitializeContextMenu);
|
||||
this.ctrlHexViewer.ByteChanged += new Be.Windows.Forms.DynamicByteProvider.ByteChangedHandler(this.ctrlHexViewer_ByteChanged);
|
||||
this.ctrlHexViewer.ByteMouseHover += new Mesen.GUI.Debugger.Controls.ctrlHexViewer.ByteMouseHoverHandler(this.ctrlHexViewer_ByteMouseHover);
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
|
@ -249,7 +251,8 @@
|
|||
this.mnuRefresh,
|
||||
this.toolStripMenuItem2,
|
||||
this.mnuAutoRefresh,
|
||||
this.mnuShowCharacters});
|
||||
this.mnuShowCharacters,
|
||||
this.mnuShowLabelInfoOnMouseOver});
|
||||
this.mnuView.Name = "mnuView";
|
||||
this.mnuView.Size = new System.Drawing.Size(44, 20);
|
||||
this.mnuView.Text = "View";
|
||||
|
@ -263,7 +266,7 @@
|
|||
this.toolStripMenuItem6,
|
||||
this.fadeSpeedToolStripMenuItem});
|
||||
this.highlightToolStripMenuItem.Name = "highlightToolStripMenuItem";
|
||||
this.highlightToolStripMenuItem.Size = new System.Drawing.Size(228, 22);
|
||||
this.highlightToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
|
||||
this.highlightToolStripMenuItem.Text = "Memory Access Highlighting";
|
||||
//
|
||||
// mnuHightlightReads
|
||||
|
@ -359,7 +362,7 @@
|
|||
this.mnuHighlightChrDrawnBytes,
|
||||
this.mnuHighlightChrReadBytes});
|
||||
this.dataTypeHighlightingToolStripMenuItem.Name = "dataTypeHighlightingToolStripMenuItem";
|
||||
this.dataTypeHighlightingToolStripMenuItem.Size = new System.Drawing.Size(228, 22);
|
||||
this.dataTypeHighlightingToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
|
||||
this.dataTypeHighlightingToolStripMenuItem.Text = "Data Type Highlighting";
|
||||
//
|
||||
// mnuHighlightCodeBytes
|
||||
|
@ -403,7 +406,7 @@
|
|||
this.mnuHideWrittenBytes,
|
||||
this.mnuHideExecutedBytes});
|
||||
this.fadeToolStripMenuItem.Name = "fadeToolStripMenuItem";
|
||||
this.fadeToolStripMenuItem.Size = new System.Drawing.Size(228, 22);
|
||||
this.fadeToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
|
||||
this.fadeToolStripMenuItem.Text = "De-emphasize";
|
||||
//
|
||||
// mnuHideUnusedBytes
|
||||
|
@ -441,16 +444,15 @@
|
|||
// toolStripMenuItem5
|
||||
//
|
||||
this.toolStripMenuItem5.Name = "toolStripMenuItem5";
|
||||
this.toolStripMenuItem5.Size = new System.Drawing.Size(225, 6);
|
||||
this.toolStripMenuItem5.Size = new System.Drawing.Size(245, 6);
|
||||
//
|
||||
// mnuRefresh
|
||||
// mnuConfigureColors
|
||||
//
|
||||
this.mnuRefresh.Image = global::Mesen.GUI.Properties.Resources.Reset;
|
||||
this.mnuRefresh.Name = "mnuRefresh";
|
||||
this.mnuRefresh.ShortcutKeys = System.Windows.Forms.Keys.F5;
|
||||
this.mnuRefresh.Size = new System.Drawing.Size(228, 22);
|
||||
this.mnuRefresh.Text = "Refresh";
|
||||
this.mnuRefresh.Click += new System.EventHandler(this.mnuRefresh_Click);
|
||||
this.mnuConfigureColors.Image = global::Mesen.GUI.Properties.Resources.PipetteSmall;
|
||||
this.mnuConfigureColors.Name = "mnuConfigureColors";
|
||||
this.mnuConfigureColors.Size = new System.Drawing.Size(248, 22);
|
||||
this.mnuConfigureColors.Text = "Configure Colors";
|
||||
this.mnuConfigureColors.Click += new System.EventHandler(this.mnuConfigureColors_Click);
|
||||
//
|
||||
// fontSizeToolStripMenuItem
|
||||
//
|
||||
|
@ -460,7 +462,7 @@
|
|||
this.mnuResetFontSize});
|
||||
this.fontSizeToolStripMenuItem.Image = global::Mesen.GUI.Properties.Resources.Font;
|
||||
this.fontSizeToolStripMenuItem.Name = "fontSizeToolStripMenuItem";
|
||||
this.fontSizeToolStripMenuItem.Size = new System.Drawing.Size(228, 22);
|
||||
this.fontSizeToolStripMenuItem.Size = new System.Drawing.Size(248, 22);
|
||||
this.fontSizeToolStripMenuItem.Text = "Text Size";
|
||||
//
|
||||
// mnuIncreaseFontSize
|
||||
|
@ -490,10 +492,19 @@
|
|||
this.mnuResetFontSize.Text = "Reset to Default";
|
||||
this.mnuResetFontSize.Click += new System.EventHandler(this.mnuResetFontSize_Click);
|
||||
//
|
||||
// mnuRefresh
|
||||
//
|
||||
this.mnuRefresh.Image = global::Mesen.GUI.Properties.Resources.Reset;
|
||||
this.mnuRefresh.Name = "mnuRefresh";
|
||||
this.mnuRefresh.ShortcutKeys = System.Windows.Forms.Keys.F5;
|
||||
this.mnuRefresh.Size = new System.Drawing.Size(248, 22);
|
||||
this.mnuRefresh.Text = "Refresh";
|
||||
this.mnuRefresh.Click += new System.EventHandler(this.mnuRefresh_Click);
|
||||
//
|
||||
// toolStripMenuItem2
|
||||
//
|
||||
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(225, 6);
|
||||
this.toolStripMenuItem2.Size = new System.Drawing.Size(245, 6);
|
||||
//
|
||||
// mnuAutoRefresh
|
||||
//
|
||||
|
@ -501,7 +512,7 @@
|
|||
this.mnuAutoRefresh.CheckOnClick = true;
|
||||
this.mnuAutoRefresh.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.mnuAutoRefresh.Name = "mnuAutoRefresh";
|
||||
this.mnuAutoRefresh.Size = new System.Drawing.Size(228, 22);
|
||||
this.mnuAutoRefresh.Size = new System.Drawing.Size(248, 22);
|
||||
this.mnuAutoRefresh.Text = "Auto-refresh";
|
||||
this.mnuAutoRefresh.Click += new System.EventHandler(this.mnuAutoRefresh_Click);
|
||||
//
|
||||
|
@ -511,9 +522,16 @@
|
|||
this.mnuShowCharacters.CheckOnClick = true;
|
||||
this.mnuShowCharacters.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.mnuShowCharacters.Name = "mnuShowCharacters";
|
||||
this.mnuShowCharacters.Size = new System.Drawing.Size(228, 22);
|
||||
this.mnuShowCharacters.Size = new System.Drawing.Size(248, 22);
|
||||
this.mnuShowCharacters.Text = "Show characters";
|
||||
//
|
||||
// mnuShowLabelInfoOnMouseOver
|
||||
//
|
||||
this.mnuShowLabelInfoOnMouseOver.CheckOnClick = true;
|
||||
this.mnuShowLabelInfoOnMouseOver.Name = "mnuShowLabelInfoOnMouseOver";
|
||||
this.mnuShowLabelInfoOnMouseOver.Size = new System.Drawing.Size(248, 22);
|
||||
this.mnuShowLabelInfoOnMouseOver.Text = "Show label tooltip on mouseover";
|
||||
//
|
||||
// toolStripMenuItem1
|
||||
//
|
||||
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
|
@ -665,14 +683,6 @@
|
|||
this.tmrRefresh.Enabled = true;
|
||||
this.tmrRefresh.Tick += new System.EventHandler(this.tmrRefresh_Tick);
|
||||
//
|
||||
// mnuConfigureColors
|
||||
//
|
||||
this.mnuConfigureColors.Image = global::Mesen.GUI.Properties.Resources.PipetteSmall;
|
||||
this.mnuConfigureColors.Name = "mnuConfigureColors";
|
||||
this.mnuConfigureColors.Size = new System.Drawing.Size(228, 22);
|
||||
this.mnuConfigureColors.Text = "Configure Colors";
|
||||
this.mnuConfigureColors.Click += new System.EventHandler(this.mnuConfigureColors_Click);
|
||||
//
|
||||
// frmMemoryViewer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
@ -767,5 +777,6 @@
|
|||
private System.Windows.Forms.ToolStripMenuItem mnuHighlightChrDrawnBytes;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuHighlightChrReadBytes;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuConfigureColors;
|
||||
private System.Windows.Forms.ToolStripMenuItem mnuShowLabelInfoOnMouseOver;
|
||||
}
|
||||
}
|
|
@ -34,6 +34,8 @@ namespace Mesen.GUI.Debugger
|
|||
|
||||
this.mnuAutoRefresh.Checked = ConfigManager.Config.DebugInfo.RamAutoRefresh;
|
||||
this.mnuShowCharacters.Checked = ConfigManager.Config.DebugInfo.RamShowCharacters;
|
||||
this.mnuShowLabelInfoOnMouseOver.Checked = ConfigManager.Config.DebugInfo.RamShowLabelInfo;
|
||||
|
||||
this.ctrlHexViewer.SetFontSize((int)ConfigManager.Config.DebugInfo.RamFontSize);
|
||||
|
||||
this.mnuHighlightExecution.Checked = ConfigManager.Config.DebugInfo.RamHighlightExecution;
|
||||
|
@ -218,6 +220,7 @@ namespace Mesen.GUI.Debugger
|
|||
{
|
||||
ConfigManager.Config.DebugInfo.RamAutoRefresh = this.mnuAutoRefresh.Checked;
|
||||
ConfigManager.Config.DebugInfo.RamShowCharacters = this.mnuShowCharacters.Checked;
|
||||
ConfigManager.Config.DebugInfo.RamShowLabelInfo = this.mnuShowLabelInfoOnMouseOver.Checked;
|
||||
ConfigManager.Config.DebugInfo.RamFontSize = this.ctrlHexViewer.HexFont.Size;
|
||||
|
||||
ConfigManager.Config.DebugInfo.RamHighlightExecution = this.mnuHighlightExecution.Checked;
|
||||
|
@ -502,5 +505,77 @@ namespace Mesen.GUI.Debugger
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private frmCodeTooltip _tooltip = null;
|
||||
private CodeLabel _lastLabelTooltip = null;
|
||||
private void ctrlHexViewer_ByteMouseHover(int address)
|
||||
{
|
||||
if(address < 0 || !mnuShowLabelInfoOnMouseOver.Checked) {
|
||||
if(_tooltip != null) {
|
||||
_tooltip.Close();
|
||||
_lastLabelTooltip = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CodeLabel label = null;
|
||||
switch(_memoryType) {
|
||||
case DebugMemoryType.CpuMemory:
|
||||
AddressTypeInfo info = new AddressTypeInfo();
|
||||
InteropEmu.DebugGetAbsoluteAddressAndType((UInt32)address, ref info);
|
||||
if(info.Address >= 0) {
|
||||
label = LabelManager.GetLabel((UInt32)info.Address, info.Type);
|
||||
}
|
||||
if(label == null) {
|
||||
label = LabelManager.GetLabel((UInt32)address, AddressType.Register);
|
||||
}
|
||||
break;
|
||||
|
||||
case DebugMemoryType.InternalRam:
|
||||
label = LabelManager.GetLabel((UInt32)address, AddressType.InternalRam);
|
||||
break;
|
||||
|
||||
case DebugMemoryType.WorkRam:
|
||||
label = LabelManager.GetLabel((UInt32)address, AddressType.WorkRam);
|
||||
break;
|
||||
|
||||
case DebugMemoryType.SaveRam:
|
||||
label = LabelManager.GetLabel((UInt32)address, AddressType.SaveRam);
|
||||
break;
|
||||
|
||||
case DebugMemoryType.PrgRom:
|
||||
label = LabelManager.GetLabel((UInt32)address, AddressType.PrgRom);
|
||||
break;
|
||||
}
|
||||
|
||||
if(label != null) {
|
||||
if(_lastLabelTooltip != label) {
|
||||
if(_tooltip != null) {
|
||||
_tooltip.Close();
|
||||
}
|
||||
|
||||
Dictionary<string, string> values = new Dictionary<string, string>();
|
||||
if(!string.IsNullOrWhiteSpace(label.Label)) {
|
||||
values["Label"] = label.Label;
|
||||
}
|
||||
values["Address"] = "$" + label.Address.ToString("X4");
|
||||
values["Address Type"] = label.AddressType.ToString();
|
||||
if(!string.IsNullOrWhiteSpace(label.Comment)) {
|
||||
values["Comment"] = label.Comment;
|
||||
}
|
||||
_tooltip = new frmCodeTooltip(values);
|
||||
_tooltip.Left = Cursor.Position.X + 10;
|
||||
_tooltip.Top = Cursor.Position.Y + 10;
|
||||
_tooltip.Show(this);
|
||||
|
||||
_lastLabelTooltip = label;
|
||||
}
|
||||
} else {
|
||||
if(_tooltip != null) {
|
||||
_tooltip.Close();
|
||||
_lastLabelTooltip = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue