From 763d5870f23fd32886c55bd72756608f265ad27d Mon Sep 17 00:00:00 2001 From: adelikat Date: Sat, 25 Jan 2020 11:21:38 -0600 Subject: [PATCH] move some lua console settings from config to console with ConfigPersist --- BizHawk.Client.Common/config/Config.cs | 2 -- .../tools/Lua/LuaConsole.cs | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index 5f0c9a6975..d2f60f3627 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -236,8 +236,6 @@ namespace BizHawk.Client.Common public RecentFiles RecentLua = new RecentFiles(8); public RecentFiles RecentLuaSession = new RecentFiles(8); public bool DisableLuaScriptsOnLoad = false; - public bool ToggleAllIfNoneSelected = true; - public bool LuaReloadOnScriptFileChange = false; public bool RunLuaDuringTurbo = true; // Watch Settings diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 85633f6615..2603869466 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -49,6 +49,9 @@ namespace BizHawk.Client.EmuHawk } public List Columns { get; set; } + + public bool ReloadOnScriptFileChange { get; set; } + public bool ToggleAllIfNoneSelected { get; set; } = true; } [ConfigPersist] @@ -233,7 +236,7 @@ namespace BizHawk.Client.EmuHawk private void AddFileWatches() { - if (Config.LuaReloadOnScriptFileChange) + if (Settings.ReloadOnScriptFileChange) { _watches.Clear(); foreach (var item in LuaImp.ScriptList.Where(s => !s.IsSeparator)) @@ -314,7 +317,7 @@ namespace BizHawk.Client.EmuHawk luaFile.State = LuaFile.RunState.Disabled; } - if (Config.LuaReloadOnScriptFileChange) + if (Settings.ReloadOnScriptFileChange) { CreateFileWatcher(processedPath); } @@ -836,7 +839,7 @@ namespace BizHawk.Client.EmuHawk private void ToggleScriptMenuItem_Click(object sender, EventArgs e) { - var files = !SelectedFiles.Any() && Config.ToggleAllIfNoneSelected + var files = !SelectedFiles.Any() && Settings.ToggleAllIfNoneSelected ? LuaImp.ScriptList : SelectedFiles; foreach (var file in files) @@ -1064,8 +1067,8 @@ namespace BizHawk.Client.EmuHawk private void OptionsSubMenu_DropDownOpened(object sender, EventArgs e) { DisableScriptsOnLoadMenuItem.Checked = Config.DisableLuaScriptsOnLoad; - ReturnAllIfNoneSelectedMenuItem.Checked = Config.ToggleAllIfNoneSelected; - ReloadWhenScriptFileChangesMenuItem.Checked = Config.LuaReloadOnScriptFileChange; + ReturnAllIfNoneSelectedMenuItem.Checked = Settings.ToggleAllIfNoneSelected; + ReloadWhenScriptFileChangesMenuItem.Checked = Settings.ReloadOnScriptFileChange; } private void DisableScriptsOnLoadMenuItem_Click(object sender, EventArgs e) @@ -1075,14 +1078,14 @@ namespace BizHawk.Client.EmuHawk private void ToggleAllIfNoneSelectedMenuItem_Click(object sender, EventArgs e) { - Config.ToggleAllIfNoneSelected ^= true; + Settings.ToggleAllIfNoneSelected ^= true; } private void ReloadWhenScriptFileChangesMenuItem_Click(object sender, EventArgs e) { - Config.LuaReloadOnScriptFileChange ^= true; + Settings.ReloadOnScriptFileChange ^= true; - if (Config.LuaReloadOnScriptFileChange) + if (Settings.ReloadOnScriptFileChange) { AddFileWatches(); }