diff --git a/BizHawk.Client.Common/config/Config.cs b/BizHawk.Client.Common/config/Config.cs index 400f58d87c..e61ffac4bf 100644 --- a/BizHawk.Client.Common/config/Config.cs +++ b/BizHawk.Client.Common/config/Config.cs @@ -142,8 +142,15 @@ namespace BizHawk.Client.Common /// public int FlushSaveRamFrames; - //check CurrentDomain_AssemblyResolve if you change the defaults or name of this key - public bool UseNLua = false; // Whether or not to use a good, reliable, memory-leak-free lua interface that is slower than the original luainterface + public enum ELuaEngine + { + /// Don't change this member's ordinal (don't reorder) without changing BizHawk.Client.EmuHawk.Program.CurrentDomain_AssemblyResolve + LuaPlusLuaInterface, + NLuaPlusKopiLua + } + + /// Don't rename this without changing BizHawk.Client.EmuHawk.Program.CurrentDomain_AssemblyResolve + public ELuaEngine LuaEngine = ELuaEngine.LuaPlusLuaInterface; public bool TurboSeek { get; set; } diff --git a/BizHawk.Client.EmuHawk/Program.cs b/BizHawk.Client.EmuHawk/Program.cs index 1cb2f8a395..7e438dad45 100644 --- a/BizHawk.Client.EmuHawk/Program.cs +++ b/BizHawk.Client.EmuHawk/Program.cs @@ -318,8 +318,8 @@ namespace BizHawk.Client.EmuHawk var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini"); if (!EXE_PROJECT.OSTailoredCode.IsUnixHost // LuaInterface is not currently working on Mono && File.Exists(configPath) - && (Array.Find(File.ReadAllLines(configPath), line => line.Contains(" \"UseNLua\": ")) ?? string.Empty) - .Contains("false")) + && (Array.Find(File.ReadAllLines(configPath), line => line.Contains(" \"LuaEngine\": ")) ?? string.Empty) + .Contains("0")) { requested = "LuaInterface"; } diff --git a/BizHawk.Client.EmuHawk/config/GuiOptions.cs b/BizHawk.Client.EmuHawk/config/GuiOptions.cs index 5a38dc3f4d..b24b37d852 100644 --- a/BizHawk.Client.EmuHawk/config/GuiOptions.cs +++ b/BizHawk.Client.EmuHawk/config/GuiOptions.cs @@ -64,8 +64,17 @@ namespace BizHawk.Client.EmuHawk cbMoviesOnDisk.Checked = Global.Config.MoviesOnDisk; cbMoviesInAWE.Checked = Global.Config.MoviesInAWE; - NLuaRadio.Checked = Global.Config.UseNLua; - LuaInterfaceRadio.Checked = !Global.Config.UseNLua; + switch (Global.Config.LuaEngine) + { + case Config.ELuaEngine.LuaPlusLuaInterface: + LuaInterfaceRadio.Checked = true; + break; + case Config.ELuaEngine.NLuaPlusKopiLua: + NLuaRadio.Checked = true; + break; + default: + throw new ArgumentOutOfRangeException(); + } if (LogConsole.ConsoleVisible) { @@ -101,13 +110,14 @@ namespace BizHawk.Client.EmuHawk Global.Config.MoviesOnDisk = cbMoviesOnDisk.Checked; Global.Config.MoviesInAWE = cbMoviesInAWE.Checked; - bool changedLua = Global.Config.UseNLua != NLuaRadio.Checked; - Global.Config.UseNLua = NLuaRadio.Checked; + var prevLuaEngine = Global.Config.LuaEngine; + if (LuaInterfaceRadio.Checked) Global.Config.LuaEngine = Config.ELuaEngine.LuaPlusLuaInterface; + else if (NLuaRadio.Checked) Global.Config.LuaEngine = Config.ELuaEngine.NLuaPlusKopiLua; Close(); DialogResult = DialogResult.OK; GlobalWin.OSD.AddMessage("Custom configurations saved."); - if(changedLua) GlobalWin.OSD.AddMessage("Restart emulator for Lua change to take effect"); + if (prevLuaEngine != Global.Config.LuaEngine) GlobalWin.OSD.AddMessage("Restart emulator for Lua change to take effect"); } private void CancelBtn_Click(object sender, EventArgs e)