mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
Made separate .Find in Static handlers for convenience.
This commit is contained in:
parent
c7e3ff2356
commit
2382a76be5
2 changed files with 35 additions and 23 deletions
|
@ -294,29 +294,6 @@ DEFINE_ACTION_FUNCTION(DEventHandler, CreateOnce)
|
|||
ACTION_RETURN_OBJECT(t->CreateNew());
|
||||
}
|
||||
|
||||
// for static
|
||||
DEFINE_ACTION_FUNCTION(DStaticEventHandler, Create)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(t, DStaticEventHandler);
|
||||
// static handlers can create any type of object.
|
||||
// generate a new object of this type.
|
||||
ACTION_RETURN_OBJECT(t->CreateNew());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DStaticEventHandler, CreateOnce)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(t, DStaticEventHandler);
|
||||
// static handlers can create any type of object.
|
||||
// check if there are already registered handlers of this type.
|
||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||
if (handler->GetClass() == t) // check precise class
|
||||
ACTION_RETURN_OBJECT(handler);
|
||||
// generate a new object of this type.
|
||||
ACTION_RETURN_OBJECT(t->CreateNew());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DEventHandler, Find)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
|
@ -343,6 +320,40 @@ DEFINE_ACTION_FUNCTION(DEventHandler, Unregister)
|
|||
ACTION_RETURN_BOOL(E_UnregisterHandler(handler));
|
||||
}
|
||||
|
||||
// for static
|
||||
DEFINE_ACTION_FUNCTION(DStaticEventHandler, Create)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(t, DStaticEventHandler);
|
||||
// static handlers can create any type of object.
|
||||
// generate a new object of this type.
|
||||
ACTION_RETURN_OBJECT(t->CreateNew());
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DStaticEventHandler, CreateOnce)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(t, DStaticEventHandler);
|
||||
// static handlers can create any type of object.
|
||||
// check if there are already registered handlers of this type.
|
||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||
if (handler->GetClass() == t) // check precise class
|
||||
ACTION_RETURN_OBJECT(handler);
|
||||
// generate a new object of this type.
|
||||
ACTION_RETURN_OBJECT(t->CreateNew());
|
||||
}
|
||||
|
||||
// we might later want to change this
|
||||
DEFINE_ACTION_FUNCTION(DStaticEventHandler, Find)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_CLASS(t, DStaticEventHandler);
|
||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||
if (handler->GetClass() == t) // check precise class
|
||||
ACTION_RETURN_OBJECT(handler);
|
||||
ACTION_RETURN_OBJECT(nullptr);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION(DStaticEventHandler, Register)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
|
|
|
@ -4,6 +4,7 @@ class StaticEventHandler : Object native
|
|||
// unlike EventHandler.Create that will not create them.
|
||||
protected static native StaticEventHandler Create(class<StaticEventHandler> type);
|
||||
protected static native StaticEventHandler CreateOnce(class<StaticEventHandler> type);
|
||||
protected static native StaticEventHandler Find(Class<StaticEventHandler> type); // just for convenience. who knows.
|
||||
|
||||
protected static native bool Register(StaticEventHandler handler);
|
||||
protected static native bool Unregister(StaticEventHandler handler);
|
||||
|
|
Loading…
Reference in a new issue