Explorar o código

Merge branch 'next' of https://github.com/blackberry-gaming/GamePlay into next

Conflicts:
	gameplay-samples/sample01-longboard/android/build.xml
	gameplay-samples/sample02-spaceship/android/build.xml
	gameplay-samples/sample03-character/android/build.xml
	gameplay-samples/sample05-lua/android/AndroidManifest.xml
	gameplay-samples/sample05-lua/android/build.xml
Darryl Gough %!s(int64=13) %!d(string=hai) anos
pai
achega
f7498ab2b0

+ 7 - 7
gameplay.sln

@@ -28,7 +28,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample00-mesh", "gameplay-s
 		{1032BA4B-57EB-4348-9E03-29DD63E80E4A} = {1032BA4B-57EB-4348-9E03-29DD63E80E4A}
 	EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample05-lua", "gameplay-samples\sample05-lua\sample05-lua.vcxproj", "{04EAF3E5-0F9E-AF4D-53F9-269CE114211F}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample05-lua", "gameplay-samples\sample05-lua\sample05-lua.vcxproj", "{C220DB61-B43A-9628-54DF-7285E1F597C8}"
 	ProjectSection(ProjectDependencies) = postProject
 		{1032BA4B-57EB-4348-9E03-29DD63E80E4A} = {1032BA4B-57EB-4348-9E03-29DD63E80E4A}
 	EndProjectSection
@@ -76,12 +76,12 @@ Global
 		{D672DC66-3CE0-4878-B0D2-813CA731012F}.DebugMem|Win32.Build.0 = DebugMem|Win32
 		{D672DC66-3CE0-4878-B0D2-813CA731012F}.Release|Win32.ActiveCfg = Release|Win32
 		{D672DC66-3CE0-4878-B0D2-813CA731012F}.Release|Win32.Build.0 = Release|Win32
-		{04EAF3E5-0F9E-AF4D-53F9-269CE114211F}.Debug|Win32.ActiveCfg = Debug|Win32
-		{04EAF3E5-0F9E-AF4D-53F9-269CE114211F}.Debug|Win32.Build.0 = Debug|Win32
-		{04EAF3E5-0F9E-AF4D-53F9-269CE114211F}.DebugMem|Win32.ActiveCfg = DebugMem|Win32
-		{04EAF3E5-0F9E-AF4D-53F9-269CE114211F}.DebugMem|Win32.Build.0 = DebugMem|Win32
-		{04EAF3E5-0F9E-AF4D-53F9-269CE114211F}.Release|Win32.ActiveCfg = Release|Win32
-		{04EAF3E5-0F9E-AF4D-53F9-269CE114211F}.Release|Win32.Build.0 = Release|Win32
+		{C220DB61-B43A-9628-54DF-7285E1F597C8}.Debug|Win32.ActiveCfg = Debug|Win32
+		{C220DB61-B43A-9628-54DF-7285E1F597C8}.Debug|Win32.Build.0 = Debug|Win32
+		{C220DB61-B43A-9628-54DF-7285E1F597C8}.DebugMem|Win32.ActiveCfg = DebugMem|Win32
+		{C220DB61-B43A-9628-54DF-7285E1F597C8}.DebugMem|Win32.Build.0 = DebugMem|Win32
+		{C220DB61-B43A-9628-54DF-7285E1F597C8}.Release|Win32.ActiveCfg = Release|Win32
+		{C220DB61-B43A-9628-54DF-7285E1F597C8}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 4 - 5
gameplay/src/Container.cpp

@@ -971,9 +971,8 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
         }
 
         Control::State currentState = control->getState();
-        if ((control->isContainer() && currentState == Control::FOCUS) ||
-            (currentState != Control::NORMAL && control->_contactIndex == data) ||
-            ((evt == Touch::TOUCH_PRESS ||
+        if ((currentState != Control::NORMAL && control->_contactIndex == data) ||
+            ((control->isContainer() || evt == Touch::TOUCH_PRESS ||
               evt == Mouse::MOUSE_PRESS_LEFT_BUTTON ||
               evt == Mouse::MOUSE_PRESS_MIDDLE_BUTTON ||
               evt == Mouse::MOUSE_PRESS_RIGHT_BUTTON ||
@@ -985,9 +984,9 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
         {
             // Pass on the event's clip relative to the control.
             if (mouse)
-                eventConsumed |= control->mouseEvent((Mouse::MouseEvent)evt, x - xPos - boundsX, y - yPos - boundsY, data);
+                eventConsumed = control->mouseEvent((Mouse::MouseEvent)evt, x - xPos - boundsX, y - yPos - boundsY, data);
             else
-                eventConsumed |= control->touchEvent((Touch::TouchEvent)evt, x - xPos - boundsX, y - yPos - boundsY, (unsigned int)data);
+                eventConsumed = control->touchEvent((Touch::TouchEvent)evt, x - xPos - boundsX, y - yPos - boundsY, (unsigned int)data);
         }
     }
 

+ 126 - 99
gameplay/src/Joystick.cpp

@@ -4,12 +4,16 @@
 namespace gameplay
 {
 
-Joystick::Joystick() : _absolute(true)
+Joystick::Joystick() : _relative(true), _innerSize(NULL), _outerSize(NULL)
 {
 }
 
 Joystick::~Joystick()
 {
+    if (_innerSize)
+        SAFE_DELETE(_innerSize);
+    if (_outerSize)
+        SAFE_DELETE(_outerSize);
 }
 
 Joystick* Joystick::create(const char* id, Theme::Style* style)
@@ -28,8 +32,6 @@ Joystick* Joystick::create(Theme::Style* style, Properties* properties)
 {
     Joystick* joystick = new Joystick();
     joystick->initialize(style, properties);
-    joystick->_consumeInputEvents = false;
-
     return joystick;
 }
 
@@ -46,20 +48,62 @@ void Joystick::initialize(Theme::Style* style, Properties* properties)
     }
     _radius = properties->getFloat("radius");
 
-    if (properties->exists("absolute"))
+    if (properties->exists("relative"))
+    {
+        setRelative(properties->getBool("relative"));
+    }
+    else
     {
-        setAbsolute(properties->getBool("absolute"));
+        setRelative(false);
     }
 
-    Vector4 v;
-    if (properties->getVector4("region", &v))
+    Theme::ThemeImage* inner = getImage("inner", _state);
+    if (inner)
     {
-        _absolute = false;
-        _region = _bounds;
-        _bounds.x = v.x;
-        _bounds.y = v.y;
-        _bounds.width = v.z;
-        _bounds.height = v.w;
+        _innerSize = new Vector2();
+        Vector2 innerSize;
+        if (properties->getVector2("innerRegion", &innerSize))
+        {
+            _innerSize->set(innerSize.x, innerSize.y);
+        }
+        else
+        {
+            const Rectangle& rect = inner->getRegion();
+            _innerSize->set(rect.width, rect.height);
+        }
+    }
+
+    Theme::ThemeImage* outer = getImage("outer", _state);
+    if (outer)
+    {
+        _outerSize = new Vector2();
+        Vector2 outerSize;
+        if (properties->getVector2("outerRegion", &outerSize))
+        {
+            _outerSize->set(outerSize.x, outerSize.y);
+        }
+        else
+        {
+            const Rectangle& rect = outer->getRegion();
+            _outerSize->set(rect.width, rect.height);
+        }
+        _screenRegion.width = _outerSize->x;
+        _screenRegion.height = _outerSize->y;
+    }
+    else
+    {
+        if (inner)
+        {
+            const Rectangle& rect = inner->getRegion();
+            float radiusx2 = _radius * 2;;
+            _screenRegion.width = rect.width;
+            _screenRegion.height = rect.height;
+        }
+        else
+        {
+            _screenRegion.width = _radius * 2.0f;
+            _screenRegion.height = _screenRegion.width;
+        }
     }
 }
 
@@ -84,74 +128,76 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
             float dx = 0.0f;
             float dy = 0.0f;
 
-            if (_absolute)
+            _contactIndex = (int) contactIndex;
+            notifyListeners(Listener::PRESS);
+
+            // Get the displacement of the touch from the centre.
+            if (!_relative)
             {
-                dx = x - _bounds.width * 0.5f;
-                dy = _bounds.height * 0.5f - y;
+                dx = x - _screenRegion.width * 0.5f;
+                dy = _screenRegion.height * 0.5f - y;
             }
             else
             {
-                _region.x = x + _bounds.x - _region.width * 0.5f;
-                _region.y = y + _bounds.y - _region.height * 0.5f;
+                _screenRegion.x = x + _bounds.x - _screenRegion.width * 0.5f;
+                _screenRegion.y = y + _bounds.y - _screenRegion.height * 0.5f;
             }
 
-            if ((dx >= -_radius && dx <= _radius) && (dy >= -_radius && dy <= _radius))
-            {
-                _contactIndex = (int) contactIndex;
-
-                notifyListeners(Listener::PRESS);
-
-                _displacement.set(dx, dy);
-                
-                Vector2 value(dx, dy);
-                if (_value != value)
-                {
-                    _value.set(value);
-                    _dirty = true;
-                    notifyListeners(Listener::VALUE_CHANGED);
-                }
-
-                _state = ACTIVE;
+            _displacement.set(dx, dy);
 
-                return _consumeInputEvents;
+            // If the displacement is greater than the radius, then cap the displacement to the
+            // radius.
+            
+            Vector2 value;
+            if ((fabs(_displacement.x) > _radius) || (fabs(_displacement.y) > _radius))
+            {
+                _displacement.normalize();
+                value.set(_displacement);
+                _displacement.scale(_radius);
             }
             else
             {
-                _state = NORMAL;
+                value.set(_displacement);
+                value.normalize();
             }
-            break;
+
+            // Check if the value has changed. Won't this always be the case?
+            if (_value != value)
+            {
+                _value.set(value);
+                _dirty = true;
+                notifyListeners(Listener::VALUE_CHANGED);
+            }
+
+            _state = ACTIVE;
+            return _consumeInputEvents;
         }
         case Touch::TOUCH_MOVE:
         {
-            float dx = x - ((!_absolute) ? _region.x - _bounds.x : 0.0f) - _region.width * 0.5f;
-            float dy = -(y - ((!_absolute) ? _region.y - _bounds.y : 0.0f) - _region.height * 0.5f);
-            if (((dx * dx) + (dy * dy)) <= (_radius * _radius))
+            float dx = x - ((_relative) ? _screenRegion.x - _bounds.x : 0.0f) - _screenRegion.width * 0.5f;
+            float dy = -(y - ((_relative) ? _screenRegion.y - _bounds.y : 0.0f) - _screenRegion.height * 0.5f);
+            
+            _displacement.set(dx, dy);
+            
+            Vector2 value;
+            if (fabs(_displacement.x) > _radius || fabs(_displacement.y) > _radius)
             {
-                GP_ASSERT(_radius);
-                Vector2 value(dx, dy);
-                value.scale(1.0f / _radius);
-                if (_value != value)
-                {
-                    _value.set(value);
-                    _dirty = true;
-                    notifyListeners(Listener::VALUE_CHANGED);
-                }
+                _displacement.normalize();
+                value.set(_displacement);
+                _displacement.scale(_radius);
             }
             else
             {
-                Vector2 value(dx, dy);
+                value.set(_displacement);
                 value.normalize();
-                value.scale(_radius);
-                value.normalize();
-                if (_value != value)
-                {
-                    _value.set(value);
-                    _dirty = true;
-                    notifyListeners(Listener::VALUE_CHANGED);
-                }
             }
 
-            _displacement.set(dx, dy);
+            if (_value != value)
+            {
+                _value.set(value);
+                _dirty = true;
+                notifyListeners(Listener::VALUE_CHANGED);
+            }
 
             return _consumeInputEvents;
         }
@@ -163,8 +209,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
 
             // Reset displacement and direction vectors.
             _displacement.set(0.0f, 0.0f);
-
-            Vector2 value(0.0f, 0.0f);
+            Vector2 value(_displacement);
             if (_value != value)
             {
                 _value.set(value);
@@ -181,65 +226,49 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
     return false;
 }
 
-void Joystick::update(const Control* container, const Vector2& offset)
-{
-    Control::update(container, offset);
-
-    _clearBounds.x -= _radius;
-    _clearBounds.y -= _radius;
-    float radiusx2 = _radius + _radius;
-    _clearBounds.width += radiusx2;
-    _clearBounds.height += radiusx2;
-}
-
 void Joystick::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
 {
     GP_ASSERT(spriteBatch);
     spriteBatch->start();
 
     // If the joystick is not absolute, then only draw if it is active.
-    if (_absolute || (!_absolute && _state == ACTIVE))
+    if (!_relative || (_relative && _state == ACTIVE))
     {
-        if (_absolute)
-            _region = _viewportClipBounds;
+        if (!_relative)
+        {
+            _screenRegion.x = _viewportClipBounds.x + (_viewportClipBounds.width - _screenRegion.width) / 2.0f;
+            _screenRegion.y = _viewportClipBounds.y + (_viewportClipBounds.height - _screenRegion.height) / 2.0f;
+        }
 
         // Draw the outer image.
         Theme::ThemeImage* outer = getImage("outer", _state);
         if (outer)
         {
-            // Get the uvs and color and draw.
             const Theme::UVs& uvs = outer->getUVs();
             const Vector4& color = outer->getColor();
-            spriteBatch->draw(_region.x, _region.y, _region.width, _region.height, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color);
+            if (_relative)
+                spriteBatch->draw(_screenRegion.x, _screenRegion.y, _outerSize->x, _outerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color);
+            else
+                spriteBatch->draw(_screenRegion.x, _screenRegion.y, _outerSize->x, _outerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
         }
 
         // Draw the inner image.
         Theme::ThemeImage* inner = getImage("inner", _state);
         if (inner)
         {
-            Rectangle region = _region;
-
+            Vector2 position(_screenRegion.x, _screenRegion.y);
+            
             // Adjust position to reflect displacement.
-            if (((_displacement.x * _displacement.x) + (_displacement.y * _displacement.y)) <= (_radius * _radius))
-            {
-                region.x += _displacement.x;
-                region.y += -_displacement.y;
-            }
-            else
-            {
-                // Find the point on the joystick's circular bound where the
-                // vector intersects. This is the position of the inner image.
-                Vector2 delta = Vector2(_displacement.x, -_displacement.y);
-                delta.normalize();
-                delta.scale(_radius);
-                region.x += delta.x;
-                region.y += delta.y;
-            }
-        
+            position.x += _displacement.x;
+            position.y += -_displacement.y;
+            
             // Get the uvs and color and draw.
             const Theme::UVs& uvs = inner->getUVs();
             const Vector4& color = inner->getColor();
-            spriteBatch->draw(region.x, region.y, _region.width, _region.height, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color);
+            if (_relative)
+                spriteBatch->draw(position.x, position.y, _innerSize->x, _innerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color);
+            else
+                spriteBatch->draw(position.x, position.y, _innerSize->x, _innerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
         }
     }
     spriteBatch->finish();
@@ -250,6 +279,4 @@ const char* Joystick::getType() const
     return "joystick";
 }
 
-
-
 }

+ 37 - 29
gameplay/src/Joystick.h

@@ -47,39 +47,54 @@ public:
     inline const Vector2& getValue() const;
 
     /**
-     * Sets the region within which the joystick will be spontaneously created on a user's touch.
+     * Sets the image size of the inner region of the joystick. Does not do anything if there is no
+     * inner image region defined.
      * 
-     * Note: This does not actually enable spontaneous joystick creation on touch input.
-     * To enable (or disable) absolute position explicitly, use setAbsolute(bool).
+     * @param region The size of the inner region of the joystick. (x, y) == (width, height)
+     */
+    inline void setInnerRegionSize(const Vector2& size);
+
+    /**
+     * Gets the image size of the inner region of the joystick. Returns (0,0) if there is no inner image
+     * region defined.
      * 
-     * @param region The region to use.
+     * @return The image size of the inner region of the joystick. (x, y) == (width, height)
      */
-    inline void setRegion(const Rectangle& region);
+    inline const Vector2& getInnerRegionSize() const;
 
     /**
-     * Gets the region within which the joystick will be spontaneously created on a user's touch.
+     * Sets the image size of the outer region of the joystick. Does not do anything if there is no
+     * outer image region defined.
      * 
-     * Note: just because the returned region is not empty does not mean that it is necessarily
-     * being used. If absolute positioning is not enabled, then it will be used (to check if
-     * absolute positioning is enabled, call isAbsolute()).
+     * @param region The size of the outer region of the joystick. (x, y) == (width, height)
+     */
+    inline void setOuterRegionSize(const Vector2& size);
+
+    /**
+     * Gets the image size of the outer region of the joystick. Returns (0,0) if there is no outer image
+     * region defined.
      * 
-     * @return The region within which the joystick will be spontaneously created on a user's touch.
+     * @return The image size of the outer region of the joystick. (x, y) == (width, height)
      */
-    inline const Rectangle& getRegion() const;
+    inline const Vector2& getOuterRegionSize() const;
 
     /**
-     * Sets whether absolute positioning is enabled or not.
+     * Sets whether relative positioning is enabled or not.
      * 
-     * @param absolute Whether absolute positioning should be enabled or not.
+     * Note: The default behavior is absolute positioning, and not relative.
+     *
+     * @param relative Whether relative positioning should be enabled or not.
      */
-    inline void setAbsolute(bool absolute);
+    inline void setRelative(bool relative);
 
     /**
      * Retrieves whether absolute positioning is enabled or not.
      * 
-     * @return <code>true</code> if absolute positioning is enabled; <code>false</code> otherwise.
+     * Note: The default behavior is absolute positioning, and not relative.
+     *
+     * @return <code>true</code> if relative positioning is enabled; <code>false</code> otherwise.
      */
-    inline bool isAbsolute() const;
+    inline bool isRelative() const;
 
     /**
      * @see Control::getType
@@ -127,15 +142,6 @@ protected:
      */
     bool touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
 
-    /**
-     * Called when a control's properties change.  Updates this control's internal rendering
-     * properties, such as its text viewport.
-     *
-     * @param container This control's parent container.
-     * @param offset Positioning offset to add to the control's position.
-     */
-    void update(const Control* container, const Vector2& offset);
-
     /**
      * Draw the images associated with this control.
      *
@@ -151,11 +157,13 @@ private:
      */
     Joystick(const Joystick& copy);
 
-    float _radius;
-    bool _absolute;
-    Vector2 _displacement;
+    float _radius; 
+    bool _relative;
+    Rectangle _screenRegion;
     Vector2 _value;
-    Rectangle _region;
+    Vector2 _displacement;
+    Vector2* _innerSize;
+    Vector2* _outerSize;
 };
 
 }

+ 25 - 10
gameplay/src/Joystick.inl

@@ -8,27 +8,42 @@ inline const Vector2& Joystick::getValue() const
     return _value;
 }
 
-inline void Joystick::setRegion(const Rectangle& region)
+inline void Joystick::setInnerRegionSize(const Vector2& size)
 {
-    if (_region.isEmpty())
-        _region = _bounds;
+    if (_innerSize)
+        _innerSize->set(size);
+}
 
-    _bounds = region;
+inline const Vector2& Joystick::getInnerRegionSize() const
+{
+    if (_innerSize)
+        return *_innerSize;
+    else
+        return Vector2::zero();
+}
+
+inline void Joystick::setOuterRegionSize(const Vector2& size)
+{
+    if (_outerSize)
+        _outerSize->set(size);
 }
 
-inline const Rectangle& Joystick::getRegion() const
+inline const Vector2& Joystick::getOuterRegionSize() const
 {
-    return _bounds;
+    if (_outerSize)
+        return *_outerSize;
+    else
+        return Vector2::zero();
 }
 
-inline void Joystick::setAbsolute(bool absolute)
+inline void Joystick::setRelative(bool relative)
 {
-    _absolute = absolute;
+    _relative = relative;
 }
 
-inline bool Joystick::isAbsolute() const
+inline bool Joystick::isRelative() const
 {
-    return _absolute;
+    return _relative;
 }
 
 }

+ 1 - 1
gameplay/src/Properties.cpp

@@ -574,7 +574,7 @@ Properties* Properties::getNamespace(const char* id, bool searchNames) const
         }
         
         // Search recursively.
-        ret = ret->getNamespace(id);
+        ret = ret->getNamespace(id, searchNames);
         if (ret != NULL)
         {
             return ret;

+ 167 - 81
gameplay/src/lua/lua_Joystick.cpp

@@ -55,11 +55,12 @@ void luaRegister_Joystick()
         {"getImageColor", lua_Joystick_getImageColor},
         {"getImageRegion", lua_Joystick_getImageRegion},
         {"getImageUVs", lua_Joystick_getImageUVs},
+        {"getInnerRegionSize", lua_Joystick_getInnerRegionSize},
         {"getMargin", lua_Joystick_getMargin},
         {"getOpacity", lua_Joystick_getOpacity},
+        {"getOuterRegionSize", lua_Joystick_getOuterRegionSize},
         {"getPadding", lua_Joystick_getPadding},
         {"getRefCount", lua_Joystick_getRefCount},
-        {"getRegion", lua_Joystick_getRegion},
         {"getSkinColor", lua_Joystick_getSkinColor},
         {"getSkinRegion", lua_Joystick_getSkinRegion},
         {"getState", lua_Joystick_getState},
@@ -73,12 +74,11 @@ void luaRegister_Joystick()
         {"getX", lua_Joystick_getX},
         {"getY", lua_Joystick_getY},
         {"getZIndex", lua_Joystick_getZIndex},
-        {"isAbsolute", lua_Joystick_isAbsolute},
         {"isContainer", lua_Joystick_isContainer},
         {"isEnabled", lua_Joystick_isEnabled},
+        {"isRelative", lua_Joystick_isRelative},
         {"release", lua_Joystick_release},
         {"removeCallback", lua_Joystick_removeCallback},
-        {"setAbsolute", lua_Joystick_setAbsolute},
         {"setAlignment", lua_Joystick_setAlignment},
         {"setAnimationPropertyValue", lua_Joystick_setAnimationPropertyValue},
         {"setAutoHeight", lua_Joystick_setAutoHeight},
@@ -93,11 +93,13 @@ void luaRegister_Joystick()
         {"setFontSize", lua_Joystick_setFontSize},
         {"setImageColor", lua_Joystick_setImageColor},
         {"setImageRegion", lua_Joystick_setImageRegion},
+        {"setInnerRegionSize", lua_Joystick_setInnerRegionSize},
         {"setMargin", lua_Joystick_setMargin},
         {"setOpacity", lua_Joystick_setOpacity},
+        {"setOuterRegionSize", lua_Joystick_setOuterRegionSize},
         {"setPadding", lua_Joystick_setPadding},
         {"setPosition", lua_Joystick_setPosition},
-        {"setRegion", lua_Joystick_setRegion},
+        {"setRelative", lua_Joystick_setRelative},
         {"setSize", lua_Joystick_setSize},
         {"setSkinColor", lua_Joystick_setSkinColor},
         {"setSkinRegion", lua_Joystick_setSkinRegion},
@@ -1832,6 +1834,52 @@ int lua_Joystick_getImageUVs(lua_State* state)
     return 0;
 }
 
+int lua_Joystick_getInnerRegionSize(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_TUSERDATA))
+            {
+                Joystick* instance = getInstance(state);
+                void* returnPtr = (void*)&(instance->getInnerRegionSize());
+                if (returnPtr)
+                {
+                    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Vector2");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Joystick_getInnerRegionSize - 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_Joystick_getMargin(lua_State* state)
 {
     // Get the number of parameters.
@@ -1938,7 +1986,7 @@ int lua_Joystick_getOpacity(lua_State* state)
     return 0;
 }
 
-int lua_Joystick_getPadding(lua_State* state)
+int lua_Joystick_getOuterRegionSize(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -1951,13 +1999,13 @@ int lua_Joystick_getPadding(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 Joystick* instance = getInstance(state);
-                void* returnPtr = (void*)&(instance->getPadding());
+                void* returnPtr = (void*)&(instance->getOuterRegionSize());
                 if (returnPtr)
                 {
                     ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
                     object->instance = returnPtr;
                     object->owns = false;
-                    luaL_getmetatable(state, "ThemeSideRegions");
+                    luaL_getmetatable(state, "Vector2");
                     lua_setmetatable(state, -2);
                 }
                 else
@@ -1969,7 +2017,7 @@ int lua_Joystick_getPadding(lua_State* state)
             }
             else
             {
-                lua_pushstring(state, "lua_Joystick_getPadding - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Joystick_getOuterRegionSize - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
@@ -1984,7 +2032,7 @@ int lua_Joystick_getPadding(lua_State* state)
     return 0;
 }
 
-int lua_Joystick_getRefCount(lua_State* state)
+int lua_Joystick_getPadding(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -1997,16 +2045,25 @@ int lua_Joystick_getRefCount(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 Joystick* instance = getInstance(state);
-                unsigned int result = instance->getRefCount();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
+                void* returnPtr = (void*)&(instance->getPadding());
+                if (returnPtr)
+                {
+                    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "ThemeSideRegions");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
 
                 return 1;
             }
             else
             {
-                lua_pushstring(state, "lua_Joystick_getRefCount - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Joystick_getPadding - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
@@ -2021,7 +2078,7 @@ int lua_Joystick_getRefCount(lua_State* state)
     return 0;
 }
 
-int lua_Joystick_getRegion(lua_State* state)
+int lua_Joystick_getRefCount(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -2034,25 +2091,16 @@ int lua_Joystick_getRegion(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 Joystick* instance = getInstance(state);
-                void* returnPtr = (void*)&(instance->getRegion());
-                if (returnPtr)
-                {
-                    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Rectangle");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
+                unsigned int result = instance->getRefCount();
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
 
                 return 1;
             }
             else
             {
-                lua_pushstring(state, "lua_Joystick_getRegion - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Joystick_getRefCount - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
@@ -2735,7 +2783,7 @@ int lua_Joystick_getZIndex(lua_State* state)
     return 0;
 }
 
-int lua_Joystick_isAbsolute(lua_State* state)
+int lua_Joystick_isContainer(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -2748,7 +2796,7 @@ int lua_Joystick_isAbsolute(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 Joystick* instance = getInstance(state);
-                bool result = instance->isAbsolute();
+                bool result = instance->isContainer();
 
                 // Push the return value onto the stack.
                 lua_pushboolean(state, result);
@@ -2757,7 +2805,7 @@ int lua_Joystick_isAbsolute(lua_State* state)
             }
             else
             {
-                lua_pushstring(state, "lua_Joystick_isAbsolute - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Joystick_isContainer - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
@@ -2772,7 +2820,7 @@ int lua_Joystick_isAbsolute(lua_State* state)
     return 0;
 }
 
-int lua_Joystick_isContainer(lua_State* state)
+int lua_Joystick_isEnabled(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -2785,7 +2833,7 @@ int lua_Joystick_isContainer(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 Joystick* instance = getInstance(state);
-                bool result = instance->isContainer();
+                bool result = instance->isEnabled();
 
                 // Push the return value onto the stack.
                 lua_pushboolean(state, result);
@@ -2794,7 +2842,7 @@ int lua_Joystick_isContainer(lua_State* state)
             }
             else
             {
-                lua_pushstring(state, "lua_Joystick_isContainer - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Joystick_isEnabled - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
@@ -2809,7 +2857,7 @@ int lua_Joystick_isContainer(lua_State* state)
     return 0;
 }
 
-int lua_Joystick_isEnabled(lua_State* state)
+int lua_Joystick_isRelative(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -2822,7 +2870,7 @@ int lua_Joystick_isEnabled(lua_State* state)
             if ((lua_type(state, 1) == LUA_TUSERDATA))
             {
                 Joystick* instance = getInstance(state);
-                bool result = instance->isEnabled();
+                bool result = instance->isRelative();
 
                 // Push the return value onto the stack.
                 lua_pushboolean(state, result);
@@ -2831,7 +2879,7 @@ int lua_Joystick_isEnabled(lua_State* state)
             }
             else
             {
-                lua_pushstring(state, "lua_Joystick_isEnabled - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Joystick_isRelative - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;
@@ -2922,44 +2970,6 @@ int lua_Joystick_removeCallback(lua_State* state)
     return 0;
 }
 
-int lua_Joystick_setAbsolute(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_TBOOLEAN)
-            {
-                // Get parameter 1 off the stack.
-                bool param1 = ScriptUtil::luaCheckBool(state, 2);
-
-                Joystick* instance = getInstance(state);
-                instance->setAbsolute(param1);
-                
-                return 0;
-            }
-            else
-            {
-                lua_pushstring(state, "lua_Joystick_setAbsolute - 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_Joystick_setAlignment(lua_State* state)
 {
     // Get the number of parameters.
@@ -3692,6 +3702,44 @@ int lua_Joystick_setImageRegion(lua_State* state)
     return 0;
 }
 
+int lua_Joystick_setInnerRegionSize(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_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                Vector2* param1 = ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true);
+
+                Joystick* instance = getInstance(state);
+                instance->setInnerRegionSize(*param1);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Joystick_setInnerRegionSize - 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_Joystick_setMargin(lua_State* state)
 {
     // Get the number of parameters.
@@ -3804,6 +3852,44 @@ int lua_Joystick_setOpacity(lua_State* state)
     return 0;
 }
 
+int lua_Joystick_setOuterRegionSize(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_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                Vector2* param1 = ScriptUtil::getObjectPointer<Vector2>(2, "Vector2", true);
+
+                Joystick* instance = getInstance(state);
+                instance->setOuterRegionSize(*param1);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Joystick_setOuterRegionSize - 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_Joystick_setPadding(lua_State* state)
 {
     // Get the number of parameters.
@@ -3896,7 +3982,7 @@ int lua_Joystick_setPosition(lua_State* state)
     return 0;
 }
 
-int lua_Joystick_setRegion(lua_State* state)
+int lua_Joystick_setRelative(lua_State* state)
 {
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
@@ -3907,19 +3993,19 @@ int lua_Joystick_setRegion(lua_State* state)
         case 2:
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
+                lua_type(state, 2) == LUA_TBOOLEAN)
             {
                 // Get parameter 1 off the stack.
-                Rectangle* param1 = ScriptUtil::getObjectPointer<Rectangle>(2, "Rectangle", true);
+                bool param1 = ScriptUtil::luaCheckBool(state, 2);
 
                 Joystick* instance = getInstance(state);
-                instance->setRegion(*param1);
+                instance->setRelative(param1);
                 
                 return 0;
             }
             else
             {
-                lua_pushstring(state, "lua_Joystick_setRegion - Failed to match the given parameters to a valid function signature.");
+                lua_pushstring(state, "lua_Joystick_setRelative - Failed to match the given parameters to a valid function signature.");
                 lua_error(state);
             }
             break;

+ 6 - 4
gameplay/src/lua/lua_Joystick.h

@@ -37,11 +37,12 @@ int lua_Joystick_getId(lua_State* state);
 int lua_Joystick_getImageColor(lua_State* state);
 int lua_Joystick_getImageRegion(lua_State* state);
 int lua_Joystick_getImageUVs(lua_State* state);
+int lua_Joystick_getInnerRegionSize(lua_State* state);
 int lua_Joystick_getMargin(lua_State* state);
 int lua_Joystick_getOpacity(lua_State* state);
+int lua_Joystick_getOuterRegionSize(lua_State* state);
 int lua_Joystick_getPadding(lua_State* state);
 int lua_Joystick_getRefCount(lua_State* state);
-int lua_Joystick_getRegion(lua_State* state);
 int lua_Joystick_getSkinColor(lua_State* state);
 int lua_Joystick_getSkinRegion(lua_State* state);
 int lua_Joystick_getState(lua_State* state);
@@ -55,12 +56,11 @@ int lua_Joystick_getWidth(lua_State* state);
 int lua_Joystick_getX(lua_State* state);
 int lua_Joystick_getY(lua_State* state);
 int lua_Joystick_getZIndex(lua_State* state);
-int lua_Joystick_isAbsolute(lua_State* state);
 int lua_Joystick_isContainer(lua_State* state);
 int lua_Joystick_isEnabled(lua_State* state);
+int lua_Joystick_isRelative(lua_State* state);
 int lua_Joystick_release(lua_State* state);
 int lua_Joystick_removeCallback(lua_State* state);
-int lua_Joystick_setAbsolute(lua_State* state);
 int lua_Joystick_setAlignment(lua_State* state);
 int lua_Joystick_setAnimationPropertyValue(lua_State* state);
 int lua_Joystick_setAutoHeight(lua_State* state);
@@ -75,11 +75,13 @@ int lua_Joystick_setFont(lua_State* state);
 int lua_Joystick_setFontSize(lua_State* state);
 int lua_Joystick_setImageColor(lua_State* state);
 int lua_Joystick_setImageRegion(lua_State* state);
+int lua_Joystick_setInnerRegionSize(lua_State* state);
 int lua_Joystick_setMargin(lua_State* state);
 int lua_Joystick_setOpacity(lua_State* state);
+int lua_Joystick_setOuterRegionSize(lua_State* state);
 int lua_Joystick_setPadding(lua_State* state);
 int lua_Joystick_setPosition(lua_State* state);
-int lua_Joystick_setRegion(lua_State* state);
+int lua_Joystick_setRelative(lua_State* state);
 int lua_Joystick_setSize(lua_State* state);
 int lua_Joystick_setSkinColor(lua_State* state);
 int lua_Joystick_setSkinRegion(lua_State* state);