diff --git a/BizHawk.Client.Common/lua/LuaSandbox.cs b/BizHawk.Client.Common/lua/LuaSandbox.cs index ae1cf5b0b4..24f5c98f30 100644 --- a/BizHawk.Client.Common/lua/LuaSandbox.cs +++ b/BizHawk.Client.Common/lua/LuaSandbox.cs @@ -7,22 +7,16 @@ namespace BizHawk.Client.Common { public unsafe class LuaSandbox { - protected static Action Logger; + private static readonly System.Runtime.CompilerServices.ConditionalWeakTable SandboxForThread = new System.Runtime.CompilerServices.ConditionalWeakTable(); - static System.Runtime.CompilerServices.ConditionalWeakTable SandboxForThread = new System.Runtime.CompilerServices.ConditionalWeakTable(); - public static Action DefaultLogger; - - public void SetLogger(Action logger) - { - Logger = logger; - } + public static Action DefaultLogger { get; set; } public void SetSandboxCurrentDirectory(string dir) { - CurrentDirectory = dir; + _currentDirectory = dir; } - private string CurrentDirectory; + private string _currentDirectory; #if WINDOWS [DllImport("kernel32.dll", SetLastError = true)] @@ -31,9 +25,9 @@ namespace BizHawk.Client.Common static extern uint GetCurrentDirectoryW(uint nBufferLength, byte* pBuffer); #endif - bool CoolSetCurrentDirectory(string path, string currDirSpeedHack = null) + private bool CoolSetCurrentDirectory(string path, string currDirSpeedHack = null) { - string target = CurrentDirectory + "\\"; + string target = _currentDirectory + "\\"; // first we'll bypass it with a general hack: dont do any setting if the value's already there (even at the OS level, setting the directory can be slow) // yeah I know, not the smoothest move to compare strings here, in case path normalization is happening at some point @@ -91,9 +85,9 @@ namespace BizHawk.Client.Common { savedEnvironmentCurrDir = Environment.CurrentDirectory; - if (CurrentDirectory != null) + if (_currentDirectory != null) { - CoolSetCurrentDirectory(CurrentDirectory, savedEnvironmentCurrDir); + CoolSetCurrentDirectory(_currentDirectory, savedEnvironmentCurrDir); } EnvironmentSandbox.Sandbox(callback); @@ -101,12 +95,12 @@ namespace BizHawk.Client.Common catch (LuaException ex) { Console.WriteLine(ex); - Logger(ex.ToString()); + DefaultLogger(ex.ToString()); exceptionCallback?.Invoke(); } finally { - if (CurrentDirectory != null) + if (_currentDirectory != null) { CoolSetCurrentDirectory(savedEnvironmentCurrDir); } @@ -118,7 +112,6 @@ namespace BizHawk.Client.Common var sandbox = new LuaSandbox(); SandboxForThread.Add(thread, sandbox); sandbox.SetSandboxCurrentDirectory(initialDirectory); - sandbox.SetLogger(DefaultLogger); return sandbox; } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 0c1d712381..118d7af99d 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -23,7 +23,7 @@ namespace BizHawk.Client.EmuHawk private bool _sortReverse; private string _lastColumnSorted; - private List _consoleCommandHistory = new List(); + private readonly List _consoleCommandHistory = new List(); private int _consoleCommandHistoryIndex = -1; public bool IsRebootingCore; @@ -82,7 +82,7 @@ namespace BizHawk.Client.EmuHawk LuaListView.QueryItemIndent += LuaListView_QueryItemIndent; LuaListView.VirtualMode = true; - //this is bad, in case we ever have more than one gui part running lua.. not sure how much other badness there is like that + // this is bad, in case we ever have more than one gui part running lua.. not sure how much other badness there is like that LuaSandbox.DefaultLogger = ConsoleLog; } diff --git a/BizHawk.sln.DotSettings b/BizHawk.sln.DotSettings index be60902ef3..57136fc367 100644 --- a/BizHawk.sln.DotSettings +++ b/BizHawk.sln.DotSettings @@ -43,6 +43,7 @@ DO_NOT_SHOW DO_NOT_SHOW HINT + DO_NOT_SHOW AF ARGB AV