diff --git a/GUI.NET/Config/DebuggerShortcutsConfig.cs b/GUI.NET/Config/DebuggerShortcutsConfig.cs index 16a189de..fcd45a24 100644 --- a/GUI.NET/Config/DebuggerShortcutsConfig.cs +++ b/GUI.NET/Config/DebuggerShortcutsConfig.cs @@ -255,8 +255,7 @@ namespace Mesen.GUI.Config } Keys keys = (XmlKeys)typeof(DebuggerShortcutsConfig).GetField(fieldName).GetValue(ConfigManager.Config.DebugInfo.Shortcuts); - - if(keys != Keys.None && !ToolStripManager.IsValidShortcut(keys)) { + if((keys != Keys.None && !ToolStripManager.IsValidShortcut(keys)) || Program.IsMono) { //Support normally invalid shortcut keys as a shortcut item.ShortcutKeys = Keys.None; item.ShortcutKeyDisplayString = GetShortcutDisplay(keys); @@ -264,7 +263,7 @@ namespace Mesen.GUI.Config Form parentForm = parent.FindForm(); if(parentForm is BaseForm) { ProcessCmdKeyHandler onProcessCmdKeyHandler = (Keys keyData) => { - if(keyData == keys) { + if(parent.ContainsFocus && keyData == keys) { item.PerformClick(); return true; } diff --git a/GUI.NET/Controls/BaseControl.cs b/GUI.NET/Controls/BaseControl.cs index 8457a94b..829dd13d 100644 --- a/GUI.NET/Controls/BaseControl.cs +++ b/GUI.NET/Controls/BaseControl.cs @@ -2,6 +2,7 @@ using System.Windows.Forms; using System.Drawing; using Mesen.GUI; using System; +using System.ComponentModel; namespace Mesen.GUI.Controls { @@ -21,6 +22,21 @@ namespace Mesen.GUI.Controls } } + public bool IsDesignMode + { + get + { + try { + return ( + LicenseManager.UsageMode == LicenseUsageMode.Designtime || + System.Diagnostics.Process.GetCurrentProcess().ProcessName == "devenv" + ); + } catch { + return false; + } + } + } + public static Bitmap DownArrow { get diff --git a/GUI.NET/Debugger/Controls/CodeViewerActions.cs b/GUI.NET/Debugger/Controls/CodeViewerActions.cs index 67e776a5..e78c486b 100644 --- a/GUI.NET/Debugger/Controls/CodeViewerActions.cs +++ b/GUI.NET/Debugger/Controls/CodeViewerActions.cs @@ -42,27 +42,28 @@ namespace Mesen.GUI.Debugger.Controls private void InitShortcuts() { - mnuEditInMemoryViewer.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_EditInMemoryViewer)); - mnuEditLabel.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_EditLabel)); - mnuSetNextStatement.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_SetNextStatement)); - mnuShowNextStatement.InitShortcut(this, nameof(DebuggerShortcutsConfig.GoToProgramCounter)); - mnuToggleBreakpoint.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_ToggleBreakpoint)); + Control parent = (Control)Viewer; + mnuEditInMemoryViewer.InitShortcut(parent, nameof(DebuggerShortcutsConfig.CodeWindow_EditInMemoryViewer)); + mnuEditLabel.InitShortcut(parent, nameof(DebuggerShortcutsConfig.CodeWindow_EditLabel)); + mnuSetNextStatement.InitShortcut(parent, nameof(DebuggerShortcutsConfig.CodeWindow_SetNextStatement)); + mnuShowNextStatement.InitShortcut(parent, nameof(DebuggerShortcutsConfig.GoToProgramCounter)); + mnuToggleBreakpoint.InitShortcut(parent, nameof(DebuggerShortcutsConfig.CodeWindow_ToggleBreakpoint)); - mnuUndoPrgChrEdit.InitShortcut(this, nameof(DebuggerShortcutsConfig.Undo)); - mnuCopySelection.InitShortcut(this, nameof(DebuggerShortcutsConfig.Copy)); + mnuUndoPrgChrEdit.InitShortcut(parent, nameof(DebuggerShortcutsConfig.Undo)); + mnuCopySelection.InitShortcut(parent, nameof(DebuggerShortcutsConfig.Copy)); - mnuSwitchView.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_SwitchView)); + mnuSwitchView.InitShortcut(parent, nameof(DebuggerShortcutsConfig.CodeWindow_SwitchView)); if(!SourceView) { - mnuNavigateBackward.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_NavigateBack)); - mnuNavigateForward.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_NavigateForward)); + mnuNavigateBackward.InitShortcut(parent, nameof(DebuggerShortcutsConfig.CodeWindow_NavigateBack)); + mnuNavigateForward.InitShortcut(parent, nameof(DebuggerShortcutsConfig.CodeWindow_NavigateForward)); - mnuEditSelectedCode.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_EditSelectedCode)); - mnuEditSubroutine.InitShortcut(this, nameof(DebuggerShortcutsConfig.CodeWindow_EditSubroutine)); + mnuEditSelectedCode.InitShortcut(parent, nameof(DebuggerShortcutsConfig.CodeWindow_EditSelectedCode)); + mnuEditSubroutine.InitShortcut(parent, nameof(DebuggerShortcutsConfig.CodeWindow_EditSubroutine)); - mnuMarkAsCode.InitShortcut(this, nameof(DebuggerShortcutsConfig.MarkAsCode)); - mnuMarkAsData.InitShortcut(this, nameof(DebuggerShortcutsConfig.MarkAsData)); - mnuMarkAsUnidentifiedData.InitShortcut(this, nameof(DebuggerShortcutsConfig.MarkAsUnidentified)); + mnuMarkAsCode.InitShortcut(parent, nameof(DebuggerShortcutsConfig.MarkAsCode)); + mnuMarkAsData.InitShortcut(parent, nameof(DebuggerShortcutsConfig.MarkAsData)); + mnuMarkAsUnidentifiedData.InitShortcut(parent, nameof(DebuggerShortcutsConfig.MarkAsUnidentified)); } } diff --git a/GUI.NET/Debugger/Controls/ICodeViewer.cs b/GUI.NET/Debugger/Controls/ICodeViewer.cs index ccd723ba..a7743938 100644 --- a/GUI.NET/Debugger/Controls/ICodeViewer.cs +++ b/GUI.NET/Debugger/Controls/ICodeViewer.cs @@ -15,7 +15,7 @@ namespace Mesen.GUI.Debugger.Controls { void ScrollToLineNumber(int lineNumber, bool scrollToTop = false); void ScrollToAddress(AddressTypeInfo addressInfo, bool scrollToTop = false); - void SetConfig(DebugViewInfo config); + void SetConfig(DebugViewInfo config, bool disableActions = false); void EditSubroutine(); void EditSelectedCode(); diff --git a/GUI.NET/Debugger/Controls/ctrlBreakpoints.cs b/GUI.NET/Debugger/Controls/ctrlBreakpoints.cs index e05b2cd9..9b548bcb 100644 --- a/GUI.NET/Debugger/Controls/ctrlBreakpoints.cs +++ b/GUI.NET/Debugger/Controls/ctrlBreakpoints.cs @@ -21,9 +21,12 @@ namespace Mesen.GUI.Debugger.Controls public ctrlBreakpoints() { InitializeComponent(); + } - bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); - if(!designMode) { + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { _markedColumnFont = new Font(this.Font.FontFamily, 13f); mnuShowLabels.Checked = ConfigManager.Config.DebugInfo.ShowBreakpointLabels; diff --git a/GUI.NET/Debugger/Controls/ctrlChrViewer.cs b/GUI.NET/Debugger/Controls/ctrlChrViewer.cs index 7cfa5c2c..932b39e8 100644 --- a/GUI.NET/Debugger/Controls/ctrlChrViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlChrViewer.cs @@ -58,7 +58,13 @@ namespace Mesen.GUI.Debugger.Controls this.chkAutoPalette.Checked = ConfigManager.Config.DebugInfo.ChrViewerUseAutoPalette; this.chkLargeSprites.Checked = ConfigManager.Config.DebugInfo.ChrViewerUseLargeSprites; + } + } + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { mnuCopyToClipboard.InitShortcut(this, nameof(DebuggerShortcutsConfig.Copy)); } } diff --git a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs index 46140ee5..0bc8d097 100644 --- a/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs +++ b/GUI.NET/Debugger/Controls/ctrlDebuggerCode.cs @@ -45,9 +45,12 @@ namespace Mesen.GUI.Debugger { InitializeComponent(); _tooltipManager = new CodeTooltipManager(this, this.ctrlCodeViewer); + } - bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); - if(!designMode) { + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { _codeViewerActions = new CodeViewerActions(this, false); ctrlFindOccurrences.Viewer = this; @@ -55,11 +58,12 @@ namespace Mesen.GUI.Debugger } } - public void SetConfig(DebugViewInfo config) + public void SetConfig(DebugViewInfo config, bool disableActions = false) { _config = config; - - _codeViewerActions.InitMenu(config); + if(!disableActions) { + _codeViewerActions.InitMenu(config); + } if(this.ctrlCodeViewer.TextZoom != config.TextZoom) { this.ctrlCodeViewer.TextZoom = config.TextZoom; @@ -390,12 +394,14 @@ namespace Mesen.GUI.Debugger public AddressTypeInfo GetAddressInfo(int lineNumber) { AddressTypeInfo info = new AddressTypeInfo(); - info.Address = this._absoluteLineNumbers[lineNumber]; - switch(this._lineMemoryType[lineNumber]) { - case 'P': info.Type = AddressType.PrgRom; break; - case 'W': info.Type = AddressType.WorkRam; break; - case 'S': info.Type = AddressType.SaveRam; break; - case 'N': info.Type = AddressType.InternalRam; break; + if(lineNumber < this._absoluteLineNumbers.Count) { + info.Address = this._absoluteLineNumbers[lineNumber]; + switch(this._lineMemoryType[lineNumber]) { + case 'P': info.Type = AddressType.PrgRom; break; + case 'W': info.Type = AddressType.WorkRam; break; + case 'S': info.Type = AddressType.SaveRam; break; + case 'N': info.Type = AddressType.InternalRam; break; + } } return info; } diff --git a/GUI.NET/Debugger/Controls/ctrlFunctionList.cs b/GUI.NET/Debugger/Controls/ctrlFunctionList.cs index b1ddbe66..64d41dc0 100644 --- a/GUI.NET/Debugger/Controls/ctrlFunctionList.cs +++ b/GUI.NET/Debugger/Controls/ctrlFunctionList.cs @@ -21,10 +21,13 @@ namespace Mesen.GUI.Debugger.Controls public ctrlFunctionList() { InitializeComponent(); + } - bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); - if(!designMode) { - this.InitShortcuts(); + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { + InitShortcuts(); } } diff --git a/GUI.NET/Debugger/Controls/ctrlHexViewer.cs b/GUI.NET/Debugger/Controls/ctrlHexViewer.cs index 486359b2..e66c2ce5 100644 --- a/GUI.NET/Debugger/Controls/ctrlHexViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlHexViewer.cs @@ -31,10 +31,15 @@ namespace Mesen.GUI.Debugger.Controls this.ctrlHexBox.ShadowSelectionColor = Color.FromArgb(100, 60, 128, 200); this.ctrlHexBox.InfoBackColor = Color.FromArgb(235, 235, 235); this.ctrlHexBox.InfoForeColor = Color.Gray; + } - if(LicenseManager.UsageMode != LicenseUsageMode.Designtime) { + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + + if(!IsDesignMode) { this.cboNumberColumns.SelectedIndex = ConfigManager.Config.DebugInfo.RamColumnCount; - this.InitShortcuts(); + InitShortcuts(); } } diff --git a/GUI.NET/Debugger/Controls/ctrlLabelList.cs b/GUI.NET/Debugger/Controls/ctrlLabelList.cs index a19a3c6b..3377114e 100644 --- a/GUI.NET/Debugger/Controls/ctrlLabelList.cs +++ b/GUI.NET/Debugger/Controls/ctrlLabelList.cs @@ -44,11 +44,14 @@ namespace Mesen.GUI.Debugger.Controls { InitializeComponent(); lstLabels.ListViewItemSorter = new LabelComparer(0, false); + } - bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); - if(!designMode) { - this.InitShortcuts(); + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { mnuShowComments.Checked = ConfigManager.Config.DebugInfo.ShowCommentsInLabelList; + InitShortcuts(); } } diff --git a/GUI.NET/Debugger/Controls/ctrlMemoryAccessCounters.cs b/GUI.NET/Debugger/Controls/ctrlMemoryAccessCounters.cs index 299b591d..6909a9f6 100644 --- a/GUI.NET/Debugger/Controls/ctrlMemoryAccessCounters.cs +++ b/GUI.NET/Debugger/Controls/ctrlMemoryAccessCounters.cs @@ -24,16 +24,19 @@ namespace Mesen.GUI.Debugger.Controls InitializeComponent(); this.toolTip.SetToolTip(chkHighlightUninitRead, "The uninitialized memory reads highlight will only be accurate if the debugger was active when the game was loaded (or if the game has been power cycled since)"); + } - bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); - if(!designMode) { - InitShortcuts(); + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { InitMemoryTypeDropdown(); cboSort.SelectedIndex = 0; + InitShortcuts(); } } - public void InitShortcuts() + private void InitShortcuts() { mnuCopy.InitShortcut(this, nameof(DebuggerShortcutsConfig.Copy)); mnuSelectAll.InitShortcut(this, nameof(DebuggerShortcutsConfig.SelectAll)); diff --git a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs index 43f94430..9965e1a9 100644 --- a/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlNametableViewer.cs @@ -50,7 +50,13 @@ namespace Mesen.GUI.Debugger.Controls chkUseGrayscalePalette.Checked = ConfigManager.Config.DebugInfo.NtViewerUseGrayscalePalette; chkHighlightTileUpdates.Checked = ConfigManager.Config.DebugInfo.NtViewerHighlightTileUpdates; chkHighlightAttributeUpdates.Checked = ConfigManager.Config.DebugInfo.NtViewerHighlightAttributeUpdates; + } + } + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { mnuCopyToClipboard.InitShortcut(this, nameof(DebuggerShortcutsConfig.Copy)); } } diff --git a/GUI.NET/Debugger/Controls/ctrlSourceViewer.cs b/GUI.NET/Debugger/Controls/ctrlSourceViewer.cs index 8238443c..e4f9673c 100644 --- a/GUI.NET/Debugger/Controls/ctrlSourceViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlSourceViewer.cs @@ -10,10 +10,11 @@ using System.Windows.Forms; using static Mesen.GUI.Debugger.Ld65DbgImporter; using System.IO; using Mesen.GUI.Config; +using Mesen.GUI.Controls; namespace Mesen.GUI.Debugger.Controls { - public partial class ctrlSourceViewer : UserControl, ICodeViewer + public partial class ctrlSourceViewer : BaseControl, ICodeViewer { private UInt32? _currentActiveAddress { get; set; } = null; private CodeTooltipManager _tooltipManager = null; @@ -24,11 +25,14 @@ namespace Mesen.GUI.Debugger.Controls public ctrlSourceViewer() { InitializeComponent(); + _tooltipManager = new CodeTooltipManager(this, this.ctrlCodeViewer); + } - bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); - if(!designMode) { + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { _codeViewerActions = new CodeViewerActions(this, true); - _tooltipManager = new CodeTooltipManager(this, this.ctrlCodeViewer); } } @@ -38,10 +42,12 @@ namespace Mesen.GUI.Debugger.Controls this.ctrlCodeViewer.Focus(); } - public void SetConfig(DebugViewInfo config) + public void SetConfig(DebugViewInfo config, bool disableActions = false) { _config = config; - _codeViewerActions.InitMenu(config); + if(!disableActions) { + _codeViewerActions.InitMenu(config); + } if(this.ctrlCodeViewer.TextZoom != config.TextZoom) { this.ctrlCodeViewer.TextZoom = config.TextZoom; } @@ -171,7 +177,7 @@ namespace Mesen.GUI.Debugger.Controls public AddressTypeInfo GetAddressInfo(int lineIndex) { return new AddressTypeInfo() { - Address = _symbolProvider.GetPrgAddress(CurrentFile.ID, lineIndex), + Address = _symbolProvider?.GetPrgAddress(CurrentFile.ID, lineIndex) ?? -1, Type = AddressType.PrgRom }; } diff --git a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs index e178d22c..434bf4b9 100644 --- a/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs +++ b/GUI.NET/Debugger/Controls/ctrlSpriteViewer.cs @@ -37,13 +37,16 @@ namespace Mesen.GUI.Debugger.Controls picPreview.Image = new Bitmap(256, 240, PixelFormat.Format32bppArgb); picSprites.Image = new Bitmap(256, 512, PixelFormat.Format32bppArgb); + } - bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); - if(!designMode) { + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { mnuCopyToClipboard.InitShortcut(this, nameof(DebuggerShortcutsConfig.Copy)); } } - + public void GetData() { DebugState state = new DebugState(); diff --git a/GUI.NET/Debugger/Controls/ctrlWatch.cs b/GUI.NET/Debugger/Controls/ctrlWatch.cs index c6e5cbeb..9b5b7b52 100644 --- a/GUI.NET/Debugger/Controls/ctrlWatch.cs +++ b/GUI.NET/Debugger/Controls/ctrlWatch.cs @@ -21,12 +21,14 @@ namespace Mesen.GUI.Debugger InitializeComponent(); this.DoubleBuffered = true; + } - bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime); - if(!designMode) { + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + if(!IsDesignMode) { this.mnuHexDisplay.Checked = ConfigManager.Config.DebugInfo.HexDisplay; WatchManager.WatchChanged += WatchManager_WatchChanged; - mnuRemoveWatch.InitShortcut(this, nameof(DebuggerShortcutsConfig.WatchList_Delete)); } } diff --git a/GUI.NET/Debugger/frmAssembler.cs b/GUI.NET/Debugger/frmAssembler.cs index 20ccc255..fb5d994e 100644 --- a/GUI.NET/Debugger/frmAssembler.cs +++ b/GUI.NET/Debugger/frmAssembler.cs @@ -59,8 +59,6 @@ namespace Mesen.GUI.Debugger ctrlHexBox.ByteProvider = new StaticByteProvider(new byte[0]); txtStartAddress.Text = _startAddress.ToString("X4"); - - this.InitShortcuts(); } private void InitShortcuts() @@ -95,6 +93,7 @@ namespace Mesen.GUI.Debugger toolTip.SetToolTip(picStartAddressWarning, "Warning: Start address is invalid. Must be a valid hexadecimal string."); UpdateWindow(); + InitShortcuts(); } private void UpdateCodeHighlighting() diff --git a/GUI.NET/Debugger/frmCodePreviewTooltip.cs b/GUI.NET/Debugger/frmCodePreviewTooltip.cs index 2d89b172..35a22849 100644 --- a/GUI.NET/Debugger/frmCodePreviewTooltip.cs +++ b/GUI.NET/Debugger/frmCodePreviewTooltip.cs @@ -60,7 +60,7 @@ namespace Mesen.GUI.Debugger _codeViewer.CodeViewer.HideSelection = true; _codeViewer.CodeViewer.ShowScrollbars = false; _codeViewer.CodeViewer.ScrollToLineIndex(_lineIndex, true); - _codeViewer.SetConfig(ConfigManager.Config.DebugInfo.LeftView); + _codeViewer.SetConfig(ConfigManager.Config.DebugInfo.LeftView, true); Control control = _codeViewer as Control; control.Dock = DockStyle.Fill; diff --git a/GUI.NET/Debugger/frmCodeTooltip.cs b/GUI.NET/Debugger/frmCodeTooltip.cs index b2d5fc61..a4651dc9 100644 --- a/GUI.NET/Debugger/frmCodeTooltip.cs +++ b/GUI.NET/Debugger/frmCodeTooltip.cs @@ -79,7 +79,7 @@ namespace Mesen.GUI.Debugger _codeViewer.CodeViewer.HideSelection = true; _codeViewer.CodeViewer.ShowScrollbars = false; _codeViewer.ScrollToAddress(_previewAddress.Value, true); - _codeViewer.SetConfig(ConfigManager.Config.DebugInfo.LeftView); + _codeViewer.SetConfig(ConfigManager.Config.DebugInfo.LeftView, true); Control control = _codeViewer as Control; control.Dock = DockStyle.Fill; diff --git a/GUI.NET/Debugger/frmDebugger.cs b/GUI.NET/Debugger/frmDebugger.cs index 3e8e99d2..c4e0b933 100644 --- a/GUI.NET/Debugger/frmDebugger.cs +++ b/GUI.NET/Debugger/frmDebugger.cs @@ -53,22 +53,6 @@ namespace Mesen.GUI.Debugger BreakpointManager.BreakpointsChanged += BreakpointManager_BreakpointsChanged; ctrlProfiler.OnFunctionSelected += ctrlProfiler_OnFunctionSelected; - ctrlDebuggerCode.CodeViewerActions.OnSetNextStatement += ctrlDebuggerCode_OnSetNextStatement; - ctrlDebuggerCode.CodeViewerActions.OnShowInSplitView += ctrlDebuggerCode_OnShowInSplitView; - ctrlDebuggerCode.CodeViewerActions.OnSwitchView += ctrlDebuggerCode_OnSwitchView; - - ctrlDebuggerCodeSplit.CodeViewerActions.OnSetNextStatement += ctrlDebuggerCode_OnSetNextStatement; - ctrlDebuggerCodeSplit.CodeViewerActions.OnShowInSplitView += ctrlDebuggerCode_OnShowInSplitView; - ctrlDebuggerCodeSplit.CodeViewerActions.OnSwitchView += ctrlDebuggerCode_OnSwitchView; - - ctrlSourceViewer.CodeViewerActions.OnSetNextStatement += ctrlDebuggerCode_OnSetNextStatement; - ctrlSourceViewer.CodeViewerActions.OnShowInSplitView += ctrlDebuggerCode_OnShowInSplitView; - ctrlSourceViewer.CodeViewerActions.OnSwitchView += ctrlDebuggerCode_OnSwitchView; - - ctrlSourceViewerSplit.CodeViewerActions.OnSetNextStatement += ctrlDebuggerCode_OnSetNextStatement; - ctrlSourceViewerSplit.CodeViewerActions.OnShowInSplitView += ctrlDebuggerCode_OnShowInSplitView; - ctrlSourceViewerSplit.CodeViewerActions.OnSwitchView += ctrlDebuggerCode_OnSwitchView; - Font font = new Font(ConfigManager.Config.DebugInfo.FontFamily, ConfigManager.Config.DebugInfo.FontSize, ConfigManager.Config.DebugInfo.FontStyle); ctrlDebuggerCode.CodeViewer.BaseFont = font; ctrlDebuggerCodeSplit.CodeViewer.BaseFont = font; @@ -154,11 +138,6 @@ namespace Mesen.GUI.Debugger _lastCodeWindow = ctrlDebuggerCode; - this.ctrlDebuggerCode.SetConfig(ConfigManager.Config.DebugInfo.LeftView); - this.ctrlSourceViewer.SetConfig(ConfigManager.Config.DebugInfo.LeftView); - this.ctrlDebuggerCodeSplit.SetConfig(ConfigManager.Config.DebugInfo.RightView); - this.ctrlSourceViewerSplit.SetConfig(ConfigManager.Config.DebugInfo.RightView); - this.toolTip.SetToolTip(this.picWatchHelp, frmBreakpoint.GetConditionTooltip(true) + Environment.NewLine + Environment.NewLine + "Additionally, the watch window supports a syntax to display X bytes starting from a specific address. e.g:" + Environment.NewLine + @@ -195,6 +174,38 @@ namespace Mesen.GUI.Debugger tmrCdlRatios.Start(); } + protected override void OnShown(EventArgs e) + { + base.OnShown(e); + + ctrlDebuggerCode.CodeViewerActions.OnSetNextStatement += ctrlDebuggerCode_OnSetNextStatement; + ctrlDebuggerCode.CodeViewerActions.OnShowInSplitView += ctrlDebuggerCode_OnShowInSplitView; + ctrlDebuggerCode.CodeViewerActions.OnSwitchView += ctrlDebuggerCode_OnSwitchView; + + ctrlDebuggerCodeSplit.CodeViewerActions.OnSetNextStatement += ctrlDebuggerCode_OnSetNextStatement; + ctrlDebuggerCodeSplit.CodeViewerActions.OnShowInSplitView += ctrlDebuggerCode_OnShowInSplitView; + ctrlDebuggerCodeSplit.CodeViewerActions.OnSwitchView += ctrlDebuggerCode_OnSwitchView; + + ctrlSourceViewer.Visible = true; + ctrlSourceViewerSplit.Visible = true; + + ctrlSourceViewer.CodeViewerActions.OnSetNextStatement += ctrlDebuggerCode_OnSetNextStatement; + ctrlSourceViewer.CodeViewerActions.OnShowInSplitView += ctrlDebuggerCode_OnShowInSplitView; + ctrlSourceViewer.CodeViewerActions.OnSwitchView += ctrlDebuggerCode_OnSwitchView; + + ctrlSourceViewerSplit.CodeViewerActions.OnSetNextStatement += ctrlDebuggerCode_OnSetNextStatement; + ctrlSourceViewerSplit.CodeViewerActions.OnShowInSplitView += ctrlDebuggerCode_OnShowInSplitView; + ctrlSourceViewerSplit.CodeViewerActions.OnSwitchView += ctrlDebuggerCode_OnSwitchView; + + ctrlDebuggerCode.SetConfig(ConfigManager.Config.DebugInfo.LeftView); + ctrlSourceViewer.SetConfig(ConfigManager.Config.DebugInfo.LeftView); + ctrlDebuggerCodeSplit.SetConfig(ConfigManager.Config.DebugInfo.RightView); + ctrlSourceViewerSplit.SetConfig(ConfigManager.Config.DebugInfo.RightView); + + ctrlSourceViewer.Visible = false; + ctrlSourceViewerSplit.Visible = false; + } + private void InitShortcuts() { mnuIncreaseFontSize.InitShortcut(this, nameof(DebuggerShortcutsConfig.IncreaseFontSize)); diff --git a/GUI.NET/Debugger/frmMemoryViewer.cs b/GUI.NET/Debugger/frmMemoryViewer.cs index b2cf9718..c15ed48e 100644 --- a/GUI.NET/Debugger/frmMemoryViewer.cs +++ b/GUI.NET/Debugger/frmMemoryViewer.cs @@ -29,15 +29,14 @@ namespace Mesen.GUI.Debugger public frmMemoryViewer() { InitializeComponent(); - - this._selectedTab = this.tabMain.SelectedTab; - this.InitShortcuts(); } protected override void OnLoad(EventArgs e) { base.OnLoad(e); + this._selectedTab = this.tabMain.SelectedTab; + DebugInfo config = ConfigManager.Config.DebugInfo; this.mnuAutoRefresh.Checked = config.RamAutoRefresh; @@ -93,6 +92,8 @@ namespace Mesen.GUI.Debugger this.Size = ConfigManager.Config.DebugInfo.MemoryViewerSize; this.Location = ConfigManager.Config.DebugInfo.MemoryViewerLocation; } + + this.InitShortcuts(); } protected override void OnFormClosing(FormClosingEventArgs e) diff --git a/GUI.NET/Debugger/frmPpuViewer.cs b/GUI.NET/Debugger/frmPpuViewer.cs index 1b2dce6a..85e3f0e4 100644 --- a/GUI.NET/Debugger/frmPpuViewer.cs +++ b/GUI.NET/Debugger/frmPpuViewer.cs @@ -40,8 +40,6 @@ namespace Mesen.GUI.Debugger this.StartPosition = FormStartPosition.Manual; this.Location = ConfigManager.Config.DebugInfo.PpuWindowLocation.Value; } - - this.InitShortcuts(); } private void InitShortcuts() @@ -71,6 +69,8 @@ namespace Mesen.GUI.Debugger this.ctrlChrViewer.RefreshViewer(); this.ctrlSpriteViewer.RefreshViewer(); this.ctrlPaletteViewer.RefreshViewer(); + + this.InitShortcuts(); } } diff --git a/GUI.NET/Debugger/frmScript.cs b/GUI.NET/Debugger/frmScript.cs index c0342a81..560f076f 100644 --- a/GUI.NET/Debugger/frmScript.cs +++ b/GUI.NET/Debugger/frmScript.cs @@ -115,13 +115,15 @@ namespace Mesen.GUI.Debugger txtScriptContent.Font = new Font(config.ScriptFontFamily, config.ScriptFontSize, config.ScriptFontStyle); txtScriptContent.Zoom = config.ScriptZoom; + } - if(!this.DesignMode) { - this._notifListener = new InteropEmu.NotificationListener(); - this._notifListener.OnNotification += this._notifListener_OnNotification; + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + this._notifListener = new InteropEmu.NotificationListener(); + this._notifListener.OnNotification += this._notifListener_OnNotification; - this.InitShortcuts(); - } + this.InitShortcuts(); } private void InitShortcuts() diff --git a/GUI.NET/Debugger/frmTraceLogger.cs b/GUI.NET/Debugger/frmTraceLogger.cs index a088e1f0..1b5f02f2 100644 --- a/GUI.NET/Debugger/frmTraceLogger.cs +++ b/GUI.NET/Debugger/frmTraceLogger.cs @@ -85,8 +85,6 @@ namespace Mesen.GUI.Debugger "[Align,50]: Align is a special tag that is useful when trying to align some content. [Align,50] will make the next tag start on column 50." ); - this.InitShortcuts(); - this._initialized = true; } @@ -105,6 +103,8 @@ namespace Mesen.GUI.Debugger UpdateMenu(); tmrUpdateLog.Start(); RefreshLog(true, true); + + InitShortcuts(); } protected override void OnFormClosing(FormClosingEventArgs e)