Use MainForm instead of GlobalWin in Lua internals
This commit is contained in:
parent
3ccdfa8289
commit
c991babdce
|
@ -1155,7 +1155,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (!alreadyOpen)
|
||||
{
|
||||
new LuaRegisteredFunctionsList(LuaImp.RegisteredFunctions)
|
||||
new LuaRegisteredFunctionsList((MainForm) MainForm, LuaImp.RegisteredFunctions)
|
||||
{
|
||||
StartLocation = this.ChildPointToScreen(LuaListView)
|
||||
}.Show();
|
||||
|
|
|
@ -8,10 +8,13 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public partial class LuaRegisteredFunctionsList : Form
|
||||
{
|
||||
private readonly IMainFormForApi _mainForm;
|
||||
|
||||
private readonly LuaFunctionList _registeredFunctions;
|
||||
|
||||
public LuaRegisteredFunctionsList(LuaFunctionList registeredFunctions)
|
||||
public LuaRegisteredFunctionsList(IMainFormForApi mainForm, LuaFunctionList registeredFunctions)
|
||||
{
|
||||
_mainForm = mainForm;
|
||||
_registeredFunctions = registeredFunctions;
|
||||
InitializeComponent();
|
||||
Icon = Properties.Resources.TextDocIcon;
|
||||
|
@ -89,7 +92,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
var guid = FunctionView.Items[index].SubItems[2].Text;
|
||||
var nlf = _registeredFunctions[guid];
|
||||
_registeredFunctions.Remove(nlf, GlobalWin.Emulator); // TODO: don't use Global
|
||||
_registeredFunctions.Remove(nlf, _mainForm.Emulator);
|
||||
}
|
||||
|
||||
PopulateListView();
|
||||
|
@ -108,7 +111,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
private void RemoveAllBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
_registeredFunctions.Clear(GlobalWin.Emulator); // TODO: don't use Global
|
||||
_registeredFunctions.Clear(_mainForm.Emulator);
|
||||
PopulateListView();
|
||||
}
|
||||
|
||||
|
|
|
@ -47,9 +47,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
_mainForm = mainForm;
|
||||
LuaWait = new AutoResetEvent(false);
|
||||
Docs.Clear();
|
||||
var apiContainer = ApiManager.RestartLua(serviceProvider, LogToLuaConsole, mainForm, displayManager, inputManager, mainForm.MovieSession, mainForm.Tools, config, emulator, game);
|
||||
var apiContainer = ApiManager.RestartLua(serviceProvider, LogToLuaConsole, _mainForm, displayManager, inputManager, _mainForm.MovieSession, _mainForm.Tools, config, emulator, game);
|
||||
|
||||
// Register lua libraries
|
||||
foreach (var lib in Client.Common.ReflectionCache.Types.Concat(EmuHawk.ReflectionCache.Types)
|
||||
|
@ -71,11 +72,11 @@ namespace BizHawk.Client.EmuHawk
|
|||
// and inject them here
|
||||
if (instance is ClientLuaLibrary clientLib)
|
||||
{
|
||||
clientLib.MainForm = mainForm;
|
||||
clientLib.MainForm = _mainForm;
|
||||
}
|
||||
else if (instance is ConsoleLuaLibrary consoleLib)
|
||||
{
|
||||
consoleLib.Tools = mainForm.Tools;
|
||||
consoleLib.Tools = _mainForm.Tools;
|
||||
_logToLuaConsoleCallback = consoleLib.Log;
|
||||
}
|
||||
else if (instance is GuiLuaLibrary guiLib)
|
||||
|
@ -89,7 +90,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else if (instance is TAStudioLuaLibrary tastudioLib)
|
||||
{
|
||||
tastudioLib.Tools = mainForm.Tools;
|
||||
tastudioLib.Tools = _mainForm.Tools;
|
||||
}
|
||||
|
||||
if (instance is DelegatingLuaLibrary dlgInstance) dlgInstance.APIs = apiContainer;
|
||||
|
@ -107,6 +108,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
EnumerateLuaFunctions(nameof(LuaCanvas), typeof(LuaCanvas), null); // add LuaCanvas to Lua function reference table
|
||||
}
|
||||
|
||||
private readonly MainForm _mainForm;
|
||||
|
||||
private Lua _lua = new Lua();
|
||||
private Lua _currThread;
|
||||
|
||||
|
@ -188,7 +191,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public override void Close()
|
||||
{
|
||||
RegisteredFunctions.Clear(GlobalWin.Emulator); // TODO: don't use globals
|
||||
RegisteredFunctions.Clear(_mainForm.Emulator);
|
||||
ScriptList.Clear();
|
||||
FormsLibrary.DestroyAll();
|
||||
_lua.Close();
|
||||
|
|
Loading…
Reference in New Issue