Revert "Allow frontend to pass arguments to Lua callback functions"

This reverts commit 8385337e71.
This commit is contained in:
YoshiRulz 2022-02-14 00:27:30 +10:00
parent 5bafc9a062
commit 49423d59a1
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
4 changed files with 9 additions and 15 deletions

View File

@ -6,7 +6,7 @@ namespace BizHawk.Client.Common
{
public interface INamedLuaFunction
{
Action InputCallback { get; }
Action Callback { get; }
Guid Guid { get; }

View File

@ -28,7 +28,7 @@ namespace BizHawk.Client.Common
{
if (emulator.InputCallbacksAvailable())
{
emulator.AsInputPollable().InputCallbacks.Remove(function.InputCallback);
emulator.AsInputPollable().InputCallbacks.Remove(function.Callback);
}
if (emulator.MemoryCallbacksAvailable())
@ -64,7 +64,7 @@ namespace BizHawk.Client.Common
{
if (emulator.InputCallbacksAvailable())
{
emulator.AsInputPollable().InputCallbacks.RemoveAll(_functions.Select(w => w.InputCallback));
emulator.AsInputPollable().InputCallbacks.RemoveAll(_functions.Select(w => w.Callback));
}
if (emulator.MemoryCallbacksAvailable())

View File

@ -44,10 +44,6 @@ namespace BizHawk.Client.Common
Log($"{scope} is not an available scope for {Emulator.Attributes().CoreName}");
}
[LuaMethod("can_use_callback_params", "Returns true. Check this function exists to decide whether to use hacks for older versions w/o parameter support.")]
[LuaMethodExample("local mem_callback = event.can_use_callback_params ~= nil and mem_callback or mem_callback_pre_28;")]
public bool CanUseCallbackParams()
=> true;
[LuaMethodExample("local steveonf = event.onframeend(\r\n\tfunction()\r\n\t\tconsole.log( \"Calls the given lua function at the end of each frame, after all emulation and drawing has completed. Note: this is the default behavior of lua scripts\" );\r\n\tend\r\n\t, \"Frame name\" );")]
[LuaMethod("onframeend", "Calls the given lua function at the end of each frame, after all emulation and drawing has completed. Note: this is the default behavior of lua scripts")]
@ -72,7 +68,7 @@ namespace BizHawk.Client.Common
{
try
{
InputPollableCore.InputCallbacks.Add(nlf.InputCallback);
InputPollableCore.InputCallbacks.Add(nlf.Callback);
return nlf.Guid.ToString();
}
catch (NotImplementedException)

View File

@ -32,19 +32,19 @@ namespace BizHawk.Client.Common
Guid = Guid.NewGuid();
Callback = args =>
Callback = () =>
{
try
{
_function.Call(args);
_function.Call();
}
catch (Exception ex)
{
logCallback($"error running function attached by the event {Event}\nError message: {ex.Message}");
}
};
InputCallback = () => Callback(Array.Empty<object>());
MemCallback = (addr, val, flags) => Callback(new object[] { addr, val, flags });
MemCallback = (address, value, flags) => Callback();
}
public void DetachFromScript()
@ -66,9 +66,7 @@ namespace BizHawk.Client.Common
public string Event { get; }
private Action<object[]> Callback { get; }
public Action InputCallback { get; }
public Action Callback { get; }
public MemoryCallbackDelegate MemCallback { get; }