aboutsummaryrefslogtreecommitdiff
path: root/src/client/callbackhandeler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/callbackhandeler.cpp')
-rw-r--r--src/client/callbackhandeler.cpp70
1 files changed, 61 insertions, 9 deletions
diff --git a/src/client/callbackhandeler.cpp b/src/client/callbackhandeler.cpp
index cf24cd2..fc44cbc 100644
--- a/src/client/callbackhandeler.cpp
+++ b/src/client/callbackhandeler.cpp
@@ -40,6 +40,7 @@ bool GlobalEventReceiver::OnEvent(const SEvent& e){
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,16 +50,67 @@ 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:{