Convert TI83 keypad to use IToolFormAutoConfig and ConfigPersist

This commit is contained in:
adelikat 2020-01-19 13:48:26 -06:00
parent 6e5a3910de
commit b1d5a4d644
3 changed files with 20 additions and 93 deletions

View File

@ -446,9 +446,7 @@ namespace BizHawk.Client.Common
public bool PlayMovie_MatchHash = true;
// TI83
public ToolDialogSettings TI83KeypadSettings = new ToolDialogSettings();
public bool TI83autoloadKeyPad = true;
public bool TI83ToolTips = true;
public BindingCollection HotkeyBindings = new BindingCollection();

View File

@ -33,12 +33,8 @@
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
this.KeyPadSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ExitMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.OptionsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.SettingsSubMenu = new System.Windows.Forms.ToolStripMenuItem();
this.ShowHotkeysMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.SaveWindowPositionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.AlwaysOnTopMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.FloatingWindowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.YButton = new System.Windows.Forms.Button();
this.SecondButton = new System.Windows.Forms.Button();
this.WindowButton = new System.Windows.Forms.Button();
@ -180,7 +176,7 @@
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItem1,
this.KeyPadSubMenu,
this.OptionsSubMenu});
this.SettingsSubMenu});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
this.menuStrip1.Size = new System.Drawing.Size(355, 24);
@ -210,16 +206,12 @@
//
// OptionsSubMenu
//
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ShowHotkeysMenuItem,
this.toolStripSeparator1,
this.SaveWindowPositionMenuItem,
this.AlwaysOnTopMenuItem,
this.FloatingWindowMenuItem});
this.OptionsSubMenu.Name = "OptionsSubMenu";
this.OptionsSubMenu.Size = new System.Drawing.Size(61, 20);
this.OptionsSubMenu.Text = "&Options";
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
this.SettingsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.ShowHotkeysMenuItem});
this.SettingsSubMenu.Name = "SettingsSubMenu";
this.SettingsSubMenu.Size = new System.Drawing.Size(61, 20);
this.SettingsSubMenu.Text = "&Settings";
this.SettingsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
//
// ShowHotkeysMenuItem
//
@ -230,32 +222,6 @@
this.ShowHotkeysMenuItem.Text = "Show Hotkeys";
this.ShowHotkeysMenuItem.Click += new System.EventHandler(this.ShowHotkeysMenuItem_Click);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(188, 6);
//
// SaveWindowPositionMenuItem
//
this.SaveWindowPositionMenuItem.Name = "SaveWindowPositionMenuItem";
this.SaveWindowPositionMenuItem.Size = new System.Drawing.Size(191, 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.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(191, 22);
this.FloatingWindowMenuItem.Text = "Floating Window";
this.FloatingWindowMenuItem.Click += new System.EventHandler(this.FloatingWindowMenuItem_Click);
//
// YEQUAL
//
this.YButton.BackColor = System.Drawing.Color.CornflowerBlue;
@ -1960,8 +1926,7 @@
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1;
private System.Windows.Forms.ToolStripMenuItem KeyPadSubMenu;
private System.Windows.Forms.ToolStripMenuItem ExitMenuItem;
private System.Windows.Forms.ToolStripMenuItem OptionsSubMenu;
private System.Windows.Forms.ToolStripMenuItem SaveWindowPositionMenuItem;
private System.Windows.Forms.ToolStripMenuItem SettingsSubMenu;
private System.Windows.Forms.Button YButton;
private System.Windows.Forms.Button SecondButton;
private System.Windows.Forms.Button WindowButton;
@ -2095,8 +2060,5 @@
private System.Windows.Forms.Label label79;
private System.Windows.Forms.Label label80;
private System.Windows.Forms.Label label81;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem AlwaysOnTopMenuItem;
private System.Windows.Forms.ToolStripMenuItem FloatingWindowMenuItem;
}
}
}

View File

@ -6,30 +6,23 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public partial class TI83KeyPad : ToolFormBase, IToolForm
public partial class TI83KeyPad : ToolFormBase, IToolFormAutoConfig
{
[RequiredService]
// ReSharper disable once UnusedAutoPropertyAccessor.Local
public TI83 Emu { get; private set; }
public TI83KeyPad()
{
InitializeComponent();
TopMost = Config.TI83KeypadSettings.TopMost;
Closing += (o, e) =>
{
Config.TI83KeypadSettings.Wndx = Location.X;
Config.TI83KeypadSettings.Wndy = Location.Y;
};
}
[ConfigPersist]
public bool TI83ToolTips { get; set; } = true;
private void TI83KeyPad_Load(object sender, EventArgs e)
{
if (Config.TI83KeypadSettings.UseWindowPosition && IsOnScreen(Config.TI83KeypadSettings.TopLeft))
{
Location = Config.TI83KeypadSettings.WindowPosition;
}
if (Config.TI83ToolTips)
if (TI83ToolTips)
{
SetToolTips();
}
@ -37,7 +30,7 @@ namespace BizHawk.Client.EmuHawk
#region Public API
public bool AskSaveChanges() { return true; }
public bool AskSaveChanges() => true;
public bool UpdateBefore => false;
public void NewUpdate(ToolFormUpdateType type) { }
@ -131,17 +124,14 @@ namespace BizHawk.Client.EmuHawk
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
{
ShowHotkeysMenuItem.Checked = Config.TI83ToolTips;
SaveWindowPositionMenuItem.Checked = Config.TI83KeypadSettings.SaveWindowPosition;
AlwaysOnTopMenuItem.Checked = Config.TI83KeypadSettings.TopMost;
FloatingWindowMenuItem.Checked = Config.TI83KeypadSettings.FloatingWindow;
ShowHotkeysMenuItem.Checked = TI83ToolTips;
}
private void ShowHotkeysMenuItem_Click(object sender, EventArgs e)
{
Config.TI83ToolTips ^= true;
TI83ToolTips ^= true;
if (Config.TI83ToolTips)
if (TI83ToolTips)
{
SetToolTips();
}
@ -151,23 +141,6 @@ namespace BizHawk.Client.EmuHawk
}
}
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
{
Config.TI83KeypadSettings.SaveWindowPosition ^= true;
}
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
{
Config.TI83KeypadSettings.TopMost ^= true;
TopMost = Config.TI83KeypadSettings.TopMost;
}
private void FloatingWindowMenuItem_Click(object sender, EventArgs e)
{
Config.TI83KeypadSettings.FloatingWindow ^= true;
RefreshFloatingWindowControl(Config.TI83KeypadSettings.FloatingWindow);
}
#endregion
#region Dialog and Controls
@ -422,12 +395,6 @@ namespace BizHawk.Client.EmuHawk
Global.ClickyVirtualPadController.Click("0");
}
protected override void OnShown(EventArgs e)
{
RefreshFloatingWindowControl(Config.TI83KeypadSettings.FloatingWindow);
base.OnShown(e);
}
#endregion
#endregion