aboutsummaryrefslogtreecommitdiff
path: root/src/client/callbackhandeler.cpp
diff options
context:
space:
mode:
authorAlexander Pickering <alex@cogarr.net>2018-06-23 06:52:55 -0600
committerAlexander Pickering <alex@cogarr.net>2018-06-23 06:52:55 -0600
commite6faff1394864a1fe0d517584d1c104997dff39f (patch)
treed7956fc8aabef903f354578d69d4d7fdf64ec928 /src/client/callbackhandeler.cpp
parent1aaa348ac080c97c0aeb0a02146ae26b74add5a1 (diff)
parent9fa5dcc9310a8c6ff8c77a47a86303f7b950dcf3 (diff)
downloadbrokengine-e6faff1394864a1fe0d517584d1c104997dff39f.tar.gz
brokengine-e6faff1394864a1fe0d517584d1c104997dff39f.tar.bz2
brokengine-e6faff1394864a1fe0d517584d1c104997dff39f.zip
Merge branch 'master' of ssh://cogarr.net:43/home/git/brokengine
Diffstat (limited to 'src/client/callbackhandeler.cpp')
-rw-r--r--src/client/callbackhandeler.cpp76
1 files changed, 64 insertions, 12 deletions
diff --git a/src/client/callbackhandeler.cpp b/src/client/callbackhandeler.cpp
index cf24cd2..76fe693 100644
--- a/src/client/callbackhandeler.cpp
+++ b/src/client/callbackhandeler.cpp
@@ -36,10 +36,11 @@ bool GlobalEventReceiver::OnEvent(const SEvent& e){
case EET_GUI_EVENT:{
IGUIElement* caller = e.GUIEvent.Caller;
EGUI_EVENT_TYPE get = e.GUIEvent.EventType;
- printf("detected gui event: %d\n",get);
+ //printf("detected gui event: %d\n",get);
bool callerregistered = guifuncs.find(caller) != guifuncs.end();
bool callerhasfunc = guifuncs[caller].find(get) != guifuncs[caller].end();
if (callerregistered && callerhasfunc){
+ //printf("Found a callback for this event\n");
return guifuncs[caller][get](e);
}
return false;
@@ -49,20 +50,71 @@ bool GlobalEventReceiver::OnEvent(const SEvent& e){
SEvent::SMouseInput se = e.MouseInput;
//printf("X: %d Y: %d\n",se.X, se.Y);
- lua_getglobal(L,"GAME");//{}
- lua_getfield(L,-1,"onMouseMove");//{},onMouseMove()
- if(!lua_isnil(L,-1)){
- lua_pushnumber(L,se.X);
- lua_pushnumber(L,se.Y);
- lua_call(L,2,0);
- lua_pop(L,1);
- }else{
- lua_pop(L,2);
+ switch(se.Event){
+ case EMIE_MOUSE_MOVED:{
+ lua_getglobal(L,"GAME");//{}
+ lua_getfield(L,-1,"onMouseMove");//{},onMouseMove()
+ if(!lua_isnil(L,-1)){
+ lua_pushnumber(L,se.X);
+ lua_pushnumber(L,se.Y);
+ lua_call(L,2,0);
+ lua_pop(L,1);
+ }else{
+ lua_pop(L,2);
+ }
+ break;
}
+ case EMIE_LMOUSE_PRESSED_DOWN:
+ case EMIE_RMOUSE_PRESSED_DOWN:
+ case EMIE_MMOUSE_PRESSED_DOWN:{
+ lua_getglobal(L,"GAME");
+ lua_getfield(L,-1,"onMouseDown");
+ if(!lua_isnil(L,-1)){
+ lua_pushnumber(L,se.X);
+ lua_pushnumber(L,se.Y);
+ lua_pushnumber(L,se.Event);
+ lua_call(L,3,0);
+ lua_pop(L,1);
+ }else{
+ lua_pop(L,2);
+ }
+ break;
+ }
+ case EMIE_LMOUSE_LEFT_UP:
+ case EMIE_RMOUSE_LEFT_UP:
+ case EMIE_MMOUSE_LEFT_UP:{
+ lua_getglobal(L,"GAME");
+ lua_getfield(L,-1,"onMouseUp");
+ if(!lua_isnil(L,-1)){
+ lua_pushnumber(L,se.X);
+ lua_pushnumber(L,se.Y);
+ lua_pushnumber(L,se.Event);
+ lua_call(L,3,0);
+ lua_pop(L,1);
+ }else{
+ lua_pop(L,2);
+ }
+ break;
+ }
+ case EMIE_MOUSE_WHEEL:{
+ lua_getglobal(L,"GAME");
+ lua_getfield(L,-1,"onMouseWheel");
+ if(!lua_isnil(L,-1)){
+ lua_pushnumber(L,se.X);
+ lua_pushnumber(L,se.Y);
+ lua_pushnumber(L,se.Wheel);
+ lua_call(L,3,0);
+ lua_pop(L,1);
+ }else{
+ lua_pop(L,2);
+ }
+ }
+ }
+
break;
}
case EET_KEY_INPUT_EVENT:{
- printf("Got input event\n");
+ //printf("Got input event\n");
SEvent::SKeyInput se = e.KeyInput;
lua_getglobal(L,"GAME");//{}
lua_getfield(L,-1,"onKeyDown");//{},()|nil
@@ -79,7 +131,7 @@ bool GlobalEventReceiver::OnEvent(const SEvent& e){
break;
}
default:
- printf("Called an unknown event\n");
+ //printf("Called an unknown event\n");
return false;
}
}