LuaConsole - have a RequiredService of IEmulator and pass it into the lua implementation instead of using Global.Emulator
This commit is contained in:
parent
d38b5396c3
commit
3bfce81eae
|
@ -44,7 +44,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
get { return (GuiLuaLibrary)Libraries[typeof(GuiLuaLibrary)]; }
|
get { return (GuiLuaLibrary)Libraries[typeof(GuiLuaLibrary)]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public EmuLuaLibrary(LuaConsole passed)
|
public EmuLuaLibrary(LuaConsole passed, IEmulatorServiceProvider serviceProvider)
|
||||||
: this()
|
: this()
|
||||||
{
|
{
|
||||||
LuaWait = new AutoResetEvent(false);
|
LuaWait = new AutoResetEvent(false);
|
||||||
|
@ -57,7 +57,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.GetTypes()
|
.GetTypes()
|
||||||
.Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
|
.Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
|
||||||
.Where(t => t.IsSealed)
|
.Where(t => t.IsSealed)
|
||||||
.Where(t => ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, t))
|
.Where(t => ServiceInjector.IsAvailable(serviceProvider, t))
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
libs.AddRange(
|
libs.AddRange(
|
||||||
|
@ -66,7 +66,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
.GetTypes()
|
.GetTypes()
|
||||||
.Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
|
.Where(t => typeof(LuaLibraryBase).IsAssignableFrom(t))
|
||||||
.Where(t => t.IsSealed)
|
.Where(t => t.IsSealed)
|
||||||
.Where(t => ServiceInjector.IsAvailable(Global.Emulator.ServiceProvider, t))
|
.Where(t => ServiceInjector.IsAvailable(serviceProvider, t))
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach (var lib in libs)
|
foreach (var lib in libs)
|
||||||
|
@ -83,7 +83,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
|
var instance = (LuaLibraryBase)Activator.CreateInstance(lib, _lua);
|
||||||
instance.LuaRegister(lib, Docs);
|
instance.LuaRegister(lib, Docs);
|
||||||
instance.LogOutputCallback = ConsoleLuaLibrary.LogOutput;
|
instance.LogOutputCallback = ConsoleLuaLibrary.LogOutput;
|
||||||
ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, instance);
|
ServiceInjector.UpdateServices(serviceProvider, instance);
|
||||||
Libraries.Add(lib, instance);
|
Libraries.Add(lib, instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,11 +94,11 @@ namespace BizHawk.Client.EmuHawk
|
||||||
EmulatorLuaLibrary.YieldCallback = EmuYield;
|
EmulatorLuaLibrary.YieldCallback = EmuYield;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Restart()
|
public void Restart(IEmulatorServiceProvider newServiceProvider)
|
||||||
{
|
{
|
||||||
foreach (var lib in Libraries)
|
foreach (var lib in Libraries)
|
||||||
{
|
{
|
||||||
ServiceInjector.UpdateServices(Global.Emulator.ServiceProvider, lib.Value);
|
ServiceInjector.UpdateServices(newServiceProvider, lib.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
using BizHawk.Emulation.Common;
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
using BizHawk.Client.EmuHawk.WinFormExtensions;
|
||||||
using BizHawk.Client.EmuHawk.ToolExtensions;
|
using BizHawk.Client.EmuHawk.ToolExtensions;
|
||||||
|
@ -15,6 +16,9 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public partial class LuaConsole : ToolFormBase, IToolFormAutoConfig
|
public partial class LuaConsole : ToolFormBase, IToolFormAutoConfig
|
||||||
{
|
{
|
||||||
|
[RequiredService]
|
||||||
|
private IEmulator Emulator { get; set; }
|
||||||
|
|
||||||
private readonly LuaFileList _luaList;
|
private readonly LuaFileList _luaList;
|
||||||
private bool _sortReverse;
|
private bool _sortReverse;
|
||||||
private string _lastColumnSorted;
|
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
|
// Even if the lua console is self-rebooting from client.reboot_core() we still want to re-inject dependencies
|
||||||
if (IsRebootingCore)
|
if (IsRebootingCore)
|
||||||
{
|
{
|
||||||
LuaImp.Restart();
|
LuaImp.Restart(Emulator.ServiceProvider);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +168,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
file.Stop();
|
file.Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
LuaImp = new EmuLuaLibrary(this);
|
LuaImp = new EmuLuaLibrary(this, Emulator.ServiceProvider);
|
||||||
InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray());
|
InputBox.AutoCompleteCustomSource.AddRange(LuaImp.Docs.Select(a => a.Library + "." + a.Name).ToArray());
|
||||||
|
|
||||||
foreach (var file in runningScripts)
|
foreach (var file in runningScripts)
|
||||||
|
|
|
@ -145,7 +145,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
private TasBranch CreateBranch()
|
private TasBranch CreateBranch()
|
||||||
{
|
{
|
||||||
// TODO: don't use Global.Emulator
|
|
||||||
return new TasBranch
|
return new TasBranch
|
||||||
{
|
{
|
||||||
Frame = Tastudio.Emulator.Frame,
|
Frame = Tastudio.Emulator.Frame,
|
||||||
|
|
Loading…
Reference in New Issue