Rename PlatformEmuLuaLibrary and implementations

EmuLuaLibrary was too close to EmulationLuaLibrary. These classes are
containers, they're not in the LuaLibraryBase inheritance heirarchy.
This commit is contained in:
YoshiRulz 2020-04-13 19:49:21 +10:00
parent e514dfd117
commit 3d532078a5
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
6 changed files with 15 additions and 13 deletions

View File

@ -563,6 +563,8 @@
<Compile Update="tools/Lua/LuaWinform.cs" SubType="Form" />
<Compile Update="tools/Lua/LuaWinform.Designer.cs" DependentUpon="LuaWinform.cs" />
<EmbeddedResource Update="tools/Lua/LuaWinform.resx" DependentUpon="LuaWinform.cs" />
<Compile Update="tools/Lua/UnixLuaLibraries.cs" DependentUpon="LuaLibraries.cs" />
<Compile Update="tools/Lua/Win32LuaLibraries.cs" DependentUpon="LuaLibraries.cs" />
<Compile Update="tools/Macros/MacroInput.ButtonSelect.cs" SubType="Form" />
<Compile Update="tools/Macros/MacroInput.cs" SubType="Form" />
<Compile Update="tools/Macros/MacroInput.Designer.cs" DependentUpon="MacroInput.cs" />

View File

@ -111,7 +111,7 @@ namespace BizHawk.Client.EmuHawk
_defaultSplitDistance = splitContainer1.SplitterDistance;
}
public PlatformEmuLuaLibrary LuaImp { get; private set; }
public LuaLibraries LuaImp { get; private set; }
public bool UpdateBefore => true;
@ -219,7 +219,7 @@ namespace BizHawk.Client.EmuHawk
}
var currentScripts = LuaImp?.ScriptList; // Temp fix for now
LuaImp = OSTailoredCode.IsUnixHost ? (PlatformEmuLuaLibrary) new NotReallyLuaLibrary() : new EmuLuaLibrary(Emulator.ServiceProvider, MainForm);
LuaImp = OSTailoredCode.IsUnixHost ? (LuaLibraries) new UnixLuaLibraries() : new Win32LuaLibraries(Emulator.ServiceProvider, MainForm);
LuaImp.ScriptList.AddRange(currentScripts ?? Enumerable.Empty<LuaFile>());
InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => $"{a.Library}.{a.Name}").ToArray());

View File

@ -8,7 +8,7 @@ using BizHawk.Emulation.Common;
namespace BizHawk.Client.EmuHawk
{
public abstract class PlatformEmuLuaLibrary
public abstract class LuaLibraries
{
public readonly LuaDocumentation Docs = new LuaDocumentation();
public abstract LuaFunctionList RegisteredFunctions { get; }
@ -29,7 +29,7 @@ namespace BizHawk.Client.EmuHawk
public abstract void EndLuaDrawing();
public abstract void ExecuteString(string command);
public abstract void Restart(IEmulatorServiceProvider newServiceProvider);
public abstract EmuLuaLibrary.ResumeResult ResumeScript(LuaFile lf);
public abstract Win32LuaLibraries.ResumeResult ResumeScript(LuaFile lf);
public abstract void SpawnAndSetFileThread(string pathToLoad, LuaFile lf);
public abstract void StartLuaDrawing();
public abstract void WindowClosed(IntPtr handle);

View File

@ -10,11 +10,11 @@ namespace BizHawk.Client.EmuHawk
{
public List<LuaEvent> ControlEvents { get; } = new List<LuaEvent>();
private readonly PlatformEmuLuaLibrary _luaImp;
private readonly LuaLibraries _luaImp;
private readonly string _currentDirectory = Environment.CurrentDirectory;
private readonly LuaFile _ownerFile;
public LuaWinform(LuaFile ownerFile, PlatformEmuLuaLibrary luaImp)
public LuaWinform(LuaFile ownerFile, LuaLibraries luaImp)
{
_ownerFile = ownerFile;
_luaImp = luaImp;

View File

@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk
/// <summary>
/// Methods intentionally blank.
/// </summary>
public sealed class NotReallyLuaLibrary : PlatformEmuLuaLibrary
public sealed class UnixLuaLibraries : LuaLibraries
{
public override void CallExitEvent(LuaFile lf)
{
@ -39,8 +39,8 @@ namespace BizHawk.Client.EmuHawk
public override void Restart(IEmulatorServiceProvider newServiceProvider)
{
}
private static readonly EmuLuaLibrary.ResumeResult EmptyResumeResult = new EmuLuaLibrary.ResumeResult();
public override EmuLuaLibrary.ResumeResult ResumeScript(LuaFile lf)
private static readonly Win32LuaLibraries.ResumeResult EmptyResumeResult = new Win32LuaLibraries.ResumeResult();
public override Win32LuaLibraries.ResumeResult ResumeScript(LuaFile lf)
{
return EmptyResumeResult;
}

View File

@ -13,16 +13,16 @@ using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
{
public class EmuLuaLibrary : PlatformEmuLuaLibrary
public class Win32LuaLibraries : LuaLibraries
{
private readonly MainForm _mainForm;
public EmuLuaLibrary()
public Win32LuaLibraries()
{
// if (NLua.Lua.WhichLua == "NLua")
_lua["keepalives"] = _lua.NewTable();
}
public EmuLuaLibrary(IEmulatorServiceProvider serviceProvider, MainForm mainForm)
public Win32LuaLibraries(IEmulatorServiceProvider serviceProvider, MainForm mainForm)
: this()
{
_mainForm = mainForm;
@ -49,7 +49,7 @@ namespace BizHawk.Client.EmuHawk
// Register lua libraries
foreach (var lib in Assembly.Load("BizHawk.Client.Common").GetTypes()
.Concat(Assembly.GetAssembly(typeof(EmuLuaLibrary)).GetTypes())
.Concat(Assembly.GetAssembly(typeof(Win32LuaLibraries)).GetTypes())
.Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t) && t.IsSealed && ServiceInjector.IsAvailable(serviceProvider, t)))
{
bool addLibrary = true;