Files
lime/project/src/app/ApplicationEvent.cpp
Joshua Granick 58057a4457 Cleanup imports
2018-06-11 14:19:37 -07:00

59 lines
1.1 KiB
C++

#include <app/ApplicationEvent.h>
#include <system/CFFI.h>
namespace lime {
ValuePointer* ApplicationEvent::callback = 0;
ValuePointer* ApplicationEvent::eventObject = 0;
static int id_deltaTime;
static int id_type;
static bool init = false;
ApplicationEvent::ApplicationEvent () {
deltaTime = 0;
type = UPDATE;
}
void ApplicationEvent::Dispatch (ApplicationEvent* event) {
if (ApplicationEvent::callback) {
if (ApplicationEvent::eventObject->IsCFFIValue ()) {
if (!init) {
id_deltaTime = val_id ("deltaTime");
id_type = val_id ("type");
init = true;
}
value object = (value)ApplicationEvent::eventObject->Get ();
alloc_field (object, id_deltaTime, alloc_int (event->deltaTime));
alloc_field (object, id_type, alloc_int (event->type));
} else {
HL_ApplicationEvent* eventObject = (HL_ApplicationEvent*)ApplicationEvent::eventObject->Get ();
eventObject->deltaTime = event->deltaTime;
eventObject->type = event->type;
}
ApplicationEvent::callback->Call ();
}
}
}