aboutsummaryrefslogtreecommitdiff
path: root/src/client/callbackhandeler.cpp
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-11-01 00:28:16 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-11-01 00:28:16 -0400
commitd2b36e6c65ec8126c0ebc96adb7e011e78a5eacc (patch)
tree9e005502ea2c125c90b5011f573f381f84ade0ef /src/client/callbackhandeler.cpp
downloadbrokengine-d2b36e6c65ec8126c0ebc96adb7e011e78a5eacc.tar.gz
brokengine-d2b36e6c65ec8126c0ebc96adb7e011e78a5eacc.tar.bz2
brokengine-d2b36e6c65ec8126c0ebc96adb7e011e78a5eacc.zip
Initial commit
Diffstat (limited to 'src/client/callbackhandeler.cpp')
-rw-r--r--src/client/callbackhandeler.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/client/callbackhandeler.cpp b/src/client/callbackhandeler.cpp
new file mode 100644
index 0000000..f39f4ca
--- /dev/null
+++ b/src/client/callbackhandeler.cpp
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <vector>
+extern "C" {
+ #include <lua.h>
+ #include <lauxlib.h>
+ #include <lualib.h>
+}
+#include <irrlicht.h>
+#include <map>
+
+#include "callbackhandeler.hpp"
+
+using namespace irr;
+using namespace gui;
+using namespace std;
+
+std::map<IGUIElement*,std::map<EGUI_EVENT_TYPE, void(*)(irr::SEvent)> > 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;
+ }
+}