From 978277bd0631a4e72eebe65ff8d11b491d77f2b4 Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 29 Nov 2019 15:32:12 -0600 Subject: [PATCH] Lua console - When turning on lua scripts, first clear registered functions for that scripts (they would still exist if the script exited on its own), Don't close the registered functions dialog when a script is toggled and no registered functions are left --- BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs | 10 ++++------ .../tools/Lua/LuaRegisteredFunctionsList.cs | 17 +++++------------ 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index d273911047..af9d3c1e37 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -1464,17 +1464,15 @@ namespace BizHawk.Client.EmuHawk if (file.Enabled && file.Thread == null) { + LuaImp.RegisteredFunctions.RemoveForFile(file); // First remove any existing registered functions for this file EnableLuaFile(file); + UpdateRegisteredFunctionsDialog(); } else if (!file.Enabled && file.Thread != null) { LuaImp.CallExitEvent(file); - - foreach (var selectedItem in SelectedItems) - { - LuaImp.RegisteredFunctions.RemoveForFile(selectedItem); - UpdateRegisteredFunctionsDialog(); - } + LuaImp.RegisteredFunctions.RemoveForFile(file); + UpdateRegisteredFunctionsDialog(); LuaImp.CallExitEvent(file); file.Stop(); diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs index c42dc73fae..fee2f09f21 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaRegisteredFunctionsList.cs @@ -13,18 +13,9 @@ namespace BizHawk.Client.EmuHawk InitializeComponent(); } - public void NewUpdate(ToolFormUpdateType type) { } - public void UpdateValues() { - if (GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any()) - { - PopulateListView(); - } - else - { - Close(); - } + PopulateListView(); } private void LuaRegisteredFunctionsList_Load(object sender, EventArgs e) @@ -46,8 +37,10 @@ namespace BizHawk.Client.EmuHawk { FunctionView.Items.Clear(); - var nlfs = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.OrderBy(x => x.Event).ThenBy(x => x.Name); - foreach (var nlf in nlfs) + var functions = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions + .OrderBy(f => f.Event) + .ThenBy(f => f.Name); + foreach (var nlf in functions) { var item = new ListViewItem { Text = nlf.Event }; item.SubItems.Add(nlf.Name);