Re-enable Lua on Linux

This commit is contained in:
YoshiRulz 2021-10-03 09:48:26 +10:00
parent e553eafee2
commit 02f23692cf
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 15 additions and 41 deletions

View File

@ -74,11 +74,7 @@ namespace BizHawk.Client.EmuHawk
private void LoadLuaFile(string filename, string archive = null) private void LoadLuaFile(string filename, string archive = null)
{ {
OpenLuaConsole(); OpenLuaConsole();
if (Tools.Has<LuaConsole>()) if (Tools.Has<LuaConsole>()) Tools.LuaConsole.LoadLuaFile(filename);
{
if (OSTailoredCode.IsUnixHost) Console.WriteLine($"The Lua environment can currently only be created on Windows, {filename} will not be loaded.");
else Tools.LuaConsole.LoadLuaFile(filename);
}
} }
private void LoadLuaSession(string filename, string archive = null) private void LoadLuaSession(string filename, string archive = null)

View File

@ -616,8 +616,7 @@ namespace BizHawk.Client.EmuHawk
//load Lua Script if requested in the command line arguments //load Lua Script if requested in the command line arguments
if (_argParser.luaScript != null) if (_argParser.luaScript != null)
{ {
if (OSTailoredCode.IsUnixHost) Console.WriteLine($"The Lua environment can currently only be created on Windows, {_argParser.luaScript} will not be loaded."); Tools.LuaConsole.LoadLuaFile(_argParser.luaScript.MakeAbsolute());
else Tools.LuaConsole.LoadLuaFile(_argParser.luaScript.MakeAbsolute());
} }
SetStatusBar(); SetStatusBar();

View File

@ -288,10 +288,8 @@ namespace BizHawk.Client.EmuHawk
//so.. we're going to resort to something really bad. //so.. we're going to resort to something really bad.
//avert your eyes. //avert your eyes.
var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini"); var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini");
if (!OSTC.IsUnixHost // LuaInterface is not currently working on Mono if (File.Exists(configPath)
&& File.Exists(configPath) && (Array.Find(File.ReadAllLines(configPath), line => line.Contains(" \"LuaEngine\": ")) ?? string.Empty).Contains("0"))
&& (Array.Find(File.ReadAllLines(configPath), line => line.Contains(" \"LuaEngine\": ")) ?? string.Empty)
.Contains("0"))
{ {
requested = "LuaInterface"; requested = "LuaInterface";
} }

View File

@ -178,17 +178,7 @@ namespace BizHawk.Client.EmuHawk
} }
} }
if (OSTailoredCode.IsUnixHost) if (OSTailoredCode.IsUnixHost) WriteToOutputWindow("Lua in Mono is currently experimental. Please report bugs here: https://github.com/TASVideos/BizHawk/issues/2951");
{
OpenSessionMenuItem.Enabled = false;
RecentSessionsSubMenu.Enabled = false;
RecentScriptsSubMenu.Enabled = false;
NewScriptMenuItem.Enabled = false;
OpenScriptMenuItem.Enabled = false;
NewScriptToolbarItem.Enabled = false;
OpenScriptToolbarItem.Enabled = false;
WriteToOutputWindow("The Lua environment can currently only be created on Windows. You may not load scripts.");
}
LuaListView.AllColumns.Clear(); LuaListView.AllColumns.Clear();
SetColumns(); SetColumns();
@ -226,20 +216,16 @@ namespace BizHawk.Client.EmuHawk
LuaFileList newScripts = new(LuaImp?.ScriptList, onChanged: SessionChangedCallback); LuaFileList newScripts = new(LuaImp?.ScriptList, onChanged: SessionChangedCallback);
LuaFunctionList registeredFuncList = new(onChanged: UpdateRegisteredFunctionsDialog); LuaFunctionList registeredFuncList = new(onChanged: UpdateRegisteredFunctionsDialog);
LuaImp = OSTailoredCode.IsUnixHost LuaImp = new Win32LuaLibraries(
? new UnixLuaLibraries( newScripts,
newScripts, registeredFuncList,
registeredFuncList) Emulator.ServiceProvider,
: new Win32LuaLibraries( (MainForm) MainForm, //HACK
newScripts, DisplayManager,
registeredFuncList, InputManager,
Emulator.ServiceProvider, Config,
(MainForm) MainForm, //HACK Emulator,
DisplayManager, Game);
InputManager,
Config,
Emulator,
Game);
InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => $"{a.Library}.{a.Name}").ToArray()); InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => $"{a.Library}.{a.Name}").ToArray());
@ -1306,11 +1292,6 @@ namespace BizHawk.Client.EmuHawk
private void LuaConsole_DragDrop(object sender, DragEventArgs e) private void LuaConsole_DragDrop(object sender, DragEventArgs e)
{ {
if (OSTailoredCode.IsUnixHost)
{
Console.WriteLine("The Lua environment can currently only be created on Windows, no scripts will be loaded.");
return;
}
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop); var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
try try
{ {