Convert cheats tool to use IToolFormAutoConfig
This commit is contained in:
parent
a416841770
commit
42864977cb
|
@ -64,13 +64,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.AlwaysLoadCheatsMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
|
||||
this.AutoSaveCheatsMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
|
||||
this.DisableCheatsOnLoadMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
|
||||
this.toolStripSeparator7 = new BizHawk.WinForms.Controls.ToolStripSeparatorEx();
|
||||
this.AutoloadMenuItem = 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.toolStripSeparator5 = new BizHawk.WinForms.Controls.ToolStripSeparatorEx();
|
||||
this.RestoreWindowSizeMenuItem = new BizHawk.WinForms.Controls.ToolStripMenuItemEx();
|
||||
this.toolStrip1 = new ToolStripEx();
|
||||
this.NewToolBarItem = new System.Windows.Forms.ToolStripButton();
|
||||
this.OpenToolBarItem = new System.Windows.Forms.ToolStripButton();
|
||||
|
@ -286,16 +279,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.OptionsSubMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.AlwaysLoadCheatsMenuItem,
|
||||
this.AutoSaveCheatsMenuItem,
|
||||
this.DisableCheatsOnLoadMenuItem,
|
||||
this.toolStripSeparator7,
|
||||
this.AutoloadMenuItem,
|
||||
this.SaveWindowPositionMenuItem,
|
||||
this.AlwaysOnTopMenuItem,
|
||||
this.FloatingWindowMenuItem,
|
||||
this.toolStripSeparator5,
|
||||
this.RestoreWindowSizeMenuItem});
|
||||
this.OptionsSubMenu.Text = "&Options";
|
||||
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.OptionsSubMenu_DropDownOpened);
|
||||
this.DisableCheatsOnLoadMenuItem});
|
||||
this.OptionsSubMenu.Text = "&Settings";
|
||||
this.OptionsSubMenu.DropDownOpened += new System.EventHandler(this.SettingsSubMenu_DropDownOpened);
|
||||
//
|
||||
// AlwaysLoadCheatsMenuItem
|
||||
//
|
||||
|
@ -312,31 +298,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
this.DisableCheatsOnLoadMenuItem.Text = "Disable Cheats on Load";
|
||||
this.DisableCheatsOnLoadMenuItem.Click += new System.EventHandler(this.CheatsOnOffLoadMenuItem_Click);
|
||||
//
|
||||
// AutoloadMenuItem
|
||||
//
|
||||
this.AutoloadMenuItem.Text = "Autoload";
|
||||
this.AutoloadMenuItem.Click += new System.EventHandler(this.AutoloadMenuItem_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);
|
||||
//
|
||||
// toolStrip1
|
||||
//
|
||||
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
|
@ -521,10 +482,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx AlwaysLoadCheatsMenuItem;
|
||||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx AutoSaveCheatsMenuItem;
|
||||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx DisableCheatsOnLoadMenuItem;
|
||||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx AutoloadMenuItem;
|
||||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx SaveWindowPositionMenuItem;
|
||||
private BizHawk.WinForms.Controls.ToolStripSeparatorEx toolStripSeparator5;
|
||||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx RestoreWindowSizeMenuItem;
|
||||
private ToolStripEx toolStrip1;
|
||||
private System.Windows.Forms.ToolStripButton NewToolBarItem;
|
||||
private System.Windows.Forms.ToolStripButton OpenToolBarItem;
|
||||
|
@ -538,7 +495,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
private System.Windows.Forms.ToolStripButton LoadGameGenieToolbarItem;
|
||||
private BizHawk.WinForms.Controls.LocLabelEx TotalLabel;
|
||||
private BizHawk.WinForms.Controls.LocLabelEx MessageLabel;
|
||||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx AlwaysOnTopMenuItem;
|
||||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx ToggleMenuItem;
|
||||
private BizHawk.WinForms.Controls.ToolStripSeparatorEx GameGenieToolbarSeparator;
|
||||
private System.Windows.Forms.ContextMenuStrip CheatsContextMenu;
|
||||
|
@ -547,8 +503,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx DisableAllContextMenuItem;
|
||||
private System.Windows.Forms.GroupBox CheatGroupBox;
|
||||
private CheatEdit CheatEditor;
|
||||
private BizHawk.WinForms.Controls.ToolStripSeparatorEx toolStripSeparator7;
|
||||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx ViewInHexEditorContextMenuItem;
|
||||
private BizHawk.WinForms.Controls.ToolStripMenuItemEx FloatingWindowMenuItem;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,7 @@ using BizHawk.Client.EmuHawk.ToolExtensions;
|
|||
|
||||
namespace BizHawk.Client.EmuHawk
|
||||
{
|
||||
public partial class Cheats : ToolFormBase, IToolForm
|
||||
public partial class Cheats : ToolFormBase, IToolFormAutoConfig
|
||||
{
|
||||
private const string NameColumn = "NamesColumn";
|
||||
private const string AddressColumn = "AddressColumn";
|
||||
|
@ -26,8 +26,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
private const string TypeColumn = "DisplayTypeColumn";
|
||||
private const string ComparisonTypeColumn = "ComparisonTypeColumn";
|
||||
|
||||
private int _defaultWidth;
|
||||
private int _defaultHeight;
|
||||
private string _sortedColumn;
|
||||
private bool _sortReverse;
|
||||
|
||||
|
@ -156,7 +154,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
Settings = new CheatsSettings();
|
||||
}
|
||||
|
||||
TopMost = Settings.TopMost;
|
||||
CheatEditor.MemoryDomains = Core;
|
||||
LoadConfigSettings();
|
||||
CheatsMenu.Items.Add(CheatListView.ToColumnsMenu(ColumnToggleCallback));
|
||||
|
@ -211,31 +208,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void SaveConfigSettings()
|
||||
{
|
||||
Settings.Columns = CheatListView.AllColumns;
|
||||
|
||||
if (WindowState == FormWindowState.Normal)
|
||||
{
|
||||
Settings.Wndx = Location.X;
|
||||
Settings.Wndy = Location.Y;
|
||||
Settings.Width = Right - Left;
|
||||
Settings.Height = Bottom - Top;
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadConfigSettings()
|
||||
{
|
||||
_defaultWidth = Size.Width;
|
||||
_defaultHeight = Size.Height;
|
||||
|
||||
if (Settings.UseWindowPosition && IsOnScreen(Settings.TopLeft))
|
||||
{
|
||||
Location = Settings.WindowPosition;
|
||||
}
|
||||
|
||||
if (Settings.UseWindowSize)
|
||||
{
|
||||
Size = Settings.WindowSize;
|
||||
}
|
||||
|
||||
CheatListView.AllColumns.Clear();
|
||||
SetColumns();
|
||||
}
|
||||
|
@ -361,7 +337,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private void RecentSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
RecentSubMenu.DropDownItems.Clear();
|
||||
RecentSubMenu.DropDownItems.AddRange(Config.Cheats.Recent.RecentMenu(LoadFileFromRecent, "Cheats", noAutoload: true));
|
||||
RecentSubMenu.DropDownItems.AddRange(Config.Cheats.Recent.RecentMenu(LoadFileFromRecent, "Cheats"));
|
||||
}
|
||||
|
||||
private void NewMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -533,15 +509,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
Tools.Load<GameShark>();
|
||||
}
|
||||
|
||||
private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
private void SettingsSubMenu_DropDownOpened(object sender, EventArgs e)
|
||||
{
|
||||
AlwaysLoadCheatsMenuItem.Checked = Config.Cheats.LoadFileByGame;
|
||||
AutoSaveCheatsMenuItem.Checked = Config.Cheats.AutoSaveOnClose;
|
||||
DisableCheatsOnLoadMenuItem.Checked = Config.Cheats.DisableOnLoad;
|
||||
AutoloadMenuItem.Checked = Config.Cheats.Recent.AutoLoad;
|
||||
SaveWindowPositionMenuItem.Checked = Settings.SaveWindowPosition;
|
||||
AlwaysOnTopMenuItem.Checked = Settings.TopMost;
|
||||
FloatingWindowMenuItem.Checked = Settings.FloatingWindow;
|
||||
}
|
||||
|
||||
private void AlwaysLoadCheatsMenuItem_Click(object sender, EventArgs e)
|
||||
|
@ -559,30 +531,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
Config.Cheats.DisableOnLoad ^= true;
|
||||
}
|
||||
|
||||
private void AutoloadMenuItem_Click(object sender, EventArgs e)
|
||||
[RestoreDefaults]
|
||||
private void RestoreDefaults()
|
||||
{
|
||||
Config.Cheats.Recent.AutoLoad ^= true;
|
||||
}
|
||||
|
||||
private void SaveWindowPositionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Settings.SaveWindowPosition ^= true;
|
||||
}
|
||||
|
||||
private void AlwaysOnTopMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
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)
|
||||
{
|
||||
Size = new Size(_defaultWidth, _defaultHeight);
|
||||
Settings = new CheatsSettings();
|
||||
|
||||
CheatsMenu.Items.Remove(
|
||||
|
@ -596,9 +547,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
Config.Cheats.LoadFileByGame = true;
|
||||
Config.Cheats.AutoSaveOnClose = true;
|
||||
|
||||
RefreshFloatingWindowControl(Settings.FloatingWindow);
|
||||
CheatListView.AllColumns.Clear();
|
||||
SetColumns();
|
||||
CheatListView.Refresh();
|
||||
}
|
||||
|
||||
private void CheatListView_DoubleClick(object sender, EventArgs e)
|
||||
|
@ -681,13 +632,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
RefreshFloatingWindowControl(Settings.FloatingWindow);
|
||||
base.OnShown(e);
|
||||
}
|
||||
|
||||
public class CheatsSettings : ToolDialogSettings
|
||||
public class CheatsSettings
|
||||
{
|
||||
public CheatsSettings()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue