From f8fbdf8fcb09b22e6bcea511edda96e922e746ca Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 17 Feb 2010 04:31:49 +0000 Subject: [PATCH] added ag.setCursorVisible() and ag.getCursorVisible() git-svn-id: svn://anubis/anaglym/trunk@248 99a6e188-d820-4881-8870-2d33a10e2619 --- .todo | 1 - Engine.h | 6 ++++++ ag.cc | 18 ++++++++++++++++++ ag.h | 2 ++ tests/managed_objects.lua | 2 ++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.todo b/.todo index 54ec4be..34f09ef 100644 --- a/.todo +++ b/.todo @@ -1,3 +1,2 @@ -add Lua interface for showing/hiding mouse cursor add 3d-picking routines using temporary ODE ray geometries add audio capabilities diff --git a/Engine.h b/Engine.h index 700b2bb..b2843fb 100644 --- a/Engine.h +++ b/Engine.h @@ -189,6 +189,12 @@ class Engine void drawList(GLuint list); void callList(GLuint list); void clearWorld(); + void setScriptCursorVisible(bool visible) + { + m_script_cursor_visible = visible; + updateCursorVisibility(); + } + bool getScriptCursorVisible() { return m_script_cursor_visible; } void getScreenSize(int * width, int * height); void drawText(const char * text, GLfloat r, GLfloat g, GLfloat b, diff --git a/ag.cc b/ag.cc index 10ced74..481566e 100644 --- a/ag.cc +++ b/ag.cc @@ -39,6 +39,7 @@ namespace ag { "exit", exit }, { "fillRect", fillRect }, { "getCamera", getCamera }, + { "getCursorVisible", getCursorVisible }, { "getScreenSize", getScreenSize }, { "getTextSize", getTextSize }, { "import", import }, @@ -54,6 +55,7 @@ namespace ag { "setAutoPhysics", setAutoPhysics }, { "setAutoStartFrame", setAutoStartFrame }, { "setCamera", setCamera }, + { "setCursorVisible", setCursorVisible }, { "setGravity", setGravity }, // { "sleep", sleep }, { "startFrame", startFrame }, @@ -411,6 +413,16 @@ namespace ag return g_engine->setCamera(L); } + int setCursorVisible(lua_State * L) + { + int argc = lua_gettop(L); + if (argc == 1 && lua_isboolean(L, 1)) + { + g_engine->setScriptCursorVisible(lua_toboolean(L, 1)); + } + return 0; + } + int setGravity(lua_State * L) { int argc = lua_gettop(L); @@ -431,6 +443,12 @@ namespace ag return g_engine->getCamera(L); } + int getCursorVisible(lua_State * L) + { + lua_pushboolean(L, g_engine->getScriptCursorVisible()); + return 1; + } + int elapsedTime(lua_State * L) { lua_pushinteger(L, SDL_GetTicks()); diff --git a/ag.h b/ag.h index a8aa93e..b7f00b8 100644 --- a/ag.h +++ b/ag.h @@ -19,6 +19,7 @@ namespace ag int endList(lua_State * L); int exit(lua_State * L); int getCamera(lua_State * L); + int getCursorVisible(lua_State * L); int getScreenSize(lua_State * L); int import(lua_State * L); int isKeyDown(lua_State * L); @@ -33,6 +34,7 @@ namespace ag int setAutoPhysics(lua_State * L); int setAutoStartFrame(lua_State * L); int setCamera(lua_State * L); + int setCursorVisible(lua_State * L); int setGravity(lua_State * L); int sleep(lua_State * L); int startFrame(lua_State * L); diff --git a/tests/managed_objects.lua b/tests/managed_objects.lua index 66384c5..c8ccfb6 100644 --- a/tests/managed_objects.lua +++ b/tests/managed_objects.lua @@ -52,5 +52,7 @@ function key_down_event(key) -- { x = 0, y = 0, z = 1, vel = 0, fmax = 0 }) -- local x, y, z = box:getPosition() -- box:setPosition(x, y, 2) + elseif (key == "minus") then + ag.setCursorVisible(not ag.getCursorVisible()) end end