From 3d532078a556f44ded4166ba0b94f995e9eb6c15 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Mon, 13 Apr 2020 19:49:21 +1000 Subject: [PATCH] Rename PlatformEmuLuaLibrary and implementations EmuLuaLibrary was too close to EmulationLuaLibrary. These classes are containers, they're not in the LuaLibraryBase inheritance heirarchy. --- BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj | 2 ++ BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs | 4 ++-- .../Lua/{PlatformEmuLuaLibrary.cs => LuaLibraries.cs} | 4 ++-- BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs | 4 ++-- .../Lua/{NotReallyLuaLibrary.cs => UnixLuaLibraries.cs} | 6 +++--- .../tools/Lua/{EmuLuaLibrary.cs => Win32LuaLibraries.cs} | 8 ++++---- 6 files changed, 15 insertions(+), 13 deletions(-) rename BizHawk.Client.EmuHawk/tools/Lua/{PlatformEmuLuaLibrary.cs => LuaLibraries.cs} (92%) rename BizHawk.Client.EmuHawk/tools/Lua/{NotReallyLuaLibrary.cs => UnixLuaLibraries.cs} (81%) rename BizHawk.Client.EmuHawk/tools/Lua/{EmuLuaLibrary.cs => Win32LuaLibraries.cs} (93%) diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index ad6928767e..767011e452 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -563,6 +563,8 @@ + + diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index 365c4bf544..be493320c0 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -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()); InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => $"{a.Library}.{a.Name}").ToArray()); diff --git a/BizHawk.Client.EmuHawk/tools/Lua/PlatformEmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs similarity index 92% rename from BizHawk.Client.EmuHawk/tools/Lua/PlatformEmuLuaLibrary.cs rename to BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs index 2da4da8d64..5f443166ed 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/PlatformEmuLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaLibraries.cs @@ -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); diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs index 8dc3f3a32f..9034da897a 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs @@ -10,11 +10,11 @@ namespace BizHawk.Client.EmuHawk { public List ControlEvents { get; } = new List(); - 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; diff --git a/BizHawk.Client.EmuHawk/tools/Lua/NotReallyLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/UnixLuaLibraries.cs similarity index 81% rename from BizHawk.Client.EmuHawk/tools/Lua/NotReallyLuaLibrary.cs rename to BizHawk.Client.EmuHawk/tools/Lua/UnixLuaLibraries.cs index 96f4ab85cd..e9d57b7fc3 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/NotReallyLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/UnixLuaLibraries.cs @@ -8,7 +8,7 @@ namespace BizHawk.Client.EmuHawk /// /// Methods intentionally blank. /// - 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; } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/EmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs similarity index 93% rename from BizHawk.Client.EmuHawk/tools/Lua/EmuLuaLibrary.cs rename to BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs index debad552c0..8ba31f507c 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/EmuLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Win32LuaLibraries.cs @@ -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;