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
src/BizHawk.Client.EmuHawk/tools/Watch

View File

@ -105,12 +105,7 @@ namespace BizHawk.Client.EmuHawk
this.LastChangeMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.OriginalMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.WatchesOnScreenMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
this.SaveWindowPositionMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
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.WatchListView = new InputRoll();
this.ListViewContextMenu.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.toolStrip1.SuspendLayout();
@ -587,14 +582,9 @@ namespace BizHawk.Client.EmuHawk
//
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.DefinePreviousValueSubMenu,
this.WatchesOnScreenMenuItem,
this.SaveWindowPositionMenuItem,
this.AlwaysOnTopMenuItem,
this.FloatingWindowMenuItem,
this.toolStripSeparator7,
this.RestoreWindowSizeMenuItem});
this.OptionsSubMenu.Text = "&Options";
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
this.WatchesOnScreenMenuItem});
this.OptionsSubMenu.Text = "&Settings";
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.SettingsSubMenu_DropDownOpened);
//
// DefinePreviousValueSubMenu
//
@ -624,27 +614,7 @@ namespace BizHawk.Client.EmuHawk
//
this.WatchesOnScreenMenuItem.Text = "Display Watches On Screen";
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
//
this.WatchListView.CellWidthPadding = 3;
@ -734,9 +704,6 @@ namespace BizHawk.Client.EmuHawk
private BizHawk.WinForms.Controls.ToolStripMenuItemEx PreviousFrameMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx LastChangeMenuItem;
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 System.Windows.Forms.ToolStripButton newToolStripButton;
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 MoveUpContextMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx MoveDownContextMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx AlwaysOnTopMenuItem;
private BizHawk.WinForms.Controls.ToolStripMenuItemEx FloatingWindowMenuItem;
private StatusStripEx statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel MessageLabel;
private System.Windows.Forms.ToolStripButton ErrorIconButton;

View File

@ -15,12 +15,10 @@ using BizHawk.Client.EmuHawk.ToolExtensions;
namespace BizHawk.Client.EmuHawk
{
public partial class RamWatch : ToolFormBase, IToolForm
public partial class RamWatch : ToolFormBase, IToolFormAutoConfig
{
private WatchList _watches;
private int _defaultWidth;
private int _defaultHeight;
private string _sortedColumn;
private bool _sortReverse;
@ -116,7 +114,7 @@ namespace BizHawk.Client.EmuHawk
[ConfigPersist]
public RamWatchSettings Settings { get; set; }
public class RamWatchSettings : ToolDialogSettings
public class RamWatchSettings
{
public RamWatchSettings()
{
@ -486,20 +484,6 @@ namespace BizHawk.Client.EmuHawk
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();
SetColumns();
}
@ -556,14 +540,6 @@ namespace BizHawk.Client.EmuHawk
private void SaveConfigSettings()
{
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)
@ -967,12 +943,9 @@ namespace BizHawk.Client.EmuHawk
WatchListView.SelectAll();
}
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
private void SettingsSubMenu_DropDownOpened(object sender, EventArgs e)
{
WatchesOnScreenMenuItem.Checked = Config.DisplayRamWatch;
SaveWindowPositionMenuItem.Checked = Settings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Settings.TopMost;
FloatingWindowMenuItem.Checked = Settings.FloatingWindow;
}
private void DefinePreviousValueSubMenu_DropDownOpened(object sender, EventArgs e)
@ -1011,26 +984,10 @@ namespace BizHawk.Client.EmuHawk
}
}
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
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)
[RestoreDefaults]
private void RestoreDefaultsMenuItem()
{
Settings = new RamWatchSettings();
Size = new Size(_defaultWidth, _defaultHeight);
RamWatchMenu.Items.Remove(
RamWatchMenu.Items
@ -1038,13 +995,10 @@ namespace BizHawk.Client.EmuHawk
.First(x => x.Name == "GeneratedColumnsSubMenu"));
RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback));
Config.DisplayRamWatch = false;
RefreshFloatingWindowControl(Settings.FloatingWindow);
WatchListView.AllColumns.Clear();
SetColumns();
WatchListView.Refresh();
}
private void RamWatch_Load(object sender, EventArgs e)
@ -1055,7 +1009,6 @@ namespace BizHawk.Client.EmuHawk
Settings = new RamWatchSettings();
}
TopMost = Settings.TopMost;
_watches = new WatchList(MemoryDomains, Emu.SystemId);
LoadConfigSettings();
RamWatchMenu.Items.Add(WatchListView.ToColumnsMenu(ColumnToggleCallback));