Cheat Window - Auto save .cht file, generate filename based on rom name if user hasn't chosen one
This commit is contained in:
parent
b3f212f745
commit
2879154344
|
@ -103,6 +103,7 @@
|
||||||
public bool CheatsSaveWindowPosition = true;
|
public bool CheatsSaveWindowPosition = true;
|
||||||
public bool DisableCheatsOnLoad = false;
|
public bool DisableCheatsOnLoad = false;
|
||||||
public bool LoadCheatFileByGame = true;
|
public bool LoadCheatFileByGame = true;
|
||||||
|
public bool CheatsAutoSaveOnClose = true;
|
||||||
public RecentFiles RecentCheats = new RecentFiles(8);
|
public RecentFiles RecentCheats = new RecentFiles(8);
|
||||||
public int CheatsWndx = -1;
|
public int CheatsWndx = -1;
|
||||||
public int CheatsWndy = -1;
|
public int CheatsWndy = -1;
|
||||||
|
|
|
@ -96,6 +96,7 @@
|
||||||
this.toggleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.toggleToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.removeSelectedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.removeSelectedToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.autoloadDialogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.autoloadDialogToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.saveCheatsOnCloseToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.CheatsMenu.SuspendLayout();
|
this.CheatsMenu.SuspendLayout();
|
||||||
this.toolStrip1.SuspendLayout();
|
this.toolStrip1.SuspendLayout();
|
||||||
this.AddCheatGroup.SuspendLayout();
|
this.AddCheatGroup.SuspendLayout();
|
||||||
|
@ -282,10 +283,11 @@
|
||||||
// optionsToolStripMenuItem
|
// optionsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.saveWindowPositionToolStripMenuItem,
|
|
||||||
this.LoadCheatFileByGameToolStripMenuItem,
|
this.LoadCheatFileByGameToolStripMenuItem,
|
||||||
|
this.saveCheatsOnCloseToolStripMenuItem,
|
||||||
this.CheatsOnOffLoadToolStripMenuItem,
|
this.CheatsOnOffLoadToolStripMenuItem,
|
||||||
this.autoloadDialogToolStripMenuItem,
|
this.autoloadDialogToolStripMenuItem,
|
||||||
|
this.saveWindowPositionToolStripMenuItem,
|
||||||
this.toolStripSeparator5,
|
this.toolStripSeparator5,
|
||||||
this.restoreWindowSizeToolStripMenuItem});
|
this.restoreWindowSizeToolStripMenuItem});
|
||||||
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
|
||||||
|
@ -694,6 +696,13 @@
|
||||||
this.autoloadDialogToolStripMenuItem.Text = "Auto-load Dialog";
|
this.autoloadDialogToolStripMenuItem.Text = "Auto-load Dialog";
|
||||||
this.autoloadDialogToolStripMenuItem.Click += new System.EventHandler(this.autoloadDialogToolStripMenuItem_Click);
|
this.autoloadDialogToolStripMenuItem.Click += new System.EventHandler(this.autoloadDialogToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// saveCheatsOnCloseToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.saveCheatsOnCloseToolStripMenuItem.Name = "saveCheatsOnCloseToolStripMenuItem";
|
||||||
|
this.saveCheatsOnCloseToolStripMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||||
|
this.saveCheatsOnCloseToolStripMenuItem.Text = "Save Cheats on Close";
|
||||||
|
this.saveCheatsOnCloseToolStripMenuItem.Click += new System.EventHandler(this.saveCheatsOnCloseToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
// Cheats
|
// Cheats
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
|
@ -790,5 +799,6 @@
|
||||||
private System.Windows.Forms.ToolStripMenuItem toggleToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem toggleToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem removeSelectedToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem removeSelectedToolStripMenuItem;
|
||||||
private System.Windows.Forms.ToolStripMenuItem autoloadDialogToolStripMenuItem;
|
private System.Windows.Forms.ToolStripMenuItem autoloadDialogToolStripMenuItem;
|
||||||
|
private System.Windows.Forms.ToolStripMenuItem saveCheatsOnCloseToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -13,11 +13,9 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
public partial class Cheats : Form
|
public partial class Cheats : Form
|
||||||
{
|
{
|
||||||
//Auto-save cheat file (generating file name based on game name)
|
|
||||||
//User option to toggle this (on by default)
|
|
||||||
//Implement Freeze functions in all memory domains
|
//Implement Freeze functions in all memory domains
|
||||||
//Restore Window Size should restore column order as well
|
//Restore Window Size should restore column order as well
|
||||||
//TODO: use currently selected memory domain! - line 50
|
//TODO: use currently selected memory domain! - line 71
|
||||||
//context menu - enable/disable highlight dependent items
|
//context menu - enable/disable highlight dependent items
|
||||||
|
|
||||||
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
|
int defaultWidth; //For saving the default size of the dialog, so the user can restore if desired
|
||||||
|
@ -47,7 +45,7 @@ namespace BizHawk.MultiClient
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AttemptLoadCheatFile()
|
public bool AttemptLoadCheatFile()
|
||||||
{
|
{
|
||||||
string CheatFile = Global.Config.LastRomPath + "\\" + Global.Game.Name + ".cht";
|
string CheatFile = MakeDefaultFilename();
|
||||||
|
|
||||||
var file = new FileInfo(CheatFile);
|
var file = new FileInfo(CheatFile);
|
||||||
if (file.Exists == false)
|
if (file.Exists == false)
|
||||||
|
@ -59,6 +57,11 @@ namespace BizHawk.MultiClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string MakeDefaultFilename()
|
||||||
|
{
|
||||||
|
return Global.Config.LastRomPath + "\\" + Global.Game.Name + ".cht";
|
||||||
|
}
|
||||||
|
|
||||||
private void ClearFields()
|
private void ClearFields()
|
||||||
{
|
{
|
||||||
NameBox.Text = "";
|
NameBox.Text = "";
|
||||||
|
@ -85,8 +88,11 @@ namespace BizHawk.MultiClient
|
||||||
|
|
||||||
protected override void OnClosing(CancelEventArgs e)
|
protected override void OnClosing(CancelEventArgs e)
|
||||||
{
|
{
|
||||||
if (!AskSave())
|
if (!Global.Config.CheatsAutoSaveOnClose)
|
||||||
e.Cancel = true;
|
{
|
||||||
|
if (!AskSave())
|
||||||
|
e.Cancel = true;
|
||||||
|
}
|
||||||
base.OnClosing(e);
|
base.OnClosing(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +263,17 @@ namespace BizHawk.MultiClient
|
||||||
Global.Config.CheatsValueWidth = CheatListView.Columns[2].Width;
|
Global.Config.CheatsValueWidth = CheatListView.Columns[2].Width;
|
||||||
Global.Config.CheatsDomainWidth = CheatListView.Columns[3].Width;
|
Global.Config.CheatsDomainWidth = CheatListView.Columns[3].Width;
|
||||||
Global.Config.CheatsOnWidth = CheatListView.Columns[4].Width;
|
Global.Config.CheatsOnWidth = CheatListView.Columns[4].Width;
|
||||||
|
|
||||||
|
if (Global.Config.CheatsAutoSaveOnClose)
|
||||||
|
{
|
||||||
|
if (changes)
|
||||||
|
{
|
||||||
|
if (currentCheatFile.Length == 0)
|
||||||
|
currentCheatFile = MakeDefaultFilename();
|
||||||
|
|
||||||
|
SaveCheatFile(currentCheatFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplayCheatsList()
|
private void DisplayCheatsList()
|
||||||
|
@ -706,6 +723,7 @@ namespace BizHawk.MultiClient
|
||||||
CheatsOnOffLoadToolStripMenuItem.Checked = Global.Config.DisableCheatsOnLoad;
|
CheatsOnOffLoadToolStripMenuItem.Checked = Global.Config.DisableCheatsOnLoad;
|
||||||
autoloadDialogToolStripMenuItem.Checked = Global.Config.AutoLoadCheats;
|
autoloadDialogToolStripMenuItem.Checked = Global.Config.AutoLoadCheats;
|
||||||
LoadCheatFileByGameToolStripMenuItem.Checked = Global.Config.LoadCheatFileByGame;
|
LoadCheatFileByGameToolStripMenuItem.Checked = Global.Config.LoadCheatFileByGame;
|
||||||
|
saveCheatsOnCloseToolStripMenuItem.Checked = Global.Config.CheatsAutoSaveOnClose;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DuplicateCheat()
|
private void DuplicateCheat()
|
||||||
|
@ -930,5 +948,10 @@ namespace BizHawk.MultiClient
|
||||||
{
|
{
|
||||||
Global.Config.LoadCheatFileByGame ^= true;
|
Global.Config.LoadCheatFileByGame ^= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void saveCheatsOnCloseToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Global.Config.CheatsAutoSaveOnClose ^= true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue