Fix `--lua=*.luases` being interpreted as a script (fixes #3814)
This commit is contained in:
parent
db589ee856
commit
aaf46cc9a7
|
@ -710,7 +710,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
//load Lua Script if requested in the command line arguments
|
||||
if (_argParser.luaScript != null)
|
||||
{
|
||||
Tools.LuaConsole.LoadLuaFile(_argParser.luaScript.MakeAbsolute());
|
||||
_ = Tools.LuaConsole.LoadByFileExtension(_argParser.luaScript.MakeAbsolute(), out _);
|
||||
}
|
||||
|
||||
SetStatusBar();
|
||||
|
|
|
@ -1261,6 +1261,25 @@ namespace BizHawk.Client.EmuHawk
|
|||
LuaImp.RegisteredFunctions.Clear(Emulator);
|
||||
}
|
||||
|
||||
public bool LoadByFileExtension(string path, out bool abort)
|
||||
{
|
||||
var ext = Path.GetExtension(path)?.ToLowerInvariant();
|
||||
if (ext is ".luases")
|
||||
{
|
||||
LoadLuaSession(path);
|
||||
abort = true;
|
||||
return true;
|
||||
}
|
||||
abort = false;
|
||||
if (ext is ".lua" or ".txt")
|
||||
{
|
||||
LoadLuaFile(path);
|
||||
UpdateDialog();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void LuaConsole_DragDrop(object sender, DragEventArgs e)
|
||||
{
|
||||
var filePaths = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||||
|
@ -1268,16 +1287,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
foreach (var path in filePaths)
|
||||
{
|
||||
if (Path.GetExtension(path)?.ToLowerInvariant() == ".lua" || Path.GetExtension(path)?.ToLowerInvariant() == ".txt")
|
||||
{
|
||||
LoadLuaFile(path);
|
||||
UpdateDialog();
|
||||
}
|
||||
else if (Path.GetExtension(path)?.ToLowerInvariant() == ".luases")
|
||||
{
|
||||
LoadLuaSession(path);
|
||||
return;
|
||||
}
|
||||
_ = LoadByFileExtension(path, out var abort);
|
||||
if (abort) return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
Loading…
Reference in New Issue