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

This commit is contained in:
adelikat 2019-11-29 15:32:12 -06:00
parent 1b264ad068
commit 978277bd06
2 changed files with 9 additions and 18 deletions

View File

@ -1464,17 +1464,15 @@ namespace BizHawk.Client.EmuHawk
if (file.Enabled && file.Thread == null) if (file.Enabled && file.Thread == null)
{ {
LuaImp.RegisteredFunctions.RemoveForFile(file); // First remove any existing registered functions for this file
EnableLuaFile(file); EnableLuaFile(file);
UpdateRegisteredFunctionsDialog();
} }
else if (!file.Enabled && file.Thread != null) else if (!file.Enabled && file.Thread != null)
{ {
LuaImp.CallExitEvent(file); LuaImp.CallExitEvent(file);
LuaImp.RegisteredFunctions.RemoveForFile(file);
foreach (var selectedItem in SelectedItems) UpdateRegisteredFunctionsDialog();
{
LuaImp.RegisteredFunctions.RemoveForFile(selectedItem);
UpdateRegisteredFunctionsDialog();
}
LuaImp.CallExitEvent(file); LuaImp.CallExitEvent(file);
file.Stop(); file.Stop();

View File

@ -13,18 +13,9 @@ namespace BizHawk.Client.EmuHawk
InitializeComponent(); InitializeComponent();
} }
public void NewUpdate(ToolFormUpdateType type) { }
public void UpdateValues() public void UpdateValues()
{ {
if (GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.Any()) PopulateListView();
{
PopulateListView();
}
else
{
Close();
}
} }
private void LuaRegisteredFunctionsList_Load(object sender, EventArgs e) private void LuaRegisteredFunctionsList_Load(object sender, EventArgs e)
@ -46,8 +37,10 @@ namespace BizHawk.Client.EmuHawk
{ {
FunctionView.Items.Clear(); FunctionView.Items.Clear();
var nlfs = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions.OrderBy(x => x.Event).ThenBy(x => x.Name); var functions = GlobalWin.Tools.LuaConsole.LuaImp.RegisteredFunctions
foreach (var nlf in nlfs) .OrderBy(f => f.Event)
.ThenBy(f => f.Name);
foreach (var nlf in functions)
{ {
var item = new ListViewItem { Text = nlf.Event }; var item = new ListViewItem { Text = nlf.Event };
item.SubItems.Add(nlf.Name); item.SubItems.Add(nlf.Name);