diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs index fa9b2fe984..29b9b4e4c5 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.cs @@ -44,7 +44,7 @@ namespace BizHawk.Client.EmuHawk get { return (GuiLuaLibrary)Libraries[typeof(GuiLuaLibrary)]; } } - public EmuLuaLibrary(LuaConsole passed) + public EmuLuaLibrary(LuaConsole passed, IEmulatorServiceProvider serviceProvider) : this() { LuaWait = new AutoResetEvent(false); @@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk .GetTypes() .Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t)) .Where(t => t.IsSealed) - .Where(t => ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, t)) + .Where(t => ServiceInjector.IsAvailable(serviceProvider, t)) .ToList(); libs.AddRange( @@ -66,7 +66,7 @@ namespace BizHawk.Client.EmuHawk .GetTypes() .Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t)) .Where(t => t.IsSealed) - .Where(t => ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, t)) + .Where(t => ServiceInjector.IsAvailable(serviceProvider, t)) ); foreach (var lib in libs) @@ -83,7 +83,7 @@ namespace BizHawk.Client.EmuHawk var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua); instance.LuaRegister(lib, Docs); instance.LogOutputCallback = ConsoleLuaLibrary.LogOutput; - ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, instance); + ServiceInjector.UpdateServices(serviceProvider, instance); Libraries.Add(lib, instance); } } @@ -94,11 +94,11 @@ namespace BizHawk.Client.EmuHawk EmulatorLuaLibrary.YieldCallback = EmuYield; } - public void Restart() + public void Restart(IEmulatorServiceProvider newServiceProvider) { foreach (var lib in Libraries) { - ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, lib.Value); + ServiceInjector.UpdateServices(newServiceProvider, lib.Value); } } diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs index d26af22151..0c98d24939 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaConsole.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; +using BizHawk.Emulation.Common; using BizHawk.Client.Common; using BizHawk.Client.EmuHawk.WinFormExtensions; using BizHawk.Client.EmuHawk.ToolExtensions; @@ -15,6 +16,9 @@ namespace BizHawk.Client.EmuHawk { public partial class LuaConsole : ToolFormBase, IToolFormAutoConfig { + [RequiredService] + private IEmulator Emulator { get; set; } + private readonly LuaFileList _luaList; private bool _sortReverse; private string _lastColumnSorted; @@ -139,7 +143,7 @@ namespace BizHawk.Client.EmuHawk // Even if the lua console is self-rebooting from client.reboot_core() we still want to re-inject dependencies if (IsRebootingCore) { - LuaImp.Restart(); + LuaImp.Restart(Emulator.ServiceProvider); return; } @@ -164,7 +168,7 @@ namespace BizHawk.Client.EmuHawk file.Stop(); } - LuaImp = new EmuLuaLibrary(this); + LuaImp = new EmuLuaLibrary(this, Emulator.ServiceProvider); InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray()); foreach (var file in runningScripts) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index 9f7964522d..98da633dff 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -145,7 +145,6 @@ namespace BizHawk.Client.EmuHawk private TasBranch CreateBranch() { - // TODO: don't use Global.Emulator return new TasBranch { Frame = Tastudio.Emulator.Frame,