Sfoglia il codice sorgente

Added Game::isGestureRegistered(Gesture::GestureEvent evt)

setaylor 13 anni fa
parent
commit
6298869deb

+ 5 - 0
gameplay/src/Game.cpp

@@ -456,6 +456,11 @@ void Game::unregisterGesture(Gesture::GestureEvent evt)
     Platform::unregisterGesture(evt);
     Platform::unregisterGesture(evt);
 }
 }
 
 
+bool Game::isGestureRegistered(Gesture::GestureEvent evt)
+{
+    return Platform::isGestureRegistered(evt);
+}
+
 void Game::gestureSwipeEvent(int x, int y, int direction)
 void Game::gestureSwipeEvent(int x, int y, int direction)
 {
 {
 }
 }

+ 8 - 1
gameplay/src/Game.h

@@ -354,7 +354,7 @@ public:
     inline bool isCursorVisible();
     inline bool isCursorVisible();
 
 
     /**
     /**
-     * Determines whether a specific gesture event is supported.
+     * Determines whether a specified gesture event is supported.
      *
      *
      * Use Gesture::GESTURE_ANY_SUPPORTED to test if one or more gesture events are supported.
      * Use Gesture::GESTURE_ANY_SUPPORTED to test if one or more gesture events are supported.
      *
      *
@@ -389,6 +389,13 @@ public:
      */
      */
     void unregisterGesture(Gesture::GestureEvent evt);
     void unregisterGesture(Gesture::GestureEvent evt);
 
 
+    /**
+     * Determines whether a specified gesture event is registered to receive event callbacks.
+     *
+     * @return true if the specified gesture event is registered; false of not registered.
+     */
+    bool isGestureRegistered(Gesture::GestureEvent evt);
+
     /**
     /**
      * Gesture callback on Gesture::SWIPE events.
      * Gesture callback on Gesture::SWIPE events.
      *
      *

+ 42 - 0
gameplay/src/lua/lua_Game.cpp

@@ -49,6 +49,7 @@ void luaRegister_Game()
         {"getWidth", lua_Game_getWidth},
         {"getWidth", lua_Game_getWidth},
         {"hasMouse", lua_Game_hasMouse},
         {"hasMouse", lua_Game_hasMouse},
         {"isCursorVisible", lua_Game_isCursorVisible},
         {"isCursorVisible", lua_Game_isCursorVisible},
+        {"isGestureRegistered", lua_Game_isGestureRegistered},
         {"isGestureSupported", lua_Game_isGestureSupported},
         {"isGestureSupported", lua_Game_isGestureSupported},
         {"isInitialized", lua_Game_isInitialized},
         {"isInitialized", lua_Game_isInitialized},
         {"isMouseCaptured", lua_Game_isMouseCaptured},
         {"isMouseCaptured", lua_Game_isMouseCaptured},
@@ -1262,6 +1263,47 @@ int lua_Game_isCursorVisible(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Game_isGestureRegistered(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                Gesture::GestureEvent param1 = (Gesture::GestureEvent)lua_enumFromString_GestureGestureEvent(luaL_checkstring(state, 2));
+
+                Game* instance = getInstance(state);
+                bool result = instance->isGestureRegistered(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Game_isGestureRegistered - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Game_isGestureSupported(lua_State* state)
 int lua_Game_isGestureSupported(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Game.h

@@ -32,6 +32,7 @@ int lua_Game_getViewport(lua_State* state);
 int lua_Game_getWidth(lua_State* state);
 int lua_Game_getWidth(lua_State* state);
 int lua_Game_hasMouse(lua_State* state);
 int lua_Game_hasMouse(lua_State* state);
 int lua_Game_isCursorVisible(lua_State* state);
 int lua_Game_isCursorVisible(lua_State* state);
+int lua_Game_isGestureRegistered(lua_State* state);
 int lua_Game_isGestureSupported(lua_State* state);
 int lua_Game_isGestureSupported(lua_State* state);
 int lua_Game_isInitialized(lua_State* state);
 int lua_Game_isInitialized(lua_State* state);
 int lua_Game_isMouseCaptured(lua_State* state);
 int lua_Game_isMouseCaptured(lua_State* state);

+ 40 - 0
gameplay/src/lua/lua_Platform.cpp

@@ -38,6 +38,7 @@ void luaRegister_Platform()
         {"isCursorVisible", lua_Platform_static_isCursorVisible},
         {"isCursorVisible", lua_Platform_static_isCursorVisible},
         {"isGamepadConnected", lua_Platform_static_isGamepadConnected},
         {"isGamepadConnected", lua_Platform_static_isGamepadConnected},
         {"isGamepadJoystickActive", lua_Platform_static_isGamepadJoystickActive},
         {"isGamepadJoystickActive", lua_Platform_static_isGamepadJoystickActive},
+        {"isGestureRegistered", lua_Platform_static_isGestureRegistered},
         {"isGestureSupported", lua_Platform_static_isGestureSupported},
         {"isGestureSupported", lua_Platform_static_isGestureSupported},
         {"isMouseCaptured", lua_Platform_static_isMouseCaptured},
         {"isMouseCaptured", lua_Platform_static_isMouseCaptured},
         {"isMultiTouch", lua_Platform_static_isMultiTouch},
         {"isMultiTouch", lua_Platform_static_isMultiTouch},
@@ -844,6 +845,45 @@ int lua_Platform_static_isGamepadJoystickActive(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Platform_static_isGestureRegistered(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                Gesture::GestureEvent param1 = (Gesture::GestureEvent)lua_enumFromString_GestureGestureEvent(luaL_checkstring(state, 1));
+
+                bool result = Platform::isGestureRegistered(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Platform_static_isGestureRegistered - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Platform_static_isGestureSupported(lua_State* state)
 int lua_Platform_static_isGestureSupported(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Platform.h

@@ -26,6 +26,7 @@ int lua_Platform_static_hasMouse(lua_State* state);
 int lua_Platform_static_isCursorVisible(lua_State* state);
 int lua_Platform_static_isCursorVisible(lua_State* state);
 int lua_Platform_static_isGamepadConnected(lua_State* state);
 int lua_Platform_static_isGamepadConnected(lua_State* state);
 int lua_Platform_static_isGamepadJoystickActive(lua_State* state);
 int lua_Platform_static_isGamepadJoystickActive(lua_State* state);
+int lua_Platform_static_isGestureRegistered(lua_State* state);
 int lua_Platform_static_isGestureSupported(lua_State* state);
 int lua_Platform_static_isGestureSupported(lua_State* state);
 int lua_Platform_static_isMouseCaptured(lua_State* state);
 int lua_Platform_static_isMouseCaptured(lua_State* state);
 int lua_Platform_static_isMultiTouch(lua_State* state);
 int lua_Platform_static_isMultiTouch(lua_State* state);