2013-10-28 20:57:25 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-10-28 19:13:01 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2014-12-04 00:43:12 +00:00
|
|
|
|
using BizHawk.Emulation.Common.IEmulatorExtensions;
|
|
|
|
|
|
2013-10-28 19:13:01 +00:00
|
|
|
|
namespace BizHawk.Client.Common
|
|
|
|
|
{
|
|
|
|
|
public class LuaFunctionList : List<NamedLuaFunction>
|
|
|
|
|
{
|
|
|
|
|
public NamedLuaFunction this[string guid]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2017-05-18 16:36:38 +00:00
|
|
|
|
return this.FirstOrDefault(nlf => nlf.Guid.ToString() == guid);
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2013-11-10 19:19:58 +00:00
|
|
|
|
|
2013-12-19 01:02:50 +00:00
|
|
|
|
public new bool Remove(NamedLuaFunction function)
|
2013-11-10 19:19:58 +00:00
|
|
|
|
{
|
2015-10-18 00:03:07 +00:00
|
|
|
|
if (Global.Emulator.InputCallbacksAvailable())
|
2014-12-04 00:43:12 +00:00
|
|
|
|
{
|
2014-12-05 00:59:00 +00:00
|
|
|
|
Global.Emulator.AsInputPollable().InputCallbacks.Remove(function.Callback);
|
2014-12-04 00:43:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-18 00:03:07 +00:00
|
|
|
|
if (Global.Emulator.MemoryCallbacksAvailable())
|
2014-12-05 01:56:45 +00:00
|
|
|
|
{
|
|
|
|
|
Global.Emulator.AsDebuggable().MemoryCallbacks.Remove(function.Callback);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-19 01:02:50 +00:00
|
|
|
|
return base.Remove(function);
|
2013-11-10 19:19:58 +00:00
|
|
|
|
}
|
2013-11-10 21:56:02 +00:00
|
|
|
|
|
|
|
|
|
public void ClearAll()
|
|
|
|
|
{
|
2015-10-12 23:02:03 +00:00
|
|
|
|
if (Global.Emulator.InputCallbacksAvailable())
|
2014-12-04 00:43:12 +00:00
|
|
|
|
{
|
2017-05-18 16:36:38 +00:00
|
|
|
|
Global.Emulator.AsInputPollable().InputCallbacks.RemoveAll(this.Select(w => w.Callback));
|
2014-12-04 00:43:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2015-10-12 23:02:03 +00:00
|
|
|
|
if (Global.Emulator.MemoryCallbacksAvailable())
|
2014-12-05 01:56:45 +00:00
|
|
|
|
{
|
2017-04-14 19:59:01 +00:00
|
|
|
|
var memoryCallbacks = Global.Emulator.AsDebuggable().MemoryCallbacks;
|
2017-05-18 16:36:38 +00:00
|
|
|
|
memoryCallbacks.RemoveAll(this.Select(w => w.Callback));
|
2014-12-05 01:56:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-10 21:56:02 +00:00
|
|
|
|
Clear();
|
|
|
|
|
}
|
2013-10-28 19:13:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|