#include #include #include extern "C" { #include #include #include } #include #include #include "callbackhandeler.hpp" using namespace irr; using namespace gui; using namespace std; std::map > guifuncs; //IrrlichtDevice* device; void registerguicallback(IGUIElement* element, EGUI_EVENT_TYPE event, void (*func)(irr::SEvent)){ printf("Callback registered\n"); guifuncs[element][event] = func; } GlobalEventReceiver::GlobalEventReceiver(IrrlichtDevice* d){ //device = d; } bool GlobalEventReceiver::OnEvent(const SEvent& e){ EEVENT_TYPE type = e.EventType; switch (type){ case EET_GUI_EVENT:{ IGUIElement* caller = e.GUIEvent.Caller; EGUI_EVENT_TYPE get = e.GUIEvent.EventType; printf("detected gui event...\n"); if ( guifuncs.find(caller) != guifuncs.end() && guifuncs[caller].find(get) != guifuncs[caller].end()){ guifuncs[caller][get](e); printf("sucessfully called a gui event\n"); return true; } return false; break; } case EET_MOUSE_INPUT_EVENT:{ } default: printf("Called an unknown event\n"); return false; } }