convert RamWatch to IToolFormAutoconfig

This commit is contained in:
adelikat 2020-07-24 12:03:23 -05:00
parent 42864977cb
commit c26659187e
2 changed files with 11 additions and 93 deletions

View File

@ -105,12 +105,7 @@ namespace BizHawk.Client.EmuHawk
this.LastChangeMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.LastChangeMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.OriginalMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.OriginalMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.WatchesOnScreenMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.WatchesOnScreenMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.SaveWindowPositionMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx(); this.WatchListView = new InputRoll();
this.AlwaysOnTopMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.FloatingWindowMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.toolStripSeparator7 = new BizHawk.WinForms.Controls.ToolStripSeparatorEx();
this.RestoreWindowSizeMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.WatchListView = new InputRoll();
this.ListViewContextMenu.SuspendLayout(); this.ListViewContextMenu.SuspendLayout();
this.statusStrip1.SuspendLayout(); this.statusStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout(); this.toolStrip1.SuspendLayout();
@ -587,14 +582,9 @@ namespace BizHawk.Client.EmuHawk
// //
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.DefinePreviousValueSubMenu, this.DefinePreviousValueSubMenu,
this.WatchesOnScreenMenuItem, this.WatchesOnScreenMenuItem});
this.SaveWindowPositionMenuItem, this.OptionsSubMenu.Text = "&Settings";
this.AlwaysOnTopMenuItem, this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.SettingsSubMenu_DropDownOpened);
this.FloatingWindowMenuItem,
this.toolStripSeparator7,
this.RestoreWindowSizeMenuItem});
this.OptionsSubMenu.Text = "&Options";
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
// //
// DefinePreviousValueSubMenu // DefinePreviousValueSubMenu
// //
@ -624,27 +614,7 @@ namespace BizHawk.Client.EmuHawk
// //
this.WatchesOnScreenMenuItem.Text = "Display Watches On Screen"; this.WatchesOnScreenMenuItem.Text = "Display Watches On Screen";
this.WatchesOnScreenMenuItem.Click += new System.EventHandler(this.WatchesOnScreenMenuItem_Click); this.WatchesOnScreenMenuItem.Click += new System.EventHandler(this.WatchesOnScreenMenuItem_Click);
// //
// SaveWindowPositionMenuItem
//
this.SaveWindowPositionMenuItem.Text = "Save Window Position";
this.SaveWindowPositionMenuItem.Click += new System.EventHandler(this.SaveWindowPositionMenuItem_Click);
//
// AlwaysOnTopMenuItem
//
this.AlwaysOnTopMenuItem.Text = "&Always On Top";
this.AlwaysOnTopMenuItem.Click += new System.EventHandler(this.AlwaysOnTopMenuItem_Click);
//
// FloatingWindowMenuItem
//
this.FloatingWindowMenuItem.Text = "&Floating Window";
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
//
// RestoreWindowSizeMenuItem
//
this.RestoreWindowSizeMenuItem.Text = "Restore Default Settings";
this.RestoreWindowSizeMenuItem.Click += new System.EventHandler(this.RestoreDefaultsMenuItem_Click);
//
// WatchListView // WatchListView
// //
this.WatchListView.CellWidthPadding = 3; this.WatchListView.CellWidthPadding = 3;
@ -734,9 +704,6 @@ namespace BizHawk.Client.EmuHawk
private BizHawk.WinForms.Controls.ToolStripMenuItemEx PreviousFrameMenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx PreviousFrameMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx LastChangeMenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx LastChangeMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx WatchesOnScreenMenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx WatchesOnScreenMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx SaveWindowPositionMenuItem;
private BizHawk.WinForms.Controls.ToolStripSeparatorEx toolStripSeparator7;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx RestoreWindowSizeMenuItem;
private ToolStripEx toolStrip1; private ToolStripEx toolStrip1;
private System.Windows.Forms.ToolStripButton newToolStripButton; private System.Windows.Forms.ToolStripButton newToolStripButton;
private System.Windows.Forms.ToolStripButton openToolStripButton; private System.Windows.Forms.ToolStripButton openToolStripButton;
@ -768,8 +735,6 @@ namespace BizHawk.Client.EmuHawk
private BizHawk.WinForms.Controls.ToolStripMenuItemEx InsertSeperatorContextMenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx InsertSeperatorContextMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx MoveUpContextMenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx MoveUpContextMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx MoveDownContextMenuItem; private BizHawk.WinForms.Controls.ToolStripMenuItemEx MoveDownContextMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx AlwaysOnTopMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx FloatingWindowMenuItem;
private StatusStripEx statusStrip1; private StatusStripEx statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel MessageLabel; private System.Windows.Forms.ToolStripStatusLabel MessageLabel;
private System.Windows.Forms.ToolStripButton ErrorIconButton; private System.Windows.Forms.ToolStripButton ErrorIconButton;

View File

@ -15,12 +15,10 @@ using BizHawk.Client.EmuHawk.ToolExtensions;
namespace BizHawk.Client.EmuHawk namespace BizHawk.Client.EmuHawk
{ {
public partial class RamWatch : ToolFormBase, IToolForm public partial class RamWatch : ToolFormBase, IToolFormAutoConfig
{ {
private WatchList _watches; private WatchList _watches;
private int _defaultWidth;
private int _defaultHeight;
private string _sortedColumn; private string _sortedColumn;
private bool _sortReverse; private bool _sortReverse;
@ -116,7 +114,7 @@ namespace BizHawk.Client.EmuHawk
[ConfigPersist] [ConfigPersist]
public RamWatchSettings Settings { get; set; } public RamWatchSettings Settings { get; set; }
public class RamWatchSettings : ToolDialogSettings public class RamWatchSettings
{ {
public RamWatchSettings() public RamWatchSettings()
{ {
@ -486,20 +484,6 @@ namespace BizHawk.Client.EmuHawk
private void LoadConfigSettings() private void LoadConfigSettings()
{ {
// Size and Positioning
_defaultWidth = Size.Width;
_defaultHeight = Size.Height;
if (Settings.UseWindowPosition && IsOnScreen(Settings.TopLeft))
{
Location = Settings.WindowPosition;
}
if (Settings.UseWindowSize)
{
Size = Settings.WindowSize;
}
WatchListView.AllColumns.Clear(); WatchListView.AllColumns.Clear();
SetColumns(); SetColumns();
} }
@ -556,14 +540,6 @@ namespace BizHawk.Client.EmuHawk
private void SaveConfigSettings() private void SaveConfigSettings()
{ {
Settings.Columns = WatchListView.AllColumns; Settings.Columns = WatchListView.AllColumns;
if (WindowState == FormWindowState.Normal)
{
Settings.Wndx = Location.X;
Settings.Wndy = Location.Y;
Settings.Width = Right - Left;
Settings.Height = Bottom - Top;
}
} }
private void SetMemoryDomain(string name) private void SetMemoryDomain(string name)
@ -967,12 +943,9 @@ namespace BizHawk.Client.EmuHawk
WatchListView.SelectAll(); WatchListView.SelectAll();
} }
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e) private void SettingsSubMenu_DropDownOpened(object sender, EventArgs e)
{ {
WatchesOnScreenMenuItem.Checked = Config.DisplayRamWatch; WatchesOnScreenMenuItem.Checked = Config.DisplayRamWatch;
SaveWindowPositionMenuItem.Checked = Settings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Settings.TopMost;
FloatingWindowMenuItem.Checked = Settings.FloatingWindow;
} }
private void DefinePreviousValueSubMenu_DropDownOpened(object sender, EventArgs e) private void DefinePreviousValueSubMenu_DropDownOpened(object sender, EventArgs e)
@ -1011,26 +984,10 @@ namespace BizHawk.Client.EmuHawk
} }
} }
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e) [RestoreDefaults]
{ private void RestoreDefaultsMenuItem()
Settings.SaveWindowPosition ^= true;
}
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
{
TopMost = Settings.TopMost ^= true;
}
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{
Settings.FloatingWindow ^= true;
RefreshFloatingWindowControl(Settings.FloatingWindow);
}
private void RestoreDefaultsMenuItem_Click(object sender, EventArgs e)
{ {
Settings = new RamWatchSettings(); Settings = new RamWatchSettings();
Size = new Size(_defaultWidth, _defaultHeight);
RamWatchMenu.Items.Remove( RamWatchMenu.Items.Remove(
RamWatchMenu.Items RamWatchMenu.Items
@ -1038,13 +995,10 @@ namespace BizHawk.Client.EmuHawk
.First(x => x.Name == "GeneratedColumnsSubMenu")); .First(x => x.Name == "GeneratedColumnsSubMenu"));
RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback)); RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback));
Config.DisplayRamWatch = false; Config.DisplayRamWatch = false;
RefreshFloatingWindowControl(Settings.FloatingWindow);
WatchListView.AllColumns.Clear(); WatchListView.AllColumns.Clear();
SetColumns(); SetColumns();
WatchListView.Refresh();
} }
private void RamWatch_Load(object sender, EventArgs e) private void RamWatch_Load(object sender, EventArgs e)
@ -1055,7 +1009,6 @@ namespace BizHawk.Client.EmuHawk
Settings = new RamWatchSettings(); Settings = new RamWatchSettings();
} }
TopMost = Settings.TopMost;
_watches = new WatchList(MemoryDomains, Emu.SystemId); _watches = new WatchList(MemoryDomains, Emu.SystemId);
LoadConfigSettings(); LoadConfigSettings();
RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback)); RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback));