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)
{
OpenLuaConsole();
if (Tools.Has<LuaConsole>())
{
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);
}
if (Tools.Has<LuaConsole>()) Tools.LuaConsole.LoadLuaFile(filename);
}
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
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.");
else Tools.LuaConsole.LoadLuaFile(_argParser.luaScript.MakeAbsolute());
Tools.LuaConsole.LoadLuaFile(_argParser.luaScript.MakeAbsolute());
}
SetStatusBar();

View File

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

View File

@ -178,17 +178,7 @@ namespace BizHawk.Client.EmuHawk
}
}
if (OSTailoredCode.IsUnixHost)
{
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.");
}
if (OSTailoredCode.IsUnixHost) WriteToOutputWindow("Lua in Mono is currently experimental. Please report bugs here: https://github.com/TASVideos/BizHawk/issues/2951");
LuaListView.AllColumns.Clear();
SetColumns();
@ -226,20 +216,16 @@ namespace BizHawk.Client.EmuHawk
LuaFileList newScripts = new(LuaImp?.ScriptList, onChanged: SessionChangedCallback);
LuaFunctionList registeredFuncList = new(onChanged: UpdateRegisteredFunctionsDialog);
LuaImp = OSTailoredCode.IsUnixHost
? new UnixLuaLibraries(
newScripts,
registeredFuncList)
: new Win32LuaLibraries(
newScripts,
registeredFuncList,
Emulator.ServiceProvider,
(MainForm) MainForm, //HACK
DisplayManager,
InputManager,
Config,
Emulator,
Game);
LuaImp = new Win32LuaLibraries(
newScripts,
registeredFuncList,
Emulator.ServiceProvider,
(MainForm) MainForm, //HACK
DisplayManager,
InputManager,
Config,
Emulator,
Game);
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)
{
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);
try
{