From 003156d28ebd267479123de55bbc47ef78f83a8a Mon Sep 17 00:00:00 2001 From: adelikat Date: Thu, 30 Jan 2014 15:28:05 +0000 Subject: [PATCH] Trace Logger - remember window size, implement floating window and restore default settings, refactor, also clean up some ToolDialogSettings logic --- .../config/ToolDialogSettings.cs | 20 ++++++++- .../tools/HexEditor/HexEditor.cs | 3 ++ .../tools/TraceLogger.Designer.cs | 42 +++++++++++++------ BizHawk.Client.EmuHawk/tools/TraceLogger.cs | 27 +++++++++++- .../tools/Watch/RamSearch.cs | 6 ++- .../tools/Watch/RamWatch.cs | 2 + 6 files changed, 83 insertions(+), 17 deletions(-) diff --git a/BizHawk.Client.Common/config/ToolDialogSettings.cs b/BizHawk.Client.Common/config/ToolDialogSettings.cs index bbbe6f9bf8..5dc40e82f8 100644 --- a/BizHawk.Client.Common/config/ToolDialogSettings.cs +++ b/BizHawk.Client.Common/config/ToolDialogSettings.cs @@ -1,4 +1,6 @@ -namespace BizHawk.Client.Common +using System.Drawing; + +namespace BizHawk.Client.Common { public class ToolDialogSettings { @@ -31,5 +33,21 @@ return SaveWindowPosition && Width.HasValue && Height.HasValue; } } + + public Point WindowPosition + { + get + { + return new Point(Wndx ?? 0, Wndy ?? 0); + } + } + + public Size WindowSize + { + get + { + return new Size(Width ?? 0, Height ?? 0); + } + } } } diff --git a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs index 664162ea5c..52926a1bb8 100644 --- a/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs +++ b/BizHawk.Client.EmuHawk/tools/HexEditor/HexEditor.cs @@ -1498,7 +1498,10 @@ namespace BizHawk.Client.EmuHawk Global.Config.HexEditorSettings.TopMost = false; Global.Config.HexEditorSettings.SaveWindowPosition = true; + Global.Config.HexEditorSettings.FloatingWindow = false; Global.Config.AutoLoadHexEditor = false; + + RefreshFloatingWindowControl(); } #endregion diff --git a/BizHawk.Client.EmuHawk/tools/TraceLogger.Designer.cs b/BizHawk.Client.EmuHawk/tools/TraceLogger.Designer.cs index 2b6313dfcb..b2a4cfd149 100644 --- a/BizHawk.Client.EmuHawk/tools/TraceLogger.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TraceLogger.Designer.cs @@ -47,6 +47,7 @@ this.AutoloadMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.BrowseBox = new System.Windows.Forms.Button(); this.FileBox = new System.Windows.Forms.TextBox(); @@ -54,7 +55,8 @@ this.ToWindowRadio = new System.Windows.Forms.RadioButton(); this.ClearButton = new System.Windows.Forms.Button(); this.LoggingEnabled = new System.Windows.Forms.CheckBox(); - this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.RestoreDefaultSettingsMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.TracerBox.SuspendLayout(); this.menuStrip1.SuspendLayout(); this.groupBox2.SuspendLayout(); @@ -186,7 +188,9 @@ this.AutoloadMenuItem, this.SaveWindowPositionMenuItem, this.AlwaysOnTopMenuItem, - this.FloatingWindowMenuItem}); + this.FloatingWindowMenuItem, + this.toolStripSeparator3, + this.RestoreDefaultSettingsMenuItem}); this.OptionsSubMenu.Name = "OptionsSubMenu"; this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20); this.OptionsSubMenu.Text = "&Options"; @@ -195,36 +199,43 @@ // MaxLinesMenuItem // this.MaxLinesMenuItem.Name = "MaxLinesMenuItem"; - this.MaxLinesMenuItem.Size = new System.Drawing.Size(191, 22); + this.MaxLinesMenuItem.Size = new System.Drawing.Size(199, 22); this.MaxLinesMenuItem.Text = "&Set Max Lines..."; this.MaxLinesMenuItem.Click += new System.EventHandler(this.MaxLinesMenuItem_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(188, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(196, 6); // // AutoloadMenuItem // this.AutoloadMenuItem.Name = "AutoloadMenuItem"; - this.AutoloadMenuItem.Size = new System.Drawing.Size(191, 22); + this.AutoloadMenuItem.Size = new System.Drawing.Size(199, 22); this.AutoloadMenuItem.Text = "&Autoload"; this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_Click); // // SaveWindowPositionMenuItem // this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem"; - this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(191, 22); + this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(199, 22); this.SaveWindowPositionMenuItem.Text = "&Save Window Position"; this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click); // // AlwaysOnTopMenuItem // this.AlwaysOnTopMenuItem.Name = "AlwaysOnTopMenuItem"; - this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(191, 22); + this.AlwaysOnTopMenuItem.Size = new System.Drawing.Size(199, 22); this.AlwaysOnTopMenuItem.Text = "&Always on Top"; this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click); // + // FloatingWindowMenuItem + // + this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem"; + this.FloatingWindowMenuItem.Size = new System.Drawing.Size(199, 22); + this.FloatingWindowMenuItem.Text = "&Floating Window"; + this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click); + // // groupBox2 // this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) @@ -312,12 +323,17 @@ this.LoggingEnabled.UseVisualStyleBackColor = true; this.LoggingEnabled.CheckedChanged += new System.EventHandler(this.LoggingEnabled_CheckedChanged); // - // FloatingWindowMenuItem + // toolStripSeparator3 // - this.FloatingWindowMenuItem.Name = "FloatingWindowMenuItem"; - this.FloatingWindowMenuItem.Size = new System.Drawing.Size(191, 22); - this.FloatingWindowMenuItem.Text = "&Floating Window"; - this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click); + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(196, 6); + // + // RestoreDefaultSettingsMenuItem + // + this.RestoreDefaultSettingsMenuItem.Name = "RestoreDefaultSettingsMenuItem"; + this.RestoreDefaultSettingsMenuItem.Size = new System.Drawing.Size(199, 22); + this.RestoreDefaultSettingsMenuItem.Text = "Restore Default Settings"; + this.RestoreDefaultSettingsMenuItem.Click += new System.EventHandler(this.RestoreDefaultSettingsMenuItem_Click); // // TraceLogger // @@ -373,5 +389,7 @@ private System.Windows.Forms.ToolStripMenuItem SelectAllMenuItem; private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem; private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem RestoreDefaultSettingsMenuItem; } } \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs index 2bcf2ff240..8d7f7bf068 100644 --- a/BizHawk.Client.EmuHawk/tools/TraceLogger.cs +++ b/BizHawk.Client.EmuHawk/tools/TraceLogger.cs @@ -14,9 +14,11 @@ namespace BizHawk.Client.EmuHawk { // Refresh rate slider // Make faster, such as not saving to disk until the logging is stopped, dont' add to Instructions list every frame, etc - // Remember window size private readonly List _instructions = new List(); + private FileInfo _logFile; + private int _defaultWidth; + private int _defaultHeight; public TraceLogger() { @@ -44,6 +46,8 @@ namespace BizHawk.Client.EmuHawk Global.CoreComm.Tracer.Enabled = false; Global.Config.TraceLoggerSettings.Wndx = Location.X; Global.Config.TraceLoggerSettings.Wndy = Location.Y; + Global.Config.TraceLoggerSettings.Width = Size.Width; + Global.Config.TraceLoggerSettings.Height = Size.Height; } private void TraceView_QueryItemText(int index, int column, out string text) @@ -53,9 +57,17 @@ namespace BizHawk.Client.EmuHawk private void TraceLogger_Load(object sender, EventArgs e) { + _defaultWidth = Size.Width; + _defaultHeight = Size.Height; + if (Global.Config.TraceLoggerSettings.UseWindowPosition) { - Location = new Point(Global.Config.TraceLoggerSettings.Wndx.Value, Global.Config.TraceLoggerSettings.Wndy.Value); + Location = Global.Config.TraceLoggerSettings.WindowPosition; + } + + if (Global.Config.TraceLoggerSettings.UseWindowSize) + { + Size = Global.Config.TraceLoggerSettings.WindowSize; } ClearList(); @@ -311,6 +323,17 @@ namespace BizHawk.Client.EmuHawk RefreshFloatingWindowControl(); } + private void RestoreDefaultSettingsMenuItem_Click(object sender, EventArgs e) + { + Size = new Size(_defaultWidth, _defaultHeight); + + Global.Config.TraceLoggerSettings.SaveWindowPosition = true; + Global.Config.TraceLoggerSettings.TopMost = false; + Global.Config.TraceLoggerSettings.FloatingWindow = false; + + RefreshFloatingWindowControl(); + } + #endregion #region Dialog and ListView Events diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs index e75c01bcaa..c3e7256498 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamSearch.cs @@ -198,12 +198,12 @@ namespace BizHawk.Client.EmuHawk if (Global.Config.RamSearchSettings.UseWindowPosition) { - Location = new Point(Global.Config.RamSearchSettings.Wndx.Value, Global.Config.RamSearchSettings.Wndy.Value); + Location = Global.Config.RamSearchSettings.WindowPosition; } if (Global.Config.RamSearchSettings.UseWindowSize) { - Size = new Size(Global.Config.RamSearchSettings.Width.Value, Global.Config.RamSearchSettings.Height.Value); + Size = Global.Config.RamSearchSettings.WindowSize; } TopMost = Global.Config.RamSearchSettings.TopMost; @@ -1288,6 +1288,8 @@ namespace BizHawk.Client.EmuHawk { SetToFastMode(); } + + RefreshFloatingWindowControl(); } #endregion diff --git a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs index 47c40c19ac..3ac7e51f4e 100644 --- a/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs +++ b/BizHawk.Client.EmuHawk/tools/Watch/RamWatch.cs @@ -923,7 +923,9 @@ namespace BizHawk.Client.EmuHawk Global.Config.DisplayRamWatch = false; Global.Config.RamWatchSettings.SaveWindowPosition = true; Global.Config.RamWatchSettings.TopMost = TopMost = false; + Global.Config.RamWatchSettings.FloatingWindow = false; + RefreshFloatingWindowControl(); LoadColumnInfo(); }