Move props from LuaLibraries to Win32LuaLibraries
This commit is contained in:
parent
c46719c602
commit
e42a021215
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using NLua;
|
||||
|
||||
|
@ -16,37 +11,21 @@ namespace BizHawk.Client.Common
|
|||
public abstract string EngineName { get; }
|
||||
|
||||
public abstract LuaFunctionList RegisteredFunctions { get; }
|
||||
public abstract GuiLuaLibrary GuiLibrary { get; }
|
||||
protected readonly Dictionary<Type, LuaLibraryBase> Libraries = new Dictionary<Type, LuaLibraryBase>();
|
||||
public readonly LuaFileList ScriptList = new LuaFileList();
|
||||
|
||||
public bool IsRebootingCore { get; set; } // pretty hacky.. we don't want a lua script to be able to restart itself by rebooting the core
|
||||
|
||||
public bool IsUpdateSupressed { get; set; }
|
||||
|
||||
public EventWaitHandle LuaWait { get; protected set; }
|
||||
|
||||
public abstract void CallExitEvent(LuaFile lf);
|
||||
public abstract void CallFrameAfterEvent();
|
||||
public abstract void CallFrameBeforeEvent();
|
||||
public abstract void CallLoadStateEvent(string name);
|
||||
public abstract void CallSaveStateEvent(string name);
|
||||
public abstract void Close();
|
||||
|
||||
public abstract INamedLuaFunction CreateAndRegisterNamedFunction(LuaFunction function, string theEvent, Action<string> logCallback, LuaFile luaFile, string name = null);
|
||||
|
||||
public abstract void EndLuaDrawing();
|
||||
public abstract void ExecuteString(string command);
|
||||
|
||||
public abstract NLuaTableHelper GetTableHelper();
|
||||
|
||||
public abstract bool RemoveNamedFunctionMatching(Func<INamedLuaFunction, bool> predicate);
|
||||
|
||||
public abstract void Restart(IEmulatorServiceProvider newServiceProvider);
|
||||
public abstract (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf);
|
||||
public abstract void SpawnAndSetFileThread(string pathToLoad, LuaFile lf);
|
||||
public abstract void StartLuaDrawing();
|
||||
|
||||
public abstract void RunScheduledDisposes();
|
||||
}
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
|
||||
using BizHawk.Client.Common;
|
||||
using BizHawk.Emulation.Common;
|
||||
|
||||
using NLua;
|
||||
|
||||
|
@ -14,57 +13,24 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public override string EngineName => null;
|
||||
|
||||
public override void CallExitEvent(LuaFile lf)
|
||||
{
|
||||
}
|
||||
public override void CallFrameAfterEvent()
|
||||
{
|
||||
}
|
||||
public override void CallFrameBeforeEvent()
|
||||
{
|
||||
}
|
||||
public override void CallLoadStateEvent(string name)
|
||||
{
|
||||
}
|
||||
public override void CallSaveStateEvent(string name)
|
||||
{
|
||||
}
|
||||
public override void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public override INamedLuaFunction CreateAndRegisterNamedFunction(LuaFunction function, string theEvent, Action<string> logCallback, LuaFile luaFile, string name = null) => null;
|
||||
|
||||
public override void EndLuaDrawing()
|
||||
{
|
||||
}
|
||||
public override void ExecuteString(string command)
|
||||
{
|
||||
}
|
||||
|
||||
public override NLuaTableHelper GetTableHelper() => null;
|
||||
|
||||
private static readonly LuaFunctionList EmptyLuaFunList = new LuaFunctionList();
|
||||
public override LuaFunctionList RegisteredFunctions => EmptyLuaFunList;
|
||||
public override GuiLuaLibrary GuiLibrary => null;
|
||||
|
||||
public override bool RemoveNamedFunctionMatching(Func<INamedLuaFunction, bool> predicate) => false;
|
||||
|
||||
public override void Restart(IEmulatorServiceProvider newServiceProvider)
|
||||
{
|
||||
}
|
||||
|
||||
public override (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf) => (false, false);
|
||||
|
||||
public override void SpawnAndSetFileThread(string pathToLoad, LuaFile lf)
|
||||
{
|
||||
}
|
||||
public override void StartLuaDrawing()
|
||||
{
|
||||
}
|
||||
|
||||
public override void RunScheduledDisposes()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -118,13 +119,17 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public override string EngineName => Lua.WhichLua;
|
||||
|
||||
public override GuiLuaLibrary GuiLibrary => (GuiLuaLibrary) Libraries[typeof(GuiLuaLibrary)];
|
||||
public GuiLuaLibrary GuiLibrary => (GuiLuaLibrary) Libraries[typeof(GuiLuaLibrary)];
|
||||
|
||||
private readonly IDictionary<Type, LuaLibraryBase> Libraries = new Dictionary<Type, LuaLibraryBase>();
|
||||
|
||||
private EventWaitHandle LuaWait;
|
||||
|
||||
private static void LogToLuaConsole(object outputs) => _logToLuaConsoleCallback(new[] { outputs });
|
||||
|
||||
public override NLuaTableHelper GetTableHelper() => _th;
|
||||
|
||||
public override void Restart(IEmulatorServiceProvider newServiceProvider)
|
||||
public void Restart(IEmulatorServiceProvider newServiceProvider)
|
||||
{
|
||||
foreach (var lib in Libraries)
|
||||
{
|
||||
|
@ -132,7 +137,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public override void StartLuaDrawing()
|
||||
public void StartLuaDrawing()
|
||||
{
|
||||
if (ScriptList.Count != 0 && GuiLibrary.SurfaceIsNull && !IsUpdateSupressed)
|
||||
{
|
||||
|
@ -140,7 +145,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public override void EndLuaDrawing()
|
||||
public void EndLuaDrawing()
|
||||
{
|
||||
if (ScriptList.Count != 0 && !IsUpdateSupressed)
|
||||
{
|
||||
|
@ -182,7 +187,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public override void CallFrameBeforeEvent()
|
||||
public void CallFrameBeforeEvent()
|
||||
{
|
||||
if (IsUpdateSupressed) return;
|
||||
try
|
||||
|
@ -198,7 +203,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public override void CallFrameAfterEvent()
|
||||
public void CallFrameAfterEvent()
|
||||
{
|
||||
if (IsUpdateSupressed) return;
|
||||
try
|
||||
|
@ -214,7 +219,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public override void CallExitEvent(LuaFile lf)
|
||||
public void CallExitEvent(LuaFile lf)
|
||||
{
|
||||
foreach (var exitCallback in RegisteredFunctions.ForFile(lf).ForEvent("OnExit"))
|
||||
{
|
||||
|
@ -222,7 +227,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
public void Close()
|
||||
{
|
||||
RegisteredFunctions.Clear(_mainForm.Emulator);
|
||||
ScriptList.Clear();
|
||||
|
@ -267,16 +272,16 @@ namespace BizHawk.Client.EmuHawk
|
|||
lf.Thread = SpawnCoroutine(pathToLoad);
|
||||
}
|
||||
|
||||
public override void ExecuteString(string command)
|
||||
public void ExecuteString(string command)
|
||||
{
|
||||
_currThread = _lua.NewThread();
|
||||
_currThread.DoString(command);
|
||||
if (true /*NLua.Lua.WhichLua == "NLua"*/) _lua.Pop();
|
||||
}
|
||||
|
||||
public override void RunScheduledDisposes() => _lua.RunScheduledDisposes();
|
||||
public void RunScheduledDisposes() => _lua.RunScheduledDisposes();
|
||||
|
||||
public override (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf)
|
||||
public (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf)
|
||||
{
|
||||
_currThread = lf.Thread;
|
||||
|
||||
|
|
Loading…
Reference in New Issue