Inline methods from LuaFunctionListExtensions and cleanup
This commit is contained in:
parent
3b8f08b1b0
commit
f7cacfab99
|
@ -45,9 +45,7 @@ namespace BizHawk.Client.Common
|
|||
|
||||
public void RemoveForFile(LuaFile file, IEmulator emulator)
|
||||
{
|
||||
var functionsToRemove = _functions
|
||||
.ForFile(file)
|
||||
.ToList();
|
||||
var functionsToRemove = _functions.Where(l => l.LuaFile.Path == file.Path || l.LuaFile.Thread == file.Thread).ToList();
|
||||
|
||||
foreach (var function in functionsToRemove)
|
||||
{
|
||||
|
@ -82,19 +80,4 @@ namespace BizHawk.Client.Common
|
|||
|
||||
private void Changed() => ChangedCallback?.Invoke();
|
||||
}
|
||||
|
||||
public static class LuaFunctionListExtensions
|
||||
{
|
||||
public static IEnumerable<NamedLuaFunction> ForFile(this IEnumerable<NamedLuaFunction> list, LuaFile luaFile)
|
||||
{
|
||||
return list
|
||||
.Where(l => l.LuaFile.Path == luaFile.Path
|
||||
|| l.LuaFile.Thread == luaFile.Thread);
|
||||
}
|
||||
|
||||
public static IEnumerable<NamedLuaFunction> ForEvent(this IEnumerable<NamedLuaFunction> list, string eventName)
|
||||
{
|
||||
return list.Where(l => l.Event == eventName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,7 +233,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void CallExitEvent(LuaFile lf)
|
||||
{
|
||||
foreach (var exitCallback in RegisteredFunctions.ForFile(lf).ForEvent("OnExit"))
|
||||
foreach (var exitCallback in RegisteredFunctions
|
||||
.Where(l => l.Event == "OnExit" && (l.LuaFile.Path == lf.Path || l.LuaFile.Thread == lf.Thread)))
|
||||
{
|
||||
exitCallback.Call();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue