From 53c12ec9d919be9ada942f8207c433ef258062fb Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 3 Dec 2019 20:42:44 -0600 Subject: [PATCH] Lua console - add newline on message to the console, better handling of attempting to load a script that already exists and has syntax errors --- .../tools/Lua/LuaConsole.cs | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 79a99acb9d..bd3d9cde22 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -279,7 +279,25 @@ namespace BizHawk.Client.EmuHawk { var processedPath = PathManager.TryMakeRelative(path); - if (LuaAlreadyInSession(processedPath) == false) + var alreadyInSession = LuaImp.ScriptList.Any(t => processedPath == t.Path); + if (alreadyInSession) + { + foreach (var file in LuaImp.ScriptList + .Where(file => processedPath == file.Path + && file.Enabled == false + && !Global.Config.DisableLuaScriptsOnLoad)) + { + if (file.Thread != null) + { + file.Toggle(); + } + + break; + } + + RunLuaScripts(); + } + else { var luaFile = new LuaFile("", processedPath); @@ -302,16 +320,6 @@ namespace BizHawk.Client.EmuHawk CreateFileWatcher(processedPath); } } - else - { - foreach (var file in LuaImp.ScriptList.Where(file => processedPath == file.Path && file.Enabled == false && !Global.Config.DisableLuaScriptsOnLoad)) - { - file.Toggle(); - break; - } - - RunLuaScripts(); - } UpdateDialog(); } @@ -454,11 +462,6 @@ namespace BizHawk.Client.EmuHawk NumberOfScripts.Text = message; } - private bool LuaAlreadyInSession(string path) - { - return LuaImp.ScriptList.Any(t => path == t.Path); - } - private int _messageCount; private const int MaxCount = 50; public void WriteToOutputWindow(string message) @@ -474,10 +477,9 @@ namespace BizHawk.Client.EmuHawk if (_messageCount <= MaxCount) { - OutputBox.Text += message; + OutputBox.Text += message + "\n"; OutputBox.SelectionStart = OutputBox.Text.Length; OutputBox.ScrollToCaret(); - } }); }