diff options
author | chai <chaifix@163.com> | 2018-10-23 12:23:58 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-10-23 12:23:58 +0800 |
commit | 40fc27154fe754181934dc7ee31375e6bdfb33fc (patch) | |
tree | 897ad98d759bc308ef66561181ba88b85f2ccd47 /src/lua/modules/mouse/mouse.cpp | |
parent | 1480c9445100075c9e1a894eb07c0ef727b509a1 (diff) |
*merge from minimal
Diffstat (limited to 'src/lua/modules/mouse/mouse.cpp')
-rw-r--r-- | src/lua/modules/mouse/mouse.cpp | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/src/lua/modules/mouse/mouse.cpp b/src/lua/modules/mouse/mouse.cpp index f907abb..9d45178 100644 --- a/src/lua/modules/mouse/mouse.cpp +++ b/src/lua/modules/mouse/mouse.cpp @@ -1,31 +1,42 @@ #include "lua/modules/luax.h" #include "libjin/jin.h" -namespace jin +namespace JinEngine { -namespace lua -{ - using namespace jin::input; - - static int l_pos(lua_State* L) + namespace Lua { - static Mouse* mouse = Mouse::get(); - int x, y; - mouse->getState(&x, &y); - luax_pushnumber(L, x); - luax_pushnumber(L, y); - return 2; - } - static const luaL_Reg f[] = { - { "position", l_pos }, - { 0, 0 } - }; + using namespace JinEngine::Input; + + static int l_pos(lua_State* L) + { + static Mouse* mouse = Mouse::get(); + int x, y; + mouse->getState(&x, &y); + luax_pushnumber(L, x); + luax_pushnumber(L, y); + return 2; + } + + static int l_setVisible(lua_State* L) + { + bool visible = luax_checkbool(L, 1); + Mouse* mouse = Mouse::get(); + mouse->setVisible(visible); + return 0; + } + + static const luaL_Reg f[] = { + { "position", l_pos }, + { "setVisible", l_setVisible }, + { 0, 0 } + }; - int luaopen_mouse(lua_State* L) - { - luax_newlib(L, f); - return 1; - } -} -}
\ No newline at end of file + int luaopen_mouse(lua_State* L) + { + luax_newlib(L, f); + return 1; + } + + } // namespace Lua +} // namespace JinEngine
\ No newline at end of file |