diff options
| author | Alexander <alex@cogarr.net> | 2019-02-10 18:16:04 -0500 |
|---|---|---|
| committer | Alexander <alex@cogarr.net> | 2019-02-10 18:16:04 -0500 |
| commit | 83a85531ae789e2f30da2379990899f815f53ff1 (patch) | |
| tree | 81140ea86f6e3d7808b218597874ea927555ef0d /src/client/callbackhandeler.cpp | |
| parent | 1482e03dd238643ff47278e207e6450f14011acf (diff) | |
| download | brokengine-83a85531ae789e2f30da2379990899f815f53ff1.tar.gz brokengine-83a85531ae789e2f30da2379990899f815f53ff1.tar.bz2 brokengine-83a85531ae789e2f30da2379990899f815f53ff1.zip | |
Added new element, added server-specific code for networking
Added a new element for client gui: iguicombobox
Added a part of the engine specifically for the server
so server is no longer just a stripped down client
Diffstat (limited to 'src/client/callbackhandeler.cpp')
| -rw-r--r-- | src/client/callbackhandeler.cpp | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/src/client/callbackhandeler.cpp b/src/client/callbackhandeler.cpp index 133635c..5d51ba6 100644 --- a/src/client/callbackhandeler.cpp +++ b/src/client/callbackhandeler.cpp @@ -17,7 +17,9 @@ using namespace gui; using namespace std; extern lua_State* L; - +/*** +@module GAME +*/ std::map<IGUIElement*, int> guielements; //For basic events @@ -50,7 +52,8 @@ void callMouse(lua_State* L, const char* funcname, double x, double y, double ev } lua_pop(L,2); }else{ - lua_pop(L,3); + //{GAME},errfunc,nil + lua_pop(L,3);// } } @@ -106,15 +109,20 @@ bool GlobalEventReceiver::OnEvent(const SEvent& e){ case EGET_TREEVIEW_NODE_COLLAPSE: fieldname = "onNodeCollapse"; break; case EGET_COUNT: break; } - lua_getfield(L,-1,fieldname);//{guielement},func() + printf("About to push error func"); + pusherrorfunc(L);//{guielement},errfunc() + lua_getfield(L,-2,fieldname);//{guielement},errfunc(),func() if(lua_isnil(L,-1)){ - lua_pop(L,2); + printf("Element did not have a function %s, returning\n",fieldname); + lua_pop(L,3);// return false; } - lua_rawgeti(L,LUA_REGISTRYINDEX,ref);//{guielement},func(),{guielement} - lua_call(L,1,1);//{guielement} + lua_rawgeti(L,LUA_REGISTRYINDEX,ref);//{guielement},errfunc(),func(),{guielement} + printf("About to pcall in callback.cpp!\n"); + lua_pcall(L,1,1,-3);//{guielement} int n = lua_gettop(L); if(n > 1){ + printf("Got an argument back!\n"); int ans = lua_toboolean(L,-1); lua_pop(L,n); return ans; @@ -125,7 +133,15 @@ bool GlobalEventReceiver::OnEvent(const SEvent& e){ break; case EET_MOUSE_INPUT_EVENT:{ //printf("Mouse event - X: %d Y: %d\n",se.X, se.Y); - +/*** +(Callback)Detects mouse movement. +Detects when the mouse moves across the game. +@function GAME.onMouseMove(x,y,event) +@tparam number x The key that the user pressed down +@tparam boolean down Was the key pressed down? +@tparam boolean pressed_ctrl Was control pressed? +@tparam boolean pressed_shift Was shift pressed? +*/ switch(se.Event){ case EMIE_MOUSE_MOVED:{ callMouse(L,"onMouseMove",se.X,se.Y,se.Event); @@ -166,6 +182,15 @@ bool GlobalEventReceiver::OnEvent(const SEvent& e){ return false; } break; +/*** +(Callback)Detects key presses. +Detects any key presses from the game. +@function GAME.onKeyDown(key,down,pressed_ctrl,pressed_shift) +@tparam number key The key that the user pressed down +@tparam boolean down Was the key pressed down? +@tparam boolean pressed_ctrl Was control pressed? +@tparam boolean pressed_shift Was shift pressed? +*/ case EET_KEY_INPUT_EVENT:{ //printf("Got input event\n"); SEvent::SKeyInput se = e.KeyInput; |
