Debugger: Added font config options

This commit is contained in:
Sour 2019-03-31 00:20:54 -04:00
parent bc891d6408
commit 2209c8acc2
5 changed files with 115 additions and 11 deletions

View file

@ -25,6 +25,11 @@ namespace Mesen.GUI.Config
public int BreakInCount = 1;
public BreakInMetric BreakInMetric = BreakInMetric.CpuInstructions;
public string FontFamily = BaseControl.MonospaceFontFamily;
public FontStyle FontStyle = FontStyle.Regular;
public float FontSize = BaseControl.DefaultFontSize;
public int TextZoom = 100;
public bool ShowSelectionLength = false;
public XmlColor CodeOpcodeColor = Color.FromArgb(22, 37, 37);

View file

@ -60,6 +60,7 @@
this.ctrlCode.Size = new System.Drawing.Size(465, 398);
this.ctrlCode.TabIndex = 0;
this.ctrlCode.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ctrlCode_MouseDown);
this.ctrlCode.TextZoomChanged += new System.EventHandler(this.ctrlCode_TextZoomChanged);
//
// ctxMenu
//

View file

@ -132,5 +132,11 @@ namespace Mesen.GUI.Debugger.Controls
_manager.ToggleBreakpoint(lineIndex);
}
}
private void ctrlCode_TextZoomChanged(object sender, EventArgs e)
{
ConfigManager.Config.Debug.TextZoom = ctrlCode.TextZoom;
ConfigManager.ApplyChanges();
}
}
}

View file

@ -76,13 +76,20 @@
this.ctrlStatus = new Mesen.GUI.Debugger.Controls.ctrlConsoleStatus();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.grpWatch = new System.Windows.Forms.GroupBox();
this.picWatchHelp = new System.Windows.Forms.PictureBox();
this.ctrlWatch = new Mesen.GUI.Debugger.ctrlWatch();
this.grpBreakpoints = new System.Windows.Forms.GroupBox();
this.ctrlBreakpoints = new Mesen.GUI.Debugger.Controls.ctrlBreakpoints();
this.grpCallstack = new System.Windows.Forms.GroupBox();
this.ctrlCallstack = new Mesen.GUI.Debugger.Controls.ctrlCallstack();
this.tsToolbar = new Mesen.GUI.Controls.ctrlMesenToolStrip();
this.picWatchHelp = new System.Windows.Forms.PictureBox();
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.toolStripMenuItem21 = new System.Windows.Forms.ToolStripSeparator();
this.mnuSelectFont = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem4 = new System.Windows.Forms.ToolStripSeparator();
this.ctrlMesenMenuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.ctrlSplitContainer)).BeginInit();
this.ctrlSplitContainer.Panel1.SuspendLayout();
@ -90,9 +97,9 @@
this.ctrlSplitContainer.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.grpWatch.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picWatchHelp)).BeginInit();
this.grpBreakpoints.SuspendLayout();
this.grpCallstack.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.picWatchHelp)).BeginInit();
this.SuspendLayout();
//
// ctrlDisassemblyView
@ -392,6 +399,8 @@
// optionsToolStripMenuItem
//
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.fontSizeToolStripMenuItem,
this.toolStripMenuItem4,
this.mnuPreferences});
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
@ -463,6 +472,16 @@
this.grpWatch.TabStop = false;
this.grpWatch.Text = "Watch";
//
// picWatchHelp
//
this.picWatchHelp.Image = global::Mesen.GUI.Properties.Resources.Help;
this.picWatchHelp.Location = new System.Drawing.Point(44, -1);
this.picWatchHelp.Name = "picWatchHelp";
this.picWatchHelp.Size = new System.Drawing.Size(16, 16);
this.picWatchHelp.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.picWatchHelp.TabIndex = 4;
this.picWatchHelp.TabStop = false;
//
// ctrlWatch
//
this.ctrlWatch.Dock = System.Windows.Forms.DockStyle.Fill;
@ -519,15 +538,56 @@
this.tsToolbar.TabIndex = 3;
this.tsToolbar.Text = "ctrlMesenToolStrip1";
//
// picWatchHelp
// fontSizeToolStripMenuItem
//
this.picWatchHelp.Image = global::Mesen.GUI.Properties.Resources.Help;
this.picWatchHelp.Location = new System.Drawing.Point(44, -1);
this.picWatchHelp.Name = "picWatchHelp";
this.picWatchHelp.Size = new System.Drawing.Size(16, 16);
this.picWatchHelp.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
this.picWatchHelp.TabIndex = 4;
this.picWatchHelp.TabStop = false;
this.fontSizeToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.mnuIncreaseFontSize,
this.mnuDecreaseFontSize,
this.mnuResetFontSize,
this.toolStripMenuItem21,
this.mnuSelectFont});
this.fontSizeToolStripMenuItem.Image = global::Mesen.GUI.Properties.Resources.Font;
this.fontSizeToolStripMenuItem.Name = "fontSizeToolStripMenuItem";
this.fontSizeToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
this.fontSizeToolStripMenuItem.Text = "Font Options";
//
// mnuIncreaseFontSize
//
this.mnuIncreaseFontSize.Name = "mnuIncreaseFontSize";
this.mnuIncreaseFontSize.ShortcutKeyDisplayString = "";
this.mnuIncreaseFontSize.Size = new System.Drawing.Size(157, 22);
this.mnuIncreaseFontSize.Text = "Increase Size";
//
// mnuDecreaseFontSize
//
this.mnuDecreaseFontSize.Name = "mnuDecreaseFontSize";
this.mnuDecreaseFontSize.ShortcutKeyDisplayString = "";
this.mnuDecreaseFontSize.Size = new System.Drawing.Size(157, 22);
this.mnuDecreaseFontSize.Text = "Decrease Size";
//
// mnuResetFontSize
//
this.mnuResetFontSize.Name = "mnuResetFontSize";
this.mnuResetFontSize.ShortcutKeyDisplayString = "";
this.mnuResetFontSize.Size = new System.Drawing.Size(157, 22);
this.mnuResetFontSize.Text = "Reset to Default";
//
// toolStripMenuItem21
//
this.toolStripMenuItem21.Name = "toolStripMenuItem21";
this.toolStripMenuItem21.Size = new System.Drawing.Size(154, 6);
//
// mnuSelectFont
//
this.mnuSelectFont.Name = "mnuSelectFont";
this.mnuSelectFont.Size = new System.Drawing.Size(157, 22);
this.mnuSelectFont.Text = "Select Font...";
this.mnuSelectFont.Click += new System.EventHandler(this.mnuSelectFont_Click);
//
// toolStripMenuItem4
//
this.toolStripMenuItem4.Name = "toolStripMenuItem4";
this.toolStripMenuItem4.Size = new System.Drawing.Size(206, 6);
//
// frmDebugger
//
@ -547,9 +607,9 @@
this.ctrlSplitContainer.ResumeLayout(false);
this.tableLayoutPanel1.ResumeLayout(false);
this.grpWatch.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picWatchHelp)).EndInit();
this.grpBreakpoints.ResumeLayout(false);
this.grpCallstack.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.picWatchHelp)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@ -609,5 +669,12 @@
private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mnuPreferences;
private System.Windows.Forms.PictureBox picWatchHelp;
private System.Windows.Forms.ToolStripMenuItem fontSizeToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem mnuIncreaseFontSize;
private System.Windows.Forms.ToolStripMenuItem mnuDecreaseFontSize;
private System.Windows.Forms.ToolStripMenuItem mnuResetFontSize;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem21;
private System.Windows.Forms.ToolStripMenuItem mnuSelectFont;
private System.Windows.Forms.ToolStripSeparator toolStripMenuItem4;
}
}

View file

@ -34,6 +34,11 @@ namespace Mesen.GUI.Debugger
InitShortcuts();
InitToolbar();
DebugInfo cfg = ConfigManager.Config.Debug;
Font font = new Font(cfg.FontFamily, cfg.FontSize, cfg.FontStyle);
ctrlDisassemblyView.CodeViewer.BaseFont = font;
ctrlDisassemblyView.CodeViewer.TextZoom = cfg.TextZoom;
toolTip.SetToolTip(picWatchHelp, ctrlWatch.GetTooltipText());
BreakpointManager.BreakpointsEnabled = true;
@ -100,6 +105,10 @@ namespace Mesen.GUI.Debugger
mnuBreakIn.InitShortcut(this, nameof(DebuggerShortcutsConfig.BreakIn));
mnuBreakOn.InitShortcut(this, nameof(DebuggerShortcutsConfig.BreakOn));
mnuIncreaseFontSize.InitShortcut(this, nameof(DebuggerShortcutsConfig.IncreaseFontSize));
mnuDecreaseFontSize.InitShortcut(this, nameof(DebuggerShortcutsConfig.DecreaseFontSize));
mnuResetFontSize.InitShortcut(this, nameof(DebuggerShortcutsConfig.ResetFontSize));
mnuStepInto.Click += (s, e) => { DebugApi.Step(1); };
mnuStepOver.Click += (s, e) => { DebugApi.Step(1, StepType.CpuStepOver); };
mnuStepOut.Click += (s, e) => { DebugApi.Step(1, StepType.CpuStepOut); };
@ -129,6 +138,10 @@ namespace Mesen.GUI.Debugger
mnuBreakIn.Click += (s, e) => { using(frmBreakIn frm = new frmBreakIn()) { frm.ShowDialog(); } };
mnuBreakOn.Click += (s, e) => { using(frmBreakOn frm = new frmBreakOn()) { frm.ShowDialog(); } };
mnuIncreaseFontSize.Click += (s, e) => { ctrlDisassemblyView.CodeViewer.TextZoom += 10; };
mnuDecreaseFontSize.Click += (s, e) => { ctrlDisassemblyView.CodeViewer.TextZoom -= 10; };
mnuResetFontSize.Click += (s, e) => { ctrlDisassemblyView.CodeViewer.TextZoom = 100; };
}
private void InitToolbar()
@ -241,6 +254,18 @@ namespace Mesen.GUI.Debugger
mnuGoToBrkHandler.Text = "BRK Handler ($" + GetVectorAddress(CpuVector.Brk).ToString("X4") + ")";
mnuGoToCopHandler.Text = "COP Handler ($" + GetVectorAddress(CpuVector.Cop).ToString("X4") + ")";
}
private void mnuSelectFont_Click(object sender, EventArgs e)
{
Font newFont = FontDialogHelper.SelectFont(ctrlDisassemblyView.CodeViewer.BaseFont);
ConfigManager.Config.Debug.FontFamily = newFont.FontFamily.Name;
ConfigManager.Config.Debug.FontStyle = newFont.Style;
ConfigManager.Config.Debug.FontSize = newFont.Size;
ConfigManager.ApplyChanges();
ctrlDisassemblyView.CodeViewer.BaseFont = newFont;
}
}
public enum CpuVector