فهرست منبع

Merge pull request #1309 from sgrenier/next

UI and Font improvements
Steve Grenier 12 سال پیش
والد
کامیت
2ccc5b5142
100فایلهای تغییر یافته به همراه11466 افزوده شده و 9619 حذف شده
  1. 0 17
      gameplay/res/shaders/form.frag
  2. 0 19
      gameplay/res/shaders/form.vert
  3. 3 0
      gameplay/src/Base.h
  4. 17 12
      gameplay/src/Button.cpp
  5. 11 6
      gameplay/src/Button.h
  6. 26 19
      gameplay/src/CheckBox.cpp
  7. 14 12
      gameplay/src/CheckBox.h
  8. 123 129
      gameplay/src/Container.cpp
  9. 30 32
      gameplay/src/Container.h
  10. 290 276
      gameplay/src/Control.cpp
  11. 82 30
      gameplay/src/Control.h
  12. 28 20
      gameplay/src/ControlFactory.cpp
  13. 22 22
      gameplay/src/ControlFactory.h
  14. 7 0
      gameplay/src/Font.cpp
  15. 254 303
      gameplay/src/Form.cpp
  16. 57 32
      gameplay/src/Form.h
  17. 511 508
      gameplay/src/Game.cpp
  18. 32 40
      gameplay/src/ImageControl.cpp
  19. 12 9
      gameplay/src/ImageControl.h
  20. 101 88
      gameplay/src/Joystick.cpp
  21. 191 194
      gameplay/src/Joystick.h
  22. 24 29
      gameplay/src/Label.cpp
  23. 152 153
      gameplay/src/Label.h
  24. 9 2
      gameplay/src/MeshBatch.cpp
  25. 6 0
      gameplay/src/MeshBatch.h
  26. 1660 1655
      gameplay/src/PlatformBlackBerry.cpp
  27. 8 0
      gameplay/src/PlatformLinux.cpp
  28. 5 0
      gameplay/src/PlatformMacOSX.mm
  29. 1356 1351
      gameplay/src/PlatformWindows.cpp
  30. 5 0
      gameplay/src/PlatformiOS.mm
  31. 2 2
      gameplay/src/Properties.cpp
  32. 35 27
      gameplay/src/RadioButton.cpp
  33. 13 11
      gameplay/src/RadioButton.h
  34. 21 0
      gameplay/src/Rectangle.cpp
  35. 11 0
      gameplay/src/Rectangle.h
  36. 55 67
      gameplay/src/Slider.cpp
  37. 15 46
      gameplay/src/Slider.h
  38. 14 1
      gameplay/src/SpriteBatch.cpp
  39. 24 0
      gameplay/src/SpriteBatch.h
  40. 40 32
      gameplay/src/TextBox.cpp
  41. 16 22
      gameplay/src/TextBox.h
  42. 78 28
      gameplay/src/Theme.cpp
  43. 24 5
      gameplay/src/Theme.h
  44. 1 0
      gameplay/src/ThemeStyle.cpp
  45. 112 1
      gameplay/src/lua/lua_Button.cpp
  46. 2 0
      gameplay/src/lua/lua_Button.h
  47. 112 1
      gameplay/src/lua/lua_CheckBox.cpp
  48. 2 0
      gameplay/src/lua/lua_CheckBox.h
  49. 190 1
      gameplay/src/lua/lua_Container.cpp
  50. 4 0
      gameplay/src/lua/lua_Container.h
  51. 83 0
      gameplay/src/lua/lua_Control.cpp
  52. 2 0
      gameplay/src/lua/lua_Control.h
  53. 1 0
      gameplay/src/lua/lua_ControlListener.cpp
  54. 185 0
      gameplay/src/lua/lua_Form.cpp
  55. 5 0
      gameplay/src/lua/lua_Form.h
  56. 2508 2507
      gameplay/src/lua/lua_Game.cpp
  57. 1062 1020
      gameplay/src/lua/lua_Global.cpp
  58. 67 64
      gameplay/src/lua/lua_Global.h
  59. 112 1
      gameplay/src/lua/lua_ImageControl.cpp
  60. 2 0
      gameplay/src/lua/lua_ImageControl.h
  61. 112 1
      gameplay/src/lua/lua_Joystick.cpp
  62. 2 0
      gameplay/src/lua/lua_Joystick.h
  63. 112 1
      gameplay/src/lua/lua_Label.cpp
  64. 2 0
      gameplay/src/lua/lua_Label.h
  65. 36 0
      gameplay/src/lua/lua_MeshBatch.cpp
  66. 1 0
      gameplay/src/lua/lua_MeshBatch.h
  67. 112 1
      gameplay/src/lua/lua_RadioButton.cpp
  68. 2 0
      gameplay/src/lua/lua_RadioButton.h
  69. 64 0
      gameplay/src/lua/lua_Rectangle.cpp
  70. 1 0
      gameplay/src/lua/lua_Rectangle.h
  71. 112 1
      gameplay/src/lua/lua_Slider.cpp
  72. 2 0
      gameplay/src/lua/lua_Slider.h
  73. 97 0
      gameplay/src/lua/lua_SpriteBatch.cpp
  74. 1 0
      gameplay/src/lua/lua_SpriteBatch.h
  75. 112 54
      gameplay/src/lua/lua_TextBox.cpp
  76. 2 1
      gameplay/src/lua/lua_TextBox.h
  77. 84 0
      gameplay/src/lua/lua_Theme.cpp
  78. 2 0
      gameplay/src/lua/lua_Theme.h
  79. 1 0
      gameplay/src/lua/lua_ThemeSideRegions.cpp
  80. 1 0
      gameplay/src/lua/lua_ThemeThemeImage.cpp
  81. 1 0
      gameplay/src/lua/lua_ThemeUVs.cpp
  82. 5 0
      samples/browser/game.config
  83. BIN
      samples/browser/res/common/arial.gpb
  84. 414 393
      samples/browser/res/common/default.theme
  85. 12 23
      samples/browser/res/common/forms/formBasicControls.form
  86. 1 3
      samples/browser/res/common/forms/formFlowLayout.form
  87. 1 3
      samples/browser/res/common/forms/formScrolling.form
  88. 5 6
      samples/browser/res/common/forms/formSelect.form
  89. 1 3
      samples/browser/res/common/forms/formVerticalLayout.form
  90. 4 3
      samples/browser/res/common/forms/formZOrder.form
  91. 8 0
      samples/browser/res/common/gamepad.theme
  92. 1 1
      samples/browser/res/common/inputs.form
  93. 8 10
      samples/browser/res/common/terrain/terrain.form
  94. BIN
      samples/browser/res/common/title.gpb
  95. 6 6
      samples/browser/src/FormsSample.cpp
  96. 3 3
      samples/browser/src/FormsSample.h
  97. 1 1
      samples/browser/src/InputSample.cpp
  98. 1 1
      samples/browser/src/LightSample.cpp
  99. 301 309
      samples/browser/src/SamplesGame.cpp
  100. 1 1
      samples/browser/src/TextSample.cpp

+ 0 - 17
gameplay/res/shaders/form.frag

@@ -1,17 +0,0 @@
-#ifdef OPENGL_ES
-precision highp float;
-#endif
-
-///////////////////////////////////////////////////////////
-// Uniforms
-uniform sampler2D u_texture;
-
-///////////////////////////////////////////////////////////
-// Varyings
-varying vec2 v_texCoord;
-
-
-void main()
-{
-    gl_FragColor = texture2D(u_texture, v_texCoord);
-}

+ 0 - 19
gameplay/res/shaders/form.vert

@@ -1,19 +0,0 @@
-///////////////////////////////////////////////////////////
-// Attributes
-attribute vec3 a_position;
-attribute vec2 a_texCoord;
-
-///////////////////////////////////////////////////////////
-// Uniforms
-uniform mat4 u_worldViewProjectionMatrix;
-
-///////////////////////////////////////////////////////////
-// Varyings
-varying vec2 v_texCoord;
-
-
-void main()
-{
-    gl_Position = u_worldViewProjectionMatrix * vec4(a_position, 1);
-    v_texCoord = a_texCoord;
-}

+ 3 - 0
gameplay/src/Base.h

@@ -59,6 +59,9 @@ namespace gameplay
  * @script{ignore}
  * @script{ignore}
  */
  */
 extern void print(const char* format, ...);
 extern void print(const char* format, ...);
+
+// Define a platform-independent case-insensitive ASCII string comparison function.
+extern int strcmpnocase(const char* s1, const char* s2);
 }
 }
 
 
 // Current function macro.
 // Current function macro.

+ 17 - 12
gameplay/src/Button.cpp

@@ -17,27 +17,32 @@ Button::~Button()
 Button* Button::create(const char* id, Theme::Style* style)
 Button* Button::create(const char* id, Theme::Style* style)
 {
 {
     Button* button = new Button();
     Button* button = new Button();
-
-    button->_id = id;
-    button->_style = style;
-
+    button->_id = id ? id : "";
+    button->initialize("Button", style, NULL);
     return button;
     return button;
 }
 }
 
 
 Control* Button::create(Theme::Style* style, Properties* properties)
 Control* Button::create(Theme::Style* style, Properties* properties)
 {
 {
     Button* button = new Button();
     Button* button = new Button();
-    button->initialize(style, properties);
+	button->initialize("Button", style, properties);
+    return button;
+}
 
 
-    // Different types of data bindings can be named differently in a button namespace.
-    // Gamepad button mappings have the name "mapping" and correspond to Gamepad::ButtonMapping enums.
-    const char* mapping = properties->getString("mapping");
-    if (mapping)
+void Button::initialize(const char* typeName, Theme::Style* style, Properties* properties)
+{
+    Label::initialize(typeName, style, properties);
+
+    if (properties)
     {
     {
-        button->_dataBinding = Gamepad::getButtonMappingFromString(mapping);
+        // Different types of data bindings can be named differently in a button namespace.
+        // Gamepad button mappings have the name "mapping" and correspond to Gamepad::ButtonMapping enums.
+        const char* mapping = properties->getString("mapping");
+        if (mapping)
+        {
+            _dataBinding = Gamepad::getButtonMappingFromString(mapping);
+        }
     }
     }
-
-    return button;
 }
 }
 
 
 const char* Button::getType() const
 const char* Button::getType() const

+ 11 - 6
gameplay/src/Button.h

@@ -40,15 +40,15 @@ class Button : public Label
 public:
 public:
 
 
     /**
     /**
-     * Create a new button control.
+     * Creates a new Button.
      *
      *
-     * @param id The control's ID.
-     * @param style The control's style.
+     * @param id The button ID.
+     * @param style The button style (optional).
      *
      *
      * @return The new button.
      * @return The new button.
      * @script{create}
      * @script{create}
      */
      */
-    static Button* create(const char* id, Theme::Style* style);
+    static Button* create(const char* id, Theme::Style* style = NULL);
 
 
 protected:
 protected:
 
 
@@ -66,11 +66,16 @@ protected:
      * Create a button with a given style and properties.
      * Create a button with a given style and properties.
      *
      *
      * @param style The style to apply to this button.
      * @param style The style to apply to this button.
-     * @param properties The properties to set on this button.
+     * @param properties A properties object containing a definition of the button (optional).
      *
      *
      * @return The new button.
      * @return The new button.
      */
      */
-    static Control* create(Theme::Style* style, Properties* properties);
+    static Control* create(Theme::Style* style, Properties* properties = NULL);
+
+    /**
+     * @see Control::initialize
+     */
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
 
 
     /**
     /**
      * @see Control::getType
      * @see Control::getType

+ 26 - 19
gameplay/src/CheckBox.cpp

@@ -16,26 +16,28 @@ CheckBox::~CheckBox()
 
 
 CheckBox* CheckBox::create(const char* id, Theme::Style* style)
 CheckBox* CheckBox::create(const char* id, Theme::Style* style)
 {
 {
-    GP_ASSERT(style);
-
-    CheckBox* checkBox = new CheckBox();
-    if (id)
-        checkBox->_id = id;
-    checkBox->setStyle(style);
-
-    return checkBox;
+    CheckBox* cb = new CheckBox();
+    cb->_id = id ? id : "";
+    cb->initialize("CheckBox", style, NULL);
+    return cb;
 }
 }
 
 
 Control* CheckBox::create(Theme::Style* style, Properties* properties)
 Control* CheckBox::create(Theme::Style* style, Properties* properties)
 {
 {
-    GP_ASSERT(properties);
+    CheckBox* cb = new CheckBox();
+    cb->initialize("CheckBox", style, properties);
+    return cb;
+}
 
 
-    CheckBox* checkBox = new CheckBox();
-    checkBox->initialize(style, properties);
-    properties->getVector2("imageSize", &checkBox->_imageSize);
-    checkBox->_checked = properties->getBool("checked");
+void CheckBox::initialize(const char* typeName, Theme::Style* style, Properties* properties)
+{
+    Button::initialize(typeName, style, properties);
 
 
-    return checkBox;
+    if (properties)
+    {
+        properties->getVector2("imageSize", &_imageSize);
+        _checked = properties->getBool("checked");
+    }
 }
 }
 
 
 bool CheckBox::isChecked()
 bool CheckBox::isChecked()
@@ -146,14 +148,14 @@ void CheckBox::update(const Control* container, const Vector2& offset)
     }
     }
 }
 }
 
 
-void CheckBox::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
+unsigned int CheckBox::drawImages(Form* form, const Rectangle& clip)
 {
 {
-    GP_ASSERT(spriteBatch);
-    GP_ASSERT(_image);
+    if (!_image)
+        return 0;
 
 
     // Left, v-center.
     // Left, v-center.
     // TODO: Set an alignment for icons.
     // TODO: Set an alignment for icons.
-    
+
     const Rectangle& region = _image->getRegion();
     const Rectangle& region = _image->getRegion();
     const Theme::UVs& uvs = _image->getUVs();
     const Theme::UVs& uvs = _image->getUVs();
     Vector4 color = _image->getColor();
     Vector4 color = _image->getColor();
@@ -171,7 +173,12 @@ void CheckBox::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
 
 
     Vector2 pos(_viewportBounds.x, _viewportBounds.y + _viewportBounds.height * 0.5f - size.y * 0.5f);
     Vector2 pos(_viewportBounds.x, _viewportBounds.y + _viewportBounds.height * 0.5f - size.y * 0.5f);
 
 
-    spriteBatch->draw(pos.x, pos.y, size.x, size.y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+    SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
+    startBatch(form, batch);
+    batch->draw(pos.x, pos.y, size.x, size.y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+    finishBatch(form, batch);
+
+    return 1;
 }
 }
 
 
 const char* CheckBox::getType() const
 const char* CheckBox::getType() const

+ 14 - 12
gameplay/src/CheckBox.h

@@ -40,15 +40,15 @@ class CheckBox : public Button
 public:
 public:
 
 
     /**
     /**
-     * Create a new check box control.
+     * Creates a new CheckBox.
      *
      *
-     * @param id The control's ID.
-     * @param style The control's style.
+     * @param id The checkbox ID.
+     * @param style The checkbox style (optional).
      *
      *
-     * @return The new check box.
+     * @return The new checkbox.
      * @script{create}
      * @script{create}
      */
      */
-    static CheckBox* create(const char* id, Theme::Style* style);
+    static CheckBox* create(const char* id, Theme::Style* style = NULL);
 
 
     /**
     /**
      * Gets whether this checkbox is checked.
      * Gets whether this checkbox is checked.
@@ -112,11 +112,16 @@ protected:
      * Create a checkbox with a given style and properties.
      * Create a checkbox with a given style and properties.
      *
      *
      * @param style The style to apply to this checkbox.
      * @param style The style to apply to this checkbox.
-     * @param properties The properties to set on this checkbox.
+     * @param properties A properties object containing a definition of the checkbox (optional).
      *
      *
      * @return The new checkbox.
      * @return The new checkbox.
      */
      */
-    static Control* create(Theme::Style* style, Properties* properties);
+    static Control* create(Theme::Style* style, Properties* properties = NULL);
+
+    /**
+    * @see Control::initialize
+    */
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
 
 
     /**
     /**
      * Keyboard callback on key events.
      * Keyboard callback on key events.
@@ -141,12 +146,9 @@ protected:
     void update(const Control* container, const Vector2& offset);
     void update(const Control* container, const Vector2& offset);
 
 
     /**
     /**
-     * Draw the checkbox icon associated with this control.
-     *
-     * @param spriteBatch The sprite batch containing this control's icons.
-     * @param clip The container position this control is relative to.
+     * @see Control::drawImages
      */
      */
-    void drawImages(SpriteBatch* spriteBatch, const Rectangle& clip);
+    unsigned int drawImages(Form* form, const Rectangle& clip);
 
 
     /**
     /**
      * Whether this checkbox is currently checked.
      * Whether this checkbox is currently checked.

+ 123 - 129
gameplay/src/Container.cpp

@@ -4,9 +4,17 @@
 #include "AbsoluteLayout.h"
 #include "AbsoluteLayout.h"
 #include "FlowLayout.h"
 #include "FlowLayout.h"
 #include "VerticalLayout.h"
 #include "VerticalLayout.h"
-#include "ControlFactory.h"
+#include "Label.h"
+#include "Button.h"
+#include "CheckBox.h"
+#include "RadioButton.h"
+#include "Slider.h"
+#include "TextBox.h"
+#include "Joystick.h"
+#include "ImageControl.h"
 #include "Form.h"
 #include "Form.h"
 #include "Game.h"
 #include "Game.h"
+#include "ControlFactory.h"
 
 
 namespace gameplay
 namespace gameplay
 {
 {
@@ -62,107 +70,96 @@ Container::~Container()
     SAFE_RELEASE(_layout);
     SAFE_RELEASE(_layout);
 }
 }
 
 
-Container* Container::create(const char* id, Theme::Style* style, Layout::Type layoutType)
+Container* Container::create(const char* id, Theme::Style* style, Layout::Type layout)
 {
 {
-    GP_ASSERT(style);
-
     Container* container = new Container();
     Container* container = new Container();
-    container->_layout = createLayout(layoutType);
-    if (id)
-        container->_id = id;
-    container->_style = style;
+    container->_id = id ? id : "";
+    container->_layout = createLayout(layout);
+    container->initialize("Container", style, NULL);
     return container;
     return container;
 }
 }
 
 
 Control* Container::create(Theme::Style* style, Properties* properties)
 Control* Container::create(Theme::Style* style, Properties* properties)
 {
 {
-    GP_ASSERT(properties);
-
     Container* container = new Container();
     Container* container = new Container();
-    container->initialize(style, properties);
+    container->initialize("Container", style, properties);
     return container;
     return container;
 }
 }
 
 
-void Container::initialize(Theme::Style* style, Properties* properties)
+void Container::initialize(const char* typeName, Theme::Style* style, Properties* properties)
 {
 {
-    Control::initialize(style, properties);
+    Control::initialize(typeName, style, properties);
 
 
-    // Parse layout
-    Properties* layoutNS = properties->getNamespace("layout", true, false);
-    if (layoutNS)
-    {
-        _layout = createLayout(getLayoutType(layoutNS->getString("type")));
-        switch (_layout->getType())
-        {
-        case Layout::LAYOUT_FLOW:
-            static_cast<FlowLayout*>(_layout)->setSpacing(layoutNS->getInt("horizontalSpacing"), layoutNS->getInt("verticalSpacing"));
-            break;
-        case Layout::LAYOUT_VERTICAL:
-            static_cast<VerticalLayout*>(_layout)->setSpacing(layoutNS->getInt("spacing"));
-            break;
-        }
-    }
-    else
-    {
-        _layout = createLayout(getLayoutType(properties->getString("layout")));
-    }
+	if (properties)
+	{
+		// Parse layout
+		Properties* layoutNS = properties->getNamespace("layout", true, false);
+		if (layoutNS)
+		{
+			_layout = createLayout(getLayoutType(layoutNS->getString("type")));
+			switch (_layout->getType())
+			{
+			case Layout::LAYOUT_FLOW:
+				static_cast<FlowLayout*>(_layout)->setSpacing(layoutNS->getInt("horizontalSpacing"), layoutNS->getInt("verticalSpacing"));
+				break;
+			case Layout::LAYOUT_VERTICAL:
+				static_cast<VerticalLayout*>(_layout)->setSpacing(layoutNS->getInt("spacing"));
+				break;
+			}
+		}
+		else
+		{
+			_layout = createLayout(getLayoutType(properties->getString("layout")));
+		}
 
 
-    setScroll(getScroll(properties->getString("scroll")));
-    _scrollBarsAutoHide = properties->getBool("scrollBarsAutoHide");
-    if (_scrollBarsAutoHide)
-    {
-        _scrollBarOpacity = 0.0f;
-    }
-    
-    _scrollWheelRequiresFocus = properties->getBool("scrollWheelRequiresFocus");
-    if (properties->exists("scrollingFriction"))
-        _scrollingFriction = properties->getFloat("scrollingFriction");
-    if (properties->exists("scrollWheelSpeed"))
-        _scrollWheelSpeed = properties->getFloat("scrollWheelSpeed");
+		setScroll(getScroll(properties->getString("scroll")));
+		_scrollBarsAutoHide = properties->getBool("scrollBarsAutoHide");
+		if (_scrollBarsAutoHide)
+		{
+			_scrollBarOpacity = 0.0f;
+		}
 
 
-    addControls(style->getTheme(), properties);
-    _layout->update(this, _scrollPosition);
+		_scrollWheelRequiresFocus = properties->getBool("scrollWheelRequiresFocus");
+		if (properties->exists("scrollingFriction"))
+			_scrollingFriction = properties->getFloat("scrollingFriction");
+		if (properties->exists("scrollWheelSpeed"))
+			_scrollWheelSpeed = properties->getFloat("scrollWheelSpeed");
 
 
-    const char* activeControl = properties->getString("activeControl");
-    if (activeControl)
-    {
-        for (size_t i = 0, count = _controls.size(); i < count; ++i)
-        {
-            if (_controls[i]->_id == activeControl)
-            {
-                _activeControl = _controls[i];
-                break;
-            }
-        }
-    }
+		addControls(properties);
+		_layout->update(this, _scrollPosition);
+
+		const char* activeControl = properties->getString("activeControl");
+		if (activeControl)
+		{
+			for (size_t i = 0, count = _controls.size(); i < count; ++i)
+			{
+				if (_controls[i]->_id == activeControl)
+				{
+					_activeControl = _controls[i];
+					break;
+				}
+			}
+		}
+	}
+
+    // Create a default layout if one does not yet exist
+    if (_layout == NULL)
+        _layout = createLayout(Layout::LAYOUT_ABSOLUTE);
 }
 }
 
 
-void Container::addControls(Theme* theme, Properties* properties)
+void Container::addControls(Properties* properties)
 {
 {
-    GP_ASSERT(theme);
     GP_ASSERT(properties);
     GP_ASSERT(properties);
 
 
     // Add all the controls to this container.
     // Add all the controls to this container.
     Properties* controlSpace = properties->getNextNamespace();
     Properties* controlSpace = properties->getNextNamespace();
     while (controlSpace != NULL)
     while (controlSpace != NULL)
     {
     {
-        Control* control = NULL;
-
-        const char* controlStyleName = controlSpace->getString("style");
-        Theme::Style* controlStyle = NULL;
-        if (controlStyleName)
-        {
-            controlStyle = theme->getStyle(controlStyleName);
-        }
-        else
-        {
-            controlStyle = theme->getEmptyStyle();
-        }
+        const char* controlName = controlSpace->getNamespace();
 
 
-        std::string controlName(controlSpace->getNamespace());
-        std::transform(controlName.begin(), controlName.end(), controlName.begin(), (int(*)(int))toupper);
-
-        control = ControlFactory::getInstance()->createControl(controlName.c_str(), controlStyle, controlSpace);
+        // Pass our own style into the creation of the child control.
+        // The child control's style will be looked up using the passed in style's theme.
+        Control* control = ControlFactory::getInstance()->createControl(controlName, _style, controlSpace);
 
 
         // Add the new control to the form.
         // Add the new control to the form.
         if (control)
         if (control)
@@ -184,9 +181,21 @@ Layout* Container::getLayout()
     return _layout;
     return _layout;
 }
 }
 
 
+void Container::setLayout(Layout::Type type)
+{
+	if (_layout == NULL || _layout->getType() != type)
+	{
+		SAFE_RELEASE(_layout);
+
+		_layout = createLayout(type);
+		_layout->update(this, _scrollPosition);
+		_dirty = true;
+	}
+}
+
 unsigned int Container::addControl(Control* control)
 unsigned int Container::addControl(Control* control)
 {
 {
-    GP_ASSERT(control);
+	GP_ASSERT(control);
 
 
     // Remove the control from its current parent
     // Remove the control from its current parent
     if (control->_parent && control->_parent != this)
     if (control->_parent && control->_parent != this)
@@ -383,12 +392,17 @@ bool Container::isScrollBarsAutoHide() const
 
 
 bool Container::isScrolling() const
 bool Container::isScrolling() const
 {
 {
+    if (_scrolling &&
+        (abs(_scrollingLastX - _scrollingVeryFirstX) > SCROLL_THRESHOLD ||
+        abs(_scrollingLastY - _scrollingVeryFirstY) > SCROLL_THRESHOLD))
+    {
+        return true;
+    }
+
     if (_parent && _parent->isScrolling())
     if (_parent && _parent->isScrolling())
         return true;
         return true;
 
 
-    return (_scrolling &&
-            (abs(_scrollingLastX - _scrollingVeryFirstX) > SCROLL_THRESHOLD ||
-             abs(_scrollingLastY - _scrollingVeryFirstY) > SCROLL_THRESHOLD));
+    return false;
 }
 }
 
 
 const Vector2& Container::getScrollPosition() const
 const Vector2& Container::getScrollPosition() const
@@ -598,52 +612,32 @@ void Container::update(const Control* container, const Vector2& offset)
     }
     }
 }
 }
 
 
-void Container::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsClear, bool cleared, float targetHeight)
+unsigned int Container::draw(Form* form, const Rectangle& clip)
 {
 {
-    if (needsClear)
-    {
-        GL_ASSERT( glEnable(GL_SCISSOR_TEST) );
-        float clearY = targetHeight - _clearBounds.y - _clearBounds.height;
-        GL_ASSERT( glScissor(_clearBounds.x, clearY, _clearBounds.width, _clearBounds.height) );
-        Game::getInstance()->clear(Game::CLEAR_COLOR, Vector4::zero(), 1.0f, 0);
-        GL_ASSERT( glDisable(GL_SCISSOR_TEST) );
-        needsClear = false;
-        cleared = true;
-    }
-    else if (!cleared)
-    {
-        needsClear = true;
-    }
-
     if (!_visible)
     if (!_visible)
-    {
-        _dirty = false;
-        return;
-    }
+        return 0;
 
 
-    spriteBatch->start();
-    Control::drawBorder(spriteBatch, clip);
-    spriteBatch->finish();
+    // Draw container skin
+    unsigned int drawCalls = Control::draw(form, clip);
 
 
-    std::vector<Control*>::const_iterator it;
-    Rectangle boundsUnion = Rectangle::empty();
-    for (it = _controls.begin(); it < _controls.end(); it++)
+    // Draw child controls
+    for (size_t i = 0, count = _controls.size(); i < count; ++i)
     {
     {
-        Control* control = *it;
-        GP_ASSERT(control);
-        if (!needsClear || control->isDirty() || control->_clearBounds.intersects(boundsUnion))
+        Control* control = _controls[i];
+        if (control && control->_absoluteClipBounds.intersects(_absoluteClipBounds))
         {
         {
-            control->draw(spriteBatch, _viewportClipBounds, needsClear, cleared, targetHeight);
-            Rectangle::combine(control->_clearBounds, boundsUnion, &boundsUnion);
+            drawCalls += control->draw(form, _viewportClipBounds);
         }
         }
     }
     }
 
 
+    // Draw scrollbars
     if (_scroll != SCROLL_NONE && (_scrollBarOpacity > 0.0f))
     if (_scroll != SCROLL_NONE && (_scrollBarOpacity > 0.0f))
     {
     {
         // Draw scroll bars.
         // Draw scroll bars.
         Rectangle clipRegion(_viewportClipBounds);
         Rectangle clipRegion(_viewportClipBounds);
 
 
-        spriteBatch->start();
+        SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
+        startBatch(form, batch);
 
 
         if (_scrollBarBounds.height > 0 && ((_scroll & SCROLL_VERTICAL) == SCROLL_VERTICAL))
         if (_scrollBarBounds.height > 0 && ((_scroll & SCROLL_VERTICAL) == SCROLL_VERTICAL))
         {
         {
@@ -665,15 +659,17 @@ void Container::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needs
             clipRegion.width += verticalRegion.width;
             clipRegion.width += verticalRegion.width;
 
 
             Rectangle bounds(_viewportBounds.x + _viewportBounds.width, _viewportBounds.y + _scrollBarBounds.y, topRegion.width, topRegion.height);
             Rectangle bounds(_viewportBounds.x + _viewportBounds.width, _viewportBounds.y + _scrollBarBounds.y, topRegion.width, topRegion.height);
-            spriteBatch->draw(bounds.x, bounds.y, bounds.width, bounds.height, topUVs.u1, topUVs.v1, topUVs.u2, topUVs.v2, topColor, clipRegion);
+            batch->draw(bounds.x, bounds.y, bounds.width, bounds.height, topUVs.u1, topUVs.v1, topUVs.u2, topUVs.v2, topColor, clipRegion);
 
 
             bounds.y += topRegion.height;
             bounds.y += topRegion.height;
             bounds.height = _scrollBarBounds.height - topRegion.height - bottomRegion.height;
             bounds.height = _scrollBarBounds.height - topRegion.height - bottomRegion.height;
-            spriteBatch->draw(bounds.x, bounds.y, bounds.width, bounds.height, verticalUVs.u1, verticalUVs.v1, verticalUVs.u2, verticalUVs.v2, verticalColor, clipRegion);
+            batch->draw(bounds.x, bounds.y, bounds.width, bounds.height, verticalUVs.u1, verticalUVs.v1, verticalUVs.u2, verticalUVs.v2, verticalColor, clipRegion);
 
 
             bounds.y += bounds.height;
             bounds.y += bounds.height;
             bounds.height = bottomRegion.height;
             bounds.height = bottomRegion.height;
-            spriteBatch->draw(bounds.x, bounds.y, bounds.width, bounds.height, bottomUVs.u1, bottomUVs.v1, bottomUVs.u2, bottomUVs.v2, bottomColor, clipRegion);
+            batch->draw(bounds.x, bounds.y, bounds.width, bounds.height, bottomUVs.u1, bottomUVs.v1, bottomUVs.u2, bottomUVs.v2, bottomColor, clipRegion);
+
+            drawCalls += 3;
         }
         }
 
 
         if (_scrollBarBounds.width > 0 && ((_scroll & SCROLL_HORIZONTAL) == SCROLL_HORIZONTAL))
         if (_scrollBarBounds.width > 0 && ((_scroll & SCROLL_HORIZONTAL) == SCROLL_HORIZONTAL))
@@ -696,28 +692,23 @@ void Container::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needs
             clipRegion.height += horizontalRegion.height;
             clipRegion.height += horizontalRegion.height;
         
         
             Rectangle bounds(_viewportBounds.x + _scrollBarBounds.x, _viewportBounds.y + _viewportBounds.height, leftRegion.width, leftRegion.height);
             Rectangle bounds(_viewportBounds.x + _scrollBarBounds.x, _viewportBounds.y + _viewportBounds.height, leftRegion.width, leftRegion.height);
-            spriteBatch->draw(bounds.x, bounds.y, bounds.width, bounds.height, leftUVs.u1, leftUVs.v1, leftUVs.u2, leftUVs.v2, leftColor, clipRegion);
+            batch->draw(bounds.x, bounds.y, bounds.width, bounds.height, leftUVs.u1, leftUVs.v1, leftUVs.u2, leftUVs.v2, leftColor, clipRegion);
 
 
             bounds.x += leftRegion.width;
             bounds.x += leftRegion.width;
             bounds.width = _scrollBarBounds.width - leftRegion.width - rightRegion.width;
             bounds.width = _scrollBarBounds.width - leftRegion.width - rightRegion.width;
-            spriteBatch->draw(bounds.x, bounds.y, bounds.width, bounds.height, horizontalUVs.u1, horizontalUVs.v1, horizontalUVs.u2, horizontalUVs.v2, horizontalColor, clipRegion);
+            batch->draw(bounds.x, bounds.y, bounds.width, bounds.height, horizontalUVs.u1, horizontalUVs.v1, horizontalUVs.u2, horizontalUVs.v2, horizontalColor, clipRegion);
 
 
             bounds.x += bounds.width;
             bounds.x += bounds.width;
             bounds.width = rightRegion.width;
             bounds.width = rightRegion.width;
-            spriteBatch->draw(bounds.x, bounds.y, bounds.width, bounds.height, rightUVs.u1, rightUVs.v1, rightUVs.u2, rightUVs.v2, rightColor, clipRegion);
-        }
-
-        spriteBatch->finish();
+            batch->draw(bounds.x, bounds.y, bounds.width, bounds.height, rightUVs.u1, rightUVs.v1, rightUVs.u2, rightUVs.v2, rightColor, clipRegion);
 
 
-        if (_scrollingVelocity.isZero())
-        {
-            _dirty = false;
+            drawCalls += 3;
         }
         }
+
+        finishBatch(form, batch);
     }
     }
-    else
-    {
-        _dirty = false;
-    }
+
+    return drawCalls;
 }
 }
 
 
 bool Container::isDirty()
 bool Container::isDirty()
@@ -999,6 +990,9 @@ void Container::stopScrolling()
     _scrollingVelocity.set(0, 0);
     _scrollingVelocity.set(0, 0);
     _scrolling = false;
     _scrolling = false;
     _dirty = true;
     _dirty = true;
+
+    if (_parent)
+        _parent->stopScrolling();
 }
 }
 
 
 bool Container::isContainer() const
 bool Container::isContainer() const
@@ -1337,7 +1331,7 @@ bool Container::mouseEventScroll(Mouse::MouseEvent evt, int x, int y, int wheelD
             if (_scrollBarVertical)
             if (_scrollBarVertical)
             {
             {
                 float vWidth = _scrollBarVertical->getRegion().width;
                 float vWidth = _scrollBarVertical->getRegion().width;
-                Rectangle vBounds(_viewportBounds.x + _viewportBounds.width,
+                Rectangle vBounds(_viewportBounds.right() - _absoluteBounds.x,
                                  _scrollBarBounds.y,
                                  _scrollBarBounds.y,
                                  vWidth, _scrollBarBounds.height);
                                  vWidth, _scrollBarBounds.height);
 
 

+ 30 - 32
gameplay/src/Container.h

@@ -73,16 +73,16 @@ public:
     };
     };
 
 
     /**
     /**
-     * Create a new container.
+     * Creates a new container.
      *
      *
-     * @param id The container's ID.
-     * @param style The container's style.
-     * @param layoutType The container's layout type.
+     * @param id The container ID.
+     * @param style The container style (optional).
+     * @param layout The container layout (optional).
      *
      *
      * @return The new container.
      * @return The new container.
      * @script{create}
      * @script{create}
      */
      */
-    static Container* create(const char* id, Theme::Style* style, Layout::Type layoutType = Layout::LAYOUT_ABSOLUTE);
+    static Container* create(const char* id, Theme::Style* style = NULL, Layout::Type layout = Layout::LAYOUT_ABSOLUTE);
 
 
     /**
     /**
      * Get this container's layout.
      * Get this container's layout.
@@ -91,20 +91,26 @@ public:
      */
      */
     Layout* getLayout();
     Layout* getLayout();
 
 
+	/**
+	 * Sets the layout type for this container.
+	 *
+	 * @param type The new layout type for the container.
+	 */
+	void setLayout(Layout::Type type);
+
     /**
     /**
-     * Add a control to this layout.
-     * The control will be assigned the next available index.
+     * Adds a new control to this container.
      *
      *
-     * @param control The Control to add.
+	 * @param control The control to add.
      *
      *
-     * @return The index assigned to the added Control.
+     * @return The index assigned to the new Control.
      */
      */
     unsigned int addControl(Control* control);
     unsigned int addControl(Control* control);
 
 
     /**
     /**
-     * Insert a control at a specific index.
+     * Inserts a control at a specific index.
      *
      *
-     * @param control The control to add.
+     * @param control The control to insert.
      * @param index The index at which to insert the control.
      * @param index The index at which to insert the control.
      */
      */
     void insertControl(Control* control, unsigned int index);
     void insertControl(Control* control, unsigned int index);
@@ -203,6 +209,11 @@ public:
      */
      */
     bool isScrolling() const;
     bool isScrolling() const;
 
 
+    /**
+     * Stops this container from scrolling if it is currently being scrolled.
+     */
+    void stopScrolling();
+
     /**
     /**
      * Get the friction applied to scrolling velocity for this container.
      * Get the friction applied to scrolling velocity for this container.
      */
      */
@@ -317,19 +328,16 @@ protected:
      * Create a container with a given style and properties, including a list of controls.
      * Create a container with a given style and properties, including a list of controls.
      *
      *
      * @param style The style to apply to this container.
      * @param style The style to apply to this container.
-     * @param properties The properties to set on this container, including nested controls.
+     * @param properties A properties object containing a definition of the container and its nested controls (optional).
      *
      *
      * @return The new container.
      * @return The new container.
      */
      */
-    static Control* create(Theme::Style* style, Properties* properties);
+    static Control* create(Theme::Style* style, Properties* properties = NULL);
 
 
     /**
     /**
-     * Initialize properties common to all Containers from a Properties object.
-     *
-     * @param style The style to apply to this control.
-     * @param properties The properties to set on this control.
+     * @see Control::initialize
      */
      */
-    void initialize(Theme::Style* style, Properties* properties);
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
 
 
     /**
     /**
      * Updates each control within this container,
      * Updates each control within this container,
@@ -364,24 +372,16 @@ protected:
     virtual bool isDirty();
     virtual bool isDirty();
 
 
     /**
     /**
-     * Adds controls nested within a properties object to this container,
-     * searching for styles within the given theme.
+     * Adds controls nested within a properties object to this container.
      *
      *
-     * @param theme The them to add controls from
      * @param properties The properties to use.
      * @param properties The properties to use.
      */
      */
-    void addControls(Theme* theme, Properties* properties);
+    void addControls(Properties* properties);
 
 
     /**
     /**
-     * Draws a sprite batch for the specified clipping rect.
-     *
-     * @param spriteBatch The sprite batch to use.
-     * @param clip The clipping rectangle.
-     * @param needsClear Whether it needs to be cleared.
-     * @param cleared Whether it was previously cleared
-     * @param targetHeight The targets height
+     * @see Control::draw
      */
      */
-    virtual void draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsClear, bool cleared, float targetHeight);
+    virtual unsigned int draw(Form* form, const Rectangle& clip);
 
 
     /**
     /**
      * Update scroll position and velocity.
      * Update scroll position and velocity.
@@ -586,8 +586,6 @@ private:
     // Starts scrolling at the given horizontal and vertical speeds.
     // Starts scrolling at the given horizontal and vertical speeds.
     void startScrolling(float x, float y, bool resetTime = true);
     void startScrolling(float x, float y, bool resetTime = true);
 
 
-    void stopScrolling();
-
     void clearContacts();
     void clearContacts();
     bool inContact();
     bool inContact();
 
 

+ 290 - 276
gameplay/src/Control.cpp

@@ -2,6 +2,7 @@
 #include "Game.h"
 #include "Game.h"
 #include "Control.h"
 #include "Control.h"
 #include "Form.h"
 #include "Form.h"
+#include "Theme.h"
 
 
 #define BOUNDS_X_PERCENTAGE_BIT 1
 #define BOUNDS_X_PERCENTAGE_BIT 1
 #define BOUNDS_Y_PERCENTAGE_BIT 2
 #define BOUNDS_Y_PERCENTAGE_BIT 2
@@ -46,7 +47,7 @@ static bool parseCoordPair(const char* s, float* v1, float* v2, bool* v1Percenta
 
 
 Control::Control()
 Control::Control()
     : _id(""), _enabled(true), _boundsBits(0), _dirty(true), _consumeInputEvents(true), _alignment(ALIGN_TOP_LEFT), _isAlignmentSet(false),
     : _id(""), _enabled(true), _boundsBits(0), _dirty(true), _consumeInputEvents(true), _alignment(ALIGN_TOP_LEFT), _isAlignmentSet(false),
-    _autoWidth(AUTO_SIZE_NONE), _autoHeight(AUTO_SIZE_NONE), _listeners(NULL), _visible(true), _zIndex(-1),
+    _autoWidth(AUTO_SIZE_NONE), _autoHeight(AUTO_SIZE_NONE), _style(NULL), _listeners(NULL), _visible(true), _zIndex(-1),
     _contactIndex(INVALID_CONTACT_INDEX), _focusIndex(-1), _canFocus(false), _parent(NULL), _styleOverridden(false), _skin(NULL)
     _contactIndex(INVALID_CONTACT_INDEX), _focusIndex(-1), _canFocus(false), _parent(NULL), _styleOverridden(false), _skin(NULL)
 {
 {
     addScriptEvent("controlEvent", "<Control>[Control::Listener::EventType]");
     addScriptEvent("controlEvent", "<Control>[Control::Listener::EventType]");
@@ -66,9 +67,15 @@ Control::~Control()
         SAFE_DELETE(_listeners);
         SAFE_DELETE(_listeners);
     }
     }
 
 
-    if (_styleOverridden)
+    if (_style)
     {
     {
-        SAFE_DELETE(_style);
+        // Release the style's theme since we addRef'd it in initialize()
+        _style->getTheme()->release();
+
+        if (_styleOverridden)
+        {
+            SAFE_DELETE(_style);
+        }
     }
     }
 }
 }
 
 
@@ -83,126 +90,165 @@ static Control::AutoSize parseAutoSize(const char* str)
     return Control::AUTO_SIZE_NONE;
     return Control::AUTO_SIZE_NONE;
 }
 }
 
 
-void Control::initialize(Theme::Style* style, Properties* properties)
+void Control::initialize(const char* typeName, Theme::Style* style, Properties* properties)
 {
 {
-    GP_ASSERT(properties);
-    _style = style;
-
-    // Properties not defined by the style.
-    const char * alignmentString = properties->getString("alignment");
-
-    _isAlignmentSet = alignmentString != NULL;
-    _alignment = getAlignment(alignmentString);
-
-    _autoWidth = parseAutoSize(properties->getString("autoWidth"));
-    _autoHeight = parseAutoSize(properties->getString("autoHeight"));
-
-    _consumeInputEvents = properties->getBool("consumeInputEvents", true);
-
-    _visible = properties->getBool("visible", true);
-
-    if (properties->exists("zIndex"))
-    {
-        _zIndex = properties->getInt("zIndex");
-    }
-    else
-    {
-        _zIndex = -1;
-    }
-
-    if (properties->exists("canFocus"))
-        _canFocus = properties->getBool("canFocus", false);
-
-    if (properties->exists("focusIndex"))
+    // Load our theme style
+    if (properties)
     {
     {
-        _focusIndex = properties->getInt("focusIndex");
-    }
-    else
-    {
-        _focusIndex = -1;
-    }
-
-    float bounds[4];
-    bool boundsBits[4];
-    if (properties->exists("position"))
-    {
-        parseCoordPair(properties->getString("position", "0,0"), &bounds[0], &bounds[1], &boundsBits[0], &boundsBits[1]);
-    }
-    else
-    {
-        bounds[0] = parseCoord(properties->getString("x", "0"), &boundsBits[0]);
-        bounds[1] = parseCoord(properties->getString("y", "0"), &boundsBits[1]);
-    }
+        // The style passed is in our parent control's style.
+        // Attempt to load our own style from our parent style's theme.
+        const char* styleName = properties->getString("style", typeName);
+        if (style)
+        {
+            // The passed in style is our parent control's style : attempt to load our style from it.
+            _style = style->getTheme()->getStyle(styleName);
+        }
 
 
-    if (properties->exists("size"))
-    {
-        parseCoordPair(properties->getString("size", "0,0"), &bounds[2], &bounds[3], &boundsBits[2], &boundsBits[3]);
+        if (!_style)
+        {
+            // Try loading a style from the default theme
+            _style = Theme::getDefault()->getStyle(styleName);
+        }
     }
     }
     else
     else
     {
     {
-        bounds[2] = parseCoord(properties->getString("width", "0"), &boundsBits[2]);
-        bounds[3] = parseCoord(properties->getString("height", "0"), &boundsBits[3]);
+        // No properties passed in - the style passed in was explicity for us.
+        _style = style;
     }
     }
-    setX(bounds[0], boundsBits[0]);
-    setY(bounds[1], boundsBits[1]);
-    setWidth(bounds[2], boundsBits[2]);
-    setHeight(bounds[3], boundsBits[3]);
 
 
-    const char* id = properties->getId();
-    if (id)
-        _id = id;
-
-    if (properties->exists("enabled"))
+    if (!_style)
     {
     {
-        setEnabled(properties->getBool("enabled"));
-    }
+        // Search for a style from the default theme that matches this control's name
+        _style = Theme::getDefault()->getStyle(typeName);
 
 
-    // Register script listeners for control events
-    if (properties->exists("listener"))
-        addScriptCallback("controlEvent", properties->getString("listener"));
-
-    // Potentially override themed properties for all states.
-    overrideThemedProperties(properties, STATE_ALL);
-
-    // Override themed properties on specific states.
-    Properties* innerSpace = properties->getNextNamespace();
-    while (innerSpace != NULL)
-    {
-        std::string spaceName(innerSpace->getNamespace());
-        std::transform(spaceName.begin(), spaceName.end(), spaceName.begin(), (int(*)(int))toupper);
-        if (spaceName == "STATENORMAL")
-        {
-            overrideThemedProperties(innerSpace, NORMAL);
-        }
-        else if (spaceName == "STATEFOCUS")
+        if (!_style)
         {
         {
-            overrideThemedProperties(innerSpace, FOCUS);
+            // No style was found, use an empty style
+            _style = style ? style->getTheme()->getEmptyStyle() : Theme::getDefault()->getEmptyStyle();
         }
         }
-        else if (spaceName == "STATEACTIVE")
-        {
-            overrideThemedProperties(innerSpace, ACTIVE);
-        }
-        else if (spaceName == "STATEDISABLED")
-        {
-            overrideThemedProperties(innerSpace, DISABLED);
-        }
-        else if (spaceName == "STATEHOVER")
-        {
-            overrideThemedProperties(innerSpace, HOVER);
-        }
-        else if (spaceName == "MARGIN")
-        {
-            setMargin(innerSpace->getFloat("top"), innerSpace->getFloat("bottom"),
-                innerSpace->getFloat("left"), innerSpace->getFloat("right"));
-        }
-        else if (spaceName == "PADDING")
-        {
-            setPadding(innerSpace->getFloat("top"), innerSpace->getFloat("bottom"),
-                innerSpace->getFloat("left"), innerSpace->getFloat("right"));
-        }
-
-        innerSpace = properties->getNextNamespace();
     }
     }
+
+    // Increase the reference count of the style's theme while we hold the style
+    _style->getTheme()->addRef();
+
+    if (properties)
+    {
+		// Properties not defined by the style.
+		const char * alignmentString = properties->getString("alignment");
+
+		_isAlignmentSet = alignmentString != NULL;
+		_alignment = getAlignment(alignmentString);
+
+		_autoWidth = parseAutoSize(properties->getString("autoWidth"));
+		_autoHeight = parseAutoSize(properties->getString("autoHeight"));
+
+		_consumeInputEvents = properties->getBool("consumeInputEvents", true);
+
+		_visible = properties->getBool("visible", true);
+
+		if (properties->exists("zIndex"))
+		{
+			_zIndex = properties->getInt("zIndex");
+		}
+		else
+		{
+			_zIndex = -1;
+		}
+
+		if (properties->exists("canFocus"))
+			_canFocus = properties->getBool("canFocus", false);
+
+		if (properties->exists("focusIndex"))
+		{
+			_focusIndex = properties->getInt("focusIndex");
+		}
+		else
+		{
+			_focusIndex = -1;
+		}
+
+		float bounds[4];
+		bool boundsBits[4];
+		if (properties->exists("position"))
+		{
+			parseCoordPair(properties->getString("position", "0,0"), &bounds[0], &bounds[1], &boundsBits[0], &boundsBits[1]);
+		}
+		else
+		{
+			bounds[0] = parseCoord(properties->getString("x", "0"), &boundsBits[0]);
+			bounds[1] = parseCoord(properties->getString("y", "0"), &boundsBits[1]);
+		}
+
+		if (properties->exists("size"))
+		{
+			parseCoordPair(properties->getString("size", "0,0"), &bounds[2], &bounds[3], &boundsBits[2], &boundsBits[3]);
+		}
+		else
+		{
+			bounds[2] = parseCoord(properties->getString("width", "0"), &boundsBits[2]);
+			bounds[3] = parseCoord(properties->getString("height", "0"), &boundsBits[3]);
+		}
+		setX(bounds[0], boundsBits[0]);
+		setY(bounds[1], boundsBits[1]);
+		setWidth(bounds[2], boundsBits[2]);
+		setHeight(bounds[3], boundsBits[3]);
+
+		const char* id = properties->getId();
+		if (id)
+			_id = id;
+
+		if (properties->exists("enabled"))
+		{
+			setEnabled(properties->getBool("enabled"));
+		}
+
+		// Register script listeners for control events
+		if (properties->exists("listener"))
+			addScriptCallback("controlEvent", properties->getString("listener"));
+
+		// Potentially override themed properties for all states.
+		overrideThemedProperties(properties, STATE_ALL);
+
+		// Override themed properties on specific states.
+		Properties* innerSpace = properties->getNextNamespace();
+		while (innerSpace != NULL)
+		{
+			std::string spaceName(innerSpace->getNamespace());
+			std::transform(spaceName.begin(), spaceName.end(), spaceName.begin(), (int(*)(int))toupper);
+			if (spaceName == "STATENORMAL")
+			{
+				overrideThemedProperties(innerSpace, NORMAL);
+			}
+			else if (spaceName == "STATEFOCUS")
+			{
+				overrideThemedProperties(innerSpace, FOCUS);
+			}
+			else if (spaceName == "STATEACTIVE")
+			{
+				overrideThemedProperties(innerSpace, ACTIVE);
+			}
+			else if (spaceName == "STATEDISABLED")
+			{
+				overrideThemedProperties(innerSpace, DISABLED);
+			}
+			else if (spaceName == "STATEHOVER")
+			{
+				overrideThemedProperties(innerSpace, HOVER);
+			}
+			else if (spaceName == "MARGIN")
+			{
+				setMargin(innerSpace->getFloat("top"), innerSpace->getFloat("bottom"),
+					innerSpace->getFloat("left"), innerSpace->getFloat("right"));
+			}
+			else if (spaceName == "PADDING")
+			{
+				setPadding(innerSpace->getFloat("top"), innerSpace->getFloat("bottom"),
+					innerSpace->getFloat("left"), innerSpace->getFloat("right"));
+			}
+
+			innerSpace = properties->getNextNamespace();
+		}
+	}
 }
 }
 
 
 const char* Control::getId() const
 const char* Control::getId() const
@@ -210,6 +256,11 @@ const char* Control::getId() const
     return _id.c_str();
     return _id.c_str();
 }
 }
 
 
+void Control::setId(const char* id)
+{
+	_id = id ? id : "";
+}
+
 float Control::getX() const
 float Control::getX() const
 {
 {
     return _bounds.x;
     return _bounds.x;
@@ -820,6 +871,11 @@ bool Control::getTextRightToLeft(State state) const
     return overlay->getTextRightToLeft();
     return overlay->getTextRightToLeft();
 }
 }
 
 
+Theme::Style* Control::getStyle() const
+{
+    return _style;
+}
+
 void Control::setStyle(Theme::Style* style)
 void Control::setStyle(Theme::Style* style)
 {
 {
     if (style != _style)
     if (style != _style)
@@ -830,9 +886,9 @@ void Control::setStyle(Theme::Style* style)
     _style = style;
     _style = style;
 }
 }
 
 
-Theme::Style* Control::getStyle() const
+Theme* Control::getTheme() const
 {
 {
-    return _style;
+    return _style ? _style->getTheme() : NULL;
 }
 }
 
 
 Control::State Control::getState() const
 Control::State Control::getState() const
@@ -988,12 +1044,12 @@ void Control::addSpecificListener(Control::Listener* listener, Control::Listener
 
 
 bool Control::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 bool Control::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
 {
-    return _consumeInputEvents;
+    return false;// _consumeInputEvents;
 }
 }
 
 
 bool Control::keyEvent(Keyboard::KeyEvent evt, int key)
 bool Control::keyEvent(Keyboard::KeyEvent evt, int key)
 {
 {
-    return _consumeInputEvents;
+    return false;// _consumeInputEvents;
 }
 }
 
 
 bool Control::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 bool Control::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
@@ -1005,7 +1061,7 @@ bool Control::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 
 
 bool Control::gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad, unsigned int analogIndex)
 bool Control::gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad, unsigned int analogIndex)
 {
 {
-    return _consumeInputEvents;
+    return false;// _consumeInputEvents;
 }
 }
 
 
 void Control::notifyListeners(Control::Listener::EventType eventType)
 void Control::notifyListeners(Control::Listener::EventType eventType)
@@ -1043,13 +1099,22 @@ void Control::controlEvent(Control::Listener::EventType evt)
 void Control::update(const Control* container, const Vector2& offset)
 void Control::update(const Control* container, const Vector2& offset)
 {
 {
     Game* game = Game::getInstance();
     Game* game = Game::getInstance();
+
     const Rectangle parentAbsoluteBounds = container ? container->_viewportBounds : Rectangle(0, 0, game->getViewport().width, game->getViewport().height);
     const Rectangle parentAbsoluteBounds = container ? container->_viewportBounds : Rectangle(0, 0, game->getViewport().width, game->getViewport().height);
-    const Rectangle parentAbsoluteClip = container ? container->getClip() : parentAbsoluteBounds;
+    const Rectangle parentAbsoluteClip = container ? container->_viewportClipBounds : parentAbsoluteBounds;
 
 
-    // Store previous absolute clip bounds
-    _clearBounds.set(_absoluteClipBounds);
+    const Theme::Border& border = getBorder(getState());
+    const Theme::Padding& padding = getPadding();
+
+    // Compute content are padding values
+    float lpadding = border.left + padding.left;
+    float rpadding = border.right + padding.right;
+    float tpadding = border.top + padding.top;
+    float bpadding = border.bottom + padding.bottom;
+    float hpadding = lpadding + rpadding;
+    float vpadding = tpadding + bpadding;
 
 
-    // Calculate local un-clipped bounds.
+    // Calculate local unclipped bounds.
     _bounds.set(_relativeBounds);
     _bounds.set(_relativeBounds);
     if (isXPercentage())
     if (isXPercentage())
         _bounds.x *= parentAbsoluteBounds.width;
         _bounds.x *= parentAbsoluteBounds.width;
@@ -1064,120 +1129,33 @@ void Control::update(const Control* container, const Vector2& offset)
     else if (isHeightPercentage())
     else if (isHeightPercentage())
         _bounds.height *= parentAbsoluteBounds.height;
         _bounds.height *= parentAbsoluteBounds.height;
 
 
-    float x, y, width, height, clipX2, x2, clipY2, y2;
+    // Calculate absolute unclipped bounds
+    _absoluteBounds.set(
+        parentAbsoluteBounds.x + offset.x + _bounds.x,
+        parentAbsoluteBounds.y + offset.y + _bounds.y,
+        _bounds.width,
+        _bounds.height);
 
 
-    // Calculate the local clipped bounds
-    width = _bounds.width;
-    height = _bounds.height;
-    if (container)
-    {
-        x = _bounds.x + offset.x;
-        y = _bounds.y + offset.y;
-        x2 = parentAbsoluteClip.x + x + width;
-        y2 = parentAbsoluteClip.y + y + height;
-    }
-    else
-    {
-        x = 0;
-        y = 0;
-        x2 = width;
-        y2 = height;
-    }
-    clipX2 = parentAbsoluteClip.x + parentAbsoluteClip.width;
-    clipY2 = parentAbsoluteClip.y + parentAbsoluteClip.height;
-    if (x2 > clipX2)
-        width -= x2 - clipX2;
-    if (y2 > clipY2)
-        height -= y2 - clipY2;
+    // Calculate absolute clipped bounds
+    Rectangle::intersect(_absoluteBounds, parentAbsoluteClip, &_absoluteClipBounds);
 
 
-    if (x < 0)
-    {
-        width += x;
-        x = -x;
-    }
-    else
-    {
-        x = 0;
-    }
-
-    if (y < 0)
-    {
-        height += y;
-        y = -y;
-    }
-    else
-    {
-        y = 0;
-    }
-
-    _clipBounds.set(x, y, width, height);
-
-    // Calculate absolute bounds un-clipped bounds
-    if (container)
-    {
-        x = _bounds.x + offset.x + parentAbsoluteBounds.x;
-        y = _bounds.y + offset.y + parentAbsoluteBounds.y;
-    }
-    else
-    {
-        x = 0;
-        y = 0;
-    }
-    _absoluteBounds.set(x, y, _bounds.width, _bounds.height);
-
-    // Calculate the absolute viewport bounds (content area, which does not include border and padding)
-    // Absolute bounds minus border and padding.
-    const Theme::Border& border = getBorder(getState());
-    const Theme::Padding& padding = getPadding();
-    x += border.left + padding.left;
-    y += border.top + padding.top;
-    width = _bounds.width - border.left - padding.left - border.right - padding.right;
-    height = _bounds.height - border.top - padding.top - border.bottom - padding.bottom;
-    _viewportBounds.set(x, y, width, height);
-
-    // Calculate the clip area.
-    // Absolute bounds, minus border and padding,
-    // clipped to the parent container's clip area.
-    if (container)
-    {
-        clipX2 = parentAbsoluteClip.x + parentAbsoluteClip.width;
-        clipY2 = parentAbsoluteClip.y + parentAbsoluteClip.height;
-    }
-    else
-    {
-        clipX2 = parentAbsoluteClip.width;
-        clipY2 = parentAbsoluteClip.height;
-    }
-    x2 = x + width;
-    if (x2 > clipX2)
-        width = clipX2 - x;
-    y2 = y + height;
-    if (y2 > clipY2)
-        height = clipY2 - y;
-
-    if (x < parentAbsoluteClip.x)
-    {
-        float dx = parentAbsoluteClip.x - x;
-        width -= dx;
-        x = parentAbsoluteClip.x;
-    }
-
-    if (y < parentAbsoluteClip.y)
-    {
-        float dy = parentAbsoluteClip.y - y;
-        height -= dy;
-        y = parentAbsoluteClip.y;
-    }
-
-    _viewportClipBounds.set(x, y, width, height);
-
-    width += border.left + padding.left + border.right + padding.right;
-    height += border.top + padding.top + border.bottom + padding.bottom;
-    _absoluteClipBounds.set(x - border.left - padding.left, y - border.top - padding.top, max(width, 0.0f), max(height, 0.0f));
-    if (_clearBounds.isEmpty())
-    {
-        _clearBounds.set(_absoluteClipBounds);
-    }
+    // Calculate the local clipped bounds
+    _clipBounds.set(
+        max(_absoluteClipBounds.x - _absoluteBounds.x, 0.0f),
+        max(_absoluteClipBounds.y - _absoluteBounds.y, 0.0f),
+        _absoluteClipBounds.width,
+        _absoluteClipBounds.height
+        );
+
+    // Calculate the absolute unclipped viewport bounds (content area, which does not include border and padding)
+    _viewportBounds.set(
+        _absoluteBounds.x + lpadding,
+        _absoluteBounds.y + tpadding,
+        _absoluteBounds.width - hpadding,
+        _absoluteBounds.height - vpadding);
+
+    // Calculate the absolute clipped viewport bounds
+    Rectangle::intersect(_viewportBounds, parentAbsoluteClip, &_viewportClipBounds);
 
 
     // Cache themed attributes for performance.
     // Cache themed attributes for performance.
     _skin = getSkin(getState());
     _skin = getSkin(getState());
@@ -1188,10 +1166,36 @@ void Control::update(const Control* container, const Vector2& offset)
         _opacity *= container->_opacity;
         _opacity *= container->_opacity;
 }
 }
 
 
-void Control::drawBorder(SpriteBatch* spriteBatch, const Rectangle& clip)
+void Control::startBatch(Form* form, SpriteBatch* batch)
 {
 {
-    if (!spriteBatch || !_skin || _absoluteBounds.width <= 0 || _absoluteBounds.height <= 0)
-        return;
+    form->startBatch(batch);
+}
+
+void Control::finishBatch(Form* form, SpriteBatch* batch)
+{
+    form->finishBatch(batch);
+}
+
+unsigned int Control::draw(Form* form, const Rectangle& clip)
+{
+    if (!_visible)
+        return 0;
+
+    unsigned int drawCalls = drawBorder(form, clip);
+    drawCalls += drawImages(form, clip);
+    drawCalls += drawText(form, clip);
+    return drawCalls;
+}
+
+unsigned int Control::drawBorder(Form* form, const Rectangle& clip)
+{
+    if (!form || !_skin || _absoluteBounds.width <= 0 || _absoluteBounds.height <= 0)
+        return 0;
+
+    unsigned int drawCalls = 0;
+
+    SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
+    startBatch(form, batch);
 
 
     // Get the border and background images for this control's current state.
     // Get the border and background images for this control's current state.
     const Theme::UVs& topLeft = _skin->getUVs(Theme::Skin::TOP_LEFT);
     const Theme::UVs& topLeft = _skin->getUVs(Theme::Skin::TOP_LEFT);
@@ -1221,65 +1225,72 @@ void Control::drawBorder(SpriteBatch* spriteBatch, const Rectangle& clip)
     if (!border.left && !border.right && !border.top && !border.bottom)
     if (!border.left && !border.right && !border.top && !border.bottom)
     {
     {
         // No border, just draw the image.
         // No border, just draw the image.
-        spriteBatch->draw(_absoluteBounds.x, _absoluteBounds.y, _absoluteBounds.width, _absoluteBounds.height, center.u1, center.v1, center.u2, center.v2, skinColor, clip);
+        batch->draw(_absoluteBounds.x, _absoluteBounds.y, _absoluteBounds.width, _absoluteBounds.height, center.u1, center.v1, center.u2, center.v2, skinColor, clip);
+        ++drawCalls;
     }
     }
     else
     else
     {
     {
         if (border.left && border.top)
         if (border.left && border.top)
-            spriteBatch->draw(_absoluteBounds.x, _absoluteBounds.y, border.left, border.top, topLeft.u1, topLeft.v1, topLeft.u2, topLeft.v2, skinColor, clip);
+        {
+            batch->draw(_absoluteBounds.x, _absoluteBounds.y, border.left, border.top, topLeft.u1, topLeft.v1, topLeft.u2, topLeft.v2, skinColor, clip);
+            ++drawCalls;
+        }
         if (border.top)
         if (border.top)
-            spriteBatch->draw(_absoluteBounds.x + border.left, _absoluteBounds.y, midWidth, border.top, top.u1, top.v1, top.u2, top.v2, skinColor, clip);
+        {
+            batch->draw(_absoluteBounds.x + border.left, _absoluteBounds.y, midWidth, border.top, top.u1, top.v1, top.u2, top.v2, skinColor, clip);
+            ++drawCalls;
+        }
         if (border.right && border.top)
         if (border.right && border.top)
-            spriteBatch->draw(rightX, _absoluteBounds.y, border.right, border.top, topRight.u1, topRight.v1, topRight.u2, topRight.v2, skinColor, clip);
+        {
+            batch->draw(rightX, _absoluteBounds.y, border.right, border.top, topRight.u1, topRight.v1, topRight.u2, topRight.v2, skinColor, clip);
+            ++drawCalls;
+        }
         if (border.left)
         if (border.left)
-            spriteBatch->draw(_absoluteBounds.x, midY, border.left, midHeight, left.u1, left.v1, left.u2, left.v2, skinColor, clip);
+        {
+            batch->draw(_absoluteBounds.x, midY, border.left, midHeight, left.u1, left.v1, left.u2, left.v2, skinColor, clip);
+            ++drawCalls;
+        }
 
 
         // Always draw the background.
         // Always draw the background.
-        spriteBatch->draw(_absoluteBounds.x + border.left, _absoluteBounds.y + border.top, _absoluteBounds.width - border.left - border.right, _absoluteBounds.height - border.top - border.bottom,
+        batch->draw(_absoluteBounds.x + border.left, _absoluteBounds.y + border.top, _absoluteBounds.width - border.left - border.right, _absoluteBounds.height - border.top - border.bottom,
             center.u1, center.v1, center.u2, center.v2, skinColor, clip);
             center.u1, center.v1, center.u2, center.v2, skinColor, clip);
+        ++drawCalls;
 
 
         if (border.right)
         if (border.right)
-            spriteBatch->draw(rightX, midY, border.right, midHeight, right.u1, right.v1, right.u2, right.v2, skinColor, clip);
+        {
+            batch->draw(rightX, midY, border.right, midHeight, right.u1, right.v1, right.u2, right.v2, skinColor, clip);
+            ++drawCalls;
+        }
         if (border.bottom && border.left)
         if (border.bottom && border.left)
-            spriteBatch->draw(_absoluteBounds.x, bottomY, border.left, border.bottom, bottomLeft.u1, bottomLeft.v1, bottomLeft.u2, bottomLeft.v2, skinColor, clip);
+        {
+            batch->draw(_absoluteBounds.x, bottomY, border.left, border.bottom, bottomLeft.u1, bottomLeft.v1, bottomLeft.u2, bottomLeft.v2, skinColor, clip);
+            ++drawCalls;
+        }
         if (border.bottom)
         if (border.bottom)
-            spriteBatch->draw(midX, bottomY, midWidth, border.bottom, bottom.u1, bottom.v1, bottom.u2, bottom.v2, skinColor, clip);
+        {
+            batch->draw(midX, bottomY, midWidth, border.bottom, bottom.u1, bottom.v1, bottom.u2, bottom.v2, skinColor, clip);
+            ++drawCalls;
+        }
         if (border.bottom && border.right)
         if (border.bottom && border.right)
-            spriteBatch->draw(rightX, bottomY, border.right, border.bottom, bottomRight.u1, bottomRight.v1, bottomRight.u2, bottomRight.v2, skinColor, clip);
+        {
+            batch->draw(rightX, bottomY, border.right, border.bottom, bottomRight.u1, bottomRight.v1, bottomRight.u2, bottomRight.v2, skinColor, clip);
+            ++drawCalls;
+        }
     }
     }
-}
 
 
-void Control::drawImages(SpriteBatch* spriteBatch, const Rectangle& position)
-{
+    finishBatch(form, batch);
+
+    return drawCalls;
 }
 }
 
 
-void Control::drawText(const Rectangle& position)
+unsigned int Control::drawImages(Form* form, const Rectangle& position)
 {
 {
+    return 0;
 }
 }
 
 
-void Control::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsClear, bool cleared, float targetHeight)
+unsigned int Control::drawText(Form* form, const Rectangle& position)
 {
 {
-    if (needsClear)
-    {
-        GL_ASSERT( glEnable(GL_SCISSOR_TEST) );
-        GL_ASSERT( glScissor(_clearBounds.x, targetHeight - _clearBounds.y - _clearBounds.height, _clearBounds.width, _clearBounds.height) );
-        Game::getInstance()->clear(Game::CLEAR_COLOR, Vector4::zero(), 1.0f, 0);
-        GL_ASSERT( glDisable(GL_SCISSOR_TEST) );
-    }
-
-    if (!_visible)
-    {
-        _dirty = false;
-        return;
-    }
-
-    spriteBatch->start();
-    drawBorder(spriteBatch, clip);
-    drawImages(spriteBatch, clip);
-    spriteBatch->finish();
-
-    drawText(clip);
-    _dirty = false;
+    return 0;
 }
 }
 
 
 bool Control::isDirty()
 bool Control::isDirty()
@@ -1325,14 +1336,17 @@ Control::State Control::getState(const char* state)
 
 
 Theme::ThemeImage* Control::getImage(const char* id, State state)
 Theme::ThemeImage* Control::getImage(const char* id, State state)
 {
 {
+    Theme::ThemeImage* image = NULL;
+
     Theme::Style::Overlay* overlay = getOverlay(state);
     Theme::Style::Overlay* overlay = getOverlay(state);
-    GP_ASSERT(overlay);
-    
-    Theme::ImageList* imageList = overlay->getImageList();
-    if (!imageList)
-        return NULL;
+    if (overlay)
+    {
+        Theme::ImageList* imageList = overlay->getImageList();
+        if (imageList)
+            image = imageList->getImage(id);
+    }
 
 
-    return imageList->getImage(id);
+    return image ? image : _style->getTheme()->_emptyImage;
 }
 }
 
 
 const char* Control::getType() const
 const char* Control::getType() const

+ 82 - 30
gameplay/src/Control.h

@@ -4,7 +4,6 @@
 #include "Ref.h"
 #include "Ref.h"
 #include "Rectangle.h"
 #include "Rectangle.h"
 #include "Vector2.h"
 #include "Vector2.h"
-#include "SpriteBatch.h"
 #include "Theme.h"
 #include "Theme.h"
 #include "ThemeStyle.h"
 #include "ThemeStyle.h"
 #include "Touch.h"
 #include "Touch.h"
@@ -248,6 +247,13 @@ public:
      */
      */
     const char* getId() const;
     const char* getId() const;
 
 
+	/**
+	 * Sets this control's ID string.
+	 *
+	 * @param id The new control ID.
+	 */
+	void setId(const char* id);
+
     /**
     /**
      * Get the x coordinate of this control.
      * Get the x coordinate of this control.
      *
      *
@@ -840,6 +846,13 @@ public:
      */
      */
     bool getConsumeInputEvents();
     bool getConsumeInputEvents();
 
 
+    /**
+     * Get this control's style.
+     *
+     * @return This control's style.
+     */
+    Theme::Style* getStyle() const;
+
     /**
     /**
      * Set the style this control will use when rendering.
      * Set the style this control will use when rendering.
      *
      *
@@ -848,11 +861,9 @@ public:
     void setStyle(Theme::Style* style);
     void setStyle(Theme::Style* style);
 
 
     /**
     /**
-     * Get this control's style.
-     *
-     * @return This control's style.
+     * Returns the theme for this control.
      */
      */
-    Theme::Style* getStyle() const;
+    Theme* getTheme() const;
 
 
     /**
     /**
      * Get this control's z-index.
      * Get this control's z-index.
@@ -1081,47 +1092,93 @@ protected:
      */
      */
     virtual void update(const Control* container, const Vector2& offset);
     virtual void update(const Control* container, const Vector2& offset);
 
 
+    /**
+     * Indicates that a control will begin drawing into the specified batch.
+     *
+     * When drawing is finshed (before any other batch can be drawn into), the
+     * finishBatch method should be called.
+     *
+     * @param form The form beign drawn.
+     * @param batch The sprite batch to be drawn into.
+     */
+    void startBatch(Form* form, SpriteBatch* batch);
+
+    /**
+     * Called after a batch has been drawn into and before any other batch is used.
+     *
+     * @param form The form being drawn.
+     * @param batch The batch that was previously started (via Control::startBatch).
+     */
+    void finishBatch(Form* form, SpriteBatch* batch);
+
+    /**
+     * Draws the control.
+     *
+     * Implementations of Control are expected to perform all drawing into a SpriteBatch.
+     * Batches should not be explicitly started or finished, but instead should be passed
+     * to Control::prepare(Form*, SpriteBatch*). This will handle automatically starting
+     * and finishing the batch when neccessary.
+     *
+     * @param form The top level form being drawn.
+     * @param clip The clipping rectangle.
+     *
+     * @return The number of draw calls issued.
+     */
+    virtual unsigned int draw(Form* form, const Rectangle& clip);
+
     /**
     /**
      * Draws the themed border and background of a control.
      * Draws the themed border and background of a control.
      *
      *
-     * @param spriteBatch The sprite batch containing this control's border images.
+     * Implementations of Control are expected to perform all drawing into a SpriteBatch.
+     * Batches should not be explicitly started or finished, but instead should be passed
+     * to Control::prepare(Form*, SpriteBatch*). This will handle automatically starting
+     * and finishing the batch when neccessary.
+     *
+     * @param form The top level form being drawn.
      * @param clip The clipping rectangle of this control's parent container.
      * @param clip The clipping rectangle of this control's parent container.
+     *
+     * @return The number of draw calls issued.
      */
      */
-    virtual void drawBorder(SpriteBatch* spriteBatch, const Rectangle& clip);
+    virtual unsigned int drawBorder(Form* form, const Rectangle& clip);
 
 
     /**
     /**
      * Draw the images associated with this control.
      * Draw the images associated with this control.
      *
      *
-     * @param spriteBatch The sprite batch containing this control's icons.
+     * Implementations of Control are expected to perform all drawing into a SpriteBatch.
+     * Batches should not be explicitly started or finished, but instead should be passed
+     * to Control::prepare(Form*, SpriteBatch*). This will handle automatically starting
+     * and finishing the batch when neccessary.
+     *
+     * @param form The top level form being drawn.
      * @param clip The clipping rectangle of this control's parent container.
      * @param clip The clipping rectangle of this control's parent container.
+     *
+     * @return The number of draw calls issued.
      */
      */
-    virtual void drawImages(SpriteBatch* spriteBatch, const Rectangle& clip);
+    virtual unsigned int drawImages(Form* form, const Rectangle& clip);
 
 
     /**
     /**
      * Draw this control's text.
      * Draw this control's text.
      *
      *
+     * Implementations of Control are expected to perform all drawing into a SpriteBatch.
+     * Batches should not be explicitly started or finished, but instead should be passed
+     * to Control::prepare(Form*, SpriteBatch*). This will handle automatically starting
+     * and finishing the batch when neccessary.
+     *
+     * @param form The top level form being drawn.
      * @param clip The clipping rectangle of this control's parent container.
      * @param clip The clipping rectangle of this control's parent container.
-     */
-    virtual void drawText(const Rectangle& clip);
-
-    /**
-     * Draws a sprite batch for the specified clipping rect.
      *
      *
-     * @param spriteBatch The sprite batch to use.
-     * @param clip The clipping rectangle.
-     * @param needsClear Whether it needs to be cleared.
-     * @param cleared Whether it was previously cleared
-     * @param targetHeight The targets height
+     * @return The number of draw calls issued.
      */
      */
-    virtual void draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsClear, bool cleared, float targetHeight);
+    virtual unsigned int drawText(Form* form, const Rectangle& clip);
 
 
     /**
     /**
-     * Initialize properties common to all Controls from a Properties object.
+     * Initializes the control.
      *
      *
-     * @param style The style to apply to this control.
-     * @param properties The properties to set on this control.
+     * @param typeName The type name of the control being initalized.
+     * @param style The style to apply to this control (optional).
+     * @param properties The properties to set on this control (optional).
      */
      */
-    virtual void initialize(Theme::Style* style, Properties* properties);
+    virtual void initialize(const char* typeName, Theme::Style* style, Properties* properties);
 
 
     /**
     /**
      * Returns whether this control has been modified and requires an update.
      * Returns whether this control has been modified and requires an update.
@@ -1222,11 +1279,6 @@ protected:
      */
      */
     Rectangle _viewportClipBounds;
     Rectangle _viewportClipBounds;
 
 
-    /**
-     * Previous frame's absolute clip bounds, to be cleared if necessary.
-     */
-    Rectangle _clearBounds;         
-
     /**
     /**
      * If the control is dirty and need updating.
      * If the control is dirty and need updating.
      */
      */
@@ -1327,7 +1379,7 @@ private:
     Theme::Skin* getSkin(State state);
     Theme::Skin* getSkin(State state);
 
 
     void addSpecificListener(Control::Listener* listener, Control::Listener::EventType eventType);
     void addSpecificListener(Control::Listener* listener, Control::Listener::EventType eventType);
-    
+
     bool _styleOverridden;
     bool _styleOverridden;
     Theme::Skin* _skin;
     Theme::Skin* _skin;
 
 

+ 28 - 20
gameplay/src/ControlFactory.cpp

@@ -10,13 +10,11 @@
 #include "Joystick.h"
 #include "Joystick.h"
 #include "ImageControl.h"
 #include "ImageControl.h"
 
 
-
-namespace gameplay 
+namespace gameplay
 {
 {
 
 
 static ControlFactory* __controlFactory = NULL;
 static ControlFactory* __controlFactory = NULL;
 
 
-
 ControlFactory::ControlFactory() 
 ControlFactory::ControlFactory() 
 {
 {
 	registerStandardControls();
 	registerStandardControls();
@@ -42,43 +40,53 @@ ControlFactory* ControlFactory::getInstance()
 	return __controlFactory;
 	return __controlFactory;
 }
 }
 
 
-bool ControlFactory::registerCustomControl(const char* name, ControlActivator activator)
+bool ControlFactory::registerCustomControl(const char* typeName, ControlActivator activator)
 {
 {
-	if (_registeredControls.find(name) != _registeredControls.end())
+    std::string upper(typeName);
+    std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper);
+
+	if (_registeredControls.find(upper) != _registeredControls.end())
 		return false;
 		return false;
 
 
-	_registeredControls[name] = activator;
+	_registeredControls[upper] = activator;
 	return true;
 	return true;
 }
 }
 
 
-void ControlFactory::unregisterCustomControl(const char* controlName)
+void ControlFactory::unregisterCustomControl(const char* typeName)
 {
 {
+    std::string upper(typeName);
+    std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper);
+
 	std::map<std::string, ControlActivator>::iterator it;
 	std::map<std::string, ControlActivator>::iterator it;
-	if ((it = _registeredControls.find(controlName)) != _registeredControls.end())
+	if ((it = _registeredControls.find(upper)) != _registeredControls.end())
 	{
 	{
 		_registeredControls.erase(it);
 		_registeredControls.erase(it);
 	}
 	}
 }
 }
 
 
-Control *ControlFactory::createControl(const char* controlName, Theme::Style* style, Properties* properties)
+Control *ControlFactory::createControl(const char* typeName, Theme::Style* style, Properties* properties)
 {
 {
-	if (_registeredControls.find(controlName) == _registeredControls.end())
+    std::string upper(typeName);
+    std::transform(upper.begin(), upper.end(), upper.begin(), (int(*)(int))toupper);
+
+    std::map<std::string, ControlActivator>::iterator it = _registeredControls.find(upper);
+    if (it == _registeredControls.end())
 		return NULL;
 		return NULL;
 
 
-	return (*_registeredControls[controlName])(style, properties);
+    return (*it->second)(style, properties);
 }
 }
 
 
 void ControlFactory::registerStandardControls() 
 void ControlFactory::registerStandardControls() 
 {
 {
-	_registeredControls["LABEL"] = &Label::create;
-	_registeredControls["BUTTON"] = &Button::create;
-	_registeredControls["CHECKBOX"] = &CheckBox::create;
-	_registeredControls["RADIOBUTTON"] = &RadioButton::create;
-	_registeredControls["CONTAINER"] = &Container::create;
-	_registeredControls["SLIDER"] = &Slider::create;
-	_registeredControls["TEXTBOX"] = &TextBox::create;
-	_registeredControls["JOYSTICK"] = &Joystick::create;
-	_registeredControls["IMAGE"] = &ImageControl::create;
+    registerCustomControl("LABEL", &Label::create);
+    registerCustomControl("BUTTON", &Button::create);
+    registerCustomControl("CHECKBOX", &CheckBox::create);
+    registerCustomControl("RADIOBUTTON", &RadioButton::create);
+    registerCustomControl("CONTAINER", &Container::create);
+    registerCustomControl("SLIDER", &Slider::create);
+    registerCustomControl("TEXTBOX", &TextBox::create);
+    registerCustomControl("JOYSTICK", &Joystick::create);
+    registerCustomControl("IMAGE", &ImageControl::create);
 }
 }
 
 
 }
 }

+ 22 - 22
gameplay/src/ControlFactory.h

@@ -1,7 +1,7 @@
 #ifndef	CONTROLFACTORY_H_
 #ifndef	CONTROLFACTORY_H_
 #define	CONTROLFACTORY_H_
 #define	CONTROLFACTORY_H_
 
 
-#include "ThemeStyle.h"
+#include "Theme.h"
 
 
 namespace gameplay 
 namespace gameplay 
 {	
 {	
@@ -17,6 +17,7 @@ class Control;
 class ControlFactory 
 class ControlFactory 
 {
 {
     friend class Game;
     friend class Game;
+	friend class Container;
 
 
 public:
 public:
 
 
@@ -35,29 +36,19 @@ public:
 	/**
 	/**
 	 * Registers a custom control and specify the activator.
 	 * Registers a custom control and specify the activator.
 	 *
 	 *
-	 * @param controlName The name of the custom control to register.
-	 * @param activator The activator for applying the style and properties to the control.
+	 * @param typeName The name of the custom control type to register.
+	 * @param activator The activator for applying the style, properties and theme to the control.
 	 *
 	 *
 	 * @return true if the control was successfully registered.
 	 * @return true if the control was successfully registered.
 	 */
 	 */
-	bool registerCustomControl(const char* controlName, ControlActivator activator);
+    bool registerCustomControl(const char* typeName, ControlActivator activator);
 
 
 	/**
 	/**
 	 * Unregisters a custom control and specify the activator.
 	 * Unregisters a custom control and specify the activator.
 	 *
 	 *
-	 * @param controlName The name of the custom control to unregister.
+	 * @param typeName The name of the custom control type to unregister.
 	 */
 	 */
-	void unregisterCustomControl(const char* controlName);
-
-	/**
-	 * Creates a controls from the set of core and custom controls registered.
-	 *
-	 * @param controlName The name of the control to create.
-     * @param style The style to apply to the control.
-     * @param properties The Properties object containing the definition of the controlo.
-     * @return The newly created control.
-	 */
-	Control* createControl(const char* controlName, Theme::Style *style, Properties *properties);
+    void unregisterCustomControl(const char* typeName);
 
 
 private:
 private:
 
 
@@ -65,8 +56,8 @@ private:
 	 * Constructor.
 	 * Constructor.
 	 */
 	 */
 	ControlFactory();
 	ControlFactory();
-		
-	/**
+
+    /**
 	 * Constructor.
 	 * Constructor.
 	 */
 	 */
 	ControlFactory(const ControlFactory& copy);
 	ControlFactory(const ControlFactory& copy);
@@ -77,16 +68,26 @@ private:
 	~ControlFactory();
 	~ControlFactory();
 
 
     /**
     /**
-    * Called when the game is shutting down to clean up resources.
-    */
+     * Cleans up resources allocated by the ControlFactory.
+     */
     static void finalize();
     static void finalize();
 
 
 	/**
 	/**
 	 * Assignment operator
 	 * Assignment operator
 	 */
 	 */
 	ControlFactory &operator=(const ControlFactory&);
 	ControlFactory &operator=(const ControlFactory&);
-	
+
 	/**
 	/**
+	* Creates a controls from the set of core and custom controls registered.
+	*
+	* @param typeName The type of the control to create.
+	* @param style The style to apply to the control.
+	* @param properties A Properties object describing the control (optional).
+	* @return The new control.
+	*/
+    Control* createControl(const char* typeName, Theme::Style *style, Properties *properties = NULL);
+
+    /**
 	 * Registers the standard (built-in) controls
 	 * Registers the standard (built-in) controls
 	 */
 	 */
 	void registerStandardControls();
 	void registerStandardControls();
@@ -97,4 +98,3 @@ private:
 }
 }
 
 
 #endif
 #endif
-

+ 7 - 0
gameplay/src/Font.cpp

@@ -676,6 +676,13 @@ void Font::drawText(const char* text, const Rectangle& area, const Vector4& colo
                     // Draw this character.
                     // Draw this character.
                     if (draw)
                     if (draw)
                     {
                     {
+                        if (getFormat() == DISTANCE_FIELD)
+                        {
+                            if (_cutoffParam == NULL)
+                                _cutoffParam = getSpriteBatch()->getMaterial()->getParameter("u_cutoff");
+                            // TODO: Fix me so that smaller font are much smoother
+                            _cutoffParam->setVector2(Vector2(1.0, 1.0));
+                        }
                         if (clip)
                         if (clip)
                         {
                         {
                             _batch->draw(xPos, yPos, g.width * scale, size, g.uvs[0], g.uvs[1], g.uvs[2], g.uvs[3], color, *clip);
                             _batch->draw(xPos, yPos, g.width * scale, size, g.uvs[0], g.uvs[1], g.uvs[2], g.uvs[3], color, *clip);

+ 254 - 303
gameplay/src/Form.cpp

@@ -10,10 +10,6 @@
 #include "CheckBox.h"
 #include "CheckBox.h"
 #include "Scene.h"
 #include "Scene.h"
 
 
-// Default form shaders
-#define FORM_VSH "res/shaders/form.vert"
-#define FORM_FSH "res/shaders/form.frag"
-
 // Scroll speed when using a DPad -- max scroll speed when using a joystick.
 // Scroll speed when using a DPad -- max scroll speed when using a joystick.
 static const float GAMEPAD_SCROLL_SPEED = 500.0f;
 static const float GAMEPAD_SCROLL_SPEED = 500.0f;
 // Distance a joystick must be pushed in order to trigger focus-change and/or scrolling.
 // Distance a joystick must be pushed in order to trigger focus-change and/or scrolling.
@@ -21,35 +17,29 @@ static const float JOYSTICK_THRESHOLD = 0.75f;
 // If the DPad or joystick is held down, this is the initial delay in milliseconds between focus changes.
 // If the DPad or joystick is held down, this is the initial delay in milliseconds between focus changes.
 static const float GAMEPAD_FOCUS_REPEAT_DELAY = 300.0f;
 static const float GAMEPAD_FOCUS_REPEAT_DELAY = 300.0f;
 
 
+// Shaders used for drawing offscreen quad when form is attached to a node
+#define FORM_VSH "res/shaders/sprite.vert"
+#define FORM_FSH "res/shaders/sprite.frag"
+
+//#define GAMEPLAY_FORMS_USE_FRAMEBUFFER
+
 namespace gameplay
 namespace gameplay
 {
 {
 
 
-static Effect* __formEffect = NULL;
 static std::vector<Form*> __forms;
 static std::vector<Form*> __forms;
 Control* Form::_focusControl = NULL;
 Control* Form::_focusControl = NULL;
 Control* Form::_activeControl = NULL;
 Control* Form::_activeControl = NULL;
 Control::State Form::_activeControlState = Control::NORMAL;
 Control::State Form::_activeControlState = Control::NORMAL;
 static bool _shiftKeyDown = false;
 static bool _shiftKeyDown = false;
 
 
-Form::Form() : _theme(NULL), _frameBuffer(NULL), _spriteBatch(NULL), _node(NULL),
-    _nodeQuad(NULL), _nodeMaterial(NULL) , _u2(0), _v1(0)
+Form::Form() : _node(NULL), _frameBuffer(NULL), _model(NULL), _batched(true)
 {
 {
 }
 }
 
 
 Form::~Form()
 Form::~Form()
 {
 {
-    SAFE_DELETE(_spriteBatch);
+    SAFE_RELEASE(_model);
     SAFE_RELEASE(_frameBuffer);
     SAFE_RELEASE(_frameBuffer);
-    SAFE_RELEASE(_theme);
-
-    if (__formEffect)
-    {
-        if (__formEffect->getRefCount() == 1)
-        {
-            __formEffect->release();
-            __formEffect = NULL;
-        }
-    }
 
 
     // Remove this Form from the global list.
     // Remove this Form from the global list.
     std::vector<Form*>::iterator it = std::find(__forms.begin(), __forms.end(), this);
     std::vector<Form*>::iterator it = std::find(__forms.begin(), __forms.end(), this);
@@ -59,86 +49,76 @@ Form::~Form()
     }
     }
 }
 }
 
 
-Form* Form::create(const char* id, Theme::Style* style, Layout::Type layoutType)
+Form* Form::create(const char* url)
 {
 {
-    GP_ASSERT(style);
-
-    Layout* layout;
-    switch (layoutType)
-    {
-    case Layout::LAYOUT_ABSOLUTE:
-        layout = AbsoluteLayout::create();
-        break;
-    case Layout::LAYOUT_FLOW:
-        layout = FlowLayout::create();
-        break;
-    case Layout::LAYOUT_VERTICAL:
-        layout = VerticalLayout::create();
-        break;
-    default:
-        GP_ERROR("Unsupported layout type '%d'.", layoutType);
-        break;
-    }
-
     Form* form = new Form();
     Form* form = new Form();
-    if (id)
-        form->_id = id;
-    form->_style = style;
-    form->_layout = layout;
-    form->_theme = style->getTheme();
-    form->_theme->addRef();
-
-    form->updateFrameBuffer();
-
-    __forms.push_back(form);
 
 
-    return form;
-}
-
-Form* Form::create(const char* url)
-{
     // Load Form from .form file.
     // Load Form from .form file.
     Properties* properties = Properties::create(url);
     Properties* properties = Properties::create(url);
-    if (properties == NULL)
+    Properties* formProperties = NULL;
+    if (properties)
     {
     {
-        GP_ASSERT(properties);
-        return NULL;
+        // Check if the Properties is valid and has a valid namespace.
+        formProperties = (strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace();
+        if (!formProperties || !(strcmpnocase(formProperties->getNamespace(), "form") == 0))
+        {
+            GP_WARN("Invalid properties file for form: %s", url);
+            SAFE_DELETE(properties);
+        }
+    }
+    if (!properties)
+    {
+        GP_WARN("Failed to load properties file for Form.");
     }
     }
 
 
-    // Check if the Properties is valid and has a valid namespace.
-    Properties* formProperties = (strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace();
-    assert(formProperties);
-    if (!formProperties || !(strcmp(formProperties->getNamespace(), "form") == 0))
+    // Load the form's theme style.
+    Theme* theme = NULL;
+    Theme::Style* style = NULL;
+    if (formProperties->exists("theme"))
     {
     {
-        GP_ASSERT(formProperties);
-        SAFE_DELETE(properties);
-        return NULL;
+        std::string themeFile;
+        if (formProperties->getPath("theme", &themeFile))
+        {
+            theme = Theme::create(themeFile.c_str());
+            if (theme)
+            {
+                // Load the form's style
+                const char* styleName = formProperties->getString("style", "Form");
+                style = theme->getStyle(styleName);
+                if (!style)
+                    style = theme->getEmptyStyle();
+            }
+        }
     }
     }
 
 
-    // Parse theme
-    std::string themeFile;
-    formProperties->getPath("theme", &themeFile);
-    Theme* theme = Theme::create(themeFile.c_str());
-    GP_ASSERT(theme);
+    form->_batched = formProperties->getBool("batchingEnabled", true);
 
 
-    // Parse style
-    const char* styleName = formProperties->getString("style");
-    Theme::Style* style = styleName ? theme->getStyle(styleName) : theme->getEmptyStyle();
+    // Initialize the form and all of its child controls
+    form->initialize("Form", style, formProperties);
 
 
-    // Create new form
-    Form* form = new Form();
-    form->_theme = theme;
+    // Release the theme: its lifetime is controlled by addRef() and release() calls
+    // in initialize (above) and ~Control.
+    SAFE_RELEASE(theme);
 
 
-    // Initialize common container properties
-    form->initialize(style, formProperties);
+    SAFE_DELETE(properties);
 
 
-    form->updateFrameBuffer();
+    return form;
+}
 
 
-    __forms.push_back(form);
+Form* Form::create(const char* id, Theme::Style* style, Layout::Type layoutType)
+{
+	Form* form = new Form();
+	form->_id = id ? id : "";
+	form->_layout = createLayout(layoutType);
+	form->initialize("Form", style, NULL);
+	return form;
+}
 
 
-    SAFE_DELETE(properties);
+void Form::initialize(const char* typeName, Theme::Style* style, Properties* properties)
+{
+    Container::initialize(typeName, style, properties);
 
 
-    return form;
+    __forms.push_back(this);
 }
 }
 
 
 Form* Form::getForm(const char* id)
 Form* Form::getForm(const char* id)
@@ -170,171 +150,108 @@ bool Form::isForm() const
     return true;
     return true;
 }
 }
 
 
-Theme* Form::getTheme() const
-{
-    return _theme;
-}
-
-void Form::updateFrameBuffer()
+void Form::setNode(Node* node)
 {
 {
-    float width = _absoluteClipBounds.width;
-    float height = _absoluteClipBounds.height;
-
-    SAFE_RELEASE(_frameBuffer);
-    SAFE_DELETE(_spriteBatch);
-
-    if (width != 0.0f && height != 0.0f)
+    if (_node != node)
     {
     {
-        // Width and height must be powers of two to create a texture.
-        unsigned int w = nextPowerOfTwo(width);
-        unsigned int h = nextPowerOfTwo(height);
-        _u2 = width / (float)w;
-        _v1 = height / (float)h;
-        
-        _frameBuffer = FrameBuffer::create(_id.c_str(), w, h);
-        GP_ASSERT(_frameBuffer);
-
-        // Re-create projection matrix for drawing onto framebuffer
-        Matrix::createOrthographicOffCenter(0, width, height, 0, 0, 1, &_projectionMatrix);
-
-        // Re-create sprite batch
-        _spriteBatch = SpriteBatch::create(_frameBuffer->getRenderTarget()->getTexture());
-        GP_ASSERT(_spriteBatch);
-
-        // Compute full-viewport ortho matrix for drawing frame buffer onto screen
-        Matrix viewportProjection;
-        Matrix::createOrthographicOffCenter(0, Game::getInstance()->getViewport().width, Game::getInstance()->getViewport().height, 0, 0, 1, &viewportProjection);
-        _spriteBatch->setProjectionMatrix(viewportProjection);
-
-        // Clear the framebuffer black
-        Game* game = Game::getInstance();
-        FrameBuffer* previousFrameBuffer = _frameBuffer->bind();
-        Rectangle previousViewport = game->getViewport();
-
-        game->setViewport(Rectangle(0, 0, width, height));
-        _theme->setProjectionMatrix(_projectionMatrix);
-        game->clear(Game::CLEAR_COLOR, Vector4::zero(), 1.0, 0);
-
-        previousFrameBuffer->bind();
-        game->setViewport(previousViewport);
-
-        // Force any attached node to be updated
-        setNode(_node);
+        _node = node;
+
+        updateFrameBuffer();
     }
     }
 }
 }
 
 
-static Effect* createEffect()
+static unsigned int nextPowerOfTwo(unsigned int v)
 {
 {
-    Effect* effect = NULL;
-    if (__formEffect == NULL)
-    {
-        __formEffect = Effect::createFromFile(FORM_VSH, FORM_FSH);
-        if (__formEffect == NULL)
-        {
-            GP_ERROR("Unable to load form effect.");
-            return NULL;
-        }
-        effect = __formEffect;
-    }
-    else
+    if (!((v & (v - 1)) == 0))
     {
     {
-        effect = __formEffect;
+        v--;
+        v |= v >> 1;
+        v |= v >> 2;
+        v |= v >> 4;
+        v |= v >> 8;
+        v |= v >> 16;
+        return v + 1;
     }
     }
-    return effect;
+
+    return v;
 }
 }
 
 
-void Form::setNode(Node* node)
+void Form::updateFrameBuffer()
 {
 {
-    // If we were already attached to a node, remove ourself from it
-    if (_node)
-    {
-        _node->setModel(NULL);
-        _nodeQuad = NULL;
-        _nodeMaterial = NULL;
-        _node = NULL;
-    }
+    SAFE_RELEASE(_model);
+    SAFE_RELEASE(_frameBuffer);
+
+#ifdef GAMEPLAY_FORMS_USE_FRAMEBUFFER
 
 
-    if (node)
+    if (_node && _absoluteClipBounds.width > 0 && _absoluteClipBounds.height > 0)
     {
     {
-        // Set this Form up to be 3D by initializing a quad.
-        float x2 = _absoluteBounds.width;
-        float y2 = _absoluteBounds.height;
+        // Create an offscreen buffer to draw our form into
+        unsigned int width = nextPowerOfTwo(_absoluteClipBounds.width);
+        unsigned int height = nextPowerOfTwo(_absoluteClipBounds.height);
+
+        _frameBuffer = FrameBuffer::create(_id.c_str(), width, height);
+
+        // Create a model (quad) to draw our offscreen buffer onto
+        float x2 = _absoluteClipBounds.width;
+        float y2 = _absoluteClipBounds.height;
+        float u2 = x2 / width;
+        float v1 = y2 / height;
         float vertices[] =
         float vertices[] =
         {
         {
-            0, y2, 0,   0, _v1,
-            0, 0, 0,    0, 0,
-            x2, y2, 0,  _u2, _v1,
-            x2, 0, 0,   _u2, 0
+            0, y2, 0, 0, v1, 1, 1, 1, 1,
+            0, 0, 0, 0, 0, 1, 1, 1, 1,
+            x2, y2, 0, u2, v1, 1, 1, 1, 1,
+            x2, 0, 0, u2, 0, 1, 1, 1, 1
         };
         };
         VertexFormat::Element elements[] =
         VertexFormat::Element elements[] =
         {
         {
             VertexFormat::Element(VertexFormat::POSITION, 3),
             VertexFormat::Element(VertexFormat::POSITION, 3),
-            VertexFormat::Element(VertexFormat::TEXCOORD0, 2)
+            VertexFormat::Element(VertexFormat::TEXCOORD0, 2),
+            VertexFormat::Element(VertexFormat::COLOR, 4)
         };
         };
-        Mesh* mesh = Mesh::createMesh(VertexFormat(elements, 2), 4, false);
+        Mesh* mesh = Mesh::createMesh(VertexFormat(elements, 3), 4, false);
         GP_ASSERT(mesh);
         GP_ASSERT(mesh);
         mesh->setPrimitiveType(Mesh::TRIANGLE_STRIP);
         mesh->setPrimitiveType(Mesh::TRIANGLE_STRIP);
         mesh->setVertexData(vertices, 0, 4);
         mesh->setVertexData(vertices, 0, 4);
 
 
-        _nodeQuad = Model::create(mesh);
+        _model = Model::create(mesh);
         SAFE_RELEASE(mesh);
         SAFE_RELEASE(mesh);
-        GP_ASSERT(_nodeQuad);
-
-        // Create the effect and material
-        Effect* effect = createEffect();
-        GP_ASSERT(effect);
-        _nodeMaterial = Material::create(effect);
 
 
-        GP_ASSERT(_nodeMaterial);
-        _nodeQuad->setMaterial(_nodeMaterial);
-        _nodeMaterial->release();
-        node->setModel(_nodeQuad);
-        _nodeQuad->release();
+        Material* material = _model->setMaterial(FORM_VSH, FORM_FSH);
+        material->getParameter("u_projectionMatrix")->bindValue(this, &Form::getProjectionMatrix);
 
 
-        // Bind the WorldViewProjection matrix.
-        _nodeMaterial->setParameterAutoBinding("u_worldViewProjectionMatrix", RenderState::WORLD_VIEW_PROJECTION_MATRIX);
-
-        // Bind the texture from the framebuffer and set the texture to clamp
-        if (_frameBuffer)
-        {
-            Texture::Sampler* sampler = Texture::Sampler::create(_frameBuffer->getRenderTarget()->getTexture());
-            GP_ASSERT(sampler);
-            sampler->setWrapMode(Texture::CLAMP, Texture::CLAMP);
-            _nodeMaterial->getParameter("u_texture")->setValue(sampler);
-            sampler->release();
-        }
+        Texture::Sampler* sampler = Texture::Sampler::create(_frameBuffer->getRenderTarget()->getTexture());
+        sampler->setWrapMode(Texture::CLAMP, Texture::CLAMP);
+        material->getParameter("u_texture")->setSampler(sampler);
+        sampler->release();
 
 
-        RenderState::StateBlock* rsBlock = _nodeMaterial->getStateBlock();
-        rsBlock->setDepthWrite(true);
-        rsBlock->setBlend(true);
-        rsBlock->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
-        rsBlock->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
+        material->getStateBlock()->setDepthWrite(true);
+        material->getStateBlock()->setBlend(true);
+        material->getStateBlock()->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
+        material->getStateBlock()->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
     }
     }
 
 
-    _node = node;
+#endif
 }
 }
 
 
 void Form::update(float elapsedTime)
 void Form::update(float elapsedTime)
 {
 {
-    if (isDirty())
-    {
-        update(NULL, Vector2::zero());
+    update(NULL, Vector2::zero());
 
 
-        Control::State state = getState();
+    Control::State state = getState();
 
 
-        // Cache themed attributes for performance.
-        _skin = getSkin(state);
-        _opacity = getOpacity(state);
+    // Cache themed attributes for performance.
+    _skin = getSkin(state);
+    _opacity = getOpacity(state);
 
 
-        GP_ASSERT(_layout);
-        if (_scroll != SCROLL_NONE)
-        {
-            updateScroll();
-        }
-        else
-        {
-            _layout->update(this, Vector2::zero());
-        }
+    GP_ASSERT(_layout);
+    if (_scroll != SCROLL_NONE)
+    {
+        updateScroll();
+    }
+    else
+    {
+        _layout->update(this, Vector2::zero());
     }
     }
 }
 }
 
 
@@ -347,63 +264,112 @@ void Form::update(const Control* container, const Vector2& offset)
 
 
     _layout->align(this, NULL);
     _layout->align(this, NULL);
 
 
-    if (_absoluteClipBounds.width != oldAbsoluteClipBounds.width || _absoluteClipBounds.height != oldAbsoluteClipBounds.height)
+    if (_absoluteClipBounds != oldAbsoluteClipBounds)
     {
     {
-        updateFrameBuffer();
+        if (_node)
+            updateFrameBuffer();
+    }
+}
+
+void Form::startBatch(SpriteBatch* batch)
+{
+    // TODO (note: might want to pass a level number/depth here so that batch draw calls can be sorted correctly, such as all text on top)
+    if (!batch->isStarted())
+    {
+        batch->setProjectionMatrix(_projectionMatrix);
+        batch->start();
+
+        if (_batched)
+            _batches.push_back(batch);
     }
     }
 }
 }
 
 
+void Form::finishBatch(SpriteBatch* batch)
+{
+    if (!_batched)
+    {
+        batch->finish();
+    }
+}
+
+const Matrix& Form::getProjectionMatrix() const
+{
+    return  _projectionMatrix;
+}
+
 unsigned int Form::draw()
 unsigned int Form::draw()
 {
 {
-    if (!_visible || !_frameBuffer)
+    if (!_visible || _absoluteClipBounds.width == 0 || _absoluteClipBounds.height == 0)
         return 0;
         return 0;
 
 
-    // The first time a form is drawn, its contents are rendered into a framebuffer.
-    // The framebuffer will only be drawn into again when the contents of the form change.
-    // If this form has a node then it's a 3D form and the framebuffer will be used
-    // to texture a quad.  The quad will be given the same dimensions as the form and
-    // must be transformed appropriately by the user, unless they call setQuad() themselves.
-    // On the other hand, if this form has not been set on a node, SpriteBatch will be used
-    // to render the contents of the framebuffer directly to the display.
+    Game* game = Game::getInstance();
+    Rectangle viewport = game->getViewport();
 
 
-    // Check whether this form has changed since the last call to draw() and if so, render into the framebuffer.
-    if (isDirty())
+    FrameBuffer* oldFrameBuffer = NULL;
+    if (_frameBuffer)
     {
     {
-        FrameBuffer* previousFrameBuffer = _frameBuffer->bind();
-
-        Game* game = Game::getInstance();
-        Rectangle prevViewport = game->getViewport();
+        // Update the viewport
         game->setViewport(Rectangle(0, 0, _absoluteClipBounds.width, _absoluteClipBounds.height));
         game->setViewport(Rectangle(0, 0, _absoluteClipBounds.width, _absoluteClipBounds.height));
 
 
-        GP_ASSERT(_theme);
-        _theme->setProjectionMatrix(_projectionMatrix);
+        // Bind the offscreen buffer and clear its color and depth.
+        oldFrameBuffer = _frameBuffer->bind();
+        Game::getInstance()->clear(Game::CLEAR_COLOR_DEPTH, Vector4::zero(), 1, 0);
 
 
-        // By setting needsClear to true here, an optimization meant to clear and redraw only areas of the form
-        // that have changed is disabled.  Currently, repositioning controls can result in areas of the screen being cleared
-        // after another control has been drawn there.  This should probably be done in two passes -- one to clear areas where
-        // dirty controls were last frame, and another to draw them where they are now.
-        Container::draw(_theme->getSpriteBatch(), _absoluteClipBounds, /*_skin != NULL*/ true, false, _absoluteClipBounds.height);
+        // Setup an ortho matrix the maps to the size of the form
+        Matrix::createOrthographicOffCenter(0, _absoluteClipBounds.width, _absoluteClipBounds.height, 0, 0, 1, &_projectionMatrix);
+    }
+    else
+    {
+        // If we're drawing in 2D (i.e. not attached to a node), we need to clear the depth buffer
+        if (_node)
+        {
+            // Drawing in 3D.
+            // Setup a projection matrix for drawing the form via the node's world transform.
+            Matrix world(_node->getWorldMatrix());
+            world.scale(1, -1, 1);
+            world.translate(0, -_absoluteClipBounds.height, 0);
+            Matrix::multiply(_node->getViewProjectionMatrix(), world, &_projectionMatrix);
+        }
+        else
+        {
+            // Drawing in 2D, so we need to clear the depth buffer
+            Game::getInstance()->clear(Game::CLEAR_DEPTH, Vector4::zero(), 1, 0);
 
 
-        // Restore the previous game viewport.
-        game->setViewport(prevViewport);
-        // Rebind the previous framebuffer and game viewport.
-        previousFrameBuffer->bind();
+            // Setup an ortho matrix that maps to the current viewport
+            const Rectangle& viewport = Game::getInstance()->getViewport();
+            Matrix::createOrthographicOffCenter(0, viewport.width, viewport.height, 0, 0, 1, &_projectionMatrix);
+        }
     }
     }
 
 
-    // Draw either with a 3D quad or sprite batch.
-    if (_node)
+    // Draw the form
+    unsigned int drawCalls = Container::draw(this, _absoluteClipBounds);
+
+    // Flush all batches that were queued during drawing and then empty the batch list
+    if (_batched)
     {
     {
-         // If we have the node set, then draw a 3D quad model.
-        _nodeQuad->draw();
+        unsigned int batchCount = _batches.size();
+        for (unsigned int i = 0; i < batchCount; ++i)
+            _batches[i]->finish();
+        _batches.clear();
+        drawCalls = batchCount;
     }
     }
-    else
+
+    // If the form was drawn into an offscreen buffer, we need to now draw that buffer
+    // using the WVP matrix of the node we're attached to.
+    if (oldFrameBuffer)
     {
     {
-        // Otherwise we draw the framebuffer in ortho space with a spritebatch.
-        _spriteBatch->start();
-        _spriteBatch->draw(_bounds.x, _bounds.y, 0, _bounds.width, _bounds.height, 0, _v1, _u2, 0, Vector4::one());
-        _spriteBatch->finish();
+        game->setViewport(viewport);
+        oldFrameBuffer->bind();
+
+        if (_model)
+        {
+            _projectionMatrix = _node->getWorldViewProjectionMatrix();
+            _model->draw();
+            ++drawCalls;
+        }
     }
     }
-    return 2;
+
+    return drawCalls;
 }
 }
 
 
 const char* Form::getType() const
 const char* Form::getType() const
@@ -411,6 +377,17 @@ const char* Form::getType() const
     return "form";
     return "form";
 }
 }
 
 
+
+bool Form::isBatchingEnabled() const
+{
+    return _batched;
+}
+
+void Form::setBatchingEnabled(bool enabled)
+{
+    _batched = enabled;
+}
+
 Control* Form::getActiveControl()
 Control* Form::getActiveControl()
 {
 {
     return _activeControl;
     return _activeControl;
@@ -444,7 +421,7 @@ bool Form::screenToForm(Control* ctrl, int* x, int* y)
             if (form->projectPoint(*x, *y, &point))
             if (form->projectPoint(*x, *y, &point))
             {
             {
                 *x = (int)point.x;
                 *x = (int)point.x;
-                *y = form->_bounds.height - (int)point.y;
+                *y = form->_absoluteBounds.height - (int)point.y;
             }
             }
             else
             else
             {
             {
@@ -452,9 +429,6 @@ bool Form::screenToForm(Control* ctrl, int* x, int* y)
             }
             }
         }
         }
 
 
-        *x -= form->_bounds.x;
-        *y -= form->_bounds.y;
-
         return true;
         return true;
     }
     }
 
 
@@ -495,11 +469,14 @@ Control* Form::findInputControl(int* x, int* y, bool focus)
 
 
 Control* Form::findInputControl(Control* control, int x, int y, bool focus)
 Control* Form::findInputControl(Control* control, int x, int y, bool focus)
 {
 {
+    if (!(control->_visible && control->_enabled))
+        return NULL;
+
     Control* result = NULL;
     Control* result = NULL;
 
 
     // Does the passed in control's bounds intersect the specified coordinates - and 
     // Does the passed in control's bounds intersect the specified coordinates - and 
     // does the control support the specified input state?
     // does the control support the specified input state?
-    if (control->_consumeInputEvents && control->_visible && control->_enabled && (!focus || control->canFocus()))
+    if (control->_consumeInputEvents && (!focus || control->canFocus()))
     {
     {
         if (control->_absoluteClipBounds.contains(x, y))
         if (control->_absoluteClipBounds.contains(x, y))
             result = control;
             result = control;
@@ -510,9 +487,9 @@ Control* Form::findInputControl(Control* control, int x, int y, bool focus)
     if (control->isContainer())
     if (control->isContainer())
     {
     {
         Container* container = static_cast<Container*>(control);
         Container* container = static_cast<Container*>(control);
-        for (int i = (int)container->getControlCount() - 1; i >= 0; --i)
+        for (unsigned int i = 0, childCount = container->getControlCount(); i < childCount; ++i)
         {
         {
-            Control* ctrl = findInputControl(container->getControl((unsigned int)i), x, y, focus);
+            Control* ctrl = findInputControl(container->getControl(i), x, y, focus);
             if (ctrl)
             if (ctrl)
                 result = ctrl;
                 result = ctrl;
         }
         }
@@ -718,31 +695,6 @@ bool Form::pointerEventInternal(bool mouse, int evt, int x, int y, int param)
 
 
     if (ctrl)
     if (ctrl)
     {
     {
-        // Handle container scrolling
-        Control* tmp = ctrl;
-        while (tmp)
-        {
-            if (tmp->isContainer())
-            {
-                Container* container = static_cast<Container*>(tmp);
-                if (container->_scroll != SCROLL_NONE)
-                {
-                    if (mouse)
-                    {
-                        if (container->mouseEventScroll((Mouse::MouseEvent)evt, formX - tmp->_absoluteBounds.x, formY - tmp->_absoluteBounds.y, param))
-                            return true;
-                    }
-                    else
-                    {
-                        if (container->touchEventScroll((Touch::TouchEvent)evt, formX - tmp->_absoluteBounds.x, formY - tmp->_absoluteBounds.y, param))
-                            return true;
-                    }
-                    break; // scrollable parent container found
-                }
-            }
-            tmp = tmp->_parent;
-        }
-
         // Handle setting focus for all press events
         // Handle setting focus for all press events
         if (pressEvent)
         if (pressEvent)
         {
         {
@@ -790,6 +742,31 @@ bool Form::pointerEventInternal(bool mouse, int evt, int x, int y, int param)
                     return true;
                     return true;
             }
             }
 
 
+            // Handle container scrolling
+            Control* tmp = ctrl;
+            while (tmp)
+            {
+                if (tmp->isContainer())
+                {
+                    Container* container = static_cast<Container*>(tmp);
+                    if (container->_scroll != SCROLL_NONE)
+                    {
+                        if (mouse)
+                        {
+                            if (container->mouseEventScroll((Mouse::MouseEvent)evt, formX - tmp->_absoluteBounds.x, formY - tmp->_absoluteBounds.y, param))
+                                return true;
+                        }
+                        else
+                        {
+                            if (container->touchEventScroll((Touch::TouchEvent)evt, formX - tmp->_absoluteBounds.x, formY - tmp->_absoluteBounds.y, param))
+                                return true;
+                        }
+                        break; // scrollable parent container found
+                    }
+                }
+                tmp = tmp->_parent;
+            }
+
             // Consume all input events anyways?
             // Consume all input events anyways?
             if (ctrl->getConsumeInputEvents())
             if (ctrl->getConsumeInputEvents())
                 return true;
                 return true;
@@ -1051,14 +1028,6 @@ void Form::resizeEventInternal(unsigned int width, unsigned int height)
         Form* form = __forms[i];
         Form* form = __forms[i];
         if (form)
         if (form)
         {
         {
-            if (form->_spriteBatch)
-            {
-                // Update viewport projection matrix
-                Matrix viewportProjection;
-                Matrix::createOrthographicOffCenter(0, Game::getInstance()->getViewport().width, Game::getInstance()->getViewport().height, 0, 0, 1, &viewportProjection);
-                form->_spriteBatch->setProjectionMatrix(viewportProjection);
-            }
-
             // Dirty the form
             // Dirty the form
             form->_dirty = true;
             form->_dirty = true;
         }
         }
@@ -1109,24 +1078,6 @@ bool Form::projectPoint(int x, int y, Vector3* point)
     return false;
     return false;
 }
 }
 
 
-unsigned int Form::nextPowerOfTwo(unsigned int v)
-{
-    if (!((v & (v - 1)) == 0))
-    {
-        v--;
-        v |= v >> 1;
-        v |= v >> 2;
-        v |= v >> 4;
-        v |= v >> 8;
-        v |= v >> 16;
-        return v + 1;
-    }
-    else
-    {
-        return v;
-    }
-}
-
 void Form::controlDisabled(Control* control)
 void Form::controlDisabled(Control* control)
 {
 {
     if (Form::_focusControl && (Form::_focusControl == control || Form::_focusControl->isChild(control)))
     if (Form::_focusControl && (Form::_focusControl == control || Form::_focusControl->isChild(control)))

+ 57 - 32
gameplay/src/Form.h

@@ -5,11 +5,11 @@
 #include "Container.h"
 #include "Container.h"
 #include "Mesh.h"
 #include "Mesh.h"
 #include "Node.h"
 #include "Node.h"
-#include "FrameBuffer.h"
 #include "Touch.h"
 #include "Touch.h"
 #include "Keyboard.h"
 #include "Keyboard.h"
 #include "Mouse.h"
 #include "Mouse.h"
 #include "Gamepad.h"
 #include "Gamepad.h"
+#include "FrameBuffer.h"
 
 
 namespace gameplay
 namespace gameplay
 {
 {
@@ -17,7 +17,12 @@ namespace gameplay
 class Theme;
 class Theme;
 
 
 /**
 /**
- * Top-level container of UI controls.  The following properties are available for forms:
+ * Top-level container of UI controls.
+ 
+   Child controls and containers can be created and added to a form using the
+   Container::addControl and Container::insertControl methods.
+
+   The following properties are available for forms:
 
 
  @verbatim
  @verbatim
     form <formID>
     form <formID>
@@ -68,10 +73,14 @@ public:
 
 
     /**
     /**
      * Create a new Form.
      * Create a new Form.
+	 *
+	 * The specified style defines the visual style for the form. If NULL is passed
+	 * for the style, the default UI theme is used. All controls attached to this
+	 * form will inherit the theme that contains the form's style.
      *
      *
      * @param id The Form's ID.
      * @param id The Form's ID.
-     * @param style The Form's style.
-     * @param layoutType The form's layout type.
+     * @param style The Form's custom style (optional - may be NULL).
+	 * @param layoutType The form's layout type (optional).
      *
      *
      * @return The new Form.
      * @return The new Form.
      * @script{create}
      * @script{create}
@@ -104,20 +113,10 @@ public:
      */
      */
     bool isForm() const;
     bool isForm() const;
 
 
-    /**
-     * Gets the theme for the form.
-     *
-     * @return The theme for the form.
-     */
-    Theme* getTheme() const;
-
     /**
     /**
      * Attach this form to a node.
      * Attach this form to a node.
      *
      *
      * A form can be drawn as part of the 3-dimensional world if it is attached to a node.
      * A form can be drawn as part of the 3-dimensional world if it is attached to a node.
-     * The form's contents will be rendered into a framebuffer which will be used to texture a quad.
-     * This quad will be given the same dimensions as the form and must be transformed appropriately.
-     * Alternatively, a quad can be set explicitly on a form with the setQuad() methods.
      *
      *
      * @param node The node to attach this form to.
      * @param node The node to attach this form to.
      */
      */
@@ -130,6 +129,8 @@ public:
 
 
     /**
     /**
      * Draws this form.
      * Draws this form.
+     *
+     * @return The nubmer of draw calls issued to draw the form.
      */
      */
     unsigned int draw();
     unsigned int draw();
 
 
@@ -138,6 +139,25 @@ public:
      */
      */
     const char* getType() const;
     const char* getType() const;
 
 
+    /**
+     * Determines whether batching is enabled for this form.
+     *
+     * @return True if batching is enabled for this form, false otherwise.
+     */
+    bool isBatchingEnabled() const;
+
+    /**
+     * Turns batching on or off for this form.
+     *
+     * By default, forms enable batching as a way to optimize performance. However, on certain
+     * complex forms that contain multiple layers of overlapping text and transparent controls,
+     * batching may cause some visual artifacts due alpha blending issues. In these cases,
+     * turning batching off usually fixes the issue at a slight performance cost.
+     *
+     * @param enabled True to enable batching (default), false otherwise.
+     */
+    void setBatchingEnabled(bool enabled);
+
     /**
     /**
      * Returns the single currently active control within the UI system.
      * Returns the single currently active control within the UI system.
      *
      *
@@ -169,6 +189,11 @@ private:
      */
      */
     virtual ~Form();
     virtual ~Form();
 
 
+    /**
+     * @see Control::initialize
+     */
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
+
     /**
     /**
      * Initialize a quad for this form in order to draw it in 3D.
      * Initialize a quad for this form in order to draw it in 3D.
      *
      *
@@ -220,13 +245,19 @@ private:
     static void resizeEventInternal(unsigned int width, unsigned int height);
     static void resizeEventInternal(unsigned int width, unsigned int height);
 
 
     /**
     /**
-     * Get the next highest power of two of an integer.  Used when creating framebuffers.
-     *
-     * @param x The number to start with.
-     *
-     * @return The next highest power of two after x, or x if it is already a power of two.
+     * Called to update internal framebuffer when forms are attached to a node.
+     */
+    void updateFrameBuffer();
+
+    /**
+     * Called during drawing to prepare a sprite batch for being drawn into for this form.
+     */
+    void startBatch(SpriteBatch* batch);
+
+    /**
+     * Called during drawing to signal completion of drawing into a batch.
      */
      */
-    static unsigned int nextPowerOfTwo(unsigned int x);
+    void finishBatch(SpriteBatch* batch);
 
 
     /**
     /**
      * Unproject a point (from a mouse or touch event) into the scene and then project it onto the form.
      * Unproject a point (from a mouse or touch event) into the scene and then project it onto the form.
@@ -239,10 +270,7 @@ private:
      */
      */
     bool projectPoint(int x, int y, Vector3* point);
     bool projectPoint(int x, int y, Vector3* point);
 
 
-    /**
-     * Called when the form is resized to update its internal frame buffer.
-     */
-    void updateFrameBuffer();
+    const Matrix& getProjectionMatrix() const;
 
 
     static bool pointerEventInternal(bool mouse, int evt, int x, int y, int param);
     static bool pointerEventInternal(bool mouse, int evt, int x, int y, int param);
 
 
@@ -266,15 +294,12 @@ private:
 
 
     static bool pollGamepad(Gamepad* gamepad);
     static bool pollGamepad(Gamepad* gamepad);
 
 
-    Theme* _theme;                      // The Theme applied to this Form.
-    FrameBuffer* _frameBuffer;          // FBO the Form is rendered into for texturing the quad. 
-    SpriteBatch* _spriteBatch;
     Node* _node;                        // Node for transforming this Form in world-space.
     Node* _node;                        // Node for transforming this Form in world-space.
-    Model* _nodeQuad;                   // Quad for rendering this Form in 3d space.
-    Material* _nodeMaterial;            // Material for rendering this Form in 3d space.
-    float _u2;
-    float _v1;
-    Matrix _projectionMatrix;           // Orthographic projection matrix to be set on SpriteBatch objects when rendering into the FBO.
+    FrameBuffer* _frameBuffer;          // FrameBuffer for offscreen drawing of forms that are attached to a Node
+    Model* _model;                      // Model used to render form in 3D when attached to a Node
+    Matrix _projectionMatrix;           // Projection matrix to be set on SpriteBatch objects when rendering the form
+    std::vector<SpriteBatch*> _batches;
+    bool _batched;
     static Control* _focusControl;
     static Control* _focusControl;
     static Control* _activeControl;
     static Control* _activeControl;
     static Control::State _activeControlState;
     static Control::State _activeControlState;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 511 - 508
gameplay/src/Game.cpp


+ 32 - 40
gameplay/src/ImageControl.cpp

@@ -17,53 +17,45 @@ ImageControl::~ImageControl()
 
 
 ImageControl* ImageControl::create(const char* id, Theme::Style* style)
 ImageControl* ImageControl::create(const char* id, Theme::Style* style)
 {
 {
-    GP_ASSERT(style);
-
     ImageControl* imageControl = new ImageControl();
     ImageControl* imageControl = new ImageControl();
-    if (id)
-        imageControl->_id = id;
-    imageControl->setStyle(style);
-
-    imageControl->_focusIndex = -2;
-
+    imageControl->_id = id ? id : "";
+    imageControl->initialize("Image", style, NULL);
     return imageControl;
     return imageControl;
 }
 }
 
 
 Control* ImageControl::create(Theme::Style* style, Properties* properties)
 Control* ImageControl::create(Theme::Style* style, Properties* properties)
 {
 {
     ImageControl* imageControl = new ImageControl();
     ImageControl* imageControl = new ImageControl();
-    imageControl->initialize(style, properties);
-
-    imageControl->_focusIndex = -2;
-
+    imageControl->initialize("Image", style, properties);
     return imageControl;
     return imageControl;
 }
 }
 
 
-void ImageControl::initialize(Theme::Style* style, Properties* properties)
+void ImageControl::initialize(const char* typeName, Theme::Style* style, Properties* properties)
 {
 {
-    GP_ASSERT(properties);
+	Control::initialize(typeName, style, properties);
 
 
-    Control::initialize(style, properties);
+	if (properties)
+	{
+		std::string path;
+		if (properties->getPath("path", &path))
+		{
+			setImage(path.c_str());
+		}
 
 
-    std::string path;
-    if (properties->getPath("path", &path))
-    {
-        setImage(path.c_str());
-    }
+		if (properties->exists("srcRegion"))
+		{
+			Vector4 region;
+			properties->getVector4("srcRegion", &region);
+			setRegionSrc(region.x, region.y, region.z, region.w);
+		}
 
 
-    if (properties->exists("srcRegion"))
-    {
-        Vector4 region;
-        properties->getVector4("srcRegion", &region);
-        setRegionSrc(region.x, region.y, region.z, region.w);
-    }
-
-    if (properties->exists("dstRegion"))
-    {
-        Vector4 region;
-        properties->getVector4("dstRegion", &region);
-        setRegionDst(region.x, region.y, region.z, region.w);
-    }
+		if (properties->exists("dstRegion"))
+		{
+			Vector4 region;
+			properties->getVector4("dstRegion", &region);
+			setRegionDst(region.x, region.y, region.z, region.w);
+		}
+	}
 }
 }
 
 
 void ImageControl::setImage(const char* path)
 void ImageControl::setImage(const char* path)
@@ -121,17 +113,16 @@ const char* ImageControl::getType() const
     return "image";
     return "image";
 }
 }
 
 
-void ImageControl::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
+unsigned int ImageControl::drawImages(Form* form, const Rectangle& clip)
 {
 {
-    spriteBatch->finish();
+    if (!_batch)
+        return 0;
 
 
-    // An ImageControl is not part of the texture atlas but should use the same projection matrix.
-    _batch->setProjectionMatrix(spriteBatch->getProjectionMatrix());
+    startBatch(form, _batch);
 
 
     Vector4 color = Vector4::one();
     Vector4 color = Vector4::one();
     color.w *= _opacity;
     color.w *= _opacity;
 
 
-    _batch->start();
     if (_dstRegion.isEmpty())
     if (_dstRegion.isEmpty())
     {
     {
         _batch->draw(_viewportBounds.x, _viewportBounds.y, _viewportBounds.width, _viewportBounds.height,
         _batch->draw(_viewportBounds.x, _viewportBounds.y, _viewportBounds.width, _viewportBounds.height,
@@ -143,9 +134,10 @@ void ImageControl::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
             _dstRegion.width, _dstRegion.height,
             _dstRegion.width, _dstRegion.height,
             _uvs.u1, _uvs.v1, _uvs.u2, _uvs.v2, color, _viewportClipBounds);
             _uvs.u1, _uvs.v1, _uvs.u2, _uvs.v2, color, _viewportClipBounds);
     }
     }
-    _batch->finish();
 
 
-    spriteBatch->start();
+    finishBatch(form, _batch);
+
+    return 1;
 }
 }
 
 
 void ImageControl::update(const Control* container, const Vector2& offset)
 void ImageControl::update(const Control* container, const Vector2& offset)

+ 12 - 9
gameplay/src/ImageControl.h

@@ -41,15 +41,15 @@ class ImageControl : public Control
 public:
 public:
 
 
     /**
     /**
-     * Create a new ImageControl.
+     * Creates a new ImageControl.
      *
      *
-     * @param id The control's ID.
-     * @param style The control's style.
+     * @param id The image control ID.
+     * @param style The image control style (optional).
      *
      *
-     * @return The new ImageControl.
+     * @return The new image control.
      * @script{create}
      * @script{create}
      */
      */
-    static ImageControl* create(const char* id, Theme::Style* style);
+    static ImageControl* create(const char* id, Theme::Style* style = NULL);
 
 
     /**
     /**
      * Set the path of the image for this ImageControl to display.
      * Set the path of the image for this ImageControl to display.
@@ -118,11 +118,14 @@ protected:
 
 
     virtual ~ImageControl();
     virtual ~ImageControl();
 
 
-    static Control* create(Theme::Style* style, Properties* properties);
+    static Control* create(Theme::Style* style, Properties* properties = NULL);
 
 
-    virtual void initialize(Theme::Style* style, Properties* properties);
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
 
 
-    void drawImages(SpriteBatch* spriteBatch, const Rectangle& clip);
+    /**
+     * @see Control::drawImages
+     */
+    unsigned int drawImages(Form* form, const Rectangle& clip);
 
 
     /**
     /**
      * @see Control#update(const Control*, const Vector2&)
      * @see Control#update(const Control*, const Vector2&)
@@ -134,7 +137,7 @@ protected:
     // Destination region.
     // Destination region.
     Rectangle _dstRegion;
     Rectangle _dstRegion;
     SpriteBatch* _batch;
     SpriteBatch* _batch;
-    
+
     // One over texture width and height, for use when calculating UVs from a new source region.
     // One over texture width and height, for use when calculating UVs from a new source region.
     float _tw;
     float _tw;
     float _th;
     float _th;

+ 101 - 88
gameplay/src/Joystick.cpp

@@ -18,96 +18,100 @@ Joystick::~Joystick()
 
 
 Joystick* Joystick::create(const char* id, Theme::Style* style)
 Joystick* Joystick::create(const char* id, Theme::Style* style)
 {
 {
-    GP_ASSERT(style);
-
     Joystick* joystick = new Joystick();
     Joystick* joystick = new Joystick();
-    if (id)
-        joystick->_id = id;
-    joystick->setStyle(style);
-
+    joystick->_id = id ? id : "";
+    joystick->initialize("Joystick", style, NULL);
     return joystick;
     return joystick;
 }
 }
 
 
 Control* Joystick::create(Theme::Style* style, Properties* properties)
 Control* Joystick::create(Theme::Style* style, Properties* properties)
 {
 {
     Joystick* joystick = new Joystick();
     Joystick* joystick = new Joystick();
-    joystick->initialize(style, properties);
-    joystick->_index = properties->getInt("index");
+    joystick->initialize("Joystick", style, properties);
     return joystick;
     return joystick;
 }
 }
 
 
-void Joystick::initialize(Theme::Style* style, Properties* properties)
+void Joystick::initialize(const char* typeName, Theme::Style* style, Properties* properties)
 {
 {
-    GP_ASSERT(properties);
-
-    Control::initialize(style, properties);
-
-    Control::State state = getState();
-
-    if (!properties->exists("radius"))
-    {
-        GP_ERROR("Failed to load joystick; required attribute 'radius' is missing.");
-        return;
-    }
-    _radius = properties->getFloat("radius");
-    GP_ASSERT(_radius != 0.0f);
-
-    if (properties->exists("relative"))
-    {
-        setRelative(properties->getBool("relative"));
-    }
-    else
-    {
-        setRelative(false);
-    }
-
-    Theme::ThemeImage* inner = getImage("inner", state);
-    if (inner)
-    {
-        _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();
-            _screenRegion.width = rect.width;
-            _screenRegion.height = rect.height;
-        }
-        else
-        {
-            _screenRegion.width = _radius * 2.0f;
-            _screenRegion.height = _screenRegion.width;
-        }
-    }
+    Control::initialize(typeName, style, properties);
+
+	if (!properties)
+	{
+		GP_WARN("Joystick creation without properties object is unsupported.");
+		return;
+	}
+
+	Control::State state = getState();
+
+	if (!properties->exists("radius"))
+	{
+		GP_WARN("Joystick: required attribute 'radius' is missing.");
+	}
+	else
+	{
+		_radius = properties->getFloat("radius");
+		if (_radius < 1.0f)
+			_radius = 1.0f;
+	}
+
+	if (properties->exists("relative"))
+	{
+		setRelative(properties->getBool("relative"));
+	}
+	else
+	{
+		setRelative(false);
+	}
+
+	Theme::ThemeImage* inner = getImage("inner", state);
+	if (inner)
+	{
+		_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();
+			_screenRegion.width = rect.width;
+			_screenRegion.height = rect.height;
+		}
+		else
+		{
+			_screenRegion.width = _radius * 2.0f;
+			_screenRegion.height = _screenRegion.width;
+		}
+	}
+
+	_index = properties->getInt("index");
 }
 }
 
 
 void Joystick::addListener(Control::Listener* listener, int eventFlags)
 void Joystick::addListener(Control::Listener* listener, int eventFlags)
@@ -237,12 +241,12 @@ bool Joystick::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int cont
     return Control::touchEvent(evt, x, y, contactIndex);
     return Control::touchEvent(evt, x, y, contactIndex);
 }
 }
 
 
-void Joystick::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
+unsigned int Joystick::drawImages(Form* form, const Rectangle& clip)
 {
 {
-    GP_ASSERT(spriteBatch);
-
     Control::State state = getState();
     Control::State state = getState();
 
 
+    unsigned int drawCalls = 0;
+
     // If the joystick is not absolute, then only draw if it is active.
     // If the joystick is not absolute, then only draw if it is active.
     if (!_relative || (_relative && state == ACTIVE))
     if (!_relative || (_relative && state == ACTIVE))
     {
     {
@@ -252,6 +256,9 @@ void Joystick::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
             _screenRegion.y = _viewportClipBounds.y + (_viewportClipBounds.height - _screenRegion.height) / 2.0f;
             _screenRegion.y = _viewportClipBounds.y + (_viewportClipBounds.height - _screenRegion.height) / 2.0f;
         }
         }
 
 
+        SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
+        startBatch(form, batch);
+
         // Draw the outer image.
         // Draw the outer image.
         Theme::ThemeImage* outer = getImage("outer", state);
         Theme::ThemeImage* outer = getImage("outer", state);
         if (outer)
         if (outer)
@@ -259,9 +266,10 @@ void Joystick::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
             const Theme::UVs& uvs = outer->getUVs();
             const Theme::UVs& uvs = outer->getUVs();
             const Vector4& color = outer->getColor();
             const Vector4& color = outer->getColor();
             if (_relative)
             if (_relative)
-                spriteBatch->draw(_screenRegion.x, _screenRegion.y, _outerSize->x, _outerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color);
+                batch->draw(_screenRegion.x, _screenRegion.y, _outerSize->x, _outerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color);
             else
             else
-                spriteBatch->draw(_screenRegion.x, _screenRegion.y, _outerSize->x, _outerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+                batch->draw(_screenRegion.x, _screenRegion.y, _outerSize->x, _outerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+            ++drawCalls;
         }
         }
 
 
         // Draw the inner image.
         // Draw the inner image.
@@ -269,20 +277,25 @@ void Joystick::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
         if (inner)
         if (inner)
         {
         {
             Vector2 position(_screenRegion.x, _screenRegion.y);
             Vector2 position(_screenRegion.x, _screenRegion.y);
-            
+
             // Adjust position to reflect displacement.
             // Adjust position to reflect displacement.
             position.x += _displacement.x;
             position.x += _displacement.x;
             position.y += -_displacement.y;
             position.y += -_displacement.y;
-            
+
             // Get the uvs and color and draw.
             // Get the uvs and color and draw.
             const Theme::UVs& uvs = inner->getUVs();
             const Theme::UVs& uvs = inner->getUVs();
             const Vector4& color = inner->getColor();
             const Vector4& color = inner->getColor();
             if (_relative)
             if (_relative)
-                spriteBatch->draw(position.x, position.y, _innerSize->x, _innerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color);
+                batch->draw(position.x, position.y, _innerSize->x, _innerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color);
             else
             else
-                spriteBatch->draw(position.x, position.y, _innerSize->x, _innerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+                batch->draw(position.x, position.y, _innerSize->x, _innerSize->y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+            ++drawCalls;
         }
         }
+
+        finishBatch(form, batch);
     }
     }
+
+    return drawCalls;
 }
 }
 
 
 const char* Joystick::getType() const
 const char* Joystick::getType() const

+ 191 - 194
gameplay/src/Joystick.h

@@ -1,194 +1,191 @@
-#ifndef JOYSTICK_H_
-#define JOYSTICK_H_
-
-#include "Control.h"
-
-namespace gameplay
-{
-
-/**
- * Defines a control representing a joystick (axis).
- *
-  @verbatim
-    slider
-    {
-        style       = <styleID>                 // A Style from the Theme.
-        position    = <x, y>                    // Position of the Control on-screen, measured in pixels.
-        alignment   = <Control::Alignment constant> // Note: 'position' will be ignored.
-        size        = <width, height>           // Size of the Control, measured in pixels.
-        radius      = <float>                   // The value of the left- / bottom-most point on the slider.
-        consumeEvents = <bool>                  // Whether the slider propagates input events to the Game's input event handler. Default is true.
-    }
- @endverbatim
- */
-class Joystick : public Control
-{
-    friend class Container;
-    friend class Gamepad;
-	friend class ControlFactory;
-
-public:
-
-    /**
-     * Create a new joystick control.
-     *
-     * @param id The control's ID.
-     * @param style The control's style.
-     *
-     * @return The new joystick.
-     * @script{create}
-     */
-    static Joystick* create(const char* id, Theme::Style* style);
-    
-    /**
-     * Add a listener to be notified of specific events affecting
-     * this control.  Event types can be OR'ed together.
-     * E.g. To listen to touch-press and touch-release events,
-     * pass <code>Control::Listener::TOUCH | Control::Listener::RELEASE</code>
-     * as the second parameter.
-     *
-     * @param listener The listener to add.
-     * @param eventFlags The events to listen for.
-     */
-    void addListener(Control::Listener* listener, int eventFlags);
-
-    /**
-     * Retrieves the value (2-dimensional direction) of the joystick.
-     * 
-     * @return The value of the joystick.
-     */
-    inline const Vector2& getValue() const;
-
-    /**
-     * Sets the image size of the inner region of the joystick. Does not do anything if there is no
-     * inner image region defined.
-     * 
-     * @param size 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.
-     * 
-     * @return The image size of the inner region of the joystick. (x, y) == (width, height)
-     */
-    inline const Vector2& getInnerRegionSize() const;
-
-    /**
-     * Sets the image size of the outer region of the joystick. Does not do anything if there is no
-     * outer image region defined.
-     * 
-     * @param size 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 image size of the outer region of the joystick. (x, y) == (width, height)
-     */
-    inline const Vector2& getOuterRegionSize() const;
-
-    /**
-     * Sets whether relative positioning is 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 setRelative(bool relative);
-
-    /**
-     * Retrieves whether absolute positioning is enabled or not.
-     * 
-     * 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 isRelative() const;
-
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
-
-    /**
-     * Gets the index of this joystick across all joysticks on a form.
-     *
-     * @return The index of this joystick on a form.
-     */
-    inline const unsigned int getIndex() const;
-
-protected:
-    
-    /**
-     * Constructor.
-     */
-    Joystick();
-
-    /**
-     * Destructor.
-     */
-    virtual ~Joystick();
-
-    /**
-     * Create a joystick with a given style and properties.
-     *
-     * @param style The style to apply to this joystick.
-     * @param properties The properties to set on this joystick.
-	 *
-     * @return The new joystick.
-     */
-    static Control* create(Theme::Style* style, Properties* properties);
-
-    /**
-     * Initialize this joystick.
-     */
-    virtual void initialize(Theme::Style* style, Properties* properties);
-
-    /**
-     * Touch callback on touch events.  Controls return true if they consume the touch event.
-     *
-     * @param evt The touch event that occurred.
-     * @param x The x position of the touch in pixels. Left edge is zero.
-     * @param y The y position of the touch in pixels. Top edge is zero.
-     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
-     *
-     * @return Whether the touch event was consumed by the control.
-     *
-     * @see Touch::TouchEvent
-     */
-    bool touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
-
-    /**
-     * Draw the images associated with this control.
-     *
-     * @param spriteBatch The sprite batch containing this control's icons.
-     * @param clip The clipping rectangle of this control's parent container.
-     */
-    void drawImages(SpriteBatch* spriteBatch, const Rectangle& clip);
-
-private:
-
-    /**
-     * Copy constructor.
-     */
-    Joystick(const Joystick& copy);
-
-    float _radius; 
-    bool _relative;
-    Rectangle _screenRegion;
-    Vector2 _value;
-    Vector2 _displacement;
-    Vector2* _innerSize;
-    Vector2* _outerSize;
-    unsigned int _index;
-};
-
-}
-
-#include "Joystick.inl"
-
-#endif
+#ifndef JOYSTICK_H_
+#define JOYSTICK_H_
+
+#include "Control.h"
+
+namespace gameplay
+{
+
+/**
+ * Defines a control representing a joystick (axis).
+ *
+  @verbatim
+    slider
+    {
+        style       = <styleID>                 // A Style from the Theme.
+        position    = <x, y>                    // Position of the Control on-screen, measured in pixels.
+        alignment   = <Control::Alignment constant> // Note: 'position' will be ignored.
+        size        = <width, height>           // Size of the Control, measured in pixels.
+        radius      = <float>                   // The value of the left- / bottom-most point on the slider.
+        consumeEvents = <bool>                  // Whether the slider propagates input events to the Game's input event handler. Default is true.
+    }
+ @endverbatim
+ */
+class Joystick : public Control
+{
+    friend class Container;
+    friend class Gamepad;
+	friend class ControlFactory;
+
+public:
+
+    /**
+     * Creates a new Joystick.
+     *
+     * @param id The joystick ID.
+     * @param style The joystick style.
+     *
+     * @return The new joystick.
+     * @script{create}
+     */
+    static Joystick* create(const char* id, Theme::Style* style = NULL);
+
+    /**
+     * Add a listener to be notified of specific events affecting
+     * this control.  Event types can be OR'ed together.
+     * E.g. To listen to touch-press and touch-release events,
+     * pass <code>Control::Listener::TOUCH | Control::Listener::RELEASE</code>
+     * as the second parameter.
+     *
+     * @param listener The listener to add.
+     * @param eventFlags The events to listen for.
+     */
+    void addListener(Control::Listener* listener, int eventFlags);
+
+    /**
+     * Retrieves the value (2-dimensional direction) of the joystick.
+     * 
+     * @return The value of the joystick.
+     */
+    inline const Vector2& getValue() const;
+
+    /**
+     * Sets the image size of the inner region of the joystick. Does not do anything if there is no
+     * inner image region defined.
+     * 
+     * @param size 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.
+     * 
+     * @return The image size of the inner region of the joystick. (x, y) == (width, height)
+     */
+    inline const Vector2& getInnerRegionSize() const;
+
+    /**
+     * Sets the image size of the outer region of the joystick. Does not do anything if there is no
+     * outer image region defined.
+     * 
+     * @param size 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 image size of the outer region of the joystick. (x, y) == (width, height)
+     */
+    inline const Vector2& getOuterRegionSize() const;
+
+    /**
+     * Sets whether relative positioning is 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 setRelative(bool relative);
+
+    /**
+     * Retrieves whether absolute positioning is enabled or not.
+     * 
+     * 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 isRelative() const;
+
+    /**
+     * @see Control::getType
+     */
+    const char* getType() const;
+
+    /**
+     * Gets the index of this joystick across all joysticks on a form.
+     *
+     * @return The index of this joystick on a form.
+     */
+    inline const unsigned int getIndex() const;
+
+protected:
+    
+    /**
+     * Constructor.
+     */
+    Joystick();
+
+    /**
+     * Destructor.
+     */
+    virtual ~Joystick();
+
+    /**
+     * Create a joystick with a given style and properties.
+     *
+     * @param style The style to apply to this joystick.
+     * @param properties A properties object containing a definition of the joystick (optional).
+	 *
+     * @return The new joystick.
+     */
+    static Control* create(Theme::Style* style, Properties* properties = NULL);
+
+    /**
+     * @see Control::initialize
+     */
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
+
+    /**
+     * Touch callback on touch events.  Controls return true if they consume the touch event.
+     *
+     * @param evt The touch event that occurred.
+     * @param x The x position of the touch in pixels. Left edge is zero.
+     * @param y The y position of the touch in pixels. Top edge is zero.
+     * @param contactIndex The order of occurrence for multiple touch contacts starting at zero.
+     *
+     * @return Whether the touch event was consumed by the control.
+     *
+     * @see Touch::TouchEvent
+     */
+    bool touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex);
+
+    /**
+     * @see Control::drawImages
+     */
+    unsigned int drawImages(Form* form, const Rectangle& clip);
+
+private:
+
+    /**
+     * Copy constructor.
+     */
+    Joystick(const Joystick& copy);
+
+    float _radius; 
+    bool _relative;
+    Rectangle _screenRegion;
+    Vector2 _value;
+    Vector2 _displacement;
+    Vector2* _innerSize;
+    Vector2* _outerSize;
+    unsigned int _index;
+};
+
+}
+
+#include "Joystick.inl"
+
+#endif

+ 24 - 29
gameplay/src/Label.cpp

@@ -14,39 +14,31 @@ Label::~Label()
 
 
 Label* Label::create(const char* id, Theme::Style* style)
 Label* Label::create(const char* id, Theme::Style* style)
 {
 {
-    GP_ASSERT(style);
-
     Label* label = new Label();
     Label* label = new Label();
-    if (id)
-        label->_id = id;
-    label->setStyle(style);
-
-    // Ensure that labels cannot receive focus.
-    label->_focusIndex = -2;
-
+    label->_id = id ? id : "";
+    label->initialize("Label", style, NULL);
     return label;
     return label;
 }
 }
 
 
 Control* Label::create(Theme::Style* style, Properties* properties)
 Control* Label::create(Theme::Style* style, Properties* properties)
 {
 {
     Label* label = new Label();
     Label* label = new Label();
-    label->initialize(style, properties);
-
-    label->_focusIndex = -2;
-
+	label->initialize("Label", style, properties);
     return label;
     return label;
 }
 }
 
 
-void Label::initialize(Theme::Style* style, Properties* properties)
+void Label::initialize(const char* typeName, Theme::Style* style, Properties* properties)
 {
 {
-    GP_ASSERT(properties);
-
-    Control::initialize(style, properties);
-    const char* text = properties->getString("text");
-    if (text)
-    {
-        _text = text;
-    }
+    Control::initialize(typeName, style, properties);
+
+	if (properties)
+	{
+		const char* text = properties->getString("text");
+		if (text)
+		{
+			_text = text;
+		}
+	}
 }
 }
 
 
 void Label::addListener(Control::Listener* listener, int eventFlags)
 void Label::addListener(Control::Listener* listener, int eventFlags)
@@ -102,19 +94,22 @@ void Label::update(const Control* container, const Vector2& offset)
     }
     }
 }
 }
 
 
-void Label::drawText(const Rectangle& clip)
+unsigned int Label::drawText(Form* form, const Rectangle& clip)
 {
 {
-    if (_text.size() <= 0)
-        return;
-
     // Draw the text.
     // Draw the text.
-    if (_font)
+    if (_text.size() > 0 && _font)
     {
     {
         Control::State state = getState();
         Control::State state = getState();
-        _font->start();
+
+        SpriteBatch* batch = _font->getSpriteBatch();
+        startBatch(form, batch);
         _font->drawText(_text.c_str(), _textBounds, _textColor, getFontSize(state), getTextAlignment(state), true, getTextRightToLeft(state), &_viewportClipBounds);
         _font->drawText(_text.c_str(), _textBounds, _textColor, getFontSize(state), getTextAlignment(state), true, getTextRightToLeft(state), &_viewportClipBounds);
-        _font->finish();
+        finishBatch(form, batch);
+
+        return 1;
     }
     }
+
+    return 0;
 }
 }
 
 
 const char* Label::getType() const
 const char* Label::getType() const

+ 152 - 153
gameplay/src/Label.h

@@ -1,153 +1,152 @@
-#ifndef LABEL_H_
-#define LABEL_H_
-
-#include "Control.h"
-#include "Theme.h"
-
-namespace gameplay
-{
-
-/**
- * A label is the most basic type of control, capable only of rendering text within its border.
- *
- * The following properties are available for labels:
-
- @verbatim
-    label <labelID>
-    {
-         style       = <styleID>
-         alignment   = <Control::Alignment constant> // Note: 'position' will be ignored.
-         position    = <x, y>
-         autoWidth   = <bool>
-         autoHeight  = <bool>
-         size        = <width, height>
-         width       = <width>   // Can be used in place of 'size', e.g. with 'autoHeight = true'
-         height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
-         text        = <string>
-         consumeEvents = <bool>  // Whether the label propagates input events to the Game's input event handler. Default is true.
-    }
- @endverbatim
- */
-class Label : public Control
-{
-    friend class Container;
-	friend class ControlFactory;
-
-public:
-
-    /**
-     * Create a new label control.
-     *
-     * @param id The control's ID.
-     * @param style The control's style.
-     *
-     * @return The new label.
-     * @script{create}
-     */
-    static Label* create(const char*id, Theme::Style* style);
-
-    /**
-     * Set the text for this label to display.
-     *
-     * @param text The text to display.
-     */
-    void setText(const char* text);
-
-    /**
-     * Get the text displayed by this label.
-     *
-     * @return The text displayed by this label.
-     */
-    const char* getText();
-
-    /**
-     * @see Control::getType
-     */
-    const char* getType() const;
-
-    /**
-     * Add a listener to be notified of specific events affecting
-     * this control.  Event types can be OR'ed together.
-     * E.g. To listen to touch-press and touch-release events,
-     * pass <code>Control::Listener::TOUCH | Control::Listener::RELEASE</code>
-     * as the second parameter.
-     *
-     * @param listener The listener to add.
-     * @param eventFlags The events to listen for.
-     */
-    virtual void addListener(Control::Listener* listener, int eventFlags);
-
-protected:
-
-    /**
-     * Constructor.
-     */
-    Label();
-
-    /**
-     * Destructor.
-     */
-    virtual ~Label();
-
-    /**
-     * Create a label with a given style and properties.
-     *
-     * @param style The style to apply to this label.
-     * @param properties The properties to set on this label.
-	 * 
-     * @return The new label.
-     */
-    static Control* create(Theme::Style* style, Properties* properties);
-
-    /**
-     * Initialize this label.
-     */
-    virtual void initialize(Theme::Style* style, Properties* properties);
-
-    /**
-     * Called when a label's properties change. Updates this label's internal rendering
-     * properties, such as its text viewport.
-     *
-     * @param container This label's parent container.
-     * @param offset The scroll offset of this label's parent container.
-     */
-    void update(const Control* container, const Vector2& offset);
-
-    /**
-     * Draw this label's text.
-     *
-     * @param clip The clipping rectangle of this label's parent container.
-     */
-    virtual void drawText(const Rectangle& clip);
-
-    /**
-     * The text displayed by this label.
-     */
-    std::string _text;
-
-    /**
-     * The font being used to display the label.
-     */
-    Font* _font;
-    
-    /**
-     * The text color being used to display the label.
-     */
-    Vector4 _textColor;
-
-    /**
-     * The position and size of this control's text area, before clipping.  Used for text alignment.
-     */
-    Rectangle _textBounds;
-
-private:
-
-    /**
-     * Constructor.
-     */
-    Label(const Label& copy);
-};
-
-}
-
-#endif
+#ifndef LABEL_H_
+#define LABEL_H_
+
+#include "Control.h"
+#include "Theme.h"
+
+namespace gameplay
+{
+
+/**
+ * A label is the most basic type of control, capable only of rendering text within its border.
+ *
+ * The following properties are available for labels:
+
+ @verbatim
+    label <labelID>
+    {
+         style       = <styleID>
+         alignment   = <Control::Alignment constant> // Note: 'position' will be ignored.
+         position    = <x, y>
+         autoWidth   = <bool>
+         autoHeight  = <bool>
+         size        = <width, height>
+         width       = <width>   // Can be used in place of 'size', e.g. with 'autoHeight = true'
+         height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
+         text        = <string>
+         consumeEvents = <bool>  // Whether the label propagates input events to the Game's input event handler. Default is true.
+    }
+ @endverbatim
+ */
+class Label : public Control
+{
+    friend class Container;
+	friend class ControlFactory;
+
+public:
+
+    /**
+     * Creates a new label.
+     *
+     * @param id The label id.
+     * @param style The label style (optional).
+     *
+     * @return The new label.
+     * @script{create}
+     */
+    static Label* create(const char* id, Theme::Style* style = NULL);
+
+    /**
+     * Set the text for this label to display.
+     *
+     * @param text The text to display.
+     */
+    void setText(const char* text);
+
+    /**
+     * Get the text displayed by this label.
+     *
+     * @return The text displayed by this label.
+     */
+    const char* getText();
+
+    /**
+     * @see Control::getType
+     */
+    const char* getType() const;
+
+    /**
+     * Add a listener to be notified of specific events affecting
+     * this control.  Event types can be OR'ed together.
+     * E.g. To listen to touch-press and touch-release events,
+     * pass <code>Control::Listener::TOUCH | Control::Listener::RELEASE</code>
+     * as the second parameter.
+     *
+     * @param listener The listener to add.
+     * @param eventFlags The events to listen for.
+     */
+    virtual void addListener(Control::Listener* listener, int eventFlags);
+
+protected:
+
+    /**
+     * Constructor.
+     */
+    Label();
+
+    /**
+     * Destructor.
+     */
+    virtual ~Label();
+
+	/**
+	* Create a new label control.
+	*
+	* @param style The control's custom style.
+	* @param properties A properties object containing a definition of the label (optional).
+	*
+	* @return The new label.
+	* @script{create}
+	*/
+	static Control* create(Theme::Style* style, Properties* properties);
+
+    /**
+     * @see Control::initialize
+     */
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
+
+    /**
+     * Called when a label's properties change. Updates this label's internal rendering
+     * properties, such as its text viewport.
+     *
+     * @param container This label's parent container.
+     * @param offset The scroll offset of this label's parent container.
+     */
+    void update(const Control* container, const Vector2& offset);
+
+    /**
+     * @see Control::drawText
+     */
+    virtual unsigned int drawText(Form* form, const Rectangle& clip);
+
+    /**
+     * The text displayed by this label.
+     */
+    std::string _text;
+
+    /**
+     * The font being used to display the label.
+     */
+    Font* _font;
+    
+    /**
+     * The text color being used to display the label.
+     */
+    Vector4 _textColor;
+
+    /**
+     * The position and size of this control's text area, before clipping.  Used for text alignment.
+     */
+    Rectangle _textBounds;
+
+private:
+
+    /**
+     * Constructor.
+     */
+    Label(const Label& copy);
+};
+
+}
+
+#endif

+ 9 - 2
gameplay/src/MeshBatch.cpp

@@ -7,7 +7,7 @@ namespace gameplay
 
 
 MeshBatch::MeshBatch(const VertexFormat& vertexFormat, Mesh::PrimitiveType primitiveType, Material* material, bool indexed, unsigned int initialCapacity, unsigned int growSize)
 MeshBatch::MeshBatch(const VertexFormat& vertexFormat, Mesh::PrimitiveType primitiveType, Material* material, bool indexed, unsigned int initialCapacity, unsigned int growSize)
     : _vertexFormat(vertexFormat), _primitiveType(primitiveType), _material(material), _indexed(indexed), _capacity(0), _growSize(growSize),
     : _vertexFormat(vertexFormat), _primitiveType(primitiveType), _material(material), _indexed(indexed), _capacity(0), _growSize(growSize),
-      _vertexCapacity(0), _indexCapacity(0), _vertexCount(0), _indexCount(0), _vertices(NULL), _verticesPtr(NULL), _indices(NULL), _indicesPtr(NULL)
+    _vertexCapacity(0), _indexCapacity(0), _vertexCount(0), _indexCount(0), _vertices(NULL), _verticesPtr(NULL), _indices(NULL), _indicesPtr(NULL), _started(false)
 {
 {
     resize(initialCapacity);
     resize(initialCapacity);
 }
 }
@@ -221,17 +221,24 @@ void MeshBatch::add(const float* vertices, unsigned int vertexCount, const unsig
 {
 {
     add(vertices, sizeof(float), vertexCount, indices, indexCount);
     add(vertices, sizeof(float), vertexCount, indices, indexCount);
 }
 }
-    
+
 void MeshBatch::start()
 void MeshBatch::start()
 {
 {
     _vertexCount = 0;
     _vertexCount = 0;
     _indexCount = 0;
     _indexCount = 0;
     _verticesPtr = _vertices;
     _verticesPtr = _vertices;
     _indicesPtr = _indices;
     _indicesPtr = _indices;
+    _started = true;
+}
+
+bool MeshBatch::isStarted() const
+{
+    return _started;
 }
 }
 
 
 void MeshBatch::finish()
 void MeshBatch::finish()
 {
 {
+    _started = false;
 }
 }
 
 
 void MeshBatch::draw()
 void MeshBatch::draw()

+ 6 - 0
gameplay/src/MeshBatch.h

@@ -126,6 +126,11 @@ public:
      */
      */
     void start();
     void start();
 
 
+    /**
+    * Determines if the batch has been started and not yet finished.
+    */
+    bool isStarted() const;
+
     /**
     /**
      * Indicates that batching is complete and prepares the batch for drawing.
      * Indicates that batching is complete and prepares the batch for drawing.
      */
      */
@@ -173,6 +178,7 @@ private:
     unsigned char* _verticesPtr;
     unsigned char* _verticesPtr;
     unsigned short* _indices;
     unsigned short* _indices;
     unsigned short* _indicesPtr;
     unsigned short* _indicesPtr;
+    bool _started;
 
 
 };
 };
 
 

+ 1660 - 1655
gameplay/src/PlatformBlackBerry.cpp

@@ -1,1660 +1,1665 @@
-#ifdef __QNX__
-
-#include "Base.h"
-#include "Platform.h"
-#include "FileSystem.h"
-#include "Game.h"
-#include "Form.h"
-#include "ScriptController.h"
-#include <unistd.h>
-#include <sys/keycodes.h>
-#include <screen/screen.h>
-#include <input/screen_helpers.h>
-#include <gestures/set.h>
-#include <gestures/swipe.h>
-#include <gestures/pinch.h>
-#include <gestures/tap.h>
-#include <bps/bps.h>
-#include <bps/event.h>
-#include <bps/screen.h>
-#include <bps/navigator.h>
-#include <bps/sensor.h>
-#include <bps/orientation.h>
-#include <bps/virtualkeyboard.h>
-
-#define TOUCH_COUNT_MAX     4
-
-using namespace std;
-
-int __argc = 0;
-char** __argv = 0;
-struct timespec __timespec;
-static double __timeStart;
-static double __timeAbsolute;
-static bool __vsync = WINDOW_VSYNC;
-static screen_context_t __screenContext;
-static screen_window_t __screenWindow;
-static screen_event_t __screenEvent;
-static int __screenWindowSize[2];
-static bool __screenFullscreen = false;
-static EGLDisplay __eglDisplay = EGL_NO_DISPLAY;
-static EGLContext __eglContext = EGL_NO_CONTEXT;
-static EGLSurface __eglSurface = EGL_NO_SURFACE;
-static EGLConfig __eglConfig = 0;
-static int __orientationAngle;
-static bool __multiTouch = false;
-static bool __multiSampling = false;
-static float __pitch;
-static float __roll;
-static float __accelRawX;
-static float __accelRawY;
-static float __accelRawZ;
-static float __gyroRawX;
-static float __gyroRawY;
-static float __gyroRawZ;
-static const char* __glExtensions;
-static struct gestures_set * __gestureSet;
-static bitset<3> __gestureEventsProcessed;
-static bool __gestureSwipeRecognized = false;
-PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray = NULL;
-PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays = NULL;
-PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays = NULL;
-PFNGLISVERTEXARRAYOESPROC glIsVertexArray = NULL;
-
-namespace gameplay
-{
-
-// Gets the Keyboard::Key enumeration constant that corresponds to the given QNX key code.
-static Keyboard::Key getKey(int qnxKeycode)
-{
-    switch (qnxKeycode)
-    {
-    case KEYCODE_SYSREQ:
-        return Keyboard::KEY_SYSREQ;
-    case KEYCODE_BREAK:
-        return Keyboard::KEY_BREAK;
-    case KEYCODE_MENU:
-        return Keyboard::KEY_MENU;
-    case KEYCODE_KP_ENTER:
-        return Keyboard::KEY_KP_ENTER;
-    case KEYCODE_PAUSE:
-        return Keyboard::KEY_PAUSE;
-    case KEYCODE_SCROLL_LOCK:
-        return Keyboard::KEY_SCROLL_LOCK;
-    case KEYCODE_PRINT:
-        return Keyboard::KEY_PRINT;
-    case KEYCODE_ESCAPE:
-        return Keyboard::KEY_ESCAPE;
-    case KEYCODE_BACKSPACE:
-        return Keyboard::KEY_BACKSPACE;
-    case KEYCODE_BACK_TAB:
-        return Keyboard::KEY_BACK_TAB;
-    case KEYCODE_TAB:
-        return Keyboard::KEY_TAB;
-    case KEYCODE_RETURN:
-        return Keyboard::KEY_RETURN;
-    case KEYCODE_CAPS_LOCK:
-        return Keyboard::KEY_CAPS_LOCK;
-    case KEYCODE_LEFT_SHIFT:
-    case KEYCODE_RIGHT_SHIFT:
-        return Keyboard::KEY_SHIFT;
-    case KEYCODE_LEFT_CTRL:
-    case KEYCODE_RIGHT_CTRL:
-        return Keyboard::KEY_CTRL;
-    case KEYCODE_LEFT_ALT:
-    case KEYCODE_RIGHT_ALT:
-        return Keyboard::KEY_ALT;
-    case KEYCODE_LEFT_HYPER:
-    case KEYCODE_RIGHT_HYPER:
-        return Keyboard::KEY_HYPER;
-    case KEYCODE_INSERT:
-        return Keyboard::KEY_INSERT;
-    case KEYCODE_HOME:
-        return Keyboard::KEY_HOME;
-    case KEYCODE_PG_UP:
-        return Keyboard::KEY_PG_UP;
-    case KEYCODE_DELETE:
-        return Keyboard::KEY_DELETE;
-    case KEYCODE_END:
-        return Keyboard::KEY_END;
-    case KEYCODE_PG_DOWN:
-        return Keyboard::KEY_PG_DOWN;
-    case KEYCODE_LEFT:
-        return Keyboard::KEY_LEFT_ARROW;
-    case KEYCODE_RIGHT:
-        return Keyboard::KEY_RIGHT_ARROW;
-    case KEYCODE_UP:
-        return Keyboard::KEY_UP_ARROW;
-    case KEYCODE_DOWN:
-        return Keyboard::KEY_DOWN_ARROW;
-    case KEYCODE_NUM_LOCK:
-        return Keyboard::KEY_NUM_LOCK;
-    case KEYCODE_KP_PLUS:
-        return Keyboard::KEY_KP_PLUS;
-    case KEYCODE_KP_MINUS:
-        return Keyboard::KEY_KP_MINUS;
-    case KEYCODE_KP_MULTIPLY:
-        return Keyboard::KEY_KP_MULTIPLY;
-    case KEYCODE_KP_DIVIDE:
-        return Keyboard::KEY_KP_DIVIDE;
-    case KEYCODE_KP_HOME:
-        return Keyboard::KEY_KP_HOME;
-    case KEYCODE_KP_UP:
-        return Keyboard::KEY_KP_UP;
-    case KEYCODE_KP_PG_UP:
-        return Keyboard::KEY_KP_PG_UP;
-    case KEYCODE_KP_LEFT:
-        return Keyboard::KEY_KP_LEFT;
-    case KEYCODE_KP_FIVE:
-        return Keyboard::KEY_KP_FIVE;
-    case KEYCODE_KP_RIGHT:
-        return Keyboard::KEY_KP_RIGHT;
-    case KEYCODE_KP_END:
-        return Keyboard::KEY_KP_END;
-    case KEYCODE_KP_DOWN:
-        return Keyboard::KEY_KP_DOWN;
-    case KEYCODE_KP_PG_DOWN:
-        return Keyboard::KEY_KP_PG_DOWN;
-    case KEYCODE_KP_INSERT:
-        return Keyboard::KEY_KP_INSERT;
-    case KEYCODE_KP_DELETE:
-        return Keyboard::KEY_KP_DELETE;
-    case KEYCODE_F1:
-        return Keyboard::KEY_F1;
-    case KEYCODE_F2:
-        return Keyboard::KEY_F2;
-    case KEYCODE_F3:
-        return Keyboard::KEY_F3;
-    case KEYCODE_F4:
-        return Keyboard::KEY_F4;
-    case KEYCODE_F5:
-        return Keyboard::KEY_F5;
-    case KEYCODE_F6:
-        return Keyboard::KEY_F6;
-    case KEYCODE_F7:
-        return Keyboard::KEY_F7;
-    case KEYCODE_F8:
-        return Keyboard::KEY_F8;
-    case KEYCODE_F9:
-        return Keyboard::KEY_F9;
-    case KEYCODE_F10:
-        return Keyboard::KEY_F10;
-    case KEYCODE_F11:
-        return Keyboard::KEY_F11;
-    case KEYCODE_F12:
-        return Keyboard::KEY_F12;
-    case KEYCODE_SPACE:
-        return Keyboard::KEY_SPACE;
-    case KEYCODE_RIGHT_PAREN:
-        return Keyboard::KEY_RIGHT_PARENTHESIS;
-    case KEYCODE_ZERO:
-        return Keyboard::KEY_ZERO;
-    case KEYCODE_EXCLAM:
-        return Keyboard::KEY_EXCLAM;
-    case KEYCODE_ONE:
-        return Keyboard::KEY_ONE;
-    case KEYCODE_AT:
-        return Keyboard::KEY_AT;
-    case KEYCODE_TWO:
-        return Keyboard::KEY_TWO;
-    case KEYCODE_NUMBER:
-        return Keyboard::KEY_NUMBER;
-    case KEYCODE_THREE:
-        return Keyboard::KEY_THREE;
-    case KEYCODE_DOLLAR:
-        return Keyboard::KEY_DOLLAR;
-    case KEYCODE_FOUR:
-        return Keyboard::KEY_FOUR;
-    case KEYCODE_PERCENT:
-        return Keyboard::KEY_PERCENT;
-    case KEYCODE_FIVE:
-        return Keyboard::KEY_FIVE;
-    case KEYCODE_CIRCUMFLEX:
-        return Keyboard::KEY_CIRCUMFLEX;
-    case KEYCODE_SIX:
-        return Keyboard::KEY_SIX;
-    case KEYCODE_AMPERSAND:
-        return Keyboard::KEY_AMPERSAND;
-    case KEYCODE_SEVEN:
-        return Keyboard::KEY_SEVEN;
-    case KEYCODE_ASTERISK:
-        return Keyboard::KEY_ASTERISK;
-    case KEYCODE_EIGHT:
-        return Keyboard::KEY_EIGHT;
-    case KEYCODE_LEFT_PAREN:
-        return Keyboard::KEY_LEFT_PARENTHESIS;
-    case KEYCODE_NINE:
-        return Keyboard::KEY_NINE;
-    case KEYCODE_EQUAL:
-        return Keyboard::KEY_EQUAL;
-    case KEYCODE_PLUS:
-        return Keyboard::KEY_PLUS;
-    case KEYCODE_LESS_THAN:
-        return Keyboard::KEY_LESS_THAN;
-    case KEYCODE_COMMA:
-        return Keyboard::KEY_COMMA;
-    case KEYCODE_UNDERSCORE:
-        return Keyboard::KEY_UNDERSCORE;
-    case KEYCODE_MINUS:
-        return Keyboard::KEY_MINUS;
-    case KEYCODE_GREATER_THAN:
-        return Keyboard::KEY_GREATER_THAN;
-    case KEYCODE_PERIOD:
-        return Keyboard::KEY_PERIOD;
-    case KEYCODE_COLON:
-        return Keyboard::KEY_COLON;
-    case KEYCODE_SEMICOLON:
-        return Keyboard::KEY_SEMICOLON;
-    case KEYCODE_QUESTION:
-        return Keyboard::KEY_QUESTION;
-    case KEYCODE_SLASH:
-        return Keyboard::KEY_SLASH;
-    case KEYCODE_GRAVE:
-        return Keyboard::KEY_GRAVE;
-    case KEYCODE_TILDE:
-        return Keyboard::KEY_TILDE;
-    case KEYCODE_LEFT_BRACE:
-        return Keyboard::KEY_LEFT_BRACE;
-    case KEYCODE_LEFT_BRACKET:
-        return Keyboard::KEY_LEFT_BRACKET;
-    case KEYCODE_BAR:
-        return Keyboard::KEY_BAR;
-    case KEYCODE_BACK_SLASH:
-        return Keyboard::KEY_BACK_SLASH;
-    case KEYCODE_RIGHT_BRACE:
-        return Keyboard::KEY_RIGHT_BRACE;
-    case KEYCODE_RIGHT_BRACKET:
-        return Keyboard::KEY_RIGHT_BRACKET;
-    case KEYCODE_QUOTE:
-        return Keyboard::KEY_QUOTE;
-    case KEYCODE_APOSTROPHE:
-        return Keyboard::KEY_APOSTROPHE;
-    case 0x20AC:
-        return Keyboard::KEY_EURO;
-    case KEYCODE_POUND_SIGN:
-        return Keyboard::KEY_POUND;
-    case KEYCODE_YEN_SIGN:
-        return Keyboard::KEY_YEN;
-    case KEYCODE_MIDDLE_DOT:
-        return Keyboard::KEY_MIDDLE_DOT;
-    case KEYCODE_CAPITAL_A:
-        return Keyboard::KEY_CAPITAL_A;
-    case KEYCODE_A:
-        return Keyboard::KEY_A;
-    case KEYCODE_CAPITAL_B:
-        return Keyboard::KEY_CAPITAL_B;
-    case KEYCODE_B:
-        return Keyboard::KEY_B;
-    case KEYCODE_CAPITAL_C:
-        return Keyboard::KEY_CAPITAL_C;
-    case KEYCODE_C:
-        return Keyboard::KEY_C;
-    case KEYCODE_CAPITAL_D:
-        return Keyboard::KEY_CAPITAL_D;
-    case KEYCODE_D:
-        return Keyboard::KEY_D;
-    case KEYCODE_CAPITAL_E:
-        return Keyboard::KEY_CAPITAL_E;
-    case KEYCODE_E:
-        return Keyboard::KEY_E;
-    case KEYCODE_CAPITAL_F:
-        return Keyboard::KEY_CAPITAL_F;
-    case KEYCODE_F:
-        return Keyboard::KEY_F;
-    case KEYCODE_CAPITAL_G:
-        return Keyboard::KEY_CAPITAL_G;
-    case KEYCODE_G:
-        return Keyboard::KEY_G;
-    case KEYCODE_CAPITAL_H:
-        return Keyboard::KEY_CAPITAL_H;
-    case KEYCODE_H:
-        return Keyboard::KEY_H;
-    case KEYCODE_CAPITAL_I:
-        return Keyboard::KEY_CAPITAL_I;
-    case KEYCODE_I:
-        return Keyboard::KEY_I;
-    case KEYCODE_CAPITAL_J:
-        return Keyboard::KEY_CAPITAL_J;
-    case KEYCODE_J:
-        return Keyboard::KEY_J;
-    case KEYCODE_CAPITAL_K:
-        return Keyboard::KEY_CAPITAL_K;
-    case KEYCODE_K:
-        return Keyboard::KEY_K;
-    case KEYCODE_CAPITAL_L:
-        return Keyboard::KEY_CAPITAL_L;
-    case KEYCODE_L:
-        return Keyboard::KEY_L;
-    case KEYCODE_CAPITAL_M:
-        return Keyboard::KEY_CAPITAL_M;
-    case KEYCODE_M:
-        return Keyboard::KEY_M;
-    case KEYCODE_CAPITAL_N:
-        return Keyboard::KEY_CAPITAL_N;
-    case KEYCODE_N:
-        return Keyboard::KEY_N;
-    case KEYCODE_CAPITAL_O:
-        return Keyboard::KEY_CAPITAL_O;
-    case KEYCODE_O:
-        return Keyboard::KEY_O;
-    case KEYCODE_CAPITAL_P:
-        return Keyboard::KEY_CAPITAL_P;
-    case KEYCODE_P:
-        return Keyboard::KEY_P;
-    case KEYCODE_CAPITAL_Q:
-        return Keyboard::KEY_CAPITAL_Q;
-    case KEYCODE_Q:
-        return Keyboard::KEY_Q;
-    case KEYCODE_CAPITAL_R:
-        return Keyboard::KEY_CAPITAL_R;
-    case KEYCODE_R:
-        return Keyboard::KEY_R;
-    case KEYCODE_CAPITAL_S:
-        return Keyboard::KEY_CAPITAL_S;
-    case KEYCODE_S:
-        return Keyboard::KEY_S;
-    case KEYCODE_CAPITAL_T:
-        return Keyboard::KEY_CAPITAL_T;
-    case KEYCODE_T:
-        return Keyboard::KEY_T;
-    case KEYCODE_CAPITAL_U:
-        return Keyboard::KEY_CAPITAL_U;
-    case KEYCODE_U:
-        return Keyboard::KEY_U;
-    case KEYCODE_CAPITAL_V:
-        return Keyboard::KEY_CAPITAL_V;
-    case KEYCODE_V:
-        return Keyboard::KEY_V;
-    case KEYCODE_CAPITAL_W:
-        return Keyboard::KEY_CAPITAL_W;
-    case KEYCODE_W:
-        return Keyboard::KEY_W;
-    case KEYCODE_CAPITAL_X:
-        return Keyboard::KEY_CAPITAL_X;
-    case KEYCODE_X:
-        return Keyboard::KEY_X;
-    case KEYCODE_CAPITAL_Y:
-        return Keyboard::KEY_CAPITAL_Y;
-    case KEYCODE_Y:
-        return Keyboard::KEY_Y;
-    case KEYCODE_CAPITAL_Z:
-        return Keyboard::KEY_CAPITAL_Z;
-    case KEYCODE_Z:
-        return Keyboard::KEY_Z;
-    default:
-        return Keyboard::KEY_NONE;
-    }
-}
-
-/**
- * Returns the unicode value from the given QNX key code value.
- * Some non-printable characters also have corresponding unicode values, such as backspace.
- *
- * @param qnxKeyCode The keyboard key code.
- *
- * @return The unicode value or 0 if the keycode did not represent a unicode key.
- */
-static int getUnicode(int qnxKeyCode)
-{
-    if (qnxKeyCode >= KEYCODE_PC_KEYS && qnxKeyCode <= UNICODE_PRIVATE_USE_AREA_LAST)
-    {
-        switch (qnxKeyCode)
-        {
-        case KEYCODE_BACKSPACE:
-            return 0x0008;
-        case KEYCODE_TAB:
-            return 0x0009;
-        case KEYCODE_KP_ENTER:
-        case KEYCODE_RETURN:
-            return 0x000A;
-        case KEYCODE_ESCAPE:
-            return 0x001B;
-        // Win32 doesn't consider delete to be a key char.
-        default:
-            return 0;
-        }
-    }
-    return qnxKeyCode;
-}
-
-extern void print(const char* format, ...)
-{
-    GP_ASSERT(format);
-    va_list argptr;
-    va_start(argptr, format);
-    vfprintf(stderr, format, argptr);
-    va_end(argptr);
-}
-
-EGLenum checkErrorEGL(const char* msg)
-{
-    GP_ASSERT(msg);
-    static const char* errmsg[] =
-    {
-        "EGL function failed",
-        "EGL is not initialized, or could not be initialized, for the specified display",
-        "EGL cannot access a requested resource",
-        "EGL failed to allocate resources for the requested operation",
-        "EGL fail to access an unrecognized attribute or attribute value was passed in an attribute list",
-        "EGLConfig argument does not name a valid EGLConfig",
-        "EGLContext argument does not name a valid EGLContext",
-        "EGL current surface of the calling thread is no longer valid",
-        "EGLDisplay argument does not name a valid EGLDisplay",
-        "EGL arguments are inconsistent",
-        "EGLNativePixmapType argument does not refer to a valid native pixmap",
-        "EGLNativeWindowType argument does not refer to a valid native window",
-        "EGL one or more argument values are invalid",
-        "EGLSurface argument does not name a valid surface configured for rendering",
-        "EGL power management event has occurred",
-    };
-    EGLenum error = eglGetError();
-    fprintf(stderr, "%s: %s\n", msg, errmsg[error - EGL_SUCCESS]);
-    return error;
-}
-
-void gesture_callback(gesture_base_t* gesture, mtouch_event_t* event, void* param, int async)
-{
-    switch (gesture->type)
-    {
-    case GESTURE_SWIPE:
-        {
-            if ( __gestureEventsProcessed.test(Gesture::GESTURE_SWIPE) )
-            {
-                gesture_swipe_t* swipe = (gesture_swipe_t*)gesture;
-                if (!__gestureSwipeRecognized)
-                {
-                    Platform::gestureSwipeEventInternal(swipe->coords.x, swipe->coords.y, swipe->direction);
-                    __gestureSwipeRecognized = true;
-                }
-
-            }
-            break;
-        }
-
-    case GESTURE_PINCH:
-        {
-            if ( __gestureEventsProcessed.test(Gesture::GESTURE_PINCH) )
-            {
-                gesture_pinch_t* pinch = (gesture_pinch_t*)gesture;
-                float dist_x = (float)pinch->last_distance.x - (float)pinch->distance.x;
-                float dist_y = (float)pinch->last_distance.y - (float)pinch->distance.y;
-                float scale = sqrt( (dist_x * dist_x) + (dist_y * dist_y) );
-                Game::getInstance()->gesturePinchEvent(pinch->centroid.x, pinch->centroid.y, scale);
-            }
-            break;
-        }
-
-    case GESTURE_TAP:
-        {
-            if ( __gestureEventsProcessed.test(Gesture::GESTURE_TAP) )
-            {
-                gesture_tap_t* tap = (gesture_tap_t*)gesture;
-                Platform::gestureTapEventInternal(tap->touch_coords.x, tap->touch_coords.y);
-            }
-            break;
-        }
-
-    default:
-        break;
-
-    }
-}
-
-#ifdef GP_USE_GAMEPAD
-
-static const char* __vendorStrings[] =
-{
-    "SteelSeries",
-    "Nintendo",
-};
-
-static const char* __productStrings[] =
-{
-    "FREE",
-    "Wii Remote",
-};
-
-static const int __VIDs[] = {
-    0x1038,
-    0x057e,
-};
-
-static const int __PIDs[] = {
-    0x1412,
-    0x0306,
-};
-
-static const unsigned int __knownGamepads = 2;
-
-void queryGamepad(GamepadHandle handle, int* buttonCount, int* joystickCount, int* productId, int* vendorId, char* productString, char* vendorString)
-{
-    char id[128];
-    screen_get_device_property_iv(handle, SCREEN_PROPERTY_BUTTON_COUNT, buttonCount);
-    screen_get_device_property_cv(handle, SCREEN_PROPERTY_ID_STRING, 128, id);
-    screen_get_device_property_cv(handle, SCREEN_PROPERTY_PRODUCT, 64, productString);
-    screen_get_device_property_cv(handle, SCREEN_PROPERTY_VENDOR, 64, vendorString);
-
-    // Check for the existence of analog sticks.
-    int analogs[3];
-    if (!screen_get_device_property_iv(handle, SCREEN_PROPERTY_ANALOG0, analogs))
-    {
-    	++(*joystickCount);
-    }
-
-    if (!screen_get_device_property_iv(handle, SCREEN_PROPERTY_ANALOG1, analogs))
-    {
-    	++(*joystickCount);
-    }
-
-    // ID string format: A-BBBB-CCCC-D.D
-    // A is the device's index
-    // BBBB is the device's Vendor ID (in hexadecimal)
-    // CCCC is the device's Product ID (also in hexadecimal)
-    // D.D is the device's version number
-    char* token = strtok(id, "-");
-    token = strtok(NULL, "-");
-    if (token)
-    {
-	    *vendorId = strtol(token, NULL, 16);
-    }
-
-    token = strtok(NULL, "-");
-    if (token)
-    {
-        *productId = strtol(token, NULL, 16);
-    }
-
-    // For gamepads unknown to BB10,
-    // check VID and PID against gamepads known to gameplay.
-    if (strlen(productString) == 0 || strlen(vendorString) == 0)
-    {
-        for (unsigned int i = 0; i < __knownGamepads; ++i)
-        {
-            if (__VIDs[i] == *vendorId && __PIDs[i] == *productId)
-            {
-            	strcpy(vendorString, __vendorStrings[i]);
-                strcpy(productString, __productStrings[i]);
-            }
-        }
-    }
-}
-
-void Platform::pollGamepadState(Gamepad* gamepad)
-{
-	unsigned int buttons;
-    screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_BUTTONS, (int*)&buttons);
-	gamepad->setButtons(buttons);
-
-    unsigned int i;
-    for (i = 0; i < gamepad->_joystickCount; ++i)
-    {
-        GP_ASSERT(i < 2);
-
-        int analog[3];
-        switch (i)
-        {
-        case 0:
-            screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_ANALOG0, analog);
-            break;
-        case 1:
-            screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_ANALOG1, analog);
-            break;
-        }
-
-        // So far we've tested two gamepads with analog sticks on BlackBerry:
-        // the SteelSeries FREE, and the iControlPad.
-        // Both return values between -128 and +127, with the y axis starting from
-        // the top at -128.
-        // 1 / 128 == 0.0078125f
-        // 1 / 127 == 0.0078740157480315f
-        float x = (float)analog[0];
-        float y = -(float)analog[1];
-        x *= (x < 0) ? 0.0078125f : 0.0078740157480315f;
-        y *= (y > 0) ? 0.0078125f : 0.0078740157480315f;
-
-		gamepad->setJoystickValue(i, x, y);
-    }
-
-    for (i = 0; i < gamepad->_triggerCount; ++i)
-    {
-        GP_ASSERT(i < 2);
-
-        int analog[3];
-        switch (i)
-        {
-        case 0:
-            screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_ANALOG0, analog);
-            break;
-        case 1:
-            screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_ANALOG1, analog);
-            break;
-        }
-
-        float value = (float)analog[2] * 0.0078125f;
-		gamepad->setTriggerValue(i, value);
-    }
-}
-#else
-void Platform::pollGamepadState(Gamepad* gamepad)
-{
-}
-#endif
-
-Platform::Platform(Game* game)
-    : _game(game)
-{
-}
-
-Platform::~Platform()
-{
-    if (__eglDisplay != EGL_NO_DISPLAY)
-    {
-        eglMakeCurrent(__eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-    }
-
-    if (__eglSurface != EGL_NO_SURFACE)
-    {
-        eglDestroySurface(__eglDisplay, __eglSurface);
-        __eglSurface = EGL_NO_SURFACE;
-    }
-
-    if (__eglContext != EGL_NO_CONTEXT)
-    {
-        eglDestroyContext(__eglDisplay, __eglContext);
-        __eglContext = EGL_NO_CONTEXT;
-    }
-
-    if (__eglDisplay != EGL_NO_DISPLAY)
-    {
-        eglTerminate(__eglDisplay);
-        __eglDisplay = EGL_NO_DISPLAY;
-    }
-
-    if (__screenWindow)
-    {
-        screen_destroy_window(__screenWindow);
-        __screenWindow = NULL;
-    }
-
-    if (__screenEvent)
-    {
-        screen_destroy_event(__screenEvent);
-        __screenEvent = NULL;
-    }
-
-    if (__screenContext)
-    {
-        screen_destroy_context(__screenContext);
-        __screenContext = NULL;
-    }
-}
-
-Platform* Platform::create(Game* game)
-{
-    FileSystem::setResourcePath("./app/native/");
-    Platform* platform = new Platform(game);
-
-    // Query game config
-    int samples = 0;
-    Properties* config = Game::getInstance()->getConfig()->getNamespace("window", true);
-    if (config)
-    {
-        samples = std::max(config->getInt("samples"), 0);
-    }
-
-    __gestureSet = gestures_set_alloc();
-    swipe_gesture_alloc(NULL, gesture_callback, __gestureSet);
-    pinch_gesture_alloc(NULL, gesture_callback, __gestureSet);
-    tap_gesture_alloc(NULL, gesture_callback, __gestureSet);
-
-    bps_initialize();
-
-    // Initialize navigator and orientation
-    static const int SENSOR_RATE = 25000; // (25000 microseconds = 40 Hz)
-    sensor_set_rate(SENSOR_TYPE_AZIMUTH_PITCH_ROLL, SENSOR_RATE);
-    sensor_set_rate(SENSOR_TYPE_ACCELEROMETER, SENSOR_RATE);
-    sensor_set_rate(SENSOR_TYPE_GYROSCOPE, SENSOR_RATE);
-    sensor_set_skip_duplicates(SENSOR_TYPE_AZIMUTH_PITCH_ROLL, true);
-    sensor_set_skip_duplicates(SENSOR_TYPE_ACCELEROMETER, true);
-    sensor_set_skip_duplicates(SENSOR_TYPE_GYROSCOPE, true);
-    sensor_request_events(SENSOR_TYPE_AZIMUTH_PITCH_ROLL);
-    sensor_request_events(SENSOR_TYPE_ACCELEROMETER);
-    sensor_request_events(SENSOR_TYPE_GYROSCOPE);
-    navigator_request_events(0);
-    navigator_rotation_lock(true);
-    __orientationAngle = atoi(getenv("ORIENTATION"));
-
-    int rc = 0;
-    int screenFormat = SCREEN_FORMAT_RGBA8888;
-#ifdef __X86__
-    int screenUsage = SCREEN_USAGE_OPENGL_ES2;
-#else
-    int screenUsage = SCREEN_USAGE_DISPLAY|SCREEN_USAGE_OPENGL_ES2; // Physical device copy directly into physical display
-#endif
-    int screenSwapInterval = WINDOW_VSYNC ? 1 : 0;
-    int screenTransparency = SCREEN_TRANSPARENCY_NONE;
-
-    char *width_str = getenv("WIDTH");
-    char *height_str = getenv("HEIGHT");
-
-    // Hard-coded to (0,0).
-    int windowPosition[] =
-    {
-        0, 0
-    };
-
-    EGLint eglConfigCount;
-
-    // Hard-coded to 32-bit/OpenGL ES 2.0.
-    // NOTE: EGL_SAMPLE_BUFFERS and EGL_SAMPLES MUST remain at the beginning of the attribute list
-    // since they are expected to be at indices 0-3 in config fallback code later.
-    EGLint eglConfigAttrs[] =
-    {
-        EGL_SAMPLE_BUFFERS,     samples > 0 ? 1 : 0,
-        EGL_SAMPLES,            samples,
-        EGL_RED_SIZE,           8,
-        EGL_GREEN_SIZE,         8,
-        EGL_BLUE_SIZE,          8,
-        EGL_ALPHA_SIZE,         8,
-        EGL_DEPTH_SIZE,         24,
-        EGL_STENCIL_SIZE,       8,
-        EGL_SURFACE_TYPE,       EGL_WINDOW_BIT,
-        EGL_RENDERABLE_TYPE,    EGL_OPENGL_ES2_BIT,
-        EGL_NONE
-    };
-    __multiSampling = samples > 0;
-
-    const EGLint eglContextAttrs[] =
-    {
-        EGL_CONTEXT_CLIENT_VERSION,    2,
-        EGL_NONE
-    };
-
-    const EGLint eglSurfaceAttrs[] =
-    {
-        EGL_RENDER_BUFFER,    EGL_BACK_BUFFER,
-        EGL_NONE
-    };
-
-    // Create the screen context.
-    rc = screen_create_context(&__screenContext, 0);
-    if (rc)
-    {
-        perror("screen_create_context");
-        goto error;
-    }
-
-    // Create the screen window.
-    rc = screen_create_window(&__screenWindow, __screenContext);
-    if (rc)
-    {
-        perror("screen_create_window");
-        goto error;
-    }
-
-    // Window group
-	rc = screen_create_window_group(__screenWindow, "windowgroup");
-	if (rc)
-	{
-		perror("screen_create_window_group failed");
-		goto error;
-	}
-
-    // Set/get any window properties.
-    rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_FORMAT, &screenFormat);
-    if (rc)
-    {
-        perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
-        goto error;
-    }
-
-    rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_USAGE, &screenUsage);
-    if (rc)
-    {
-        perror("screen_set_window_property_iv(SCREEN_PROPERTY_USAGE)");
-        goto error;
-    }
-
-    if (width_str && height_str)
-    {
-        __screenWindowSize[0] = atoi(width_str);
-        __screenWindowSize[1] = atoi(height_str);
-    }
-    else
-    {
-        screen_display_t screen_display;
-        rc = screen_get_window_property_pv(__screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&screen_display);
-        if (rc)
-        {
-            perror("screen_get_window_property_pv(SCREEN_PROPERTY_DISPLAY)");
-            goto error;
-        }
-
-        screen_display_mode_t screen_mode;
-        rc = screen_get_display_property_pv(screen_display, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
-        if (rc)
-        {
-            perror("screen_get_display_property_pv(SCREEN_PROPERTY_MODE)");
-            goto error;
-        }
-
-        int size[2];
-        rc = screen_get_window_property_iv(__screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, size);
-        if (rc)
-        {
-            perror("screen_get_window_property_iv(SCREEN_PROPERTY_BUFFER_SIZE)");
-            goto error;
-        }
-
-        __screenWindowSize[0] = size[0];
-        __screenWindowSize[1] = size[1];
-
-        if ((__orientationAngle == 0) || (__orientationAngle == 180))
-        {
-            if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
-                ((screen_mode.width < screen_mode.height) && (size[0] > size[1])))
-            {
-                __screenWindowSize[1] = size[0];
-                __screenWindowSize[0] = size[1];
-            }
-        }
-        else if ((__orientationAngle == 90) || (__orientationAngle == 270))
-        {
-            if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
-                ((screen_mode.width < screen_mode.height) && (size[0] < size[1])))
-            {
-                __screenWindowSize[1] = size[0];
-                __screenWindowSize[0] = size[1];
-            }
-        }
-        else
-        {
-            perror("Navigator returned an unexpected orientation angle.");
-            goto error;
-        }
-
-
-        rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_ROTATION, &__orientationAngle);
-        if (rc)
-        {
-            perror("screen_set_window_property_iv(SCREEN_PROPERTY_ROTATION)");
-            goto error;
-        }
-    }
-
-    rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, __screenWindowSize);
-    if (rc)
-    {
-        perror("screen_set_window_property_iv(SCREEN_PROPERTY_BUFFER_SIZE)");
-        goto error;
-    }
-
-    if (windowPosition[0] != 0 || windowPosition[1] != 0)
-    {
-        rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_POSITION, windowPosition);
-        if (rc)
-        {
-            perror("screen_set_window_property_iv(SCREEN_PROPERTY_POSITION)");
-            goto error;
-        }
-    }
-
-    rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_TRANSPARENCY, &screenTransparency);
-    if (rc)
-    {
-        perror("screen_set_window_property_iv(SCREEN_PROPERTY_TRANSPARENCY)");
-        goto error;
-    }
-
-    // Double buffered.
-    rc = screen_create_window_buffers(__screenWindow, 2);
-    if (rc)
-    {
-        perror("screen_create_window_buffers");
-        goto error;
-    }
-
-    // Create screen event object.
-    rc = screen_create_event(&__screenEvent);
-    if (rc)
-    {
-        perror("screen_create_event");
-        goto error;
-    }
-
-    // Request screen events.
-    screen_request_events(__screenContext);
-
-    // Get the EGL display and initialize.
-    __eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
-    if (__eglDisplay == EGL_NO_DISPLAY)
-    {
-        perror("eglGetDisplay");
-        goto error;
-    }
-    if (eglInitialize(__eglDisplay, NULL, NULL) != EGL_TRUE)
-    {
-        perror("eglInitialize");
-        goto error;
-    }
-
-    if (eglChooseConfig(__eglDisplay, eglConfigAttrs, &__eglConfig, 1, &eglConfigCount) != EGL_TRUE || eglConfigCount == 0)
-    {
-        bool success = false;
-        while (samples)
-        {
-            // Try lowering the MSAA sample count until we find a supported config
-            GP_WARN("Failed to find a valid EGL configuration with EGL samples=%d. Trying samples=%d instead.", samples, samples/2);
-            samples /= 2;
-            eglConfigAttrs[1] = samples > 0 ? 1 : 0;
-            eglConfigAttrs[3] = samples;
-            if (eglChooseConfig(__eglDisplay, eglConfigAttrs, &__eglConfig, 1, &eglConfigCount) == EGL_TRUE && eglConfigCount > 0)
-            {
-                success = true;
-                break;
-            }
-        }
-
-        __multiSampling = samples > 0;
-
-        if (!success)
-        {
-            checkErrorEGL("eglChooseConfig");
-            goto error;
-        }
-    }
-
-    __eglContext = eglCreateContext(__eglDisplay, __eglConfig, EGL_NO_CONTEXT, eglContextAttrs);
-    if (__eglContext == EGL_NO_CONTEXT)
-    {
-        checkErrorEGL("eglCreateContext");
-        goto error;
-    }
-
-    __eglSurface = eglCreateWindowSurface(__eglDisplay, __eglConfig, __screenWindow, eglSurfaceAttrs);
-    if (__eglSurface == EGL_NO_SURFACE)
-    {
-        checkErrorEGL("eglCreateWindowSurface");
-        goto error;
-    }
-
-    if (eglMakeCurrent(__eglDisplay, __eglSurface, __eglSurface, __eglContext) != EGL_TRUE)
-    {
-        checkErrorEGL("eglMakeCurrent");
-        goto error;
-    }
-
-    // Set vsync.
-    eglSwapInterval(__eglDisplay, screenSwapInterval);
-
-    // Initialize OpenGL ES extensions.
-    __glExtensions = (const char*)glGetString(GL_EXTENSIONS);
-
-    if (strstr(__glExtensions, "GL_OES_vertex_array_object") || strstr(__glExtensions, "GL_ARB_vertex_array_object"))
-    {
-        glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES");
-        glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES");
-        glGenVertexArrays = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES");
-        glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress("glIsVertexArrayOES");
-    }
-
- #ifdef GP_USE_GAMEPAD
-
-    screen_device_t* screenDevs;
-
-    // Discover initial gamepad devices.
-    int count;
-    screen_get_context_property_iv(__screenContext, SCREEN_PROPERTY_DEVICE_COUNT, &count);
-    screenDevs = (screen_device_t*)calloc(count, sizeof(screen_device_t));
-    screen_get_context_property_pv(__screenContext, SCREEN_PROPERTY_DEVICES, (void**)screenDevs);
-
-	for (int i = 0; i < count; i++)
-    {
-	    int type;
-        screen_get_device_property_iv(screenDevs[i], SCREEN_PROPERTY_TYPE, &type);
-
-        if (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK)
-        {
-            int buttonCount = 0;
-            int joystickCount = 0;
-            int productId;
-            int vendorId;
-            char productString[64];
-            char vendorString[64];
-            queryGamepad(screenDevs[i], &buttonCount, &joystickCount, &productId, &vendorId, productString, vendorString);
-            Platform::gamepadEventConnectedInternal(screenDevs[i], buttonCount, joystickCount, 0, vendorId, productId, vendorString, productString);
-        }
-	}
-	free(screenDevs);
-#endif
-
-    return platform;
-
-error:
-
-    return NULL;
-}
-
-/**
- * Convert the timespec into milliseconds.
- */
-double timespec2millis(struct timespec *a)
-{
-    GP_ASSERT(a);
-    return (1000.0 * a->tv_sec) + (0.000001 * a->tv_nsec);
-}
-
-/**
- * Fires a mouse event or a touch event on the game.
- * If the mouse event is not consumed, a touch event is fired instead.
- *
- * @param mouseEvent The mouse event to fire.
- * @param touchEvent The touch event to fire.
- * @param x The x position of the touch in pixels.
- * @param y The y position of the touch in pixels.
- */
-void mouseOrTouchEvent(Mouse::MouseEvent mouseEvent, Touch::TouchEvent touchEvent, int x, int y)
-{
-    if (!gameplay::Platform::mouseEventInternal(mouseEvent, x, y, 0))
-    {
-        Platform::touchEventInternal(touchEvent, x, y, 0, true);
-    }
-}
-
-int Platform::enterMessagePump()
-{
-    GP_ASSERT(_game);
-
-    int rc;
-    int eventType;
-    int flags;
-    int value;
-    int position[2];
-    int domain;
-    mtouch_event_t touchEvent;
-    bool suspended = false;
-
-    // Get the initial time.
-    clock_gettime(CLOCK_REALTIME, &__timespec);
-    __timeStart = timespec2millis(&__timespec);
-    __timeAbsolute = 0L;
-
-    _game->run();
-
-    // Message loop.
-    while (true)
-    {
-        bps_event_t* event = NULL;
-
-        while (true)
-        {
-            rc = bps_get_event(&event, 1);
-            GP_ASSERT(rc == BPS_SUCCESS);
-
-            if (event == NULL)
-                break;
-
-#ifdef GP_USE_SOCIAL
-            // if the social controller needs to deal with the event do that here
-            if (Game::getInstance()->getSocialController()->handleEvent(event))
-            	break;
-#endif
-
-            domain = bps_event_get_domain(event);
-
-            if (domain == screen_get_domain())
-            {
-                __screenEvent = screen_event_get_event(event);
-                screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_TYPE, &eventType);
-                switch (eventType)
-                {
-                    case SCREEN_EVENT_MTOUCH_TOUCH:
-                    {
-                        screen_get_mtouch_event(__screenEvent, &touchEvent, 0);
-                        if (__gestureEventsProcessed.any())
-                            rc = gestures_set_process_event(__gestureSet, &touchEvent, NULL);
-
-                        if ( !rc && (__multiTouch || touchEvent.contact_id == 0) )
-                        {
-                            gameplay::Platform::touchEventInternal(Touch::TOUCH_PRESS, touchEvent.x, touchEvent.y, touchEvent.contact_id);
-                        }
-                        break;
-                    }
-
-                    case SCREEN_EVENT_MTOUCH_RELEASE:
-                    {
-                        screen_get_mtouch_event(__screenEvent, &touchEvent, 0);
-                        if (__gestureEventsProcessed.any())
-                            rc = gestures_set_process_event(__gestureSet, &touchEvent, NULL);
-
-                        if ( !rc && (__multiTouch || touchEvent.contact_id == 0) )
-                        {
-                            gameplay::Platform::touchEventInternal(Touch::TOUCH_RELEASE, touchEvent.x, touchEvent.y, touchEvent.contact_id);
-                        }
-                        if (__gestureSwipeRecognized)
-                        {
-                            __gestureSwipeRecognized = false;
-                        }
-                        break;
-                    }
-
-                    case SCREEN_EVENT_MTOUCH_MOVE:
-                    {
-                        screen_get_mtouch_event(__screenEvent, &touchEvent, 0);
-                        if (__gestureEventsProcessed.any())
-                            rc = gestures_set_process_event(__gestureSet, &touchEvent, NULL);
-
-                        if ( !rc && (__multiTouch || touchEvent.contact_id == 0) )
-                        {
-                            gameplay::Platform::touchEventInternal(Touch::TOUCH_MOVE, touchEvent.x, touchEvent.y, touchEvent.contact_id);
-                        }
-                        break;
-                    }
-
-                    case SCREEN_EVENT_POINTER:
-                    {
-                        static int mouse_pressed = 0;
-                        int buttons;
-                        int wheel;
-                        // A move event will be fired unless a button state changed.
-                        bool move = true;
-                        bool left_move = false;
-                        // This is a mouse move event, it is applicable to a device with a usb mouse or simulator.
-                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_BUTTONS, &buttons);
-                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_SOURCE_POSITION, position);
-                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_MOUSE_WHEEL, &wheel);
-
-                        // Handle left mouse. Interpret as touch if the left mouse event is not consumed.
-                        if (buttons & SCREEN_LEFT_MOUSE_BUTTON)
-                        {
-                            if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON)
-                            {
-                                left_move = true;
-                            }
-                            else
-                            {
-                                move = false;
-                                mouse_pressed |= SCREEN_LEFT_MOUSE_BUTTON;
-                                mouseOrTouchEvent(Mouse::MOUSE_PRESS_LEFT_BUTTON, Touch::TOUCH_PRESS, position[0], position[1]);
-                            }
-                        }
-                        else if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON)
-                        {
-                            move = false;
-                            mouse_pressed &= ~SCREEN_LEFT_MOUSE_BUTTON;
-                            mouseOrTouchEvent(Mouse::MOUSE_RELEASE_LEFT_BUTTON, Touch::TOUCH_RELEASE, position[0], position[1]);
-                        }
-
-                        // Handle right mouse.
-                        if (buttons & SCREEN_RIGHT_MOUSE_BUTTON)
-                        {
-                            if ((mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) == 0)
-                            {
-                                move = false;
-                                mouse_pressed |= SCREEN_RIGHT_MOUSE_BUTTON;
-                                gameplay::Platform::mouseEventInternal(Mouse::MOUSE_PRESS_RIGHT_BUTTON, position[0], position[1], 0);
-                            }
-                        }
-                        else if (mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON)
-                        {
-                            move = false;
-                            mouse_pressed &= ~SCREEN_RIGHT_MOUSE_BUTTON;
-                            gameplay::Platform::mouseEventInternal(Mouse::MOUSE_RELEASE_RIGHT_BUTTON, position[0], position[1], 0);
-                        }
-
-                        // Handle middle mouse.
-                        if (buttons & SCREEN_MIDDLE_MOUSE_BUTTON)
-                        {
-                            if ((mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) == 0)
-                            {
-                                move = false;
-                                mouse_pressed |= SCREEN_MIDDLE_MOUSE_BUTTON;
-                                gameplay::Platform::mouseEventInternal(Mouse::MOUSE_PRESS_MIDDLE_BUTTON, position[0], position[1], 0);
-                            }
-                        }
-                        else if (mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON)
-                        {
-                            move = false;
-                            mouse_pressed &= ~SCREEN_MIDDLE_MOUSE_BUTTON;
-                            gameplay::Platform::mouseEventInternal(Mouse::MOUSE_RELEASE_MIDDLE_BUTTON, position[0], position[1], 0);
-                        }
-
-                        // Fire a move event if none of the buttons changed.
-                        if (left_move)
-                        {
-                            mouseOrTouchEvent(Mouse::MOUSE_MOVE, Touch::TOUCH_MOVE, position[0], position[1]);
-                        }
-                        else if (move)
-                        {
-                            gameplay::Platform::mouseEventInternal(Mouse::MOUSE_MOVE, position[0], position[1], 0);
-                        }
-
-                        // Handle mouse wheel events.
-                        if (wheel)
-                        {
-                            gameplay::Platform::mouseEventInternal(Mouse::MOUSE_WHEEL, position[0], position[1], -wheel);
-                        }
-                        break;
-                    }
-
-                    case SCREEN_EVENT_KEYBOARD:
-                    {
-                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_KEY_FLAGS, &flags);
-                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_KEY_SYM, &value);
-                        gameplay::Keyboard::KeyEvent evt = (flags & KEY_DOWN) ? gameplay::Keyboard::KEY_PRESS :  gameplay::Keyboard::KEY_RELEASE;
-                        // Suppress key repeats.
-                        if ((flags & KEY_REPEAT) == 0)
-                        {
-                            keyEventInternal(evt, getKey(value));
-                            if (evt == gameplay::Keyboard::KEY_PRESS && (flags & KEY_SYM_VALID))
-                            {
-                                int unicode = getUnicode(value);
-                                if (unicode)
-                                    keyEventInternal(gameplay::Keyboard::KEY_CHAR, unicode);
-                            }
-                        }
-                        break;
-                    }
-#ifdef GP_USE_GAMEPAD
-                    case SCREEN_EVENT_DEVICE:
-                    {
-                        // A device was attached or removed.
-                        screen_device_t device;
-                        int attached;
-
-                        screen_get_event_property_pv(__screenEvent, SCREEN_PROPERTY_DEVICE, (void**)&device);
-                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_ATTACHED, &attached);
-
-                        if (attached)
-                        {
-                            int type;
-                            screen_get_device_property_iv(device, SCREEN_PROPERTY_TYPE, &type);
-                            if (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK)
-                            {
-                                int buttonCount = 0;
-                                int joystickCount = 0;
-                                int productId;
-                                int vendorId;
-                                char productString[64];
-                                char vendorString[64];
-                                queryGamepad(device, &buttonCount, &joystickCount, &productId, &vendorId, productString, vendorString);
-                                Platform::gamepadEventConnectedInternal(device, buttonCount, joystickCount, 0, vendorId, productId, vendorString, productString);
-                            }
-                        }
-                        else
-                        {
-                            Platform::gamepadEventDisconnectedInternal(device);
-                        }
-
-                        break;
-                    }
-#endif
-                    default:
-                        break;
-                }
-            }
-            else if (domain == navigator_get_domain())
-            {
-                switch (bps_event_get_code(event))
-                {
-                case NAVIGATOR_WINDOW_STATE:
-                {
-                    navigator_window_state_t state = navigator_event_get_window_state(event);
-                    switch (state)
-                    {
-                    case NAVIGATOR_WINDOW_FULLSCREEN:
-                        if (!__screenFullscreen)
-                            __screenFullscreen = true;
-                        _game->resume();
-                        suspended = false;
-                        break;
-                    case NAVIGATOR_WINDOW_THUMBNAIL:
-                    case NAVIGATOR_WINDOW_INVISIBLE:
-                        if (__screenFullscreen && !suspended)
-                        {
-                            _game->pause();
-                            suspended = true;
-                        }
-                        break;
-                    }
-                    break;
-                }
-                case NAVIGATOR_EXIT:
-                	// Call Game::shutdown directly, instead of Game::exit.
-                	// We need to do this since exit() queues a request to shutdown for the
-                	// next frame, which will never get executed because we are suspended.
-                    _game->shutdown();
-                    break;
-                }
-            }
-            else if (domain == sensor_get_domain())
-            {
-                if (bps_event_get_code(event) == SENSOR_AZIMUTH_PITCH_ROLL_READING)
-                {
-                    float azimuth;
-                    sensor_event_get_apr(event, &azimuth, &__pitch, &__roll);
-                }
-                else if (bps_event_get_code(event) == SENSOR_ACCELEROMETER_READING)
-                {
-                    sensor_event_get_xyz(event, &__accelRawX, &__accelRawY, &__accelRawZ);
-                }
-                else if (bps_event_get_code(event) == SENSOR_GYROSCOPE_READING)
-                {
-                    sensor_event_get_xyz(event, &__gyroRawX, &__gyroRawY, &__gyroRawZ);
-                }
-            }
-        }
-
-        // If we are done, then exit.
-        if (_game->getState() == Game::UNINITIALIZED)
-            break;
-
-        if (!suspended)
-        {
-            _game->frame();
-
-            // Post the new frame to the display.
-            // Note that there are a couple cases where eglSwapBuffers could fail
-            // with an error code that requires a certain level of re-initialization:
-            //
-            // 1) EGL_BAD_NATIVE_WINDOW - Called when the surface we're currently using
-            //    is invalidated. This would require us to destroy our EGL surface,
-            //    close our OpenKODE window, and start again.
-            //
-            // 2) EGL_CONTEXT_LOST - Power management event that led to our EGL context
-            //    being lost. Requires us to re-create and re-initalize our EGL context
-            //    and all OpenGL ES state.
-            //
-            // For now, if we get these, we'll simply exit.
-            rc = eglSwapBuffers(__eglDisplay, __eglSurface);
-            if (rc != EGL_TRUE)
-            {
-                _game->shutdown();
-                perror("eglSwapBuffers");
-                break;
-            }
-        }
-    }
-
-    screen_stop_events(__screenContext);
-    bps_shutdown();
-    screen_destroy_context(__screenContext);
-
-    return 0;
-}
-    
-void Platform::signalShutdown() 
-{
-    // nothing to do  
-}
-
-bool Platform::canExit()
-{
-    return true;
-}
-
-unsigned int Platform::getDisplayWidth()
-{
-    return __screenWindowSize[0];
-}
-
-unsigned int Platform::getDisplayHeight()
-{
-    return __screenWindowSize[1];
-}
-
-double Platform::getAbsoluteTime()
-{
-    clock_gettime(CLOCK_REALTIME, &__timespec);
-    double now = timespec2millis(&__timespec);
-    __timeAbsolute = now - __timeStart;
-
-    return __timeAbsolute;
-}
-
-void Platform::setAbsoluteTime(double time)
-{
-    __timeAbsolute = time;
-}
-
-bool Platform::isVsync()
-{
-    return __vsync;
-}
-
-void Platform::setVsync(bool enable)
-{
-    eglSwapInterval(__eglDisplay, enable ? 1 : 0);
-    __vsync = enable;
-}
-
-void Platform::swapBuffers()
-{
-    if (__eglDisplay && __eglSurface)
-        eglSwapBuffers(__eglDisplay, __eglSurface);
-}
-
-void Platform::sleep(long ms)
-{
-    usleep(ms * 1000);
-}
-
-void Platform::setMultiSampling(bool enabled)
-{
-    if (enabled == __multiSampling)
-    {
-        return;
-    }
-
-    // TODO:
-    __multiSampling = enabled;
-}
-
-bool Platform::isMultiSampling()
-{
-    return __multiSampling;
-}
-
-void Platform::setMultiTouch(bool enabled)
-{
-    __multiTouch = enabled;
-}
-
-bool Platform::isMultiTouch()
-{
-    return __multiTouch;
-}
-
-bool Platform::hasAccelerometer()
-{
-    return true;
-}
-
-void Platform::getAccelerometerValues(float* pitch, float* roll)
-{
-    GP_ASSERT(pitch);
-    GP_ASSERT(roll);
-
-    switch(__orientationAngle)
-    {
-    // Landscape based device adjusting for landscape game mode
-    case 0:
-        if (pitch)
-            *pitch = __pitch;
-        if (roll)
-            *roll = -__roll;
-        break;
-    case 180:
-        if (pitch)
-            *pitch = -__pitch;
-        if (roll)
-            *roll = __roll;
-        break;
-
-    // Portrait based device adjusting for landscape game mode
-    case 90:
-        if (pitch)
-            *pitch = -__roll;
-        if (roll)
-            *roll = -__pitch;
-        break;
-
-    case  270:
-        if (pitch)
-            *pitch = __roll;
-        if (roll)
-            *roll = __pitch;
-        break;
-
-    default:
-        break;
-    }
-}
-
-void Platform::getSensorValues(float* accelX, float* accelY, float* accelZ, float* gyroX, float* gyroY, float* gyroZ)
-{
-	if (accelX)
-	{
-		*accelX = __accelRawX;
-	}
-
-	if (accelY)
-	{
-		*accelY = __accelRawY;
-	}
-
-	if (accelZ)
-	{
-		*accelZ = __accelRawZ;
-	}
-
-	if (gyroX)
-	{
-		*gyroX = __gyroRawX;
-	}
-
-	if (gyroY)
-	{
-		*gyroY = __gyroRawY;
-	}
-
-	if (gyroZ)
-	{
-		*gyroZ = __gyroRawZ;
-	}
-}
-
-void Platform::getArguments(int* argc, char*** argv)
-{
-    if (argc)
-        *argc = __argc;
-    if (argv)
-        *argv = __argv;
-}
-
-bool Platform::hasMouse()
-{
-    // not supported
-    return false;
-}
-
-void Platform::setMouseCaptured(bool captured)
-{
-    // not supported
-}
-
-bool Platform::isMouseCaptured()
-{
-    // not supported
-    return false;
-}
-
-void Platform::setCursorVisible(bool visible)
-{
-    // not supported
-}
-
-bool Platform::isCursorVisible()
-{
-    // not supported
-    return false;
-}
-
-void Platform::displayKeyboard(bool display)
-{
-    if (display)
-        virtualkeyboard_show();
-    else
-        virtualkeyboard_hide();
-}
-
-void Platform::shutdownInternal()
-{
-    Game::getInstance()->shutdown();
-}
-
-bool Platform::isGestureSupported(Gesture::GestureEvent evt)
-{
-    // All are supported no need to test the bitset
-    return true;
-}
-
-void Platform::registerGesture(Gesture::GestureEvent evt)
-{
-    switch(evt)
-    {
-    case Gesture::GESTURE_ANY_SUPPORTED:
-        __gestureEventsProcessed.set();
-        break;
-
-    case Gesture::GESTURE_SWIPE:
-    case Gesture::GESTURE_PINCH:
-    case Gesture::GESTURE_TAP:
-        __gestureEventsProcessed.set(evt);
-        break;
-
-    default:
-        break;
-    }
-}
-
-void Platform::unregisterGesture(Gesture::GestureEvent evt)
-{
-    switch(evt)
-    {
-    case Gesture::GESTURE_ANY_SUPPORTED:
-        __gestureEventsProcessed.reset();
-        break;
-
-    case Gesture::GESTURE_SWIPE:
-    case Gesture::GESTURE_PINCH:
-    case Gesture::GESTURE_TAP:
-        __gestureEventsProcessed.set(evt, 0);
-        break;
-
-    default:
-        break;
-    }
-}
-    
-bool Platform::isGestureRegistered(Gesture::GestureEvent evt)
-{
-    return __gestureEventsProcessed.test(evt);
-}
-
-bool Platform::launchURL(const char* url)
-{
-    if (url == NULL || *url == '\0')
-        return false;
-
-    return navigator_invoke(url, NULL) == BPS_SUCCESS;
-}
-
+#ifdef __QNX__
+
+#include "Base.h"
+#include "Platform.h"
+#include "FileSystem.h"
+#include "Game.h"
+#include "Form.h"
+#include "ScriptController.h"
+#include <unistd.h>
+#include <sys/keycodes.h>
+#include <screen/screen.h>
+#include <input/screen_helpers.h>
+#include <gestures/set.h>
+#include <gestures/swipe.h>
+#include <gestures/pinch.h>
+#include <gestures/tap.h>
+#include <bps/bps.h>
+#include <bps/event.h>
+#include <bps/screen.h>
+#include <bps/navigator.h>
+#include <bps/sensor.h>
+#include <bps/orientation.h>
+#include <bps/virtualkeyboard.h>
+
+#define TOUCH_COUNT_MAX     4
+
+using namespace std;
+
+int __argc = 0;
+char** __argv = 0;
+struct timespec __timespec;
+static double __timeStart;
+static double __timeAbsolute;
+static bool __vsync = WINDOW_VSYNC;
+static screen_context_t __screenContext;
+static screen_window_t __screenWindow;
+static screen_event_t __screenEvent;
+static int __screenWindowSize[2];
+static bool __screenFullscreen = false;
+static EGLDisplay __eglDisplay = EGL_NO_DISPLAY;
+static EGLContext __eglContext = EGL_NO_CONTEXT;
+static EGLSurface __eglSurface = EGL_NO_SURFACE;
+static EGLConfig __eglConfig = 0;
+static int __orientationAngle;
+static bool __multiTouch = false;
+static bool __multiSampling = false;
+static float __pitch;
+static float __roll;
+static float __accelRawX;
+static float __accelRawY;
+static float __accelRawZ;
+static float __gyroRawX;
+static float __gyroRawY;
+static float __gyroRawZ;
+static const char* __glExtensions;
+static struct gestures_set * __gestureSet;
+static bitset<3> __gestureEventsProcessed;
+static bool __gestureSwipeRecognized = false;
+PFNGLBINDVERTEXARRAYOESPROC glBindVertexArray = NULL;
+PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArrays = NULL;
+PFNGLGENVERTEXARRAYSOESPROC glGenVertexArrays = NULL;
+PFNGLISVERTEXARRAYOESPROC glIsVertexArray = NULL;
+
+namespace gameplay
+{
+
+// Gets the Keyboard::Key enumeration constant that corresponds to the given QNX key code.
+static Keyboard::Key getKey(int qnxKeycode)
+{
+    switch (qnxKeycode)
+    {
+    case KEYCODE_SYSREQ:
+        return Keyboard::KEY_SYSREQ;
+    case KEYCODE_BREAK:
+        return Keyboard::KEY_BREAK;
+    case KEYCODE_MENU:
+        return Keyboard::KEY_MENU;
+    case KEYCODE_KP_ENTER:
+        return Keyboard::KEY_KP_ENTER;
+    case KEYCODE_PAUSE:
+        return Keyboard::KEY_PAUSE;
+    case KEYCODE_SCROLL_LOCK:
+        return Keyboard::KEY_SCROLL_LOCK;
+    case KEYCODE_PRINT:
+        return Keyboard::KEY_PRINT;
+    case KEYCODE_ESCAPE:
+        return Keyboard::KEY_ESCAPE;
+    case KEYCODE_BACKSPACE:
+        return Keyboard::KEY_BACKSPACE;
+    case KEYCODE_BACK_TAB:
+        return Keyboard::KEY_BACK_TAB;
+    case KEYCODE_TAB:
+        return Keyboard::KEY_TAB;
+    case KEYCODE_RETURN:
+        return Keyboard::KEY_RETURN;
+    case KEYCODE_CAPS_LOCK:
+        return Keyboard::KEY_CAPS_LOCK;
+    case KEYCODE_LEFT_SHIFT:
+    case KEYCODE_RIGHT_SHIFT:
+        return Keyboard::KEY_SHIFT;
+    case KEYCODE_LEFT_CTRL:
+    case KEYCODE_RIGHT_CTRL:
+        return Keyboard::KEY_CTRL;
+    case KEYCODE_LEFT_ALT:
+    case KEYCODE_RIGHT_ALT:
+        return Keyboard::KEY_ALT;
+    case KEYCODE_LEFT_HYPER:
+    case KEYCODE_RIGHT_HYPER:
+        return Keyboard::KEY_HYPER;
+    case KEYCODE_INSERT:
+        return Keyboard::KEY_INSERT;
+    case KEYCODE_HOME:
+        return Keyboard::KEY_HOME;
+    case KEYCODE_PG_UP:
+        return Keyboard::KEY_PG_UP;
+    case KEYCODE_DELETE:
+        return Keyboard::KEY_DELETE;
+    case KEYCODE_END:
+        return Keyboard::KEY_END;
+    case KEYCODE_PG_DOWN:
+        return Keyboard::KEY_PG_DOWN;
+    case KEYCODE_LEFT:
+        return Keyboard::KEY_LEFT_ARROW;
+    case KEYCODE_RIGHT:
+        return Keyboard::KEY_RIGHT_ARROW;
+    case KEYCODE_UP:
+        return Keyboard::KEY_UP_ARROW;
+    case KEYCODE_DOWN:
+        return Keyboard::KEY_DOWN_ARROW;
+    case KEYCODE_NUM_LOCK:
+        return Keyboard::KEY_NUM_LOCK;
+    case KEYCODE_KP_PLUS:
+        return Keyboard::KEY_KP_PLUS;
+    case KEYCODE_KP_MINUS:
+        return Keyboard::KEY_KP_MINUS;
+    case KEYCODE_KP_MULTIPLY:
+        return Keyboard::KEY_KP_MULTIPLY;
+    case KEYCODE_KP_DIVIDE:
+        return Keyboard::KEY_KP_DIVIDE;
+    case KEYCODE_KP_HOME:
+        return Keyboard::KEY_KP_HOME;
+    case KEYCODE_KP_UP:
+        return Keyboard::KEY_KP_UP;
+    case KEYCODE_KP_PG_UP:
+        return Keyboard::KEY_KP_PG_UP;
+    case KEYCODE_KP_LEFT:
+        return Keyboard::KEY_KP_LEFT;
+    case KEYCODE_KP_FIVE:
+        return Keyboard::KEY_KP_FIVE;
+    case KEYCODE_KP_RIGHT:
+        return Keyboard::KEY_KP_RIGHT;
+    case KEYCODE_KP_END:
+        return Keyboard::KEY_KP_END;
+    case KEYCODE_KP_DOWN:
+        return Keyboard::KEY_KP_DOWN;
+    case KEYCODE_KP_PG_DOWN:
+        return Keyboard::KEY_KP_PG_DOWN;
+    case KEYCODE_KP_INSERT:
+        return Keyboard::KEY_KP_INSERT;
+    case KEYCODE_KP_DELETE:
+        return Keyboard::KEY_KP_DELETE;
+    case KEYCODE_F1:
+        return Keyboard::KEY_F1;
+    case KEYCODE_F2:
+        return Keyboard::KEY_F2;
+    case KEYCODE_F3:
+        return Keyboard::KEY_F3;
+    case KEYCODE_F4:
+        return Keyboard::KEY_F4;
+    case KEYCODE_F5:
+        return Keyboard::KEY_F5;
+    case KEYCODE_F6:
+        return Keyboard::KEY_F6;
+    case KEYCODE_F7:
+        return Keyboard::KEY_F7;
+    case KEYCODE_F8:
+        return Keyboard::KEY_F8;
+    case KEYCODE_F9:
+        return Keyboard::KEY_F9;
+    case KEYCODE_F10:
+        return Keyboard::KEY_F10;
+    case KEYCODE_F11:
+        return Keyboard::KEY_F11;
+    case KEYCODE_F12:
+        return Keyboard::KEY_F12;
+    case KEYCODE_SPACE:
+        return Keyboard::KEY_SPACE;
+    case KEYCODE_RIGHT_PAREN:
+        return Keyboard::KEY_RIGHT_PARENTHESIS;
+    case KEYCODE_ZERO:
+        return Keyboard::KEY_ZERO;
+    case KEYCODE_EXCLAM:
+        return Keyboard::KEY_EXCLAM;
+    case KEYCODE_ONE:
+        return Keyboard::KEY_ONE;
+    case KEYCODE_AT:
+        return Keyboard::KEY_AT;
+    case KEYCODE_TWO:
+        return Keyboard::KEY_TWO;
+    case KEYCODE_NUMBER:
+        return Keyboard::KEY_NUMBER;
+    case KEYCODE_THREE:
+        return Keyboard::KEY_THREE;
+    case KEYCODE_DOLLAR:
+        return Keyboard::KEY_DOLLAR;
+    case KEYCODE_FOUR:
+        return Keyboard::KEY_FOUR;
+    case KEYCODE_PERCENT:
+        return Keyboard::KEY_PERCENT;
+    case KEYCODE_FIVE:
+        return Keyboard::KEY_FIVE;
+    case KEYCODE_CIRCUMFLEX:
+        return Keyboard::KEY_CIRCUMFLEX;
+    case KEYCODE_SIX:
+        return Keyboard::KEY_SIX;
+    case KEYCODE_AMPERSAND:
+        return Keyboard::KEY_AMPERSAND;
+    case KEYCODE_SEVEN:
+        return Keyboard::KEY_SEVEN;
+    case KEYCODE_ASTERISK:
+        return Keyboard::KEY_ASTERISK;
+    case KEYCODE_EIGHT:
+        return Keyboard::KEY_EIGHT;
+    case KEYCODE_LEFT_PAREN:
+        return Keyboard::KEY_LEFT_PARENTHESIS;
+    case KEYCODE_NINE:
+        return Keyboard::KEY_NINE;
+    case KEYCODE_EQUAL:
+        return Keyboard::KEY_EQUAL;
+    case KEYCODE_PLUS:
+        return Keyboard::KEY_PLUS;
+    case KEYCODE_LESS_THAN:
+        return Keyboard::KEY_LESS_THAN;
+    case KEYCODE_COMMA:
+        return Keyboard::KEY_COMMA;
+    case KEYCODE_UNDERSCORE:
+        return Keyboard::KEY_UNDERSCORE;
+    case KEYCODE_MINUS:
+        return Keyboard::KEY_MINUS;
+    case KEYCODE_GREATER_THAN:
+        return Keyboard::KEY_GREATER_THAN;
+    case KEYCODE_PERIOD:
+        return Keyboard::KEY_PERIOD;
+    case KEYCODE_COLON:
+        return Keyboard::KEY_COLON;
+    case KEYCODE_SEMICOLON:
+        return Keyboard::KEY_SEMICOLON;
+    case KEYCODE_QUESTION:
+        return Keyboard::KEY_QUESTION;
+    case KEYCODE_SLASH:
+        return Keyboard::KEY_SLASH;
+    case KEYCODE_GRAVE:
+        return Keyboard::KEY_GRAVE;
+    case KEYCODE_TILDE:
+        return Keyboard::KEY_TILDE;
+    case KEYCODE_LEFT_BRACE:
+        return Keyboard::KEY_LEFT_BRACE;
+    case KEYCODE_LEFT_BRACKET:
+        return Keyboard::KEY_LEFT_BRACKET;
+    case KEYCODE_BAR:
+        return Keyboard::KEY_BAR;
+    case KEYCODE_BACK_SLASH:
+        return Keyboard::KEY_BACK_SLASH;
+    case KEYCODE_RIGHT_BRACE:
+        return Keyboard::KEY_RIGHT_BRACE;
+    case KEYCODE_RIGHT_BRACKET:
+        return Keyboard::KEY_RIGHT_BRACKET;
+    case KEYCODE_QUOTE:
+        return Keyboard::KEY_QUOTE;
+    case KEYCODE_APOSTROPHE:
+        return Keyboard::KEY_APOSTROPHE;
+    case 0x20AC:
+        return Keyboard::KEY_EURO;
+    case KEYCODE_POUND_SIGN:
+        return Keyboard::KEY_POUND;
+    case KEYCODE_YEN_SIGN:
+        return Keyboard::KEY_YEN;
+    case KEYCODE_MIDDLE_DOT:
+        return Keyboard::KEY_MIDDLE_DOT;
+    case KEYCODE_CAPITAL_A:
+        return Keyboard::KEY_CAPITAL_A;
+    case KEYCODE_A:
+        return Keyboard::KEY_A;
+    case KEYCODE_CAPITAL_B:
+        return Keyboard::KEY_CAPITAL_B;
+    case KEYCODE_B:
+        return Keyboard::KEY_B;
+    case KEYCODE_CAPITAL_C:
+        return Keyboard::KEY_CAPITAL_C;
+    case KEYCODE_C:
+        return Keyboard::KEY_C;
+    case KEYCODE_CAPITAL_D:
+        return Keyboard::KEY_CAPITAL_D;
+    case KEYCODE_D:
+        return Keyboard::KEY_D;
+    case KEYCODE_CAPITAL_E:
+        return Keyboard::KEY_CAPITAL_E;
+    case KEYCODE_E:
+        return Keyboard::KEY_E;
+    case KEYCODE_CAPITAL_F:
+        return Keyboard::KEY_CAPITAL_F;
+    case KEYCODE_F:
+        return Keyboard::KEY_F;
+    case KEYCODE_CAPITAL_G:
+        return Keyboard::KEY_CAPITAL_G;
+    case KEYCODE_G:
+        return Keyboard::KEY_G;
+    case KEYCODE_CAPITAL_H:
+        return Keyboard::KEY_CAPITAL_H;
+    case KEYCODE_H:
+        return Keyboard::KEY_H;
+    case KEYCODE_CAPITAL_I:
+        return Keyboard::KEY_CAPITAL_I;
+    case KEYCODE_I:
+        return Keyboard::KEY_I;
+    case KEYCODE_CAPITAL_J:
+        return Keyboard::KEY_CAPITAL_J;
+    case KEYCODE_J:
+        return Keyboard::KEY_J;
+    case KEYCODE_CAPITAL_K:
+        return Keyboard::KEY_CAPITAL_K;
+    case KEYCODE_K:
+        return Keyboard::KEY_K;
+    case KEYCODE_CAPITAL_L:
+        return Keyboard::KEY_CAPITAL_L;
+    case KEYCODE_L:
+        return Keyboard::KEY_L;
+    case KEYCODE_CAPITAL_M:
+        return Keyboard::KEY_CAPITAL_M;
+    case KEYCODE_M:
+        return Keyboard::KEY_M;
+    case KEYCODE_CAPITAL_N:
+        return Keyboard::KEY_CAPITAL_N;
+    case KEYCODE_N:
+        return Keyboard::KEY_N;
+    case KEYCODE_CAPITAL_O:
+        return Keyboard::KEY_CAPITAL_O;
+    case KEYCODE_O:
+        return Keyboard::KEY_O;
+    case KEYCODE_CAPITAL_P:
+        return Keyboard::KEY_CAPITAL_P;
+    case KEYCODE_P:
+        return Keyboard::KEY_P;
+    case KEYCODE_CAPITAL_Q:
+        return Keyboard::KEY_CAPITAL_Q;
+    case KEYCODE_Q:
+        return Keyboard::KEY_Q;
+    case KEYCODE_CAPITAL_R:
+        return Keyboard::KEY_CAPITAL_R;
+    case KEYCODE_R:
+        return Keyboard::KEY_R;
+    case KEYCODE_CAPITAL_S:
+        return Keyboard::KEY_CAPITAL_S;
+    case KEYCODE_S:
+        return Keyboard::KEY_S;
+    case KEYCODE_CAPITAL_T:
+        return Keyboard::KEY_CAPITAL_T;
+    case KEYCODE_T:
+        return Keyboard::KEY_T;
+    case KEYCODE_CAPITAL_U:
+        return Keyboard::KEY_CAPITAL_U;
+    case KEYCODE_U:
+        return Keyboard::KEY_U;
+    case KEYCODE_CAPITAL_V:
+        return Keyboard::KEY_CAPITAL_V;
+    case KEYCODE_V:
+        return Keyboard::KEY_V;
+    case KEYCODE_CAPITAL_W:
+        return Keyboard::KEY_CAPITAL_W;
+    case KEYCODE_W:
+        return Keyboard::KEY_W;
+    case KEYCODE_CAPITAL_X:
+        return Keyboard::KEY_CAPITAL_X;
+    case KEYCODE_X:
+        return Keyboard::KEY_X;
+    case KEYCODE_CAPITAL_Y:
+        return Keyboard::KEY_CAPITAL_Y;
+    case KEYCODE_Y:
+        return Keyboard::KEY_Y;
+    case KEYCODE_CAPITAL_Z:
+        return Keyboard::KEY_CAPITAL_Z;
+    case KEYCODE_Z:
+        return Keyboard::KEY_Z;
+    default:
+        return Keyboard::KEY_NONE;
+    }
+}
+
+/**
+ * Returns the unicode value from the given QNX key code value.
+ * Some non-printable characters also have corresponding unicode values, such as backspace.
+ *
+ * @param qnxKeyCode The keyboard key code.
+ *
+ * @return The unicode value or 0 if the keycode did not represent a unicode key.
+ */
+static int getUnicode(int qnxKeyCode)
+{
+    if (qnxKeyCode >= KEYCODE_PC_KEYS && qnxKeyCode <= UNICODE_PRIVATE_USE_AREA_LAST)
+    {
+        switch (qnxKeyCode)
+        {
+        case KEYCODE_BACKSPACE:
+            return 0x0008;
+        case KEYCODE_TAB:
+            return 0x0009;
+        case KEYCODE_KP_ENTER:
+        case KEYCODE_RETURN:
+            return 0x000A;
+        case KEYCODE_ESCAPE:
+            return 0x001B;
+        // Win32 doesn't consider delete to be a key char.
+        default:
+            return 0;
+        }
+    }
+    return qnxKeyCode;
+}
+
+extern void print(const char* format, ...)
+{
+    GP_ASSERT(format);
+    va_list argptr;
+    va_start(argptr, format);
+    vfprintf(stderr, format, argptr);
+    va_end(argptr);
+}
+
+extern int strcmpnocase(const char* s1, const char* s2)
+{
+    return strcasecmp(s1, s2);
+}
+
+EGLenum checkErrorEGL(const char* msg)
+{
+    GP_ASSERT(msg);
+    static const char* errmsg[] =
+    {
+        "EGL function failed",
+        "EGL is not initialized, or could not be initialized, for the specified display",
+        "EGL cannot access a requested resource",
+        "EGL failed to allocate resources for the requested operation",
+        "EGL fail to access an unrecognized attribute or attribute value was passed in an attribute list",
+        "EGLConfig argument does not name a valid EGLConfig",
+        "EGLContext argument does not name a valid EGLContext",
+        "EGL current surface of the calling thread is no longer valid",
+        "EGLDisplay argument does not name a valid EGLDisplay",
+        "EGL arguments are inconsistent",
+        "EGLNativePixmapType argument does not refer to a valid native pixmap",
+        "EGLNativeWindowType argument does not refer to a valid native window",
+        "EGL one or more argument values are invalid",
+        "EGLSurface argument does not name a valid surface configured for rendering",
+        "EGL power management event has occurred",
+    };
+    EGLenum error = eglGetError();
+    fprintf(stderr, "%s: %s\n", msg, errmsg[error - EGL_SUCCESS]);
+    return error;
+}
+
+void gesture_callback(gesture_base_t* gesture, mtouch_event_t* event, void* param, int async)
+{
+    switch (gesture->type)
+    {
+    case GESTURE_SWIPE:
+        {
+            if ( __gestureEventsProcessed.test(Gesture::GESTURE_SWIPE) )
+            {
+                gesture_swipe_t* swipe = (gesture_swipe_t*)gesture;
+                if (!__gestureSwipeRecognized)
+                {
+                    Platform::gestureSwipeEventInternal(swipe->coords.x, swipe->coords.y, swipe->direction);
+                    __gestureSwipeRecognized = true;
+                }
+
+            }
+            break;
+        }
+
+    case GESTURE_PINCH:
+        {
+            if ( __gestureEventsProcessed.test(Gesture::GESTURE_PINCH) )
+            {
+                gesture_pinch_t* pinch = (gesture_pinch_t*)gesture;
+                float dist_x = (float)pinch->last_distance.x - (float)pinch->distance.x;
+                float dist_y = (float)pinch->last_distance.y - (float)pinch->distance.y;
+                float scale = sqrt( (dist_x * dist_x) + (dist_y * dist_y) );
+                Game::getInstance()->gesturePinchEvent(pinch->centroid.x, pinch->centroid.y, scale);
+            }
+            break;
+        }
+
+    case GESTURE_TAP:
+        {
+            if ( __gestureEventsProcessed.test(Gesture::GESTURE_TAP) )
+            {
+                gesture_tap_t* tap = (gesture_tap_t*)gesture;
+                Platform::gestureTapEventInternal(tap->touch_coords.x, tap->touch_coords.y);
+            }
+            break;
+        }
+
+    default:
+        break;
+
+    }
+}
+
+#ifdef GP_USE_GAMEPAD
+
+static const char* __vendorStrings[] =
+{
+    "SteelSeries",
+    "Nintendo",
+};
+
+static const char* __productStrings[] =
+{
+    "FREE",
+    "Wii Remote",
+};
+
+static const int __VIDs[] = {
+    0x1038,
+    0x057e,
+};
+
+static const int __PIDs[] = {
+    0x1412,
+    0x0306,
+};
+
+static const unsigned int __knownGamepads = 2;
+
+void queryGamepad(GamepadHandle handle, int* buttonCount, int* joystickCount, int* productId, int* vendorId, char* productString, char* vendorString)
+{
+    char id[128];
+    screen_get_device_property_iv(handle, SCREEN_PROPERTY_BUTTON_COUNT, buttonCount);
+    screen_get_device_property_cv(handle, SCREEN_PROPERTY_ID_STRING, 128, id);
+    screen_get_device_property_cv(handle, SCREEN_PROPERTY_PRODUCT, 64, productString);
+    screen_get_device_property_cv(handle, SCREEN_PROPERTY_VENDOR, 64, vendorString);
+
+    // Check for the existence of analog sticks.
+    int analogs[3];
+    if (!screen_get_device_property_iv(handle, SCREEN_PROPERTY_ANALOG0, analogs))
+    {
+    	++(*joystickCount);
+    }
+
+    if (!screen_get_device_property_iv(handle, SCREEN_PROPERTY_ANALOG1, analogs))
+    {
+    	++(*joystickCount);
+    }
+
+    // ID string format: A-BBBB-CCCC-D.D
+    // A is the device's index
+    // BBBB is the device's Vendor ID (in hexadecimal)
+    // CCCC is the device's Product ID (also in hexadecimal)
+    // D.D is the device's version number
+    char* token = strtok(id, "-");
+    token = strtok(NULL, "-");
+    if (token)
+    {
+	    *vendorId = strtol(token, NULL, 16);
+    }
+
+    token = strtok(NULL, "-");
+    if (token)
+    {
+        *productId = strtol(token, NULL, 16);
+    }
+
+    // For gamepads unknown to BB10,
+    // check VID and PID against gamepads known to gameplay.
+    if (strlen(productString) == 0 || strlen(vendorString) == 0)
+    {
+        for (unsigned int i = 0; i < __knownGamepads; ++i)
+        {
+            if (__VIDs[i] == *vendorId && __PIDs[i] == *productId)
+            {
+            	strcpy(vendorString, __vendorStrings[i]);
+                strcpy(productString, __productStrings[i]);
+            }
+        }
+    }
+}
+
+void Platform::pollGamepadState(Gamepad* gamepad)
+{
+	unsigned int buttons;
+    screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_BUTTONS, (int*)&buttons);
+	gamepad->setButtons(buttons);
+
+    unsigned int i;
+    for (i = 0; i < gamepad->_joystickCount; ++i)
+    {
+        GP_ASSERT(i < 2);
+
+        int analog[3];
+        switch (i)
+        {
+        case 0:
+            screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_ANALOG0, analog);
+            break;
+        case 1:
+            screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_ANALOG1, analog);
+            break;
+        }
+
+        // So far we've tested two gamepads with analog sticks on BlackBerry:
+        // the SteelSeries FREE, and the iControlPad.
+        // Both return values between -128 and +127, with the y axis starting from
+        // the top at -128.
+        // 1 / 128 == 0.0078125f
+        // 1 / 127 == 0.0078740157480315f
+        float x = (float)analog[0];
+        float y = -(float)analog[1];
+        x *= (x < 0) ? 0.0078125f : 0.0078740157480315f;
+        y *= (y > 0) ? 0.0078125f : 0.0078740157480315f;
+
+		gamepad->setJoystickValue(i, x, y);
+    }
+
+    for (i = 0; i < gamepad->_triggerCount; ++i)
+    {
+        GP_ASSERT(i < 2);
+
+        int analog[3];
+        switch (i)
+        {
+        case 0:
+            screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_ANALOG0, analog);
+            break;
+        case 1:
+            screen_get_device_property_iv(gamepad->_handle, SCREEN_PROPERTY_ANALOG1, analog);
+            break;
+        }
+
+        float value = (float)analog[2] * 0.0078125f;
+		gamepad->setTriggerValue(i, value);
+    }
+}
+#else
+void Platform::pollGamepadState(Gamepad* gamepad)
+{
+}
+#endif
+
+Platform::Platform(Game* game)
+    : _game(game)
+{
+}
+
+Platform::~Platform()
+{
+    if (__eglDisplay != EGL_NO_DISPLAY)
+    {
+        eglMakeCurrent(__eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+    }
+
+    if (__eglSurface != EGL_NO_SURFACE)
+    {
+        eglDestroySurface(__eglDisplay, __eglSurface);
+        __eglSurface = EGL_NO_SURFACE;
+    }
+
+    if (__eglContext != EGL_NO_CONTEXT)
+    {
+        eglDestroyContext(__eglDisplay, __eglContext);
+        __eglContext = EGL_NO_CONTEXT;
+    }
+
+    if (__eglDisplay != EGL_NO_DISPLAY)
+    {
+        eglTerminate(__eglDisplay);
+        __eglDisplay = EGL_NO_DISPLAY;
+    }
+
+    if (__screenWindow)
+    {
+        screen_destroy_window(__screenWindow);
+        __screenWindow = NULL;
+    }
+
+    if (__screenEvent)
+    {
+        screen_destroy_event(__screenEvent);
+        __screenEvent = NULL;
+    }
+
+    if (__screenContext)
+    {
+        screen_destroy_context(__screenContext);
+        __screenContext = NULL;
+    }
+}
+
+Platform* Platform::create(Game* game)
+{
+    FileSystem::setResourcePath("./app/native/");
+    Platform* platform = new Platform(game);
+
+    // Query game config
+    int samples = 0;
+    Properties* config = Game::getInstance()->getConfig()->getNamespace("window", true);
+    if (config)
+    {
+        samples = std::max(config->getInt("samples"), 0);
+    }
+
+    __gestureSet = gestures_set_alloc();
+    swipe_gesture_alloc(NULL, gesture_callback, __gestureSet);
+    pinch_gesture_alloc(NULL, gesture_callback, __gestureSet);
+    tap_gesture_alloc(NULL, gesture_callback, __gestureSet);
+
+    bps_initialize();
+
+    // Initialize navigator and orientation
+    static const int SENSOR_RATE = 25000; // (25000 microseconds = 40 Hz)
+    sensor_set_rate(SENSOR_TYPE_AZIMUTH_PITCH_ROLL, SENSOR_RATE);
+    sensor_set_rate(SENSOR_TYPE_ACCELEROMETER, SENSOR_RATE);
+    sensor_set_rate(SENSOR_TYPE_GYROSCOPE, SENSOR_RATE);
+    sensor_set_skip_duplicates(SENSOR_TYPE_AZIMUTH_PITCH_ROLL, true);
+    sensor_set_skip_duplicates(SENSOR_TYPE_ACCELEROMETER, true);
+    sensor_set_skip_duplicates(SENSOR_TYPE_GYROSCOPE, true);
+    sensor_request_events(SENSOR_TYPE_AZIMUTH_PITCH_ROLL);
+    sensor_request_events(SENSOR_TYPE_ACCELEROMETER);
+    sensor_request_events(SENSOR_TYPE_GYROSCOPE);
+    navigator_request_events(0);
+    navigator_rotation_lock(true);
+    __orientationAngle = atoi(getenv("ORIENTATION"));
+
+    int rc = 0;
+    int screenFormat = SCREEN_FORMAT_RGBA8888;
+#ifdef __X86__
+    int screenUsage = SCREEN_USAGE_OPENGL_ES2;
+#else
+    int screenUsage = SCREEN_USAGE_DISPLAY|SCREEN_USAGE_OPENGL_ES2; // Physical device copy directly into physical display
+#endif
+    int screenSwapInterval = WINDOW_VSYNC ? 1 : 0;
+    int screenTransparency = SCREEN_TRANSPARENCY_NONE;
+
+    char *width_str = getenv("WIDTH");
+    char *height_str = getenv("HEIGHT");
+
+    // Hard-coded to (0,0).
+    int windowPosition[] =
+    {
+        0, 0
+    };
+
+    EGLint eglConfigCount;
+
+    // Hard-coded to 32-bit/OpenGL ES 2.0.
+    // NOTE: EGL_SAMPLE_BUFFERS and EGL_SAMPLES MUST remain at the beginning of the attribute list
+    // since they are expected to be at indices 0-3 in config fallback code later.
+    EGLint eglConfigAttrs[] =
+    {
+        EGL_SAMPLE_BUFFERS,     samples > 0 ? 1 : 0,
+        EGL_SAMPLES,            samples,
+        EGL_RED_SIZE,           8,
+        EGL_GREEN_SIZE,         8,
+        EGL_BLUE_SIZE,          8,
+        EGL_ALPHA_SIZE,         8,
+        EGL_DEPTH_SIZE,         24,
+        EGL_STENCIL_SIZE,       8,
+        EGL_SURFACE_TYPE,       EGL_WINDOW_BIT,
+        EGL_RENDERABLE_TYPE,    EGL_OPENGL_ES2_BIT,
+        EGL_NONE
+    };
+    __multiSampling = samples > 0;
+
+    const EGLint eglContextAttrs[] =
+    {
+        EGL_CONTEXT_CLIENT_VERSION,    2,
+        EGL_NONE
+    };
+
+    const EGLint eglSurfaceAttrs[] =
+    {
+        EGL_RENDER_BUFFER,    EGL_BACK_BUFFER,
+        EGL_NONE
+    };
+
+    // Create the screen context.
+    rc = screen_create_context(&__screenContext, 0);
+    if (rc)
+    {
+        perror("screen_create_context");
+        goto error;
+    }
+
+    // Create the screen window.
+    rc = screen_create_window(&__screenWindow, __screenContext);
+    if (rc)
+    {
+        perror("screen_create_window");
+        goto error;
+    }
+
+    // Window group
+	rc = screen_create_window_group(__screenWindow, "windowgroup");
+	if (rc)
+	{
+		perror("screen_create_window_group failed");
+		goto error;
+	}
+
+    // Set/get any window properties.
+    rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_FORMAT, &screenFormat);
+    if (rc)
+    {
+        perror("screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT)");
+        goto error;
+    }
+
+    rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_USAGE, &screenUsage);
+    if (rc)
+    {
+        perror("screen_set_window_property_iv(SCREEN_PROPERTY_USAGE)");
+        goto error;
+    }
+
+    if (width_str && height_str)
+    {
+        __screenWindowSize[0] = atoi(width_str);
+        __screenWindowSize[1] = atoi(height_str);
+    }
+    else
+    {
+        screen_display_t screen_display;
+        rc = screen_get_window_property_pv(__screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&screen_display);
+        if (rc)
+        {
+            perror("screen_get_window_property_pv(SCREEN_PROPERTY_DISPLAY)");
+            goto error;
+        }
+
+        screen_display_mode_t screen_mode;
+        rc = screen_get_display_property_pv(screen_display, SCREEN_PROPERTY_MODE, (void**)&screen_mode);
+        if (rc)
+        {
+            perror("screen_get_display_property_pv(SCREEN_PROPERTY_MODE)");
+            goto error;
+        }
+
+        int size[2];
+        rc = screen_get_window_property_iv(__screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, size);
+        if (rc)
+        {
+            perror("screen_get_window_property_iv(SCREEN_PROPERTY_BUFFER_SIZE)");
+            goto error;
+        }
+
+        __screenWindowSize[0] = size[0];
+        __screenWindowSize[1] = size[1];
+
+        if ((__orientationAngle == 0) || (__orientationAngle == 180))
+        {
+            if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
+                ((screen_mode.width < screen_mode.height) && (size[0] > size[1])))
+            {
+                __screenWindowSize[1] = size[0];
+                __screenWindowSize[0] = size[1];
+            }
+        }
+        else if ((__orientationAngle == 90) || (__orientationAngle == 270))
+        {
+            if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
+                ((screen_mode.width < screen_mode.height) && (size[0] < size[1])))
+            {
+                __screenWindowSize[1] = size[0];
+                __screenWindowSize[0] = size[1];
+            }
+        }
+        else
+        {
+            perror("Navigator returned an unexpected orientation angle.");
+            goto error;
+        }
+
+
+        rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_ROTATION, &__orientationAngle);
+        if (rc)
+        {
+            perror("screen_set_window_property_iv(SCREEN_PROPERTY_ROTATION)");
+            goto error;
+        }
+    }
+
+    rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_BUFFER_SIZE, __screenWindowSize);
+    if (rc)
+    {
+        perror("screen_set_window_property_iv(SCREEN_PROPERTY_BUFFER_SIZE)");
+        goto error;
+    }
+
+    if (windowPosition[0] != 0 || windowPosition[1] != 0)
+    {
+        rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_POSITION, windowPosition);
+        if (rc)
+        {
+            perror("screen_set_window_property_iv(SCREEN_PROPERTY_POSITION)");
+            goto error;
+        }
+    }
+
+    rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_TRANSPARENCY, &screenTransparency);
+    if (rc)
+    {
+        perror("screen_set_window_property_iv(SCREEN_PROPERTY_TRANSPARENCY)");
+        goto error;
+    }
+
+    // Double buffered.
+    rc = screen_create_window_buffers(__screenWindow, 2);
+    if (rc)
+    {
+        perror("screen_create_window_buffers");
+        goto error;
+    }
+
+    // Create screen event object.
+    rc = screen_create_event(&__screenEvent);
+    if (rc)
+    {
+        perror("screen_create_event");
+        goto error;
+    }
+
+    // Request screen events.
+    screen_request_events(__screenContext);
+
+    // Get the EGL display and initialize.
+    __eglDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
+    if (__eglDisplay == EGL_NO_DISPLAY)
+    {
+        perror("eglGetDisplay");
+        goto error;
+    }
+    if (eglInitialize(__eglDisplay, NULL, NULL) != EGL_TRUE)
+    {
+        perror("eglInitialize");
+        goto error;
+    }
+
+    if (eglChooseConfig(__eglDisplay, eglConfigAttrs, &__eglConfig, 1, &eglConfigCount) != EGL_TRUE || eglConfigCount == 0)
+    {
+        bool success = false;
+        while (samples)
+        {
+            // Try lowering the MSAA sample count until we find a supported config
+            GP_WARN("Failed to find a valid EGL configuration with EGL samples=%d. Trying samples=%d instead.", samples, samples/2);
+            samples /= 2;
+            eglConfigAttrs[1] = samples > 0 ? 1 : 0;
+            eglConfigAttrs[3] = samples;
+            if (eglChooseConfig(__eglDisplay, eglConfigAttrs, &__eglConfig, 1, &eglConfigCount) == EGL_TRUE && eglConfigCount > 0)
+            {
+                success = true;
+                break;
+            }
+        }
+
+        __multiSampling = samples > 0;
+
+        if (!success)
+        {
+            checkErrorEGL("eglChooseConfig");
+            goto error;
+        }
+    }
+
+    __eglContext = eglCreateContext(__eglDisplay, __eglConfig, EGL_NO_CONTEXT, eglContextAttrs);
+    if (__eglContext == EGL_NO_CONTEXT)
+    {
+        checkErrorEGL("eglCreateContext");
+        goto error;
+    }
+
+    __eglSurface = eglCreateWindowSurface(__eglDisplay, __eglConfig, __screenWindow, eglSurfaceAttrs);
+    if (__eglSurface == EGL_NO_SURFACE)
+    {
+        checkErrorEGL("eglCreateWindowSurface");
+        goto error;
+    }
+
+    if (eglMakeCurrent(__eglDisplay, __eglSurface, __eglSurface, __eglContext) != EGL_TRUE)
+    {
+        checkErrorEGL("eglMakeCurrent");
+        goto error;
+    }
+
+    // Set vsync.
+    eglSwapInterval(__eglDisplay, screenSwapInterval);
+
+    // Initialize OpenGL ES extensions.
+    __glExtensions = (const char*)glGetString(GL_EXTENSIONS);
+
+    if (strstr(__glExtensions, "GL_OES_vertex_array_object") || strstr(__glExtensions, "GL_ARB_vertex_array_object"))
+    {
+        glBindVertexArray = (PFNGLBINDVERTEXARRAYOESPROC)eglGetProcAddress("glBindVertexArrayOES");
+        glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSOESPROC)eglGetProcAddress("glDeleteVertexArraysOES");
+        glGenVertexArrays = (PFNGLGENVERTEXARRAYSOESPROC)eglGetProcAddress("glGenVertexArraysOES");
+        glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress("glIsVertexArrayOES");
+    }
+
+ #ifdef GP_USE_GAMEPAD
+
+    screen_device_t* screenDevs;
+
+    // Discover initial gamepad devices.
+    int count;
+    screen_get_context_property_iv(__screenContext, SCREEN_PROPERTY_DEVICE_COUNT, &count);
+    screenDevs = (screen_device_t*)calloc(count, sizeof(screen_device_t));
+    screen_get_context_property_pv(__screenContext, SCREEN_PROPERTY_DEVICES, (void**)screenDevs);
+
+	for (int i = 0; i < count; i++)
+    {
+	    int type;
+        screen_get_device_property_iv(screenDevs[i], SCREEN_PROPERTY_TYPE, &type);
+
+        if (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK)
+        {
+            int buttonCount = 0;
+            int joystickCount = 0;
+            int productId;
+            int vendorId;
+            char productString[64];
+            char vendorString[64];
+            queryGamepad(screenDevs[i], &buttonCount, &joystickCount, &productId, &vendorId, productString, vendorString);
+            Platform::gamepadEventConnectedInternal(screenDevs[i], buttonCount, joystickCount, 0, vendorId, productId, vendorString, productString);
+        }
+	}
+	free(screenDevs);
+#endif
+
+    return platform;
+
+error:
+
+    return NULL;
+}
+
+/**
+ * Convert the timespec into milliseconds.
+ */
+double timespec2millis(struct timespec *a)
+{
+    GP_ASSERT(a);
+    return (1000.0 * a->tv_sec) + (0.000001 * a->tv_nsec);
+}
+
+/**
+ * Fires a mouse event or a touch event on the game.
+ * If the mouse event is not consumed, a touch event is fired instead.
+ *
+ * @param mouseEvent The mouse event to fire.
+ * @param touchEvent The touch event to fire.
+ * @param x The x position of the touch in pixels.
+ * @param y The y position of the touch in pixels.
+ */
+void mouseOrTouchEvent(Mouse::MouseEvent mouseEvent, Touch::TouchEvent touchEvent, int x, int y)
+{
+    if (!gameplay::Platform::mouseEventInternal(mouseEvent, x, y, 0))
+    {
+        Platform::touchEventInternal(touchEvent, x, y, 0, true);
+    }
+}
+
+int Platform::enterMessagePump()
+{
+    GP_ASSERT(_game);
+
+    int rc;
+    int eventType;
+    int flags;
+    int value;
+    int position[2];
+    int domain;
+    mtouch_event_t touchEvent;
+    bool suspended = false;
+
+    // Get the initial time.
+    clock_gettime(CLOCK_REALTIME, &__timespec);
+    __timeStart = timespec2millis(&__timespec);
+    __timeAbsolute = 0L;
+
+    _game->run();
+
+    // Message loop.
+    while (true)
+    {
+        bps_event_t* event = NULL;
+
+        while (true)
+        {
+            rc = bps_get_event(&event, 1);
+            GP_ASSERT(rc == BPS_SUCCESS);
+
+            if (event == NULL)
+                break;
+
+#ifdef GP_USE_SOCIAL
+            // if the social controller needs to deal with the event do that here
+            if (Game::getInstance()->getSocialController()->handleEvent(event))
+            	break;
+#endif
+
+            domain = bps_event_get_domain(event);
+
+            if (domain == screen_get_domain())
+            {
+                __screenEvent = screen_event_get_event(event);
+                screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_TYPE, &eventType);
+                switch (eventType)
+                {
+                    case SCREEN_EVENT_MTOUCH_TOUCH:
+                    {
+                        screen_get_mtouch_event(__screenEvent, &touchEvent, 0);
+                        if (__gestureEventsProcessed.any())
+                            rc = gestures_set_process_event(__gestureSet, &touchEvent, NULL);
+
+                        if ( !rc && (__multiTouch || touchEvent.contact_id == 0) )
+                        {
+                            gameplay::Platform::touchEventInternal(Touch::TOUCH_PRESS, touchEvent.x, touchEvent.y, touchEvent.contact_id);
+                        }
+                        break;
+                    }
+
+                    case SCREEN_EVENT_MTOUCH_RELEASE:
+                    {
+                        screen_get_mtouch_event(__screenEvent, &touchEvent, 0);
+                        if (__gestureEventsProcessed.any())
+                            rc = gestures_set_process_event(__gestureSet, &touchEvent, NULL);
+
+                        if ( !rc && (__multiTouch || touchEvent.contact_id == 0) )
+                        {
+                            gameplay::Platform::touchEventInternal(Touch::TOUCH_RELEASE, touchEvent.x, touchEvent.y, touchEvent.contact_id);
+                        }
+                        if (__gestureSwipeRecognized)
+                        {
+                            __gestureSwipeRecognized = false;
+                        }
+                        break;
+                    }
+
+                    case SCREEN_EVENT_MTOUCH_MOVE:
+                    {
+                        screen_get_mtouch_event(__screenEvent, &touchEvent, 0);
+                        if (__gestureEventsProcessed.any())
+                            rc = gestures_set_process_event(__gestureSet, &touchEvent, NULL);
+
+                        if ( !rc && (__multiTouch || touchEvent.contact_id == 0) )
+                        {
+                            gameplay::Platform::touchEventInternal(Touch::TOUCH_MOVE, touchEvent.x, touchEvent.y, touchEvent.contact_id);
+                        }
+                        break;
+                    }
+
+                    case SCREEN_EVENT_POINTER:
+                    {
+                        static int mouse_pressed = 0;
+                        int buttons;
+                        int wheel;
+                        // A move event will be fired unless a button state changed.
+                        bool move = true;
+                        bool left_move = false;
+                        // This is a mouse move event, it is applicable to a device with a usb mouse or simulator.
+                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_BUTTONS, &buttons);
+                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_SOURCE_POSITION, position);
+                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_MOUSE_WHEEL, &wheel);
+
+                        // Handle left mouse. Interpret as touch if the left mouse event is not consumed.
+                        if (buttons & SCREEN_LEFT_MOUSE_BUTTON)
+                        {
+                            if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON)
+                            {
+                                left_move = true;
+                            }
+                            else
+                            {
+                                move = false;
+                                mouse_pressed |= SCREEN_LEFT_MOUSE_BUTTON;
+                                mouseOrTouchEvent(Mouse::MOUSE_PRESS_LEFT_BUTTON, Touch::TOUCH_PRESS, position[0], position[1]);
+                            }
+                        }
+                        else if (mouse_pressed & SCREEN_LEFT_MOUSE_BUTTON)
+                        {
+                            move = false;
+                            mouse_pressed &= ~SCREEN_LEFT_MOUSE_BUTTON;
+                            mouseOrTouchEvent(Mouse::MOUSE_RELEASE_LEFT_BUTTON, Touch::TOUCH_RELEASE, position[0], position[1]);
+                        }
+
+                        // Handle right mouse.
+                        if (buttons & SCREEN_RIGHT_MOUSE_BUTTON)
+                        {
+                            if ((mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON) == 0)
+                            {
+                                move = false;
+                                mouse_pressed |= SCREEN_RIGHT_MOUSE_BUTTON;
+                                gameplay::Platform::mouseEventInternal(Mouse::MOUSE_PRESS_RIGHT_BUTTON, position[0], position[1], 0);
+                            }
+                        }
+                        else if (mouse_pressed & SCREEN_RIGHT_MOUSE_BUTTON)
+                        {
+                            move = false;
+                            mouse_pressed &= ~SCREEN_RIGHT_MOUSE_BUTTON;
+                            gameplay::Platform::mouseEventInternal(Mouse::MOUSE_RELEASE_RIGHT_BUTTON, position[0], position[1], 0);
+                        }
+
+                        // Handle middle mouse.
+                        if (buttons & SCREEN_MIDDLE_MOUSE_BUTTON)
+                        {
+                            if ((mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON) == 0)
+                            {
+                                move = false;
+                                mouse_pressed |= SCREEN_MIDDLE_MOUSE_BUTTON;
+                                gameplay::Platform::mouseEventInternal(Mouse::MOUSE_PRESS_MIDDLE_BUTTON, position[0], position[1], 0);
+                            }
+                        }
+                        else if (mouse_pressed & SCREEN_MIDDLE_MOUSE_BUTTON)
+                        {
+                            move = false;
+                            mouse_pressed &= ~SCREEN_MIDDLE_MOUSE_BUTTON;
+                            gameplay::Platform::mouseEventInternal(Mouse::MOUSE_RELEASE_MIDDLE_BUTTON, position[0], position[1], 0);
+                        }
+
+                        // Fire a move event if none of the buttons changed.
+                        if (left_move)
+                        {
+                            mouseOrTouchEvent(Mouse::MOUSE_MOVE, Touch::TOUCH_MOVE, position[0], position[1]);
+                        }
+                        else if (move)
+                        {
+                            gameplay::Platform::mouseEventInternal(Mouse::MOUSE_MOVE, position[0], position[1], 0);
+                        }
+
+                        // Handle mouse wheel events.
+                        if (wheel)
+                        {
+                            gameplay::Platform::mouseEventInternal(Mouse::MOUSE_WHEEL, position[0], position[1], -wheel);
+                        }
+                        break;
+                    }
+
+                    case SCREEN_EVENT_KEYBOARD:
+                    {
+                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_KEY_FLAGS, &flags);
+                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_KEY_SYM, &value);
+                        gameplay::Keyboard::KeyEvent evt = (flags & KEY_DOWN) ? gameplay::Keyboard::KEY_PRESS :  gameplay::Keyboard::KEY_RELEASE;
+                        // Suppress key repeats.
+                        if ((flags & KEY_REPEAT) == 0)
+                        {
+                            keyEventInternal(evt, getKey(value));
+                            if (evt == gameplay::Keyboard::KEY_PRESS && (flags & KEY_SYM_VALID))
+                            {
+                                int unicode = getUnicode(value);
+                                if (unicode)
+                                    keyEventInternal(gameplay::Keyboard::KEY_CHAR, unicode);
+                            }
+                        }
+                        break;
+                    }
+#ifdef GP_USE_GAMEPAD
+                    case SCREEN_EVENT_DEVICE:
+                    {
+                        // A device was attached or removed.
+                        screen_device_t device;
+                        int attached;
+
+                        screen_get_event_property_pv(__screenEvent, SCREEN_PROPERTY_DEVICE, (void**)&device);
+                        screen_get_event_property_iv(__screenEvent, SCREEN_PROPERTY_ATTACHED, &attached);
+
+                        if (attached)
+                        {
+                            int type;
+                            screen_get_device_property_iv(device, SCREEN_PROPERTY_TYPE, &type);
+                            if (type == SCREEN_EVENT_GAMEPAD || type == SCREEN_EVENT_JOYSTICK)
+                            {
+                                int buttonCount = 0;
+                                int joystickCount = 0;
+                                int productId;
+                                int vendorId;
+                                char productString[64];
+                                char vendorString[64];
+                                queryGamepad(device, &buttonCount, &joystickCount, &productId, &vendorId, productString, vendorString);
+                                Platform::gamepadEventConnectedInternal(device, buttonCount, joystickCount, 0, vendorId, productId, vendorString, productString);
+                            }
+                        }
+                        else
+                        {
+                            Platform::gamepadEventDisconnectedInternal(device);
+                        }
+
+                        break;
+                    }
+#endif
+                    default:
+                        break;
+                }
+            }
+            else if (domain == navigator_get_domain())
+            {
+                switch (bps_event_get_code(event))
+                {
+                case NAVIGATOR_WINDOW_STATE:
+                {
+                    navigator_window_state_t state = navigator_event_get_window_state(event);
+                    switch (state)
+                    {
+                    case NAVIGATOR_WINDOW_FULLSCREEN:
+                        if (!__screenFullscreen)
+                            __screenFullscreen = true;
+                        _game->resume();
+                        suspended = false;
+                        break;
+                    case NAVIGATOR_WINDOW_THUMBNAIL:
+                    case NAVIGATOR_WINDOW_INVISIBLE:
+                        if (__screenFullscreen && !suspended)
+                        {
+                            _game->pause();
+                            suspended = true;
+                        }
+                        break;
+                    }
+                    break;
+                }
+                case NAVIGATOR_EXIT:
+                	// Call Game::shutdown directly, instead of Game::exit.
+                	// We need to do this since exit() queues a request to shutdown for the
+                	// next frame, which will never get executed because we are suspended.
+                    _game->shutdown();
+                    break;
+                }
+            }
+            else if (domain == sensor_get_domain())
+            {
+                if (bps_event_get_code(event) == SENSOR_AZIMUTH_PITCH_ROLL_READING)
+                {
+                    float azimuth;
+                    sensor_event_get_apr(event, &azimuth, &__pitch, &__roll);
+                }
+                else if (bps_event_get_code(event) == SENSOR_ACCELEROMETER_READING)
+                {
+                    sensor_event_get_xyz(event, &__accelRawX, &__accelRawY, &__accelRawZ);
+                }
+                else if (bps_event_get_code(event) == SENSOR_GYROSCOPE_READING)
+                {
+                    sensor_event_get_xyz(event, &__gyroRawX, &__gyroRawY, &__gyroRawZ);
+                }
+            }
+        }
+
+        // If we are done, then exit.
+        if (_game->getState() == Game::UNINITIALIZED)
+            break;
+
+        if (!suspended)
+        {
+            _game->frame();
+
+            // Post the new frame to the display.
+            // Note that there are a couple cases where eglSwapBuffers could fail
+            // with an error code that requires a certain level of re-initialization:
+            //
+            // 1) EGL_BAD_NATIVE_WINDOW - Called when the surface we're currently using
+            //    is invalidated. This would require us to destroy our EGL surface,
+            //    close our OpenKODE window, and start again.
+            //
+            // 2) EGL_CONTEXT_LOST - Power management event that led to our EGL context
+            //    being lost. Requires us to re-create and re-initalize our EGL context
+            //    and all OpenGL ES state.
+            //
+            // For now, if we get these, we'll simply exit.
+            rc = eglSwapBuffers(__eglDisplay, __eglSurface);
+            if (rc != EGL_TRUE)
+            {
+                _game->shutdown();
+                perror("eglSwapBuffers");
+                break;
+            }
+        }
+    }
+
+    screen_stop_events(__screenContext);
+    bps_shutdown();
+    screen_destroy_context(__screenContext);
+
+    return 0;
+}
+    
+void Platform::signalShutdown() 
+{
+    // nothing to do  
+}
+
+bool Platform::canExit()
+{
+    return true;
+}
+
+unsigned int Platform::getDisplayWidth()
+{
+    return __screenWindowSize[0];
+}
+
+unsigned int Platform::getDisplayHeight()
+{
+    return __screenWindowSize[1];
+}
+
+double Platform::getAbsoluteTime()
+{
+    clock_gettime(CLOCK_REALTIME, &__timespec);
+    double now = timespec2millis(&__timespec);
+    __timeAbsolute = now - __timeStart;
+
+    return __timeAbsolute;
+}
+
+void Platform::setAbsoluteTime(double time)
+{
+    __timeAbsolute = time;
+}
+
+bool Platform::isVsync()
+{
+    return __vsync;
+}
+
+void Platform::setVsync(bool enable)
+{
+    eglSwapInterval(__eglDisplay, enable ? 1 : 0);
+    __vsync = enable;
+}
+
+void Platform::swapBuffers()
+{
+    if (__eglDisplay && __eglSurface)
+        eglSwapBuffers(__eglDisplay, __eglSurface);
+}
+
+void Platform::sleep(long ms)
+{
+    usleep(ms * 1000);
+}
+
+void Platform::setMultiSampling(bool enabled)
+{
+    if (enabled == __multiSampling)
+    {
+        return;
+    }
+
+    // TODO:
+    __multiSampling = enabled;
+}
+
+bool Platform::isMultiSampling()
+{
+    return __multiSampling;
+}
+
+void Platform::setMultiTouch(bool enabled)
+{
+    __multiTouch = enabled;
+}
+
+bool Platform::isMultiTouch()
+{
+    return __multiTouch;
+}
+
+bool Platform::hasAccelerometer()
+{
+    return true;
+}
+
+void Platform::getAccelerometerValues(float* pitch, float* roll)
+{
+    GP_ASSERT(pitch);
+    GP_ASSERT(roll);
+
+    switch(__orientationAngle)
+    {
+    // Landscape based device adjusting for landscape game mode
+    case 0:
+        if (pitch)
+            *pitch = __pitch;
+        if (roll)
+            *roll = -__roll;
+        break;
+    case 180:
+        if (pitch)
+            *pitch = -__pitch;
+        if (roll)
+            *roll = __roll;
+        break;
+
+    // Portrait based device adjusting for landscape game mode
+    case 90:
+        if (pitch)
+            *pitch = -__roll;
+        if (roll)
+            *roll = -__pitch;
+        break;
+
+    case  270:
+        if (pitch)
+            *pitch = __roll;
+        if (roll)
+            *roll = __pitch;
+        break;
+
+    default:
+        break;
+    }
+}
+
+void Platform::getSensorValues(float* accelX, float* accelY, float* accelZ, float* gyroX, float* gyroY, float* gyroZ)
+{
+	if (accelX)
+	{
+		*accelX = __accelRawX;
+	}
+
+	if (accelY)
+	{
+		*accelY = __accelRawY;
+	}
+
+	if (accelZ)
+	{
+		*accelZ = __accelRawZ;
+	}
+
+	if (gyroX)
+	{
+		*gyroX = __gyroRawX;
+	}
+
+	if (gyroY)
+	{
+		*gyroY = __gyroRawY;
+	}
+
+	if (gyroZ)
+	{
+		*gyroZ = __gyroRawZ;
+	}
+}
+
+void Platform::getArguments(int* argc, char*** argv)
+{
+    if (argc)
+        *argc = __argc;
+    if (argv)
+        *argv = __argv;
+}
+
+bool Platform::hasMouse()
+{
+    // not supported
+    return false;
+}
+
+void Platform::setMouseCaptured(bool captured)
+{
+    // not supported
+}
+
+bool Platform::isMouseCaptured()
+{
+    // not supported
+    return false;
+}
+
+void Platform::setCursorVisible(bool visible)
+{
+    // not supported
+}
+
+bool Platform::isCursorVisible()
+{
+    // not supported
+    return false;
+}
+
+void Platform::displayKeyboard(bool display)
+{
+    if (display)
+        virtualkeyboard_show();
+    else
+        virtualkeyboard_hide();
+}
+
+void Platform::shutdownInternal()
+{
+    Game::getInstance()->shutdown();
+}
+
+bool Platform::isGestureSupported(Gesture::GestureEvent evt)
+{
+    // All are supported no need to test the bitset
+    return true;
+}
+
+void Platform::registerGesture(Gesture::GestureEvent evt)
+{
+    switch(evt)
+    {
+    case Gesture::GESTURE_ANY_SUPPORTED:
+        __gestureEventsProcessed.set();
+        break;
+
+    case Gesture::GESTURE_SWIPE:
+    case Gesture::GESTURE_PINCH:
+    case Gesture::GESTURE_TAP:
+        __gestureEventsProcessed.set(evt);
+        break;
+
+    default:
+        break;
+    }
+}
+
+void Platform::unregisterGesture(Gesture::GestureEvent evt)
+{
+    switch(evt)
+    {
+    case Gesture::GESTURE_ANY_SUPPORTED:
+        __gestureEventsProcessed.reset();
+        break;
+
+    case Gesture::GESTURE_SWIPE:
+    case Gesture::GESTURE_PINCH:
+    case Gesture::GESTURE_TAP:
+        __gestureEventsProcessed.set(evt, 0);
+        break;
+
+    default:
+        break;
+    }
+}
+    
+bool Platform::isGestureRegistered(Gesture::GestureEvent evt)
+{
+    return __gestureEventsProcessed.test(evt);
+}
+
+bool Platform::launchURL(const char* url)
+{
+    if (url == NULL || *url == '\0')
+        return false;
+
+    return navigator_invoke(url, NULL) == BPS_SUCCESS;
+}
+
 std::string Platform::displayFileDialog(size_t mode, const char* title, const char* filterDescription, const char* filterExtensions, const char* initialDirectory)
 std::string Platform::displayFileDialog(size_t mode, const char* title, const char* filterDescription, const char* filterExtensions, const char* initialDirectory)
 {
 {
     return "";
     return "";
+}
+
 }
 }
 
 
-}
-
-#endif
+#endif

+ 8 - 0
gameplay/src/PlatformLinux.cpp

@@ -545,6 +545,14 @@ extern void print(const char* format, ...)
     vfprintf(stderr, format, argptr);
     vfprintf(stderr, format, argptr);
     va_end(argptr);
     va_end(argptr);
 }
 }
+    extern int strcmpnocase(const char* s1, const char* s2)
+    {
+        return strcasecmp(s1, s2);
+    }
+
+    Platform::Platform(Game* game) : _game(game)
+    {
+    }
 
 
 Platform::Platform(Game* game) : _game(game)
 Platform::Platform(Game* game) : _game(game)
 {
 {

+ 5 - 0
gameplay/src/PlatformMacOSX.mm

@@ -1613,6 +1613,11 @@ extern void print(const char* format, ...)
     vfprintf(stderr, format, argptr);
     vfprintf(stderr, format, argptr);
     va_end(argptr);
     va_end(argptr);
 }
 }
+
+extern int strcmpnocase(const char* s1, const char* s2)
+{
+    return strcasecmp(s1, s2);
+}
     
     
 Platform::Platform(Game* game)
 Platform::Platform(Game* game)
 : _game(game)
 : _game(game)

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1356 - 1351
gameplay/src/PlatformWindows.cpp


+ 5 - 0
gameplay/src/PlatformiOS.mm

@@ -1469,6 +1469,11 @@ extern void print(const char* format, ...)
     va_end(argptr);
     va_end(argptr);
 }
 }
 
 
+extern int strcmpnocase(const char* s1, const char* s2)
+{
+    return strcasecmp(s1, s2);
+}
+
 Platform::Platform(Game* game) : _game(game)
 Platform::Platform(Game* game) : _game(game)
 {
 {
 }
 }

+ 2 - 2
gameplay/src/Properties.cpp

@@ -962,7 +962,7 @@ bool Properties::getColor(const char* name, Vector4* out) const
             valueString[0] != '#')
             valueString[0] != '#')
         {
         {
             // Not a color string.
             // Not a color string.
-            GP_ERROR("Error attempting to parse property '%s' as an RGBA color (not specified as a color string).", name);
+            GP_WARN("Error attempting to parse property '%s' as an RGBA color (not specified as a color string).", name);
             out->set(0.0f, 0.0f, 0.0f, 0.0f);
             out->set(0.0f, 0.0f, 0.0f, 0.0f);
             return false;
             return false;
         }
         }
@@ -971,7 +971,7 @@ bool Properties::getColor(const char* name, Vector4* out) const
         unsigned int color;
         unsigned int color;
         if (sscanf(valueString+1, "%x", &color) != 1)
         if (sscanf(valueString+1, "%x", &color) != 1)
         {
         {
-            GP_ERROR("Error attempting to parse property '%s' as an RGBA color.", name);
+            GP_WARN("Error attempting to parse property '%s' as an RGBA color.", name);
             out->set(0.0f, 0.0f, 0.0f, 0.0f);
             out->set(0.0f, 0.0f, 0.0f, 0.0f);
             return false;
             return false;
         }
         }

+ 35 - 27
gameplay/src/RadioButton.cpp

@@ -21,42 +21,45 @@ RadioButton::~RadioButton()
 
 
 RadioButton* RadioButton::create(const char* id, Theme::Style* style)
 RadioButton* RadioButton::create(const char* id, Theme::Style* style)
 {
 {
-    GP_ASSERT(style);
+    RadioButton* rb = new RadioButton();
+    rb->_id = id ? id : "";
+    rb->initialize("RadioButton", style, NULL);
 
 
-    RadioButton* radioButton = new RadioButton();
-    if (id)
-        radioButton->_id = id;
-    radioButton->setStyle(style);
+    __radioButtons.push_back(rb);
 
 
-    __radioButtons.push_back(radioButton);
-
-    return radioButton;
+    return rb;
 }
 }
 
 
 Control* RadioButton::create(Theme::Style* style, Properties* properties)
 Control* RadioButton::create(Theme::Style* style, Properties* properties)
 {
 {
-    GP_ASSERT(properties);
+    RadioButton* rb = new RadioButton();
+    rb->initialize("RadioButton", style, properties);
 
 
-    RadioButton* radioButton = new RadioButton();
-    radioButton->initialize(style, properties);
+    __radioButtons.push_back(rb);
 
 
-    properties->getVector2("imageSize", &radioButton->_imageSize);
+    return rb;
+}
 
 
-    if (properties->getBool("selected"))
-    {
-        RadioButton::clearSelected(radioButton->_groupId);
-        radioButton->_selected = true;
-    }
+void RadioButton::initialize(const char* typeName, Theme::Style* style, Properties* properties)
+{
+    Button::initialize(typeName, style, properties);
 
 
-    const char* groupId = properties->getString("group");
-    if (groupId)
+    if (properties)
     {
     {
-        radioButton->_groupId = groupId;
-    }
+        properties->getVector2("imageSize", &_imageSize);
 
 
-    __radioButtons.push_back(radioButton);
+        if (properties->getBool("selected"))
+        {
+            RadioButton::clearSelected(_groupId);
+            _selected = true;
+        }
 
 
-    return radioButton;
+        const char* groupId = properties->getString("group");
+        if (groupId)
+        {
+            _groupId = groupId;
+        }
+    }
 }
 }
 
 
 bool RadioButton::isSelected() const
 bool RadioButton::isSelected() const
@@ -190,10 +193,10 @@ void RadioButton::update(const Control* container, const Vector2& offset)
     }
     }
 }
 }
 
 
-void RadioButton::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
+unsigned int RadioButton::drawImages(Form* form, const Rectangle& clip)
 {
 {
-    GP_ASSERT(spriteBatch);
-    GP_ASSERT(_image);
+    if (!_image)
+        return 0;
 
 
     // Left, v-center.
     // Left, v-center.
     // TODO: Set an alignment for radio button images.   
     // TODO: Set an alignment for radio button images.   
@@ -214,7 +217,12 @@ void RadioButton::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
 
 
     Vector2 pos(_viewportBounds.x, _viewportBounds.y + _viewportBounds.height * 0.5f - size.y * 0.5f);
     Vector2 pos(_viewportBounds.x, _viewportBounds.y + _viewportBounds.height * 0.5f - size.y * 0.5f);
 
 
-    spriteBatch->draw(pos.x, pos.y, size.x, size.y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+    SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
+    startBatch(form, batch);
+    batch->draw(pos.x, pos.y, size.x, size.y, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+    finishBatch(form, batch);
+
+    return 1;
 }
 }
 
 
 const char* RadioButton::getType() const
 const char* RadioButton::getType() const

+ 13 - 11
gameplay/src/RadioButton.h

@@ -42,15 +42,15 @@ class RadioButton : public Button
 public:
 public:
 
 
     /**
     /**
-     * Create a new radio button control.
+     * Creates a new RadioButton.
      *
      *
-     * @param id The control's ID.
-     * @param style The control's style.
+     * @param id The radio button ID.
+     * @param id The radio button style (optional).
      *
      *
      * @return The new radio button.
      * @return The new radio button.
      * @script{create}
      * @script{create}
      */
      */
-    static RadioButton* create(const char* id, Theme::Style* style);
+    static RadioButton* create(const char* id, Theme::Style* style = NULL);
 
 
     /**
     /**
      * Get whether this radio button is currently selected.
      * Get whether this radio button is currently selected.
@@ -125,11 +125,16 @@ protected:
      * Create a radio button with a given style and properties.
      * Create a radio button with a given style and properties.
      *
      *
      * @param style The style to apply to this radio button.
      * @param style The style to apply to this radio button.
-     * @param properties The properties to set on this radio button.
+     * @param properties A properties object containing a definition of the radio button (optional).
      *
      *
      * @return The new radio button.
      * @return The new radio button.
      */
      */
-    static Control* create(Theme::Style* style, Properties* properties);
+    static Control* create(Theme::Style* style, Properties* properties = NULL);
+
+    /**
+     * @see Control::initialize
+     */
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
 
 
     /**
     /**
      * Keyboard callback on key events.
      * Keyboard callback on key events.
@@ -154,12 +159,9 @@ protected:
     void update(const Control* container, const Vector2& offset);
     void update(const Control* container, const Vector2& offset);
 
 
     /**
     /**
-     * Draw the images associated with this control.
-     *
-     * @param spriteBatch The sprite batch containing this control's icons.
-     * @param clip The clipping rectangle of this control's parent container.
+     * @see Control::drawImages
      */
      */
-    void drawImages(SpriteBatch* spriteBatch, const Rectangle& clip);
+    unsigned int drawImages(Form* form, const Rectangle& clip);
 
 
     /**
     /**
      * Clear the _selected flag of all radio buttons in the given group.
      * Clear the _selected flag of all radio buttons in the given group.

+ 21 - 0
gameplay/src/Rectangle.cpp

@@ -108,6 +108,27 @@ bool Rectangle::intersects(const Rectangle& r) const
     return intersects(r.x, r.y, r.width, r.height);
     return intersects(r.x, r.y, r.width, r.height);
 }
 }
 
 
+bool Rectangle::intersect(const Rectangle& r1, const Rectangle& r2, Rectangle* dst)
+{
+    GP_ASSERT(dst);
+
+    float xmin = max(r1.x, r2.x);
+    float xmax = min(r1.right(), r2.right());
+    if (xmax > xmin)
+    {
+        float ymin = max(r1.y, r2.y);
+        float ymax = min(r1.bottom(), r2.bottom());
+        if (ymax > ymin)
+        {
+            dst->set(xmin, ymin, xmax - xmin, ymax - ymin);
+            return true;
+        }
+    }
+
+    dst->set(0, 0, 0, 0);
+    return false;
+}
+
 void Rectangle::combine(const Rectangle& r1, const Rectangle& r2, Rectangle* dst)
 void Rectangle::combine(const Rectangle& r1, const Rectangle& r2, Rectangle* dst)
 {
 {
     GP_ASSERT(dst);
     GP_ASSERT(dst);

+ 11 - 0
gameplay/src/Rectangle.h

@@ -190,6 +190,17 @@ public:
      */
      */
     bool intersects(const Rectangle& r) const;
     bool intersects(const Rectangle& r) const;
 
 
+    /**
+     * Computes the intersection of two rectangles and returns the result.
+     *
+     * @param r1 The first rectangle.
+     * @param r2 The second rectangle.
+     * @param dst Populated with the resulting intersection, or Rectangle.empty if they do not intersect.
+     *
+     * @return True if the two rectangles intersect, false otherwise.
+     */
+    static bool intersect(const Rectangle& r1, const Rectangle& r2, Rectangle* dst);
+
     /**
     /**
      * Returns a new rectangle that exactly contains two other rectangles.
      * Returns a new rectangle that exactly contains two other rectangles.
      *
      *

+ 55 - 67
gameplay/src/Slider.cpp

@@ -8,14 +8,10 @@ namespace gameplay
 static const float SCROLLWHEEL_FRACTION = 0.1f;
 static const float SCROLLWHEEL_FRACTION = 0.1f;
 // Fraction of slider to scroll for a delta of 1.0f when a gamepad or keyboard is used.
 // Fraction of slider to scroll for a delta of 1.0f when a gamepad or keyboard is used.
 static const float MOVE_FRACTION = 0.005f;
 static const float MOVE_FRACTION = 0.005f;
-// Distance that a slider must be moved before it starts consuming input events,
-// e.g. to prevent its parent container from scrolling at the same time.
-static const float SLIDER_THRESHOLD = 5.0f;
 
 
 Slider::Slider() : _min(0.0f), _max(0.0f), _step(0.0f), _value(0.0f), _delta(0.0f), _minImage(NULL),
 Slider::Slider() : _min(0.0f), _max(0.0f), _step(0.0f), _value(0.0f), _delta(0.0f), _minImage(NULL),
     _maxImage(NULL), _trackImage(NULL), _markerImage(NULL), _valueTextVisible(false),
     _maxImage(NULL), _trackImage(NULL), _markerImage(NULL), _valueTextVisible(false),
-    _valueTextAlignment(Font::ALIGN_BOTTOM_HCENTER), _valueTextPrecision(0), _valueText(""),
-    _selectButtonDown(false), _directionButtonDown(false), _gamepadValue(0.0f)
+    _valueTextAlignment(Font::ALIGN_BOTTOM_HCENTER), _valueTextPrecision(0), _valueText(""), _gamepadValue(0.0f)
 {
 {
     _canFocus = true;
     _canFocus = true;
 }
 }
@@ -26,36 +22,37 @@ Slider::~Slider()
 
 
 Slider* Slider::create(const char* id, Theme::Style* style)
 Slider* Slider::create(const char* id, Theme::Style* style)
 {
 {
-    GP_ASSERT(style);
-
     Slider* slider = new Slider();
     Slider* slider = new Slider();
-    if (id)
-        slider->_id = id;
-    slider->setStyle(style);
-
+    slider->_id = id ? id : "";
+    slider->initialize("Slider", style, NULL);
     return slider;
     return slider;
 }
 }
 
 
 Control* Slider::create(Theme::Style* style, Properties* properties)
 Control* Slider::create(Theme::Style* style, Properties* properties)
 {
 {
-    GP_ASSERT(properties);
-
     Slider* slider = new Slider();
     Slider* slider = new Slider();
-    slider->initialize(style, properties);
+    slider->initialize("Slider", style, properties);
+    return slider;
+}
 
 
-    slider->_min = properties->getFloat("min");
-    slider->_max = properties->getFloat("max");
-    slider->_value = properties->getFloat("value");
-    slider->_step = properties->getFloat("step");
-    slider->_valueTextVisible = properties->getBool("valueTextVisible");
-    slider->_valueTextPrecision = properties->getInt("valueTextPrecision");
+void Slider::initialize(const char* typeName, Theme::Style* style, Properties* properties)
+{
+    Label::initialize(typeName, style, properties);
 
 
-    if (properties->exists("valueTextAlignment"))
+    if (properties)
     {
     {
-        slider->_valueTextAlignment = Font::getJustify(properties->getString("valueTextAlignment"));
+        _min = properties->getFloat("min");
+        _max = properties->getFloat("max");
+        _value = properties->getFloat("value");
+        _step = properties->getFloat("step");
+        _valueTextVisible = properties->getBool("valueTextVisible");
+        _valueTextPrecision = properties->getInt("valueTextPrecision");
+
+        if (properties->exists("valueTextAlignment"))
+        {
+            _valueTextAlignment = Font::getJustify(properties->getString("valueTextAlignment"));
+        }
     }
     }
-
-    return slider;
 }
 }
 
 
 void Slider::setMin(float min)
 void Slider::setMin(float min)
@@ -228,13 +225,22 @@ bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contac
     return Control::touchEvent(evt, x, y, contactIndex);
     return Control::touchEvent(evt, x, y, contactIndex);
 }
 }
 
 
+static bool isScrollable(Container* container)
+{
+    if (container->getScroll() != Container::SCROLL_NONE)
+        return true;
+
+    Container* parent = static_cast<Container*>(container->getParent());
+    return parent ? isScrollable(parent) : false;
+}
+
 bool Slider::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 bool Slider::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 {
 {
     switch (evt)
     switch (evt)
     {
     {
         case Mouse::MOUSE_WHEEL:
         case Mouse::MOUSE_WHEEL:
         {
         {
-            if (hasFocus())
+            if (hasFocus() && !isScrollable(_parent))
             {
             {
                 float total = _max - _min;
                 float total = _max - _min;
                 float oldValue = _value;
                 float oldValue = _value;
@@ -387,41 +393,10 @@ void Slider::update(const Control* container, const Vector2& offset)
     }
     }
 }
 }
 
 
-void Slider::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsClear, bool cleared, float targetHeight)
+unsigned int Slider::drawImages(Form* form, const Rectangle& clip)
 {
 {
-    if (needsClear)
-    {
-        GL_ASSERT( glEnable(GL_SCISSOR_TEST) );
-        GL_ASSERT( glScissor(_clearBounds.x, targetHeight - _clearBounds.y - _clearBounds.height, _clearBounds.width, _clearBounds.height) );
-        Game::getInstance()->clear(Game::CLEAR_COLOR, Vector4::zero(), 1.0f, 0);
-        GL_ASSERT( glDisable(GL_SCISSOR_TEST) );
-    }
-
-    if (!_visible)
-    {
-        _dirty = false;
-        return;
-    }
-
-    spriteBatch->start();
-    drawBorder(spriteBatch, clip);
-    drawImages(spriteBatch, clip);
-    spriteBatch->finish();
-
-    drawText(clip);
-    if (_delta == 0.0f)
-    {
-        _dirty = false;
-    }
-}
-
-void Slider::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
-{
-    GP_ASSERT(spriteBatch);
-    GP_ASSERT(_minImage);
-    GP_ASSERT(_maxImage);
-    GP_ASSERT(_markerImage);
-    GP_ASSERT(_trackImage);
+    if (!(_minImage && _maxImage && _markerImage && _trackImage))
+        return 0;
 
 
     // TODO: Vertical slider.
     // TODO: Vertical slider.
 
 
@@ -448,37 +423,50 @@ void Slider::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
     markerColor.w *= _opacity;
     markerColor.w *= _opacity;
     trackColor.w *= _opacity;
     trackColor.w *= _opacity;
 
 
+    SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
+    startBatch(form, batch);
+
     // Draw order: track, caps, marker.
     // Draw order: track, caps, marker.
     float midY = _viewportBounds.y + (_viewportBounds.height) * 0.5f;
     float midY = _viewportBounds.y + (_viewportBounds.height) * 0.5f;
     Vector2 pos(_viewportBounds.x, midY - trackRegion.height * 0.5f);
     Vector2 pos(_viewportBounds.x, midY - trackRegion.height * 0.5f);
-    spriteBatch->draw(pos.x, pos.y, _viewportBounds.width, trackRegion.height, track.u1, track.v1, track.u2, track.v2, trackColor, _viewportClipBounds);
+    batch->draw(pos.x, pos.y, _viewportBounds.width, trackRegion.height, track.u1, track.v1, track.u2, track.v2, trackColor, _viewportClipBounds);
 
 
     pos.y = midY - minCapRegion.height * 0.5f;
     pos.y = midY - minCapRegion.height * 0.5f;
     pos.x -= minCapRegion.width * 0.5f;
     pos.x -= minCapRegion.width * 0.5f;
-    spriteBatch->draw(pos.x, pos.y, minCapRegion.width, minCapRegion.height, minCap.u1, minCap.v1, minCap.u2, minCap.v2, minCapColor, _viewportClipBounds);
+    batch->draw(pos.x, pos.y, minCapRegion.width, minCapRegion.height, minCap.u1, minCap.v1, minCap.u2, minCap.v2, minCapColor, _viewportClipBounds);
 
 
     pos.x = _viewportBounds.x + _viewportBounds.width - maxCapRegion.width * 0.5f;
     pos.x = _viewportBounds.x + _viewportBounds.width - maxCapRegion.width * 0.5f;
-    spriteBatch->draw(pos.x, pos.y, maxCapRegion.width, maxCapRegion.height, maxCap.u1, maxCap.v1, maxCap.u2, maxCap.v2, maxCapColor, _viewportClipBounds);
+    batch->draw(pos.x, pos.y, maxCapRegion.width, maxCapRegion.height, maxCap.u1, maxCap.v1, maxCap.u2, maxCap.v2, maxCapColor, _viewportClipBounds);
 
 
     // Percent across.
     // Percent across.
     float markerPosition = (_value - _min) / (_max - _min);
     float markerPosition = (_value - _min) / (_max - _min);
     markerPosition *= _viewportBounds.width - minCapRegion.width * 0.5f - maxCapRegion.width * 0.5f - markerRegion.width;
     markerPosition *= _viewportBounds.width - minCapRegion.width * 0.5f - maxCapRegion.width * 0.5f - markerRegion.width;
     pos.x = _viewportBounds.x + minCapRegion.width * 0.5f + markerPosition;
     pos.x = _viewportBounds.x + minCapRegion.width * 0.5f + markerPosition;
     pos.y = midY - markerRegion.height / 2.0f;
     pos.y = midY - markerRegion.height / 2.0f;
-    spriteBatch->draw(pos.x, pos.y, markerRegion.width, markerRegion.height, marker.u1, marker.v1, marker.u2, marker.v2, markerColor, _viewportClipBounds);
+    batch->draw(pos.x, pos.y, markerRegion.width, markerRegion.height, marker.u1, marker.v1, marker.u2, marker.v2, markerColor, _viewportClipBounds);
+
+    finishBatch(form, batch);
+
+    return 4;
 }
 }
 
 
-void Slider::drawText(const Rectangle& clip)
+unsigned int Slider::drawText(Form* form, const Rectangle& clip)
 {
 {
-    Label::drawText(clip);
+    unsigned int drawCalls = Label::drawText(form, clip);
 
 
     if (_valueTextVisible && _font)
     if (_valueTextVisible && _font)
     {
     {
         Control::State state = getState();
         Control::State state = getState();
-        _font->start();
+
+        SpriteBatch* batch = _font->getSpriteBatch();
+        startBatch(form, batch);
         _font->drawText(_valueText.c_str(), _textBounds, _textColor, getFontSize(state), _valueTextAlignment, true, getTextRightToLeft(state), &_viewportClipBounds);
         _font->drawText(_valueText.c_str(), _textBounds, _textColor, getFontSize(state), _valueTextAlignment, true, getTextRightToLeft(state), &_viewportClipBounds);
-        _font->finish();
+        finishBatch(form, batch);
+
+        ++drawCalls;
     }
     }
+
+    return drawCalls;
 }
 }
 
 
 const char* Slider::getType() const
 const char* Slider::getType() const

+ 15 - 46
gameplay/src/Slider.h

@@ -38,15 +38,15 @@ class Slider : public Label
 public:
 public:
 
 
     /**
     /**
-     * Create a new slider control.
+     * Creates a new Slider.
      *
      *
-     * @param id The control's ID.
-     * @param style The control's style.
+     * @param id The slider ID.
+     * @param style The slider style (optional).
      *
      *
      * @return The new slider.
      * @return The new slider.
      * @script{create}
      * @script{create}
      */
      */
-    static Slider* create(const char* id, Theme::Style* style);
+    static Slider* create(const char* id, Theme::Style* style = NULL);
 
 
     /**
     /**
      * Set the minimum value that can be set on this slider.
      * Set the minimum value that can be set on this slider.
@@ -181,11 +181,16 @@ protected:
      * Create a slider with a given style and properties.
      * Create a slider with a given style and properties.
      *
      *
      * @param style The style to apply to this slider.
      * @param style The style to apply to this slider.
-     * @param properties The properties to set on this slider.
+     * @param properties A properties object containing a definition of the slider (optional).
      *
      *
      * @return The new slider.
      * @return The new slider.
      */
      */
-    static Control* create(Theme::Style* style, Properties* properties);
+    static Control* create(Theme::Style* style, Properties* properties = NULL);
+
+    /**
+     * @see Control::initialize
+     */
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
 
 
     /**
     /**
      * Touch callback on touch events.  Controls return true if they consume the touch event.
      * Touch callback on touch events.  Controls return true if they consume the touch event.
@@ -231,25 +236,14 @@ protected:
     bool keyEvent(Keyboard::KeyEvent evt, int key);
     bool keyEvent(Keyboard::KeyEvent evt, int key);
 
 
     /**
     /**
-     * Slider overrides draw() so that it can avoid resetting the _dirty flag
-     * when a joystick is being used to change its value.
+     * @see Control::drawImages
      */
      */
-    void draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsClear, bool cleared, float targetHeight);
+    unsigned int drawImages(Form* form, const Rectangle& clip);
 
 
     /**
     /**
-     * Draw the images associated with this control.
-     *
-     * @param spriteBatch The sprite batch containing this control's icons.
-     * @param clip The clipping rectangle of this control's parent container.
+     * @see Control::drawText
      */
      */
-    void drawImages(SpriteBatch* spriteBatch, const Rectangle& clip);
-
-    /**
-     * Draw this slider's text.
-     *
-     * @param clip The clipping rectangle of this slider's parent container.
-     */
-    void drawText(const Rectangle& clip);
+    unsigned int drawText(Form* form, const Rectangle& clip);
 
 
     /**
     /**
      * Called when a slider's properties change. Updates this slider's internal rendering
      * Called when a slider's properties change. Updates this slider's internal rendering
@@ -285,26 +279,6 @@ protected:
      */
      */
     float _delta;
     float _delta;
 
 
-    /**
-     * The X coordinate of the first touch event in a sequence.
-     */
-    float _originalX;
-
-    /**
-     * The Slider's original value at the start of a sequence of touch events.
-     */
-    float _originalValue;
-
-    /**
-     * The Slider's original setting of _consumeInputEvents at the start of a sequence of touch events.
-     */
-    bool _originalConsumeInputEvents;
-
-    /**
-     * Whether the Slider's current movement has been cancelled, e.g. because the user is scrolling the parent container.
-     */
-    bool _moveCancelled;
-
     /**
     /**
      * The image for the minimum slider value.
      * The image for the minimum slider value.
      */
      */
@@ -345,11 +319,6 @@ protected:
      */
      */
     std::string _valueText;
     std::string _valueText;
 
 
-    // Used by gamepads to toggle Slider state between FOCUS and ACTIVE.
-    bool _selectButtonDown;
-
-    bool _directionButtonDown;
-
     float _gamepadValue;
     float _gamepadValue;
 
 
 private:
 private:

+ 14 - 1
gameplay/src/SpriteBatch.cpp

@@ -105,6 +105,7 @@ SpriteBatch* SpriteBatch::create(Texture* texture,  Effect* effect, unsigned int
     material->getStateBlock()->setBlend(true);
     material->getStateBlock()->setBlend(true);
     material->getStateBlock()->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
     material->getStateBlock()->setBlendSrc(RenderState::BLEND_SRC_ALPHA);
     material->getStateBlock()->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
     material->getStateBlock()->setBlendDst(RenderState::BLEND_ONE_MINUS_SRC_ALPHA);
+    //material->getStateBlock()->setDepthFunction(RenderState::DEPTH_LEQUAL);
 
 
     // Bind the texture to the material as a sampler
     // Bind the texture to the material as a sampler
     Texture::Sampler* sampler = Texture::Sampler::create(texture); // +ref texture
     Texture::Sampler* sampler = Texture::Sampler::create(texture); // +ref texture
@@ -144,6 +145,11 @@ void SpriteBatch::start()
     _batch->start();
     _batch->start();
 }
 }
 
 
+bool SpriteBatch::isStarted() const
+{
+    return _batch->isStarted();
+}
+
 void SpriteBatch::draw(const Rectangle& dst, const Rectangle& src, const Vector4& color)
 void SpriteBatch::draw(const Rectangle& dst, const Rectangle& src, const Vector4& color)
 {
 {
     // Calculate uvs.
     // Calculate uvs.
@@ -298,9 +304,16 @@ void SpriteBatch::draw(float x, float y, float width, float height, float u1, fl
 
 
 void SpriteBatch::draw(float x, float y, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Rectangle& clip)
 void SpriteBatch::draw(float x, float y, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Rectangle& clip)
 {
 {
+    draw(x, y, 0, width, height, u1, v1, u2, v2, color, clip);
+}
+
+void SpriteBatch::draw(float x, float y, float z, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Rectangle& clip)
+{
+    // TODO: Perform software clipping instead of culling the entire sprite.
+
     // Only draw if at least part of the sprite is within the clip region.
     // Only draw if at least part of the sprite is within the clip region.
     if (clipSprite(clip, x, y, width, height, u1, v1, u2, v2))
     if (clipSprite(clip, x, y, width, height, u1, v1, u2, v2))
-        draw(x, y, 0, width, height, u1, v1, u2, v2, color);
+        draw(x, y, z, width, height, u1, v1, u2, v2, color);
 }
 }
 
 
 void SpriteBatch::addSprite(float x, float y, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, SpriteBatch::SpriteVertex* vertices)
 void SpriteBatch::addSprite(float x, float y, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, SpriteBatch::SpriteVertex* vertices)

+ 24 - 0
gameplay/src/SpriteBatch.h

@@ -96,6 +96,13 @@ public:
      */
      */
     void start();
     void start();
 
 
+    /**
+     * Determines if the sprite batch has been started but not yet finished.
+     *
+     * @return True if the batch has been started and not finished.
+     */
+    bool isStarted() const;
+
     /**
     /**
      * Draws a single sprite.
      * Draws a single sprite.
      * 
      * 
@@ -220,6 +227,23 @@ public:
      */
      */
     void draw(float x, float y, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Rectangle& clip);
     void draw(float x, float y, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Rectangle& clip);
 
 
+    /**
+     * Draws a single sprite, clipped within a rectangle.
+     * 
+     * @param x The x coordinate.
+     * @param y The y coordinate.
+     * @param z The z coordinate.
+     * @param width The sprite width.
+     * @param height The sprite height
+     * @param u1 Texture coordinate.
+     * @param v1 Texture coordinate.
+     * @param u2 Texture coordinate.
+     * @param v2 Texture coordinate.
+     * @param color The color to tint the sprite. Use white for no tint.
+     * @param clip The clip rectangle.
+     */
+    void draw(float x, float y, float z, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Rectangle& clip);
+
     /**
     /**
      * Draws a single sprite.
      * Draws a single sprite.
      * 
      * 

+ 40 - 32
gameplay/src/TextBox.cpp

@@ -20,30 +20,27 @@ TextBox::~TextBox()
 
 
 TextBox* TextBox::create(const char* id, Theme::Style* style)
 TextBox* TextBox::create(const char* id, Theme::Style* style)
 {
 {
-    GP_ASSERT(style);
-
     TextBox* textBox = new TextBox();
     TextBox* textBox = new TextBox();
-    if (id)
-        textBox->_id = id;
-    textBox->setStyle(style);
-
+    textBox->_id = id ? id : "";
+    textBox->initialize("TextBox", style, NULL);
     return textBox;
     return textBox;
 }
 }
 
 
 Control* TextBox::create(Theme::Style* style, Properties* properties)
 Control* TextBox::create(Theme::Style* style, Properties* properties)
 {
 {
     TextBox* textBox = new TextBox();
     TextBox* textBox = new TextBox();
-    textBox->initialize(style, properties);
-
+    textBox->initialize("TextBox", style, properties);
     return textBox;
     return textBox;
 }
 }
 
 
-void TextBox::initialize(Theme::Style* style, Properties* properties)
+void TextBox::initialize(const char* typeName, Theme::Style* style, Properties* properties)
 {
 {
-    GP_ASSERT(properties);
+    Label::initialize(typeName, style, properties);
 
 
-    Label::initialize(style, properties);
-    _inputMode = getInputMode(properties->getString("inputMode"));
+	if (properties)
+	{
+		_inputMode = getInputMode(properties->getString("inputMode"));
+	}
 }
 }
 
 
 int TextBox::getLastKeypress()
 int TextBox::getLastKeypress()
@@ -327,7 +324,7 @@ void TextBox::update(const Control* container, const Vector2& offset)
     _caretImage = getImage("textCaret", state);
     _caretImage = getImage("textCaret", state);
 }
 }
 
 
-void TextBox::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
+unsigned int TextBox::drawImages(Form* form, const Rectangle& clip)
 {
 {
     Control::State state = getState();
     Control::State state = getState();
 
 
@@ -337,7 +334,6 @@ void TextBox::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
         const Rectangle& region = _caretImage->getRegion();
         const Rectangle& region = _caretImage->getRegion();
         if (!region.isEmpty())
         if (!region.isEmpty())
         {
         {
-            GP_ASSERT(spriteBatch);
             const Theme::UVs uvs = _caretImage->getUVs();
             const Theme::UVs uvs = _caretImage->getUVs();
             Vector4 color = _caretImage->getColor();
             Vector4 color = _caretImage->getColor();
             color.w *= _opacity;
             color.w *= _opacity;
@@ -349,11 +345,39 @@ void TextBox::drawImages(SpriteBatch* spriteBatch, const Rectangle& clip)
             Vector2 point;
             Vector2 point;
             font->getLocationAtIndex(getDisplayedText().c_str(), _textBounds, fontSize, &point, _caretLocation, 
             font->getLocationAtIndex(getDisplayedText().c_str(), _textBounds, fontSize, &point, _caretLocation, 
                  getTextAlignment(state), true, getTextRightToLeft(state));
                  getTextAlignment(state), true, getTextRightToLeft(state));
-            spriteBatch->draw(point.x - caretWidth * 0.5f, point.y, caretWidth, fontSize, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+
+            SpriteBatch* batch = _style->getTheme()->getSpriteBatch();
+            startBatch(form, batch);
+            batch->draw(point.x - caretWidth * 0.5f, point.y, caretWidth, fontSize, uvs.u1, uvs.v1, uvs.u2, uvs.v2, color, _viewportClipBounds);
+            finishBatch(form, batch);
+
+            return 1;
         }
         }
     }
     }
 
 
-    _dirty = false;
+    return 0;
+}
+
+unsigned int TextBox::drawText(Form* form, const Rectangle& clip)
+{
+    if (_text.size() <= 0)
+        return 0;
+
+    // Draw the text.
+    if (_font)
+    {
+        Control::State state = getState();
+        const std::string displayedText = getDisplayedText();
+
+        SpriteBatch* batch = _font->getSpriteBatch();
+        startBatch(form, batch);
+        _font->drawText(displayedText.c_str(), _textBounds, _textColor, getFontSize(state), getTextAlignment(state), true, getTextRightToLeft(state), &_viewportClipBounds);
+        finishBatch(form, batch);
+
+        return 1;
+    }
+
+    return 0;
 }
 }
 
 
 void TextBox::setCaretLocation(int x, int y)
 void TextBox::setCaretLocation(int x, int y)
@@ -448,22 +472,6 @@ TextBox::InputMode TextBox::getInputMode() const
     return _inputMode;
     return _inputMode;
 }
 }
 
 
-void TextBox::drawText(const Rectangle& clip)
-{
-    if (_text.size() <= 0)
-        return;
-
-    // Draw the text.
-    if (_font)
-    {
-        Control::State state = getState();
-        const std::string displayedText = getDisplayedText();
-        _font->start();
-        _font->drawText(displayedText.c_str(), _textBounds, _textColor, getFontSize(state), getTextAlignment(state), true, getTextRightToLeft(state), &_viewportClipBounds);
-        _font->finish();
-    }
-}
-
 TextBox::InputMode TextBox::getInputMode(const char* inputMode)
 TextBox::InputMode TextBox::getInputMode(const char* inputMode)
 {
 {
     if (!inputMode)
     if (!inputMode)

+ 16 - 22
gameplay/src/TextBox.h

@@ -58,20 +58,15 @@ public:
     };
     };
 
 
     /**
     /**
-     * Create a new text box control.
+     * Creates a new TextBox.
      *
      *
-     * @param id The control's ID.
-     * @param style The control's style.
+     * @param id The textbox ID.
+     * @param style The textbox style (optional).
      *
      *
-     * @return The new text box.
+     * @return The new textbox.
      * @script{create}
      * @script{create}
      */
      */
-    static TextBox* create(const char* id, Theme::Style* style);
-
-    /**
-     * Initialize this textbox.
-     */
-    virtual void initialize(Theme::Style* style, Properties* properties);
+    static TextBox* create(const char* id, Theme::Style* style = NULL);
 
 
     /**
     /**
      * Returns the current location of the caret with the text of this TextBox.
      * Returns the current location of the caret with the text of this TextBox.
@@ -143,11 +138,16 @@ protected:
      * Create a text box with a given style and properties.
      * Create a text box with a given style and properties.
      *
      *
      * @param style The style to apply to this text box.
      * @param style The style to apply to this text box.
-     * @param properties The properties to set on this text box.
+     * @param properties A properties object containing a definition of the text box (optional).
      *
      *
      * @return The new text box.
      * @return The new text box.
      */
      */
-    static Control* create(Theme::Style* style, Properties* properties);
+    static Control* create(Theme::Style* style, Properties* properties = NULL);
+
+    /**
+     * @see Control::initialize
+     */
+    void initialize(const char* typeName, Theme::Style* style, Properties* properties);
 
 
     /**
     /**
      * Touch callback on touch events.  Controls return true if they consume the touch event.
      * Touch callback on touch events.  Controls return true if they consume the touch event.
@@ -190,20 +190,14 @@ protected:
     void update(const Control* container, const Vector2& offset);
     void update(const Control* container, const Vector2& offset);
 
 
     /**
     /**
-     * Draw the images associated with this control.
-     *
-     * @param spriteBatch The sprite batch containing this control's icons.
-     * @param clip The clipping rectangle of this control's parent container.
+     * @see Control::drawImages
      */
      */
-    void drawImages(SpriteBatch* spriteBatch, const Rectangle& clip);
+    unsigned int drawImages(Form* form, const Rectangle& clip);
 
 
     /**
     /**
-     * Draw this textbox's text.
-     *
-     * @param clip The clipping rectangle of this textbox's
-     * parent container.
+     * @see Control::drawText
      */
      */
-    virtual void drawText(const Rectangle& clip);
+    unsigned int drawText(Form* form, const Rectangle& clip);
 
 
     /**
     /**
      * Gets an InputMode by string.
      * Gets an InputMode by string.

+ 78 - 28
gameplay/src/Theme.cpp

@@ -1,13 +1,16 @@
 #include "Base.h"
 #include "Base.h"
 #include "Theme.h"
 #include "Theme.h"
 #include "ThemeStyle.h"
 #include "ThemeStyle.h"
+#include "Game.h"
+#include "FileSystem.h"
 
 
 namespace gameplay
 namespace gameplay
 {
 {
 
 
 static std::vector<Theme*> __themeCache;
 static std::vector<Theme*> __themeCache;
+static Theme* __defaultTheme = NULL;
 
 
-Theme::Theme()
+Theme::Theme() : _texture(NULL), _spriteBatch(NULL), _emptyImage(NULL)
 {
 {
 }
 }
 
 
@@ -47,6 +50,50 @@ Theme::~Theme()
     {
     {
         __themeCache.erase(itr);
         __themeCache.erase(itr);
     }
     }
+
+    SAFE_RELEASE(_emptyImage);
+
+	if (__defaultTheme == this)
+		__defaultTheme = NULL;
+}
+
+Theme* Theme::getDefault()
+{
+	if (!__defaultTheme)
+	{
+		// Check game.config for a default theme setting
+		Properties* config = Game::getInstance()->getConfig()->getNamespace("ui", true);
+		if (config)
+		{
+			const char* defaultTheme = config->getString("defaultTheme");
+			if (defaultTheme && FileSystem::fileExists(defaultTheme))
+				__defaultTheme = Theme::create(defaultTheme);
+		}
+
+        if (!__defaultTheme)
+        {
+            GP_WARN("No default theme detected.");
+
+            // Create an empty theme so that UI's with no theme don't just crash
+            __defaultTheme = new Theme();
+            unsigned int color = 0x00000000;
+            __defaultTheme->_texture = Texture::create(Texture::RGBA, 1, 1, (unsigned char*)&color, false);
+            __defaultTheme->_emptyImage = new Theme::ThemeImage(1.0f, 1.0f, Rectangle::empty(), Vector4::zero());
+            __defaultTheme->_spriteBatch = SpriteBatch::create(__defaultTheme->_texture);
+            __defaultTheme->_spriteBatch->getSampler()->setFilterMode(Texture::LINEAR_MIPMAP_LINEAR, Texture::LINEAR);
+            __defaultTheme->_spriteBatch->getSampler()->setWrapMode(Texture::CLAMP, Texture::CLAMP);
+        }
+
+		// TODO: Use a built-in (compiled-in) default theme resource as the final fallback so that
+		// UI still works even when no theme files are present.
+	}
+
+	return __defaultTheme;
+}
+
+void Theme::finalize()
+{
+    SAFE_RELEASE(__defaultTheme);
 }
 }
 
 
 Theme* Theme::create(const char* url)
 Theme* Theme::create(const char* url)
@@ -77,7 +124,7 @@ Theme* Theme::create(const char* url)
     // Check if the Properties is valid and has a valid namespace.
     // Check if the Properties is valid and has a valid namespace.
     Properties* themeProperties = (strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace();
     Properties* themeProperties = (strlen(properties->getNamespace()) > 0) ? properties : properties->getNextNamespace();
     GP_ASSERT(themeProperties);
     GP_ASSERT(themeProperties);
-    if (!themeProperties || !(strcmp(themeProperties->getNamespace(), "theme") == 0))
+    if (!themeProperties || !(strcmpnocase(themeProperties->getNamespace(), "theme") == 0))
     {
     {
         SAFE_DELETE(properties);
         SAFE_DELETE(properties);
         return NULL;
         return NULL;
@@ -86,42 +133,44 @@ Theme* Theme::create(const char* url)
     // Create a new theme.
     // Create a new theme.
     Theme* theme = new Theme();
     Theme* theme = new Theme();
     theme->_url = url;
     theme->_url = url;
-        
+
     // Parse the Properties object and set up the theme.
     // Parse the Properties object and set up the theme.
     std::string textureFile;
     std::string textureFile;
     themeProperties->getPath("texture", &textureFile);
     themeProperties->getPath("texture", &textureFile);
-    theme->_texture = Texture::create(textureFile.c_str(), false);
+    theme->_texture = Texture::create(textureFile.c_str(), true);
     GP_ASSERT(theme->_texture);
     GP_ASSERT(theme->_texture);
     theme->_spriteBatch = SpriteBatch::create(theme->_texture);
     theme->_spriteBatch = SpriteBatch::create(theme->_texture);
     GP_ASSERT(theme->_spriteBatch);
     GP_ASSERT(theme->_spriteBatch);
-    theme->_spriteBatch->getSampler()->setFilterMode(Texture::LINEAR, Texture::LINEAR);
+    theme->_spriteBatch->getSampler()->setFilterMode(Texture::LINEAR_MIPMAP_LINEAR, Texture::LINEAR);
     theme->_spriteBatch->getSampler()->setWrapMode(Texture::CLAMP, Texture::CLAMP);
     theme->_spriteBatch->getSampler()->setWrapMode(Texture::CLAMP, Texture::CLAMP);
 
 
     float tw = 1.0f / theme->_texture->getWidth();
     float tw = 1.0f / theme->_texture->getWidth();
     float th = 1.0f / theme->_texture->getHeight();
     float th = 1.0f / theme->_texture->getHeight();
 
 
+    theme->_emptyImage = new Theme::ThemeImage(tw, th, Rectangle::empty(), Vector4::zero());
+
     Properties* space = themeProperties->getNextNamespace();
     Properties* space = themeProperties->getNextNamespace();
     while (space != NULL)
     while (space != NULL)
     {
     {
         // First load all cursors, checkboxes etc. that can be referred to by styles.
         // First load all cursors, checkboxes etc. that can be referred to by styles.
         const char* spacename = space->getNamespace();
         const char* spacename = space->getNamespace();
             
             
-        if (strcmp(spacename, "image") == 0)
+        if (strcmpnocase(spacename, "image") == 0)
         {
         {
             theme->_images.push_back(ThemeImage::create(tw, th, space, Vector4::one()));
             theme->_images.push_back(ThemeImage::create(tw, th, space, Vector4::one()));
         }
         }
-        else if (strcmp(spacename, "imageList") == 0)
+        else if (strcmpnocase(spacename, "imageList") == 0)
         {
         {
             theme->_imageLists.push_back(ImageList::create(tw, th, space));
             theme->_imageLists.push_back(ImageList::create(tw, th, space));
         }
         }
-        else if (strcmp(spacename, "skin") == 0)
+        else if (strcmpnocase(spacename, "skin") == 0)
         {
         {
             Theme::Border border;
             Theme::Border border;
             Properties* innerSpace = space->getNextNamespace();
             Properties* innerSpace = space->getNextNamespace();
             if (innerSpace)
             if (innerSpace)
             {
             {
                 const char* innerSpacename = innerSpace->getNamespace();
                 const char* innerSpacename = innerSpace->getNamespace();
-                if (strcmp(innerSpacename, "border") == 0)
+                if (strcmpnocase(innerSpacename, "border") == 0)
                 {
                 {
                     border.top = innerSpace->getFloat("top");
                     border.top = innerSpace->getFloat("top");
                     border.bottom = innerSpace->getFloat("bottom");
                     border.bottom = innerSpace->getFloat("bottom");
@@ -153,7 +202,7 @@ Theme* Theme::create(const char* url)
     while (space != NULL)
     while (space != NULL)
     {
     {
         const char* spacename = space->getNamespace();
         const char* spacename = space->getNamespace();
-        if (strcmp(spacename, "style") == 0)
+        if (strcmpnocase(spacename, "style") == 0)
         {
         {
             // Each style contains up to MAX_OVERLAYS overlays,
             // Each style contains up to MAX_OVERLAYS overlays,
             // as well as Border and Padding namespaces.
             // as well as Border and Padding namespaces.
@@ -170,7 +219,7 @@ Theme* Theme::create(const char* url)
             while (innerSpace != NULL)
             while (innerSpace != NULL)
             {
             {
                 const char* innerSpacename = innerSpace->getNamespace();
                 const char* innerSpacename = innerSpace->getNamespace();
-                if (strcmp(innerSpacename, "stateNormal") == 0)
+                if (strcmpnocase(innerSpacename, "stateNormal") == 0)
                 {
                 {
                     Vector4 textColor(0, 0, 0, 1);
                     Vector4 textColor(0, 0, 0, 1);
                     if (innerSpace->exists("textColor"))
                     if (innerSpace->exists("textColor"))
@@ -231,28 +280,30 @@ Theme* Theme::create(const char* url)
 
 
             // At least the OVERLAY_NORMAL is required.
             // At least the OVERLAY_NORMAL is required.
             if (!normal)
             if (!normal)
-                GP_ERROR("All themes require the normal state overlay to be defined.");
+            {
+                normal = Theme::Style::Overlay::create();
+            }
 
 
             space->rewind();
             space->rewind();
             innerSpace = space->getNextNamespace();
             innerSpace = space->getNextNamespace();
             while (innerSpace != NULL)
             while (innerSpace != NULL)
             {
             {
                 const char* innerSpacename = innerSpace->getNamespace();
                 const char* innerSpacename = innerSpace->getNamespace();
-                if (strcmp(innerSpacename, "margin") == 0)
+                if (strcmpnocase(innerSpacename, "margin") == 0)
                 {
                 {
                     margin.top = innerSpace->getFloat("top");
                     margin.top = innerSpace->getFloat("top");
                     margin.bottom = innerSpace->getFloat("bottom");
                     margin.bottom = innerSpace->getFloat("bottom");
                     margin.left = innerSpace->getFloat("left");
                     margin.left = innerSpace->getFloat("left");
                     margin.right = innerSpace->getFloat("right");
                     margin.right = innerSpace->getFloat("right");
                 }
                 }
-                else if (strcmp(innerSpacename, "padding") == 0)
+                else if (strcmpnocase(innerSpacename, "padding") == 0)
                 {
                 {
                     padding.top = innerSpace->getFloat("top");
                     padding.top = innerSpace->getFloat("top");
                     padding.bottom = innerSpace->getFloat("bottom");
                     padding.bottom = innerSpace->getFloat("bottom");
                     padding.left = innerSpace->getFloat("left");
                     padding.left = innerSpace->getFloat("left");
                     padding.right = innerSpace->getFloat("right");
                     padding.right = innerSpace->getFloat("right");
                 }
                 }
-                else if (strcmp(innerSpacename, "stateNormal") != 0)
+                else if (strcmpnocase(innerSpacename, "stateNormal") != 0)
                 {
                 {
                     // Either OVERLAY_FOCUS or OVERLAY_ACTIVE.
                     // Either OVERLAY_FOCUS or OVERLAY_ACTIVE.
                     // If a property isn't specified, it inherits from OVERLAY_NORMAL.
                     // If a property isn't specified, it inherits from OVERLAY_NORMAL.
@@ -336,7 +387,7 @@ Theme* Theme::create(const char* url)
                         skin = normal->getSkin();
                         skin = normal->getSkin();
                     }
                     }
 
 
-                    if (strcmp(innerSpacename, "stateFocus") == 0)
+                    if (strcmpnocase(innerSpacename, "stateFocus") == 0)
                     {
                     {
                         focus = Theme::Style::Overlay::create();
                         focus = Theme::Style::Overlay::create();
                         GP_ASSERT(focus);
                         GP_ASSERT(focus);
@@ -356,7 +407,7 @@ Theme* Theme::create(const char* url)
                             font->release();
                             font->release();
                         }
                         }
                     }
                     }
-                    else if (strcmp(innerSpacename, "stateActive") == 0)
+                    else if (strcmpnocase(innerSpacename, "stateActive") == 0)
                     {
                     {
                         active = Theme::Style::Overlay::create();
                         active = Theme::Style::Overlay::create();
                         GP_ASSERT(active);
                         GP_ASSERT(active);
@@ -376,7 +427,7 @@ Theme* Theme::create(const char* url)
                             font->release();
                             font->release();
                         }
                         }
                     }
                     }
-                    else if (strcmp(innerSpacename, "stateDisabled") == 0)
+                    else if (strcmpnocase(innerSpacename, "stateDisabled") == 0)
                     {
                     {
                         disabled = Theme::Style::Overlay::create();
                         disabled = Theme::Style::Overlay::create();
                         GP_ASSERT(disabled);
                         GP_ASSERT(disabled);
@@ -396,7 +447,7 @@ Theme* Theme::create(const char* url)
                             font->release();
                             font->release();
                         }
                         }
                     }
                     }
-                    else if (strcmp(innerSpacename, "stateHover") == 0)
+                    else if (strcmpnocase(innerSpacename, "stateHover") == 0)
                     {
                     {
                         hover = Theme::Style::Overlay::create();
                         hover = Theme::Style::Overlay::create();
                         GP_ASSERT(hover);
                         GP_ASSERT(hover);
@@ -420,7 +471,7 @@ Theme* Theme::create(const char* url)
 
 
                 innerSpace = space->getNextNamespace();
                 innerSpace = space->getNextNamespace();
             }
             }
-                
+
             if (!focus)
             if (!focus)
             {
             {
                 focus = normal;
                 focus = normal;
@@ -459,7 +510,7 @@ Theme::Style* Theme::getStyle(const char* name) const
     for (size_t i = 0, count = _styles.size(); i < count; ++i)
     for (size_t i = 0, count = _styles.size(); i < count; ++i)
     {
     {
         GP_ASSERT(_styles[i]);
         GP_ASSERT(_styles[i]);
-        if (strcmp(name, _styles[i]->getId()) == 0)
+        if (strcmpnocase(name, _styles[i]->getId()) == 0)
         {
         {
             return _styles[i];
             return _styles[i];
         }
         }
@@ -660,13 +711,12 @@ Theme::ThemeImage* Theme::ImageList::getImage(const char* imageId) const
 {
 {
     GP_ASSERT(imageId);
     GP_ASSERT(imageId);
 
 
-    std::vector<ThemeImage*>::const_iterator it;
-    for (it = _images.begin(); it != _images.end(); ++it)
+    for (size_t i = 0, count = _images.size(); i < count; ++i)
     {
     {
-        ThemeImage* image = *it;
+        ThemeImage* image = _images[i];
         GP_ASSERT(image);
         GP_ASSERT(image);
         GP_ASSERT(image->getId());
         GP_ASSERT(image->getId());
-        if (strcmp(image->getId(), imageId) == 0)
+        if (strcmpnocase(image->getId(), imageId) == 0)
         {
         {
             return image;
             return image;
         }
         }
@@ -808,7 +858,7 @@ void Theme::lookUpSprites(const Properties* overlaySpace, ImageList** imageList,
         {
         {
             GP_ASSERT(_imageLists[i]);
             GP_ASSERT(_imageLists[i]);
             GP_ASSERT(_imageLists[i]->getId());
             GP_ASSERT(_imageLists[i]->getId());
-            if (strcmp(_imageLists[i]->getId(), imageListString) == 0)
+            if (strcmpnocase(_imageLists[i]->getId(), imageListString) == 0)
             {
             {
                 GP_ASSERT(imageList);
                 GP_ASSERT(imageList);
                 *imageList = _imageLists[i];
                 *imageList = _imageLists[i];
@@ -824,7 +874,7 @@ void Theme::lookUpSprites(const Properties* overlaySpace, ImageList** imageList,
         {
         {
             GP_ASSERT(_images[i]);
             GP_ASSERT(_images[i]);
             GP_ASSERT(_images[i]->getId());
             GP_ASSERT(_images[i]->getId());
-            if (strcmp(_images[i]->getId(), cursorString) == 0)
+            if (strcmpnocase(_images[i]->getId(), cursorString) == 0)
             {
             {
                 GP_ASSERT(cursor);
                 GP_ASSERT(cursor);
                 *cursor = _images[i];
                 *cursor = _images[i];
@@ -840,7 +890,7 @@ void Theme::lookUpSprites(const Properties* overlaySpace, ImageList** imageList,
         {
         {
             GP_ASSERT(_skins[i]);
             GP_ASSERT(_skins[i]);
             GP_ASSERT(_skins[i]->getId());
             GP_ASSERT(_skins[i]->getId());
-            if (strcmp(_skins[i]->getId(), skinString) == 0)
+            if (strcmpnocase(_skins[i]->getId(), skinString) == 0)
             {
             {
                 GP_ASSERT(skin);
                 GP_ASSERT(skin);
                 *skin = _skins[i];
                 *skin = _skins[i];

+ 24 - 5
gameplay/src/Theme.h

@@ -137,6 +137,7 @@ class Theme: public Ref
     friend class Control;
     friend class Control;
     friend class Form;
     friend class Form;
     friend class Skin;
     friend class Skin;
+    friend class Game;
 
 
 public:
 public:
 
 
@@ -236,17 +237,17 @@ public:
          */
          */
         float right;
         float right;
     };
     };
-    
+
     /** 
     /** 
      * Struct representing margin areas by the width or height of each side.
      * Struct representing margin areas by the width or height of each side.
      */
      */
     typedef SideRegions Margin;
     typedef SideRegions Margin;
-    
+
     /** 
     /** 
      * Struct representing border areas by the width or height of each side.
      * Struct representing border areas by the width or height of each side.
      */
      */
     typedef SideRegions Border;
     typedef SideRegions Border;
-    
+
     /** 
     /** 
      * Struct representing padding areas by the width or height of each side.
      * Struct representing padding areas by the width or height of each side.
      */
      */
@@ -308,6 +309,13 @@ public:
      */
      */
     static Theme* create(const char* url);
     static Theme* create(const char* url);
 
 
+    /**
+     * Returns the default theme.
+     *
+     * @return The default theme.
+     */
+    static Theme* getDefault();
+
     /**
     /**
      * Get a style by its ID.
      * Get a style by its ID.
      *
      *
@@ -328,6 +336,13 @@ public:
      */
      */
     Theme::Style* getEmptyStyle();
     Theme::Style* getEmptyStyle();
 
 
+    /**
+     * Returns the sprite batch for this theme.
+     *
+     * @return The theme's sprite batch.
+     */
+    SpriteBatch* getSpriteBatch() const;
+
 private:
 private:
 
 
     /**
     /**
@@ -450,6 +465,11 @@ private:
      */
      */
     ~Theme();
     ~Theme();
 
 
+    /**
+     * Cleans up any theme related resources when the game shuts down.
+     */
+    static void finalize();
+
     /**
     /**
      * Hidden copy assignment operator.
      * Hidden copy assignment operator.
      */
      */
@@ -457,8 +477,6 @@ private:
 
 
     void setProjectionMatrix(const Matrix& matrix);
     void setProjectionMatrix(const Matrix& matrix);
 
 
-    SpriteBatch* getSpriteBatch() const;
-
     static void generateUVs(float tw, float th, float x, float y, float width, float height, UVs* uvs);
     static void generateUVs(float tw, float th, float x, float y, float width, float height, UVs* uvs);
 
 
     void lookUpSprites(const Properties* overlaySpace, ImageList** imageList, ThemeImage** mouseCursor, Skin** skin);
     void lookUpSprites(const Properties* overlaySpace, ImageList** imageList, ThemeImage** mouseCursor, Skin** skin);
@@ -466,6 +484,7 @@ private:
     std::string _url;
     std::string _url;
     Texture* _texture;
     Texture* _texture;
     SpriteBatch* _spriteBatch;
     SpriteBatch* _spriteBatch;
+    Theme::ThemeImage* _emptyImage;
     std::vector<Style*> _styles;
     std::vector<Style*> _styles;
     std::vector<ThemeImage*> _images;
     std::vector<ThemeImage*> _images;
     std::vector<ImageList*> _imageLists;
     std::vector<ImageList*> _imageLists;

+ 1 - 0
gameplay/src/ThemeStyle.cpp

@@ -22,6 +22,7 @@ Theme::Style::Style(Theme* theme, const char* id, float tw, float th,
 
 
 Theme::Style::Style(const Style& copy)
 Theme::Style::Style(const Style& copy)
 {
 {
+    _theme = copy._theme;
     _id = copy._id;
     _id = copy._id;
     _margin = copy._margin;
     _margin = copy._margin;
     _padding = copy._padding;
     _padding = copy._padding;

+ 112 - 1
gameplay/src/lua/lua_Button.cpp

@@ -14,6 +14,7 @@
 #include "Ref.h"
 #include "Ref.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"
@@ -72,6 +73,7 @@ void luaRegister_Button()
         {"getTextAlignment", lua_Button_getTextAlignment},
         {"getTextAlignment", lua_Button_getTextAlignment},
         {"getTextColor", lua_Button_getTextColor},
         {"getTextColor", lua_Button_getTextColor},
         {"getTextRightToLeft", lua_Button_getTextRightToLeft},
         {"getTextRightToLeft", lua_Button_getTextRightToLeft},
+        {"getTheme", lua_Button_getTheme},
         {"getTopLevelForm", lua_Button_getTopLevelForm},
         {"getTopLevelForm", lua_Button_getTopLevelForm},
         {"getWidth", lua_Button_getWidth},
         {"getWidth", lua_Button_getWidth},
         {"getX", lua_Button_getX},
         {"getX", lua_Button_getX},
@@ -107,6 +109,7 @@ void luaRegister_Button()
         {"setFont", lua_Button_setFont},
         {"setFont", lua_Button_setFont},
         {"setFontSize", lua_Button_setFontSize},
         {"setFontSize", lua_Button_setFontSize},
         {"setHeight", lua_Button_setHeight},
         {"setHeight", lua_Button_setHeight},
+        {"setId", lua_Button_setId},
         {"setImageColor", lua_Button_setImageColor},
         {"setImageColor", lua_Button_setImageColor},
         {"setImageRegion", lua_Button_setImageRegion},
         {"setImageRegion", lua_Button_setImageRegion},
         {"setMargin", lua_Button_setMargin},
         {"setMargin", lua_Button_setMargin},
@@ -2487,6 +2490,50 @@ int lua_Button_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Button_getTheme(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))
+            {
+                Button* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Button_getTheme - 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_Button_getTopLevelForm(lua_State* state)
 int lua_Button_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -3983,6 +4030,42 @@ int lua_Button_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Button_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                Button* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Button_setId - 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_Button_setImageColor(lua_State* state)
 int lua_Button_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -5150,6 +5233,34 @@ int lua_Button_static_create(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                void* returnPtr = (void*)Button::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "Button");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Button_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         case 2:
         case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
@@ -5190,7 +5301,7 @@ int lua_Button_static_create(lua_State* state)
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 0
gameplay/src/lua/lua_Button.h

@@ -50,6 +50,7 @@ int lua_Button_getText(lua_State* state);
 int lua_Button_getTextAlignment(lua_State* state);
 int lua_Button_getTextAlignment(lua_State* state);
 int lua_Button_getTextColor(lua_State* state);
 int lua_Button_getTextColor(lua_State* state);
 int lua_Button_getTextRightToLeft(lua_State* state);
 int lua_Button_getTextRightToLeft(lua_State* state);
+int lua_Button_getTheme(lua_State* state);
 int lua_Button_getTopLevelForm(lua_State* state);
 int lua_Button_getTopLevelForm(lua_State* state);
 int lua_Button_getWidth(lua_State* state);
 int lua_Button_getWidth(lua_State* state);
 int lua_Button_getX(lua_State* state);
 int lua_Button_getX(lua_State* state);
@@ -85,6 +86,7 @@ int lua_Button_setFocusIndex(lua_State* state);
 int lua_Button_setFont(lua_State* state);
 int lua_Button_setFont(lua_State* state);
 int lua_Button_setFontSize(lua_State* state);
 int lua_Button_setFontSize(lua_State* state);
 int lua_Button_setHeight(lua_State* state);
 int lua_Button_setHeight(lua_State* state);
+int lua_Button_setId(lua_State* state);
 int lua_Button_setImageColor(lua_State* state);
 int lua_Button_setImageColor(lua_State* state);
 int lua_Button_setImageRegion(lua_State* state);
 int lua_Button_setImageRegion(lua_State* state);
 int lua_Button_setMargin(lua_State* state);
 int lua_Button_setMargin(lua_State* state);

+ 112 - 1
gameplay/src/lua/lua_CheckBox.cpp

@@ -15,6 +15,7 @@
 #include "Ref.h"
 #include "Ref.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"
@@ -74,6 +75,7 @@ void luaRegister_CheckBox()
         {"getTextAlignment", lua_CheckBox_getTextAlignment},
         {"getTextAlignment", lua_CheckBox_getTextAlignment},
         {"getTextColor", lua_CheckBox_getTextColor},
         {"getTextColor", lua_CheckBox_getTextColor},
         {"getTextRightToLeft", lua_CheckBox_getTextRightToLeft},
         {"getTextRightToLeft", lua_CheckBox_getTextRightToLeft},
+        {"getTheme", lua_CheckBox_getTheme},
         {"getTopLevelForm", lua_CheckBox_getTopLevelForm},
         {"getTopLevelForm", lua_CheckBox_getTopLevelForm},
         {"getType", lua_CheckBox_getType},
         {"getType", lua_CheckBox_getType},
         {"getWidth", lua_CheckBox_getWidth},
         {"getWidth", lua_CheckBox_getWidth},
@@ -112,6 +114,7 @@ void luaRegister_CheckBox()
         {"setFont", lua_CheckBox_setFont},
         {"setFont", lua_CheckBox_setFont},
         {"setFontSize", lua_CheckBox_setFontSize},
         {"setFontSize", lua_CheckBox_setFontSize},
         {"setHeight", lua_CheckBox_setHeight},
         {"setHeight", lua_CheckBox_setHeight},
+        {"setId", lua_CheckBox_setId},
         {"setImageColor", lua_CheckBox_setImageColor},
         {"setImageColor", lua_CheckBox_setImageColor},
         {"setImageRegion", lua_CheckBox_setImageRegion},
         {"setImageRegion", lua_CheckBox_setImageRegion},
         {"setImageSize", lua_CheckBox_setImageSize},
         {"setImageSize", lua_CheckBox_setImageSize},
@@ -2537,6 +2540,50 @@ int lua_CheckBox_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_CheckBox_getTheme(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))
+            {
+                CheckBox* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_CheckBox_getTheme - 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_CheckBox_getTopLevelForm(lua_State* state)
 int lua_CheckBox_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4139,6 +4186,42 @@ int lua_CheckBox_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_CheckBox_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                CheckBox* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_CheckBox_setId - 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_CheckBox_setImageColor(lua_State* state)
 int lua_CheckBox_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -5346,6 +5429,34 @@ int lua_CheckBox_static_create(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                void* returnPtr = (void*)CheckBox::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "CheckBox");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_CheckBox_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         case 2:
         case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
@@ -5386,7 +5497,7 @@ int lua_CheckBox_static_create(lua_State* state)
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 0
gameplay/src/lua/lua_CheckBox.h

@@ -51,6 +51,7 @@ int lua_CheckBox_getText(lua_State* state);
 int lua_CheckBox_getTextAlignment(lua_State* state);
 int lua_CheckBox_getTextAlignment(lua_State* state);
 int lua_CheckBox_getTextColor(lua_State* state);
 int lua_CheckBox_getTextColor(lua_State* state);
 int lua_CheckBox_getTextRightToLeft(lua_State* state);
 int lua_CheckBox_getTextRightToLeft(lua_State* state);
+int lua_CheckBox_getTheme(lua_State* state);
 int lua_CheckBox_getTopLevelForm(lua_State* state);
 int lua_CheckBox_getTopLevelForm(lua_State* state);
 int lua_CheckBox_getType(lua_State* state);
 int lua_CheckBox_getType(lua_State* state);
 int lua_CheckBox_getWidth(lua_State* state);
 int lua_CheckBox_getWidth(lua_State* state);
@@ -89,6 +90,7 @@ int lua_CheckBox_setFocusIndex(lua_State* state);
 int lua_CheckBox_setFont(lua_State* state);
 int lua_CheckBox_setFont(lua_State* state);
 int lua_CheckBox_setFontSize(lua_State* state);
 int lua_CheckBox_setFontSize(lua_State* state);
 int lua_CheckBox_setHeight(lua_State* state);
 int lua_CheckBox_setHeight(lua_State* state);
+int lua_CheckBox_setId(lua_State* state);
 int lua_CheckBox_setImageColor(lua_State* state);
 int lua_CheckBox_setImageColor(lua_State* state);
 int lua_CheckBox_setImageRegion(lua_State* state);
 int lua_CheckBox_setImageRegion(lua_State* state);
 int lua_CheckBox_setImageSize(lua_State* state);
 int lua_CheckBox_setImageSize(lua_State* state);

+ 190 - 1
gameplay/src/lua/lua_Container.cpp

@@ -5,17 +5,26 @@
 #include "Animation.h"
 #include "Animation.h"
 #include "AnimationTarget.h"
 #include "AnimationTarget.h"
 #include "Base.h"
 #include "Base.h"
+#include "Button.h"
+#include "CheckBox.h"
 #include "Container.h"
 #include "Container.h"
 #include "Control.h"
 #include "Control.h"
 #include "ControlFactory.h"
 #include "ControlFactory.h"
 #include "FlowLayout.h"
 #include "FlowLayout.h"
 #include "Form.h"
 #include "Form.h"
 #include "Game.h"
 #include "Game.h"
+#include "ImageControl.h"
+#include "Joystick.h"
+#include "Label.h"
 #include "Layout.h"
 #include "Layout.h"
 #include "Node.h"
 #include "Node.h"
+#include "RadioButton.h"
 #include "Ref.h"
 #include "Ref.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Slider.h"
+#include "TextBox.h"
+#include "Theme.h"
 #include "VerticalLayout.h"
 #include "VerticalLayout.h"
 #include "lua_ContainerScroll.h"
 #include "lua_ContainerScroll.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
@@ -86,6 +95,7 @@ void luaRegister_Container()
         {"getTextAlignment", lua_Container_getTextAlignment},
         {"getTextAlignment", lua_Container_getTextAlignment},
         {"getTextColor", lua_Container_getTextColor},
         {"getTextColor", lua_Container_getTextColor},
         {"getTextRightToLeft", lua_Container_getTextRightToLeft},
         {"getTextRightToLeft", lua_Container_getTextRightToLeft},
+        {"getTheme", lua_Container_getTheme},
         {"getTopLevelForm", lua_Container_getTopLevelForm},
         {"getTopLevelForm", lua_Container_getTopLevelForm},
         {"getType", lua_Container_getType},
         {"getType", lua_Container_getType},
         {"getWidth", lua_Container_getWidth},
         {"getWidth", lua_Container_getWidth},
@@ -128,8 +138,10 @@ void luaRegister_Container()
         {"setFont", lua_Container_setFont},
         {"setFont", lua_Container_setFont},
         {"setFontSize", lua_Container_setFontSize},
         {"setFontSize", lua_Container_setFontSize},
         {"setHeight", lua_Container_setHeight},
         {"setHeight", lua_Container_setHeight},
+        {"setId", lua_Container_setId},
         {"setImageColor", lua_Container_setImageColor},
         {"setImageColor", lua_Container_setImageColor},
         {"setImageRegion", lua_Container_setImageRegion},
         {"setImageRegion", lua_Container_setImageRegion},
+        {"setLayout", lua_Container_setLayout},
         {"setMargin", lua_Container_setMargin},
         {"setMargin", lua_Container_setMargin},
         {"setOpacity", lua_Container_setOpacity},
         {"setOpacity", lua_Container_setOpacity},
         {"setPadding", lua_Container_setPadding},
         {"setPadding", lua_Container_setPadding},
@@ -152,6 +164,7 @@ void luaRegister_Container()
         {"setX", lua_Container_setX},
         {"setX", lua_Container_setX},
         {"setY", lua_Container_setY},
         {"setY", lua_Container_setY},
         {"setZIndex", lua_Container_setZIndex},
         {"setZIndex", lua_Container_setZIndex},
+        {"stopScrolling", lua_Container_stopScrolling},
         {NULL, NULL}
         {NULL, NULL}
     };
     };
     const luaL_Reg lua_statics[] = 
     const luaL_Reg lua_statics[] = 
@@ -2909,6 +2922,50 @@ int lua_Container_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Container_getTheme(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))
+            {
+                Container* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Container_getTheme - 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_Container_getTopLevelForm(lua_State* state)
 int lua_Container_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4705,6 +4762,42 @@ int lua_Container_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Container_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                Container* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Container_setId - 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_Container_setImageColor(lua_State* state)
 int lua_Container_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4861,6 +4954,42 @@ int lua_Container_setImageRegion(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Container_setLayout(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.
+                Layout::Type param1 = (Layout::Type)lua_enumFromString_LayoutType(luaL_checkstring(state, 2));
+
+                Container* instance = getInstance(state);
+                instance->setLayout(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Container_setLayout - 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_Container_setMargin(lua_State* state)
 int lua_Container_setMargin(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -6075,6 +6204,34 @@ int lua_Container_static_create(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                void* returnPtr = (void*)Container::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "Container");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Container_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         case 2:
         case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
@@ -6157,7 +6314,39 @@ int lua_Container_static_create(lua_State* state)
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2 or 3).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1, 2 or 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Container_stopScrolling(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))
+            {
+                Container* instance = getInstance(state);
+                instance->stopScrolling();
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Container_stopScrolling - 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);
             lua_error(state);
             break;
             break;
         }
         }

+ 4 - 0
gameplay/src/lua/lua_Container.h

@@ -59,6 +59,7 @@ int lua_Container_getStyle(lua_State* state);
 int lua_Container_getTextAlignment(lua_State* state);
 int lua_Container_getTextAlignment(lua_State* state);
 int lua_Container_getTextColor(lua_State* state);
 int lua_Container_getTextColor(lua_State* state);
 int lua_Container_getTextRightToLeft(lua_State* state);
 int lua_Container_getTextRightToLeft(lua_State* state);
+int lua_Container_getTheme(lua_State* state);
 int lua_Container_getTopLevelForm(lua_State* state);
 int lua_Container_getTopLevelForm(lua_State* state);
 int lua_Container_getType(lua_State* state);
 int lua_Container_getType(lua_State* state);
 int lua_Container_getWidth(lua_State* state);
 int lua_Container_getWidth(lua_State* state);
@@ -101,8 +102,10 @@ int lua_Container_setFocusIndex(lua_State* state);
 int lua_Container_setFont(lua_State* state);
 int lua_Container_setFont(lua_State* state);
 int lua_Container_setFontSize(lua_State* state);
 int lua_Container_setFontSize(lua_State* state);
 int lua_Container_setHeight(lua_State* state);
 int lua_Container_setHeight(lua_State* state);
+int lua_Container_setId(lua_State* state);
 int lua_Container_setImageColor(lua_State* state);
 int lua_Container_setImageColor(lua_State* state);
 int lua_Container_setImageRegion(lua_State* state);
 int lua_Container_setImageRegion(lua_State* state);
+int lua_Container_setLayout(lua_State* state);
 int lua_Container_setMargin(lua_State* state);
 int lua_Container_setMargin(lua_State* state);
 int lua_Container_setOpacity(lua_State* state);
 int lua_Container_setOpacity(lua_State* state);
 int lua_Container_setPadding(lua_State* state);
 int lua_Container_setPadding(lua_State* state);
@@ -134,6 +137,7 @@ int lua_Container_static_ANIMATE_SIZE(lua_State* state);
 int lua_Container_static_ANIMATE_SIZE_HEIGHT(lua_State* state);
 int lua_Container_static_ANIMATE_SIZE_HEIGHT(lua_State* state);
 int lua_Container_static_ANIMATE_SIZE_WIDTH(lua_State* state);
 int lua_Container_static_ANIMATE_SIZE_WIDTH(lua_State* state);
 int lua_Container_static_create(lua_State* state);
 int lua_Container_static_create(lua_State* state);
+int lua_Container_stopScrolling(lua_State* state);
 
 
 void luaRegister_Container();
 void luaRegister_Container();
 
 

+ 83 - 0
gameplay/src/lua/lua_Control.cpp

@@ -11,6 +11,7 @@
 #include "Ref.h"
 #include "Ref.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"
@@ -68,6 +69,7 @@ void luaRegister_Control()
         {"getTextAlignment", lua_Control_getTextAlignment},
         {"getTextAlignment", lua_Control_getTextAlignment},
         {"getTextColor", lua_Control_getTextColor},
         {"getTextColor", lua_Control_getTextColor},
         {"getTextRightToLeft", lua_Control_getTextRightToLeft},
         {"getTextRightToLeft", lua_Control_getTextRightToLeft},
+        {"getTheme", lua_Control_getTheme},
         {"getTopLevelForm", lua_Control_getTopLevelForm},
         {"getTopLevelForm", lua_Control_getTopLevelForm},
         {"getType", lua_Control_getType},
         {"getType", lua_Control_getType},
         {"getWidth", lua_Control_getWidth},
         {"getWidth", lua_Control_getWidth},
@@ -104,6 +106,7 @@ void luaRegister_Control()
         {"setFont", lua_Control_setFont},
         {"setFont", lua_Control_setFont},
         {"setFontSize", lua_Control_setFontSize},
         {"setFontSize", lua_Control_setFontSize},
         {"setHeight", lua_Control_setHeight},
         {"setHeight", lua_Control_setHeight},
+        {"setId", lua_Control_setId},
         {"setImageColor", lua_Control_setImageColor},
         {"setImageColor", lua_Control_setImageColor},
         {"setImageRegion", lua_Control_setImageRegion},
         {"setImageRegion", lua_Control_setImageRegion},
         {"setMargin", lua_Control_setMargin},
         {"setMargin", lua_Control_setMargin},
@@ -2447,6 +2450,50 @@ int lua_Control_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Control_getTheme(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))
+            {
+                Control* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Control_getTheme - 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_Control_getTopLevelForm(lua_State* state)
 int lua_Control_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -3978,6 +4025,42 @@ int lua_Control_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Control_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                Control* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Control_setId - 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_Control_setImageColor(lua_State* state)
 int lua_Control_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 2 - 0
gameplay/src/lua/lua_Control.h

@@ -49,6 +49,7 @@ int lua_Control_getStyle(lua_State* state);
 int lua_Control_getTextAlignment(lua_State* state);
 int lua_Control_getTextAlignment(lua_State* state);
 int lua_Control_getTextColor(lua_State* state);
 int lua_Control_getTextColor(lua_State* state);
 int lua_Control_getTextRightToLeft(lua_State* state);
 int lua_Control_getTextRightToLeft(lua_State* state);
+int lua_Control_getTheme(lua_State* state);
 int lua_Control_getTopLevelForm(lua_State* state);
 int lua_Control_getTopLevelForm(lua_State* state);
 int lua_Control_getType(lua_State* state);
 int lua_Control_getType(lua_State* state);
 int lua_Control_getWidth(lua_State* state);
 int lua_Control_getWidth(lua_State* state);
@@ -85,6 +86,7 @@ int lua_Control_setFocusIndex(lua_State* state);
 int lua_Control_setFont(lua_State* state);
 int lua_Control_setFont(lua_State* state);
 int lua_Control_setFontSize(lua_State* state);
 int lua_Control_setFontSize(lua_State* state);
 int lua_Control_setHeight(lua_State* state);
 int lua_Control_setHeight(lua_State* state);
+int lua_Control_setId(lua_State* state);
 int lua_Control_setImageColor(lua_State* state);
 int lua_Control_setImageColor(lua_State* state);
 int lua_Control_setImageRegion(lua_State* state);
 int lua_Control_setImageRegion(lua_State* state);
 int lua_Control_setMargin(lua_State* state);
 int lua_Control_setMargin(lua_State* state);

+ 1 - 0
gameplay/src/lua/lua_ControlListener.cpp

@@ -11,6 +11,7 @@
 #include "Ref.h"
 #include "Ref.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"

+ 185 - 0
gameplay/src/lua/lua_Form.cpp

@@ -13,13 +13,18 @@
 #include "FlowLayout.h"
 #include "FlowLayout.h"
 #include "Form.h"
 #include "Form.h"
 #include "Game.h"
 #include "Game.h"
+#include "ImageControl.h"
+#include "Joystick.h"
 #include "Label.h"
 #include "Label.h"
 #include "Layout.h"
 #include "Layout.h"
 #include "Node.h"
 #include "Node.h"
+#include "RadioButton.h"
 #include "Ref.h"
 #include "Ref.h"
 #include "Scene.h"
 #include "Scene.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Slider.h"
+#include "TextBox.h"
 #include "Theme.h"
 #include "Theme.h"
 #include "VerticalLayout.h"
 #include "VerticalLayout.h"
 #include "lua_ContainerScroll.h"
 #include "lua_ContainerScroll.h"
@@ -101,6 +106,7 @@ void luaRegister_Form()
         {"getZIndex", lua_Form_getZIndex},
         {"getZIndex", lua_Form_getZIndex},
         {"hasFocus", lua_Form_hasFocus},
         {"hasFocus", lua_Form_hasFocus},
         {"insertControl", lua_Form_insertControl},
         {"insertControl", lua_Form_insertControl},
+        {"isBatchingEnabled", lua_Form_isBatchingEnabled},
         {"isChild", lua_Form_isChild},
         {"isChild", lua_Form_isChild},
         {"isContainer", lua_Form_isContainer},
         {"isContainer", lua_Form_isContainer},
         {"isEnabled", lua_Form_isEnabled},
         {"isEnabled", lua_Form_isEnabled},
@@ -123,6 +129,7 @@ void luaRegister_Form()
         {"setAnimationPropertyValue", lua_Form_setAnimationPropertyValue},
         {"setAnimationPropertyValue", lua_Form_setAnimationPropertyValue},
         {"setAutoHeight", lua_Form_setAutoHeight},
         {"setAutoHeight", lua_Form_setAutoHeight},
         {"setAutoWidth", lua_Form_setAutoWidth},
         {"setAutoWidth", lua_Form_setAutoWidth},
+        {"setBatchingEnabled", lua_Form_setBatchingEnabled},
         {"setBorder", lua_Form_setBorder},
         {"setBorder", lua_Form_setBorder},
         {"setBounds", lua_Form_setBounds},
         {"setBounds", lua_Form_setBounds},
         {"setCanFocus", lua_Form_setCanFocus},
         {"setCanFocus", lua_Form_setCanFocus},
@@ -135,8 +142,10 @@ void luaRegister_Form()
         {"setFont", lua_Form_setFont},
         {"setFont", lua_Form_setFont},
         {"setFontSize", lua_Form_setFontSize},
         {"setFontSize", lua_Form_setFontSize},
         {"setHeight", lua_Form_setHeight},
         {"setHeight", lua_Form_setHeight},
+        {"setId", lua_Form_setId},
         {"setImageColor", lua_Form_setImageColor},
         {"setImageColor", lua_Form_setImageColor},
         {"setImageRegion", lua_Form_setImageRegion},
         {"setImageRegion", lua_Form_setImageRegion},
+        {"setLayout", lua_Form_setLayout},
         {"setMargin", lua_Form_setMargin},
         {"setMargin", lua_Form_setMargin},
         {"setNode", lua_Form_setNode},
         {"setNode", lua_Form_setNode},
         {"setOpacity", lua_Form_setOpacity},
         {"setOpacity", lua_Form_setOpacity},
@@ -160,6 +169,7 @@ void luaRegister_Form()
         {"setX", lua_Form_setX},
         {"setX", lua_Form_setX},
         {"setY", lua_Form_setY},
         {"setY", lua_Form_setY},
         {"setZIndex", lua_Form_setZIndex},
         {"setZIndex", lua_Form_setZIndex},
+        {"stopScrolling", lua_Form_stopScrolling},
         {"update", lua_Form_update},
         {"update", lua_Form_update},
         {NULL, NULL}
         {NULL, NULL}
     };
     };
@@ -3301,6 +3311,41 @@ int lua_Form_insertControl(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Form_isBatchingEnabled(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))
+            {
+                Form* instance = getInstance(state);
+                bool result = instance->isBatchingEnabled();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Form_isBatchingEnabled - 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_Form_isChild(lua_State* state)
 int lua_Form_isChild(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4216,6 +4261,42 @@ int lua_Form_setAutoWidth(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Form_setBatchingEnabled(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
+
+                Form* instance = getInstance(state);
+                instance->setBatchingEnabled(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Form_setBatchingEnabled - 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_Form_setBorder(lua_State* state)
 int lua_Form_setBorder(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4797,6 +4878,42 @@ int lua_Form_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Form_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                Form* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Form_setId - 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_Form_setImageColor(lua_State* state)
 int lua_Form_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4953,6 +5070,42 @@ int lua_Form_setImageRegion(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Form_setLayout(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.
+                Layout::Type param1 = (Layout::Type)lua_enumFromString_LayoutType(luaL_checkstring(state, 2));
+
+                Form* instance = getInstance(state);
+                instance->setLayout(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Form_setLayout - 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_Form_setMargin(lua_State* state)
 int lua_Form_setMargin(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -6475,6 +6628,38 @@ int lua_Form_static_getForm(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Form_stopScrolling(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))
+            {
+                Form* instance = getInstance(state);
+                instance->stopScrolling();
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Form_stopScrolling - 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_Form_update(lua_State* state)
 int lua_Form_update(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 5 - 0
gameplay/src/lua/lua_Form.h

@@ -69,6 +69,7 @@ int lua_Form_getY(lua_State* state);
 int lua_Form_getZIndex(lua_State* state);
 int lua_Form_getZIndex(lua_State* state);
 int lua_Form_hasFocus(lua_State* state);
 int lua_Form_hasFocus(lua_State* state);
 int lua_Form_insertControl(lua_State* state);
 int lua_Form_insertControl(lua_State* state);
+int lua_Form_isBatchingEnabled(lua_State* state);
 int lua_Form_isChild(lua_State* state);
 int lua_Form_isChild(lua_State* state);
 int lua_Form_isContainer(lua_State* state);
 int lua_Form_isContainer(lua_State* state);
 int lua_Form_isEnabled(lua_State* state);
 int lua_Form_isEnabled(lua_State* state);
@@ -91,6 +92,7 @@ int lua_Form_setAlignment(lua_State* state);
 int lua_Form_setAnimationPropertyValue(lua_State* state);
 int lua_Form_setAnimationPropertyValue(lua_State* state);
 int lua_Form_setAutoHeight(lua_State* state);
 int lua_Form_setAutoHeight(lua_State* state);
 int lua_Form_setAutoWidth(lua_State* state);
 int lua_Form_setAutoWidth(lua_State* state);
+int lua_Form_setBatchingEnabled(lua_State* state);
 int lua_Form_setBorder(lua_State* state);
 int lua_Form_setBorder(lua_State* state);
 int lua_Form_setBounds(lua_State* state);
 int lua_Form_setBounds(lua_State* state);
 int lua_Form_setCanFocus(lua_State* state);
 int lua_Form_setCanFocus(lua_State* state);
@@ -103,8 +105,10 @@ int lua_Form_setFocusIndex(lua_State* state);
 int lua_Form_setFont(lua_State* state);
 int lua_Form_setFont(lua_State* state);
 int lua_Form_setFontSize(lua_State* state);
 int lua_Form_setFontSize(lua_State* state);
 int lua_Form_setHeight(lua_State* state);
 int lua_Form_setHeight(lua_State* state);
+int lua_Form_setId(lua_State* state);
 int lua_Form_setImageColor(lua_State* state);
 int lua_Form_setImageColor(lua_State* state);
 int lua_Form_setImageRegion(lua_State* state);
 int lua_Form_setImageRegion(lua_State* state);
+int lua_Form_setLayout(lua_State* state);
 int lua_Form_setMargin(lua_State* state);
 int lua_Form_setMargin(lua_State* state);
 int lua_Form_setNode(lua_State* state);
 int lua_Form_setNode(lua_State* state);
 int lua_Form_setOpacity(lua_State* state);
 int lua_Form_setOpacity(lua_State* state);
@@ -141,6 +145,7 @@ int lua_Form_static_create(lua_State* state);
 int lua_Form_static_getActiveControl(lua_State* state);
 int lua_Form_static_getActiveControl(lua_State* state);
 int lua_Form_static_getFocusControl(lua_State* state);
 int lua_Form_static_getFocusControl(lua_State* state);
 int lua_Form_static_getForm(lua_State* state);
 int lua_Form_static_getForm(lua_State* state);
+int lua_Form_stopScrolling(lua_State* state);
 int lua_Form_update(lua_State* state);
 int lua_Form_update(lua_State* state);
 
 
 void luaRegister_Form();
 void luaRegister_Form();

+ 2508 - 2507
gameplay/src/lua/lua_Game.cpp

@@ -1,2507 +1,2508 @@
-#include "Base.h"
-#include "ScriptController.h"
-#include "lua_Game.h"
-#include "Base.h"
-#include "ControlFactory.h"
-#include "FileSystem.h"
-#include "FrameBuffer.h"
-#include "Game.h"
-#include "Platform.h"
-#include "RenderState.h"
-#include "SceneLoader.h"
-#include "lua_GameClearFlags.h"
-#include "lua_GameState.h"
-#include "lua_GamepadGamepadEvent.h"
-#include "lua_GestureGestureEvent.h"
-#include "lua_KeyboardKeyEvent.h"
-#include "lua_MouseMouseEvent.h"
-#include "lua_TouchTouchEvent.h"
-
-namespace gameplay
-{
-
-void luaRegister_Game()
-{
-    const luaL_Reg lua_members[] = 
-    {
-        {"canExit", lua_Game_canExit},
-        {"clear", lua_Game_clear},
-        {"displayKeyboard", lua_Game_displayKeyboard},
-        {"exit", lua_Game_exit},
-        {"frame", lua_Game_frame},
-        {"gamepadEvent", lua_Game_gamepadEvent},
-        {"gestureDragEvent", lua_Game_gestureDragEvent},
-        {"gestureDropEvent", lua_Game_gestureDropEvent},
-        {"gestureLongTapEvent", lua_Game_gestureLongTapEvent},
-        {"gesturePinchEvent", lua_Game_gesturePinchEvent},
-        {"gestureSwipeEvent", lua_Game_gestureSwipeEvent},
-        {"gestureTapEvent", lua_Game_gestureTapEvent},
-        {"getAIController", lua_Game_getAIController},
-        {"getAccelerometerValues", lua_Game_getAccelerometerValues},
-        {"getAnimationController", lua_Game_getAnimationController},
-        {"getAspectRatio", lua_Game_getAspectRatio},
-        {"getAudioController", lua_Game_getAudioController},
-        {"getAudioListener", lua_Game_getAudioListener},
-        {"getConfig", lua_Game_getConfig},
-        {"getFrameRate", lua_Game_getFrameRate},
-        {"getGamepad", lua_Game_getGamepad},
-        {"getGamepadCount", lua_Game_getGamepadCount},
-        {"getHeight", lua_Game_getHeight},
-        {"getPhysicsController", lua_Game_getPhysicsController},
-        {"getScriptController", lua_Game_getScriptController},
-        {"getSensorValues", lua_Game_getSensorValues},
-        {"getState", lua_Game_getState},
-        {"getViewport", lua_Game_getViewport},
-        {"getWidth", lua_Game_getWidth},
-        {"hasAccelerometer", lua_Game_hasAccelerometer},
-        {"hasMouse", lua_Game_hasMouse},
-        {"isCursorVisible", lua_Game_isCursorVisible},
-        {"isGestureRegistered", lua_Game_isGestureRegistered},
-        {"isGestureSupported", lua_Game_isGestureSupported},
-        {"isInitialized", lua_Game_isInitialized},
-        {"isMouseCaptured", lua_Game_isMouseCaptured},
-        {"isMultiSampling", lua_Game_isMultiSampling},
-        {"isMultiTouch", lua_Game_isMultiTouch},
-        {"keyEvent", lua_Game_keyEvent},
-        {"launchURL", lua_Game_launchURL},
-        {"mouseEvent", lua_Game_mouseEvent},
-        {"pause", lua_Game_pause},
-        {"registerGesture", lua_Game_registerGesture},
-        {"resizeEvent", lua_Game_resizeEvent},
-        {"resume", lua_Game_resume},
-        {"run", lua_Game_run},
-        {"schedule", lua_Game_schedule},
-        {"setCursorVisible", lua_Game_setCursorVisible},
-        {"setMouseCaptured", lua_Game_setMouseCaptured},
-        {"setMultiSampling", lua_Game_setMultiSampling},
-        {"setMultiTouch", lua_Game_setMultiTouch},
-        {"setViewport", lua_Game_setViewport},
-        {"touchEvent", lua_Game_touchEvent},
-        {"unregisterGesture", lua_Game_unregisterGesture},
-        {NULL, NULL}
-    };
-    const luaL_Reg lua_statics[] = 
-    {
-        {"getAbsoluteTime", lua_Game_static_getAbsoluteTime},
-        {"getGameTime", lua_Game_static_getGameTime},
-        {"getInstance", lua_Game_static_getInstance},
-        {"isVsync", lua_Game_static_isVsync},
-        {"setVsync", lua_Game_static_setVsync},
-        {NULL, NULL}
-    };
-    std::vector<std::string> scopePath;
-
-    gameplay::ScriptUtil::registerClass("Game", lua_members, NULL, lua_Game__gc, lua_statics, scopePath);
-}
-
-static Game* getInstance(lua_State* state)
-{
-    void* userdata = luaL_checkudata(state, 1, "Game");
-    luaL_argcheck(state, userdata != NULL, 1, "'Game' expected.");
-    return (Game*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
-}
-
-int lua_Game__gc(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))
-            {
-                void* userdata = luaL_checkudata(state, 1, "Game");
-                luaL_argcheck(state, userdata != NULL, 1, "'Game' expected.");
-                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
-                if (object->owns)
-                {
-                    Game* instance = (Game*)object->instance;
-                    SAFE_DELETE(instance);
-                }
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game__gc - 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_Game_canExit(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))
-            {
-                Game* instance = getInstance(state);
-                bool result = instance->canExit();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_canExit - 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_Game_clear(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 5:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                    (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
-                    lua_type(state, 4) == LUA_TNUMBER &&
-                    lua_type(state, 5) == LUA_TNUMBER)
-                {
-                    // Get parameter 1 off the stack.
-                    Game::ClearFlags param1 = (Game::ClearFlags)lua_enumFromString_GameClearFlags(luaL_checkstring(state, 2));
-
-                    // Get parameter 2 off the stack.
-                    bool param2Valid;
-                    gameplay::ScriptUtil::LuaArray<Vector4> param2 = gameplay::ScriptUtil::getObjectPointer<Vector4>(3, "Vector4", true, &param2Valid);
-                    if (!param2Valid)
-                        break;
-
-                    // Get parameter 3 off the stack.
-                    float param3 = (float)luaL_checknumber(state, 4);
-
-                    // Get parameter 4 off the stack.
-                    int param4 = (int)luaL_checkint(state, 5);
-
-                    Game* instance = getInstance(state);
-                    instance->clear(param1, *param2, param3, param4);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_Game_clear - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 8:
-        {
-            do
-            {
-                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                    lua_type(state, 3) == LUA_TNUMBER &&
-                    lua_type(state, 4) == LUA_TNUMBER &&
-                    lua_type(state, 5) == LUA_TNUMBER &&
-                    lua_type(state, 6) == LUA_TNUMBER &&
-                    lua_type(state, 7) == LUA_TNUMBER &&
-                    lua_type(state, 8) == LUA_TNUMBER)
-                {
-                    // Get parameter 1 off the stack.
-                    Game::ClearFlags param1 = (Game::ClearFlags)lua_enumFromString_GameClearFlags(luaL_checkstring(state, 2));
-
-                    // Get parameter 2 off the stack.
-                    float param2 = (float)luaL_checknumber(state, 3);
-
-                    // Get parameter 3 off the stack.
-                    float param3 = (float)luaL_checknumber(state, 4);
-
-                    // Get parameter 4 off the stack.
-                    float param4 = (float)luaL_checknumber(state, 5);
-
-                    // Get parameter 5 off the stack.
-                    float param5 = (float)luaL_checknumber(state, 6);
-
-                    // Get parameter 6 off the stack.
-                    float param6 = (float)luaL_checknumber(state, 7);
-
-                    // Get parameter 7 off the stack.
-                    int param7 = (int)luaL_checkint(state, 8);
-
-                    Game* instance = getInstance(state);
-                    instance->clear(param1, param2, param3, param4, param5, param6, param7);
-                    
-                    return 0;
-                }
-            } while (0);
-
-            lua_pushstring(state, "lua_Game_clear - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 5 or 8).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_displayKeyboard(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
-
-                Game* instance = getInstance(state);
-                instance->displayKeyboard(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_displayKeyboard - 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_exit(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))
-            {
-                Game* instance = getInstance(state);
-                instance->exit();
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_exit - 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_Game_frame(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))
-            {
-                Game* instance = getInstance(state);
-                instance->frame();
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_frame - 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_Game_gamepadEvent(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 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                Gamepad::GamepadEvent param1 = (Gamepad::GamepadEvent)lua_enumFromString_GamepadGamepadEvent(luaL_checkstring(state, 2));
-
-                // Get parameter 2 off the stack.
-                bool param2Valid;
-                gameplay::ScriptUtil::LuaArray<Gamepad> param2 = gameplay::ScriptUtil::getObjectPointer<Gamepad>(3, "Gamepad", false, &param2Valid);
-                if (!param2Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Gamepad'.");
-                    lua_error(state);
-                }
-
-                Game* instance = getInstance(state);
-                instance->gamepadEvent(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_gamepadEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_gestureDragEvent(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 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                lua_type(state, 3) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                int param1 = (int)luaL_checkint(state, 2);
-
-                // Get parameter 2 off the stack.
-                int param2 = (int)luaL_checkint(state, 3);
-
-                Game* instance = getInstance(state);
-                instance->gestureDragEvent(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_gestureDragEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_gestureDropEvent(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 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                lua_type(state, 3) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                int param1 = (int)luaL_checkint(state, 2);
-
-                // Get parameter 2 off the stack.
-                int param2 = (int)luaL_checkint(state, 3);
-
-                Game* instance = getInstance(state);
-                instance->gestureDropEvent(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_gestureDropEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_gestureLongTapEvent(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 4:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                lua_type(state, 3) == LUA_TNUMBER &&
-                lua_type(state, 4) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                int param1 = (int)luaL_checkint(state, 2);
-
-                // Get parameter 2 off the stack.
-                int param2 = (int)luaL_checkint(state, 3);
-
-                // Get parameter 3 off the stack.
-                float param3 = (float)luaL_checknumber(state, 4);
-
-                Game* instance = getInstance(state);
-                instance->gestureLongTapEvent(param1, param2, param3);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_gestureLongTapEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 4).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_gesturePinchEvent(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 4:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                lua_type(state, 3) == LUA_TNUMBER &&
-                lua_type(state, 4) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                int param1 = (int)luaL_checkint(state, 2);
-
-                // Get parameter 2 off the stack.
-                int param2 = (int)luaL_checkint(state, 3);
-
-                // Get parameter 3 off the stack.
-                float param3 = (float)luaL_checknumber(state, 4);
-
-                Game* instance = getInstance(state);
-                instance->gesturePinchEvent(param1, param2, param3);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_gesturePinchEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 4).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_gestureSwipeEvent(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 4:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                lua_type(state, 3) == LUA_TNUMBER &&
-                lua_type(state, 4) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                int param1 = (int)luaL_checkint(state, 2);
-
-                // Get parameter 2 off the stack.
-                int param2 = (int)luaL_checkint(state, 3);
-
-                // Get parameter 3 off the stack.
-                int param3 = (int)luaL_checkint(state, 4);
-
-                Game* instance = getInstance(state);
-                instance->gestureSwipeEvent(param1, param2, param3);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_gestureSwipeEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 4).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_gestureTapEvent(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 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                lua_type(state, 3) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                int param1 = (int)luaL_checkint(state, 2);
-
-                // Get parameter 2 off the stack.
-                int param2 = (int)luaL_checkint(state, 3);
-
-                Game* instance = getInstance(state);
-                instance->gestureTapEvent(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_gestureTapEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_getAIController(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))
-            {
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getAIController();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "AIController");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getAIController - 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_Game_getAccelerometerValues(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 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
-                (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA))
-            {
-                // Get parameter 1 off the stack.
-                gameplay::ScriptUtil::LuaArray<float> param1 = gameplay::ScriptUtil::getFloatPointer(2);
-
-                // Get parameter 2 off the stack.
-                gameplay::ScriptUtil::LuaArray<float> param2 = gameplay::ScriptUtil::getFloatPointer(3);
-
-                Game* instance = getInstance(state);
-                instance->getAccelerometerValues(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_getAccelerometerValues - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_getAnimationController(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))
-            {
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getAnimationController();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "AnimationController");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getAnimationController - 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_Game_getAspectRatio(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))
-            {
-                Game* instance = getInstance(state);
-                float result = instance->getAspectRatio();
-
-                // Push the return value onto the stack.
-                lua_pushnumber(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getAspectRatio - 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_Game_getAudioController(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))
-            {
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getAudioController();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "AudioController");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getAudioController - 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_Game_getAudioListener(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))
-            {
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getAudioListener();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "AudioListener");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getAudioListener - 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_Game_getConfig(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))
-            {
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getConfig();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Properties");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getConfig - 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_Game_getFrameRate(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))
-            {
-                Game* instance = getInstance(state);
-                unsigned int result = instance->getFrameRate();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getFrameRate - 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_Game_getGamepad(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_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
-
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getGamepad(param1);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Gamepad");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getGamepad - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        case 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                lua_type(state, 3) == LUA_TBOOLEAN)
-            {
-                // Get parameter 1 off the stack.
-                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
-
-                // Get parameter 2 off the stack.
-                bool param2 = gameplay::ScriptUtil::luaCheckBool(state, 3);
-
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getGamepad(param1, param2);
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Gamepad");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getGamepad - 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 or 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_getGamepadCount(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))
-            {
-                Game* instance = getInstance(state);
-                unsigned int result = instance->getGamepadCount();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getGamepadCount - 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_Game_getHeight(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))
-            {
-                Game* instance = getInstance(state);
-                unsigned int result = instance->getHeight();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getHeight - 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_Game_getPhysicsController(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))
-            {
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getPhysicsController();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "PhysicsController");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getPhysicsController - 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_Game_getScriptController(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))
-            {
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)instance->getScriptController();
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "ScriptController");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getScriptController - 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_Game_getSensorValues(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 7:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
-                (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA) &&
-                (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
-                (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
-                (lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA) &&
-                (lua_type(state, 7) == LUA_TTABLE || lua_type(state, 7) == LUA_TLIGHTUSERDATA))
-            {
-                // Get parameter 1 off the stack.
-                gameplay::ScriptUtil::LuaArray<float> param1 = gameplay::ScriptUtil::getFloatPointer(2);
-
-                // Get parameter 2 off the stack.
-                gameplay::ScriptUtil::LuaArray<float> param2 = gameplay::ScriptUtil::getFloatPointer(3);
-
-                // Get parameter 3 off the stack.
-                gameplay::ScriptUtil::LuaArray<float> param3 = gameplay::ScriptUtil::getFloatPointer(4);
-
-                // Get parameter 4 off the stack.
-                gameplay::ScriptUtil::LuaArray<float> param4 = gameplay::ScriptUtil::getFloatPointer(5);
-
-                // Get parameter 5 off the stack.
-                gameplay::ScriptUtil::LuaArray<float> param5 = gameplay::ScriptUtil::getFloatPointer(6);
-
-                // Get parameter 6 off the stack.
-                gameplay::ScriptUtil::LuaArray<float> param6 = gameplay::ScriptUtil::getFloatPointer(7);
-
-                Game* instance = getInstance(state);
-                instance->getSensorValues(param1, param2, param3, param4, param5, param6);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_getSensorValues - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 7).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_getState(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))
-            {
-                Game* instance = getInstance(state);
-                Game::State result = instance->getState();
-
-                // Push the return value onto the stack.
-                lua_pushstring(state, lua_stringFromEnum_GameState(result));
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getState - 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_Game_getViewport(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))
-            {
-                Game* instance = getInstance(state);
-                void* returnPtr = (void*)&(instance->getViewport());
-                if (returnPtr)
-                {
-                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                    object->instance = returnPtr;
-                    object->owns = false;
-                    luaL_getmetatable(state, "Rectangle");
-                    lua_setmetatable(state, -2);
-                }
-                else
-                {
-                    lua_pushnil(state);
-                }
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getViewport - 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_Game_getWidth(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))
-            {
-                Game* instance = getInstance(state);
-                unsigned int result = instance->getWidth();
-
-                // Push the return value onto the stack.
-                lua_pushunsigned(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_getWidth - 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_Game_hasAccelerometer(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))
-            {
-                Game* instance = getInstance(state);
-                bool result = instance->hasAccelerometer();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_hasAccelerometer - 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_Game_hasMouse(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))
-            {
-                Game* instance = getInstance(state);
-                bool result = instance->hasMouse();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_hasMouse - 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_Game_isCursorVisible(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))
-            {
-                Game* instance = getInstance(state);
-                bool result = instance->isCursorVisible();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_isCursorVisible - 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_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;
-            }
-
-            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)
-{
-    // 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->isGestureSupported(param1);
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_isGestureSupported - 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_isInitialized(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))
-            {
-                Game* instance = getInstance(state);
-                bool result = instance->isInitialized();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_isInitialized - 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_Game_isMouseCaptured(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))
-            {
-                Game* instance = getInstance(state);
-                bool result = instance->isMouseCaptured();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_isMouseCaptured - 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_Game_isMultiSampling(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))
-            {
-                Game* instance = getInstance(state);
-                bool result = instance->isMultiSampling();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_isMultiSampling - 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_Game_isMultiTouch(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))
-            {
-                Game* instance = getInstance(state);
-                bool result = instance->isMultiTouch();
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_isMultiTouch - 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_Game_keyEvent(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 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                lua_type(state, 3) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                Keyboard::KeyEvent param1 = (Keyboard::KeyEvent)lua_enumFromString_KeyboardKeyEvent(luaL_checkstring(state, 2));
-
-                // Get parameter 2 off the stack.
-                int param2 = (int)luaL_checkint(state, 3);
-
-                Game* instance = getInstance(state);
-                instance->keyEvent(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_keyEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_launchURL(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.
-                const char* param1 = gameplay::ScriptUtil::getString(2, false);
-
-                Game* instance = getInstance(state);
-                bool result = instance->launchURL(param1);
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_launchURL - 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_mouseEvent(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 5:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                lua_type(state, 3) == LUA_TNUMBER &&
-                lua_type(state, 4) == LUA_TNUMBER &&
-                lua_type(state, 5) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                Mouse::MouseEvent param1 = (Mouse::MouseEvent)lua_enumFromString_MouseMouseEvent(luaL_checkstring(state, 2));
-
-                // Get parameter 2 off the stack.
-                int param2 = (int)luaL_checkint(state, 3);
-
-                // Get parameter 3 off the stack.
-                int param3 = (int)luaL_checkint(state, 4);
-
-                // Get parameter 4 off the stack.
-                int param4 = (int)luaL_checkint(state, 5);
-
-                Game* instance = getInstance(state);
-                bool result = instance->mouseEvent(param1, param2, param3, param4);
-
-                // Push the return value onto the stack.
-                lua_pushboolean(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_mouseEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 5).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_pause(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))
-            {
-                Game* instance = getInstance(state);
-                instance->pause();
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_pause - 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_Game_registerGesture(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);
-                instance->registerGesture(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_registerGesture - 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_resizeEvent(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 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                lua_type(state, 3) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
-
-                // Get parameter 2 off the stack.
-                unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);
-
-                Game* instance = getInstance(state);
-                instance->resizeEvent(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_resizeEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_resume(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))
-            {
-                Game* instance = getInstance(state);
-                instance->resume();
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_resume - 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_Game_run(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))
-            {
-                Game* instance = getInstance(state);
-                int result = instance->run();
-
-                // Push the return value onto the stack.
-                lua_pushinteger(state, result);
-
-                return 1;
-            }
-
-            lua_pushstring(state, "lua_Game_run - 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_Game_schedule(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 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                lua_type(state, 2) == LUA_TNUMBER &&
-                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                float param1 = (float)luaL_checknumber(state, 2);
-
-                // Get parameter 2 off the stack.
-                const char* param2 = gameplay::ScriptUtil::getString(3, false);
-
-                Game* instance = getInstance(state);
-                instance->schedule(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_schedule - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_setCursorVisible(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
-
-                Game* instance = getInstance(state);
-                instance->setCursorVisible(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_setCursorVisible - 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_setMouseCaptured(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
-
-                Game* instance = getInstance(state);
-                instance->setMouseCaptured(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_setMouseCaptured - 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_setMultiSampling(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
-
-                Game* instance = getInstance(state);
-                instance->setMultiSampling(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_setMultiSampling - 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_setMultiTouch(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
-
-                Game* instance = getInstance(state);
-                instance->setMultiTouch(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_setMultiTouch - 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_setViewport(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.
-                bool param1Valid;
-                gameplay::ScriptUtil::LuaArray<Rectangle> param1 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(2, "Rectangle", true, &param1Valid);
-                if (!param1Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Rectangle'.");
-                    lua_error(state);
-                }
-
-                Game* instance = getInstance(state);
-                instance->setViewport(*param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_setViewport - 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_static_getAbsoluteTime(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 0:
-        {
-            double result = Game::getAbsoluteTime();
-
-            // Push the return value onto the stack.
-            lua_pushnumber(state, result);
-
-            return 1;
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 0).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_static_getGameTime(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 0:
-        {
-            double result = Game::getGameTime();
-
-            // Push the return value onto the stack.
-            lua_pushnumber(state, result);
-
-            return 1;
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 0).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_static_getInstance(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 0:
-        {
-            void* returnPtr = (void*)Game::getInstance();
-            if (returnPtr)
-            {
-                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
-                object->instance = returnPtr;
-                object->owns = false;
-                luaL_getmetatable(state, "Game");
-                lua_setmetatable(state, -2);
-            }
-            else
-            {
-                lua_pushnil(state);
-            }
-
-            return 1;
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 0).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_static_isVsync(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 0:
-        {
-            bool result = Game::isVsync();
-
-            // Push the return value onto the stack.
-            lua_pushboolean(state, result);
-
-            return 1;
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 0).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_static_setVsync(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_TBOOLEAN)
-            {
-                // Get parameter 1 off the stack.
-                bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 1);
-
-                Game::setVsync(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_static_setVsync - 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_Game_touchEvent(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 5:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
-                lua_type(state, 3) == LUA_TNUMBER &&
-                lua_type(state, 4) == LUA_TNUMBER &&
-                lua_type(state, 5) == LUA_TNUMBER)
-            {
-                // Get parameter 1 off the stack.
-                Touch::TouchEvent param1 = (Touch::TouchEvent)lua_enumFromString_TouchTouchEvent(luaL_checkstring(state, 2));
-
-                // Get parameter 2 off the stack.
-                int param2 = (int)luaL_checkint(state, 3);
-
-                // Get parameter 3 off the stack.
-                int param3 = (int)luaL_checkint(state, 4);
-
-                // Get parameter 4 off the stack.
-                unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
-
-                Game* instance = getInstance(state);
-                instance->touchEvent(param1, param2, param3, param4);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_touchEvent - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 5).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
-int lua_Game_unregisterGesture(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);
-                instance->unregisterGesture(param1);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_Game_unregisterGesture - 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;
-}
-
-}
+#include "Base.h"
+#include "ScriptController.h"
+#include "lua_Game.h"
+#include "Base.h"
+#include "ControlFactory.h"
+#include "FileSystem.h"
+#include "FrameBuffer.h"
+#include "Game.h"
+#include "Platform.h"
+#include "RenderState.h"
+#include "SceneLoader.h"
+#include "Theme.h"
+#include "lua_GameClearFlags.h"
+#include "lua_GameState.h"
+#include "lua_GamepadGamepadEvent.h"
+#include "lua_GestureGestureEvent.h"
+#include "lua_KeyboardKeyEvent.h"
+#include "lua_MouseMouseEvent.h"
+#include "lua_TouchTouchEvent.h"
+
+namespace gameplay
+{
+
+void luaRegister_Game()
+{
+    const luaL_Reg lua_members[] = 
+    {
+        {"canExit", lua_Game_canExit},
+        {"clear", lua_Game_clear},
+        {"displayKeyboard", lua_Game_displayKeyboard},
+        {"exit", lua_Game_exit},
+        {"frame", lua_Game_frame},
+        {"gamepadEvent", lua_Game_gamepadEvent},
+        {"gestureDragEvent", lua_Game_gestureDragEvent},
+        {"gestureDropEvent", lua_Game_gestureDropEvent},
+        {"gestureLongTapEvent", lua_Game_gestureLongTapEvent},
+        {"gesturePinchEvent", lua_Game_gesturePinchEvent},
+        {"gestureSwipeEvent", lua_Game_gestureSwipeEvent},
+        {"gestureTapEvent", lua_Game_gestureTapEvent},
+        {"getAIController", lua_Game_getAIController},
+        {"getAccelerometerValues", lua_Game_getAccelerometerValues},
+        {"getAnimationController", lua_Game_getAnimationController},
+        {"getAspectRatio", lua_Game_getAspectRatio},
+        {"getAudioController", lua_Game_getAudioController},
+        {"getAudioListener", lua_Game_getAudioListener},
+        {"getConfig", lua_Game_getConfig},
+        {"getFrameRate", lua_Game_getFrameRate},
+        {"getGamepad", lua_Game_getGamepad},
+        {"getGamepadCount", lua_Game_getGamepadCount},
+        {"getHeight", lua_Game_getHeight},
+        {"getPhysicsController", lua_Game_getPhysicsController},
+        {"getScriptController", lua_Game_getScriptController},
+        {"getSensorValues", lua_Game_getSensorValues},
+        {"getState", lua_Game_getState},
+        {"getViewport", lua_Game_getViewport},
+        {"getWidth", lua_Game_getWidth},
+        {"hasAccelerometer", lua_Game_hasAccelerometer},
+        {"hasMouse", lua_Game_hasMouse},
+        {"isCursorVisible", lua_Game_isCursorVisible},
+        {"isGestureRegistered", lua_Game_isGestureRegistered},
+        {"isGestureSupported", lua_Game_isGestureSupported},
+        {"isInitialized", lua_Game_isInitialized},
+        {"isMouseCaptured", lua_Game_isMouseCaptured},
+        {"isMultiSampling", lua_Game_isMultiSampling},
+        {"isMultiTouch", lua_Game_isMultiTouch},
+        {"keyEvent", lua_Game_keyEvent},
+        {"launchURL", lua_Game_launchURL},
+        {"mouseEvent", lua_Game_mouseEvent},
+        {"pause", lua_Game_pause},
+        {"registerGesture", lua_Game_registerGesture},
+        {"resizeEvent", lua_Game_resizeEvent},
+        {"resume", lua_Game_resume},
+        {"run", lua_Game_run},
+        {"schedule", lua_Game_schedule},
+        {"setCursorVisible", lua_Game_setCursorVisible},
+        {"setMouseCaptured", lua_Game_setMouseCaptured},
+        {"setMultiSampling", lua_Game_setMultiSampling},
+        {"setMultiTouch", lua_Game_setMultiTouch},
+        {"setViewport", lua_Game_setViewport},
+        {"touchEvent", lua_Game_touchEvent},
+        {"unregisterGesture", lua_Game_unregisterGesture},
+        {NULL, NULL}
+    };
+    const luaL_Reg lua_statics[] = 
+    {
+        {"getAbsoluteTime", lua_Game_static_getAbsoluteTime},
+        {"getGameTime", lua_Game_static_getGameTime},
+        {"getInstance", lua_Game_static_getInstance},
+        {"isVsync", lua_Game_static_isVsync},
+        {"setVsync", lua_Game_static_setVsync},
+        {NULL, NULL}
+    };
+    std::vector<std::string> scopePath;
+
+    gameplay::ScriptUtil::registerClass("Game", lua_members, NULL, lua_Game__gc, lua_statics, scopePath);
+}
+
+static Game* getInstance(lua_State* state)
+{
+    void* userdata = luaL_checkudata(state, 1, "Game");
+    luaL_argcheck(state, userdata != NULL, 1, "'Game' expected.");
+    return (Game*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
+}
+
+int lua_Game__gc(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))
+            {
+                void* userdata = luaL_checkudata(state, 1, "Game");
+                luaL_argcheck(state, userdata != NULL, 1, "'Game' expected.");
+                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)userdata;
+                if (object->owns)
+                {
+                    Game* instance = (Game*)object->instance;
+                    SAFE_DELETE(instance);
+                }
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game__gc - 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_Game_canExit(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))
+            {
+                Game* instance = getInstance(state);
+                bool result = instance->canExit();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_canExit - 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_Game_clear(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 5:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                    (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TNIL) &&
+                    lua_type(state, 4) == LUA_TNUMBER &&
+                    lua_type(state, 5) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    Game::ClearFlags param1 = (Game::ClearFlags)lua_enumFromString_GameClearFlags(luaL_checkstring(state, 2));
+
+                    // Get parameter 2 off the stack.
+                    bool param2Valid;
+                    gameplay::ScriptUtil::LuaArray<Vector4> param2 = gameplay::ScriptUtil::getObjectPointer<Vector4>(3, "Vector4", true, &param2Valid);
+                    if (!param2Valid)
+                        break;
+
+                    // Get parameter 3 off the stack.
+                    float param3 = (float)luaL_checknumber(state, 4);
+
+                    // Get parameter 4 off the stack.
+                    int param4 = (int)luaL_checkint(state, 5);
+
+                    Game* instance = getInstance(state);
+                    instance->clear(param1, *param2, param3, param4);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_Game_clear - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 8:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER &&
+                    lua_type(state, 4) == LUA_TNUMBER &&
+                    lua_type(state, 5) == LUA_TNUMBER &&
+                    lua_type(state, 6) == LUA_TNUMBER &&
+                    lua_type(state, 7) == LUA_TNUMBER &&
+                    lua_type(state, 8) == LUA_TNUMBER)
+                {
+                    // Get parameter 1 off the stack.
+                    Game::ClearFlags param1 = (Game::ClearFlags)lua_enumFromString_GameClearFlags(luaL_checkstring(state, 2));
+
+                    // Get parameter 2 off the stack.
+                    float param2 = (float)luaL_checknumber(state, 3);
+
+                    // Get parameter 3 off the stack.
+                    float param3 = (float)luaL_checknumber(state, 4);
+
+                    // Get parameter 4 off the stack.
+                    float param4 = (float)luaL_checknumber(state, 5);
+
+                    // Get parameter 5 off the stack.
+                    float param5 = (float)luaL_checknumber(state, 6);
+
+                    // Get parameter 6 off the stack.
+                    float param6 = (float)luaL_checknumber(state, 7);
+
+                    // Get parameter 7 off the stack.
+                    int param7 = (int)luaL_checkint(state, 8);
+
+                    Game* instance = getInstance(state);
+                    instance->clear(param1, param2, param3, param4, param5, param6, param7);
+                    
+                    return 0;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_Game_clear - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 5 or 8).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_displayKeyboard(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
+
+                Game* instance = getInstance(state);
+                instance->displayKeyboard(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_displayKeyboard - 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_exit(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))
+            {
+                Game* instance = getInstance(state);
+                instance->exit();
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_exit - 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_Game_frame(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))
+            {
+                Game* instance = getInstance(state);
+                instance->frame();
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_frame - 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_Game_gamepadEvent(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 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                Gamepad::GamepadEvent param1 = (Gamepad::GamepadEvent)lua_enumFromString_GamepadGamepadEvent(luaL_checkstring(state, 2));
+
+                // Get parameter 2 off the stack.
+                bool param2Valid;
+                gameplay::ScriptUtil::LuaArray<Gamepad> param2 = gameplay::ScriptUtil::getObjectPointer<Gamepad>(3, "Gamepad", false, &param2Valid);
+                if (!param2Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Gamepad'.");
+                    lua_error(state);
+                }
+
+                Game* instance = getInstance(state);
+                instance->gamepadEvent(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_gamepadEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_gestureDragEvent(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 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                int param1 = (int)luaL_checkint(state, 2);
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                Game* instance = getInstance(state);
+                instance->gestureDragEvent(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_gestureDragEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_gestureDropEvent(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 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                int param1 = (int)luaL_checkint(state, 2);
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                Game* instance = getInstance(state);
+                instance->gestureDropEvent(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_gestureDropEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_gestureLongTapEvent(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 4:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                int param1 = (int)luaL_checkint(state, 2);
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                // Get parameter 3 off the stack.
+                float param3 = (float)luaL_checknumber(state, 4);
+
+                Game* instance = getInstance(state);
+                instance->gestureLongTapEvent(param1, param2, param3);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_gestureLongTapEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_gesturePinchEvent(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 4:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                int param1 = (int)luaL_checkint(state, 2);
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                // Get parameter 3 off the stack.
+                float param3 = (float)luaL_checknumber(state, 4);
+
+                Game* instance = getInstance(state);
+                instance->gesturePinchEvent(param1, param2, param3);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_gesturePinchEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_gestureSwipeEvent(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 4:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                int param1 = (int)luaL_checkint(state, 2);
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                // Get parameter 3 off the stack.
+                int param3 = (int)luaL_checkint(state, 4);
+
+                Game* instance = getInstance(state);
+                instance->gestureSwipeEvent(param1, param2, param3);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_gestureSwipeEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_gestureTapEvent(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 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                int param1 = (int)luaL_checkint(state, 2);
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                Game* instance = getInstance(state);
+                instance->gestureTapEvent(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_gestureTapEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_getAIController(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))
+            {
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getAIController();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "AIController");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getAIController - 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_Game_getAccelerometerValues(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 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA))
+            {
+                // Get parameter 1 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param1 = gameplay::ScriptUtil::getFloatPointer(2);
+
+                // Get parameter 2 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param2 = gameplay::ScriptUtil::getFloatPointer(3);
+
+                Game* instance = getInstance(state);
+                instance->getAccelerometerValues(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_getAccelerometerValues - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_getAnimationController(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))
+            {
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getAnimationController();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "AnimationController");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getAnimationController - 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_Game_getAspectRatio(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))
+            {
+                Game* instance = getInstance(state);
+                float result = instance->getAspectRatio();
+
+                // Push the return value onto the stack.
+                lua_pushnumber(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getAspectRatio - 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_Game_getAudioController(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))
+            {
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getAudioController();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "AudioController");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getAudioController - 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_Game_getAudioListener(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))
+            {
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getAudioListener();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "AudioListener");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getAudioListener - 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_Game_getConfig(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))
+            {
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getConfig();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Properties");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getConfig - 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_Game_getFrameRate(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))
+            {
+                Game* instance = getInstance(state);
+                unsigned int result = instance->getFrameRate();
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getFrameRate - 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_Game_getGamepad(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_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
+
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getGamepad(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Gamepad");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getGamepad - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        case 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TBOOLEAN)
+            {
+                // Get parameter 1 off the stack.
+                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
+
+                // Get parameter 2 off the stack.
+                bool param2 = gameplay::ScriptUtil::luaCheckBool(state, 3);
+
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getGamepad(param1, param2);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Gamepad");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getGamepad - 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 or 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_getGamepadCount(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))
+            {
+                Game* instance = getInstance(state);
+                unsigned int result = instance->getGamepadCount();
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getGamepadCount - 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_Game_getHeight(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))
+            {
+                Game* instance = getInstance(state);
+                unsigned int result = instance->getHeight();
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getHeight - 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_Game_getPhysicsController(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))
+            {
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getPhysicsController();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "PhysicsController");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getPhysicsController - 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_Game_getScriptController(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))
+            {
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getScriptController();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "ScriptController");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getScriptController - 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_Game_getSensorValues(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 7:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 7) == LUA_TTABLE || lua_type(state, 7) == LUA_TLIGHTUSERDATA))
+            {
+                // Get parameter 1 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param1 = gameplay::ScriptUtil::getFloatPointer(2);
+
+                // Get parameter 2 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param2 = gameplay::ScriptUtil::getFloatPointer(3);
+
+                // Get parameter 3 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param3 = gameplay::ScriptUtil::getFloatPointer(4);
+
+                // Get parameter 4 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param4 = gameplay::ScriptUtil::getFloatPointer(5);
+
+                // Get parameter 5 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param5 = gameplay::ScriptUtil::getFloatPointer(6);
+
+                // Get parameter 6 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param6 = gameplay::ScriptUtil::getFloatPointer(7);
+
+                Game* instance = getInstance(state);
+                instance->getSensorValues(param1, param2, param3, param4, param5, param6);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_getSensorValues - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 7).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_getState(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))
+            {
+                Game* instance = getInstance(state);
+                Game::State result = instance->getState();
+
+                // Push the return value onto the stack.
+                lua_pushstring(state, lua_stringFromEnum_GameState(result));
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getState - 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_Game_getViewport(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))
+            {
+                Game* instance = getInstance(state);
+                void* returnPtr = (void*)&(instance->getViewport());
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Rectangle");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getViewport - 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_Game_getWidth(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))
+            {
+                Game* instance = getInstance(state);
+                unsigned int result = instance->getWidth();
+
+                // Push the return value onto the stack.
+                lua_pushunsigned(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_getWidth - 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_Game_hasAccelerometer(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))
+            {
+                Game* instance = getInstance(state);
+                bool result = instance->hasAccelerometer();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_hasAccelerometer - 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_Game_hasMouse(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))
+            {
+                Game* instance = getInstance(state);
+                bool result = instance->hasMouse();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_hasMouse - 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_Game_isCursorVisible(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))
+            {
+                Game* instance = getInstance(state);
+                bool result = instance->isCursorVisible();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_isCursorVisible - 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_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;
+            }
+
+            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)
+{
+    // 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->isGestureSupported(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_isGestureSupported - 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_isInitialized(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))
+            {
+                Game* instance = getInstance(state);
+                bool result = instance->isInitialized();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_isInitialized - 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_Game_isMouseCaptured(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))
+            {
+                Game* instance = getInstance(state);
+                bool result = instance->isMouseCaptured();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_isMouseCaptured - 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_Game_isMultiSampling(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))
+            {
+                Game* instance = getInstance(state);
+                bool result = instance->isMultiSampling();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_isMultiSampling - 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_Game_isMultiTouch(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))
+            {
+                Game* instance = getInstance(state);
+                bool result = instance->isMultiTouch();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_isMultiTouch - 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_Game_keyEvent(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 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                Keyboard::KeyEvent param1 = (Keyboard::KeyEvent)lua_enumFromString_KeyboardKeyEvent(luaL_checkstring(state, 2));
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                Game* instance = getInstance(state);
+                instance->keyEvent(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_keyEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_launchURL(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                Game* instance = getInstance(state);
+                bool result = instance->launchURL(param1);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_launchURL - 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_mouseEvent(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 5:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER &&
+                lua_type(state, 5) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                Mouse::MouseEvent param1 = (Mouse::MouseEvent)lua_enumFromString_MouseMouseEvent(luaL_checkstring(state, 2));
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                // Get parameter 3 off the stack.
+                int param3 = (int)luaL_checkint(state, 4);
+
+                // Get parameter 4 off the stack.
+                int param4 = (int)luaL_checkint(state, 5);
+
+                Game* instance = getInstance(state);
+                bool result = instance->mouseEvent(param1, param2, param3, param4);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_mouseEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 5).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_pause(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))
+            {
+                Game* instance = getInstance(state);
+                instance->pause();
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_pause - 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_Game_registerGesture(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);
+                instance->registerGesture(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_registerGesture - 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_resizeEvent(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 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                unsigned int param1 = (unsigned int)luaL_checkunsigned(state, 2);
+
+                // Get parameter 2 off the stack.
+                unsigned int param2 = (unsigned int)luaL_checkunsigned(state, 3);
+
+                Game* instance = getInstance(state);
+                instance->resizeEvent(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_resizeEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_resume(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))
+            {
+                Game* instance = getInstance(state);
+                instance->resume();
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_resume - 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_Game_run(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))
+            {
+                Game* instance = getInstance(state);
+                int result = instance->run();
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Game_run - 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_Game_schedule(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 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                (lua_type(state, 3) == LUA_TSTRING || lua_type(state, 3) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                float param1 = (float)luaL_checknumber(state, 2);
+
+                // Get parameter 2 off the stack.
+                const char* param2 = gameplay::ScriptUtil::getString(3, false);
+
+                Game* instance = getInstance(state);
+                instance->schedule(param1, param2);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_schedule - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_setCursorVisible(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
+
+                Game* instance = getInstance(state);
+                instance->setCursorVisible(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_setCursorVisible - 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_setMouseCaptured(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
+
+                Game* instance = getInstance(state);
+                instance->setMouseCaptured(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_setMouseCaptured - 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_setMultiSampling(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
+
+                Game* instance = getInstance(state);
+                instance->setMultiSampling(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_setMultiSampling - 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_setMultiTouch(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 = gameplay::ScriptUtil::luaCheckBool(state, 2);
+
+                Game* instance = getInstance(state);
+                instance->setMultiTouch(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_setMultiTouch - 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_setViewport(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.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Rectangle> param1 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(2, "Rectangle", true, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Rectangle'.");
+                    lua_error(state);
+                }
+
+                Game* instance = getInstance(state);
+                instance->setViewport(*param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_setViewport - 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_static_getAbsoluteTime(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 0:
+        {
+            double result = Game::getAbsoluteTime();
+
+            // Push the return value onto the stack.
+            lua_pushnumber(state, result);
+
+            return 1;
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_static_getGameTime(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 0:
+        {
+            double result = Game::getGameTime();
+
+            // Push the return value onto the stack.
+            lua_pushnumber(state, result);
+
+            return 1;
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_static_getInstance(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 0:
+        {
+            void* returnPtr = (void*)Game::getInstance();
+            if (returnPtr)
+            {
+                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                object->instance = returnPtr;
+                object->owns = false;
+                luaL_getmetatable(state, "Game");
+                lua_setmetatable(state, -2);
+            }
+            else
+            {
+                lua_pushnil(state);
+            }
+
+            return 1;
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_static_isVsync(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 0:
+        {
+            bool result = Game::isVsync();
+
+            // Push the return value onto the stack.
+            lua_pushboolean(state, result);
+
+            return 1;
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_static_setVsync(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_TBOOLEAN)
+            {
+                // Get parameter 1 off the stack.
+                bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 1);
+
+                Game::setVsync(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_static_setVsync - 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_Game_touchEvent(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 5:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL) &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER &&
+                lua_type(state, 5) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                Touch::TouchEvent param1 = (Touch::TouchEvent)lua_enumFromString_TouchTouchEvent(luaL_checkstring(state, 2));
+
+                // Get parameter 2 off the stack.
+                int param2 = (int)luaL_checkint(state, 3);
+
+                // Get parameter 3 off the stack.
+                int param3 = (int)luaL_checkint(state, 4);
+
+                // Get parameter 4 off the stack.
+                unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 5);
+
+                Game* instance = getInstance(state);
+                instance->touchEvent(param1, param2, param3, param4);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_touchEvent - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 5).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+int lua_Game_unregisterGesture(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);
+                instance->unregisterGesture(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_unregisterGesture - 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;
+}
+
+}

+ 1062 - 1020
gameplay/src/lua/lua_Global.cpp

@@ -1,1020 +1,1062 @@
-#include "ScriptController.h"
-#include "lua_Global.h"
-
-namespace gameplay
-{
-
-void luaRegister_lua_Global()
-{
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Container");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Control");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "ImageControl");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Joystick");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Label");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "MaterialParameter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Node");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Transform");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Button", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Button", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Camera::Listener", "AudioListener");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Camera::Listener", "TerrainPatch");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Container", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Container");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "ImageControl");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Joystick");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Label");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "AbsoluteLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "FlowLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "VerticalLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Node", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsCharacter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsGhostObject");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsRigidBody");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsVehicle");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsVehicleWheel");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsFixedConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsGenericConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsHingeConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsSocketConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsSpringConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGenericConstraint", "PhysicsFixedConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGenericConstraint", "PhysicsSpringConstraint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGhostObject", "PhysicsCharacter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AIAgent");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AIState");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AbsoluteLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Animation");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AnimationClip");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AudioBuffer");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AudioSource");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Bundle");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Camera");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Container");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Control");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Curve");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "DepthStencilTarget");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Effect");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "FlowLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Font");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "FrameBuffer");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "HeightField");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Image");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "ImageControl");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Joystick");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Label");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Layout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Light");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Material");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "MaterialParameter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Mesh");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Model");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Node");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "ParticleEmitter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Pass");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "PhysicsCollisionShape");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderState");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderState::StateBlock");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderTarget");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Scene");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Technique");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Terrain");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Texture");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Texture::Sampler");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Theme");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Theme::ThemeImage");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "VertexAttributeBinding");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "VerticalLayout");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Material");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Pass");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Technique");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "AIAgent");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "AIState");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Button");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "CheckBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Container");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Control");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Form");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "ImageControl");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Joystick");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Label");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Node");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "PhysicsController");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "RadioButton");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Slider");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "TextBox");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Transform");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform", "Joint");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform", "Node");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "AudioSource");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "Camera");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "MeshSkin");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsCharacter");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsGhostObject");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsRigidBody");
-    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "Terrain");
-    gameplay::ScriptUtil::addStringFromEnumConversionFunction(&gameplay::lua_stringFromEnumGlobal);
-
-    // Register enumeration AIMessage::ParameterType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("AIMessage");
-        gameplay::ScriptUtil::registerConstantString("UNDEFINED", "UNDEFINED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INTEGER", "INTEGER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LONG", "LONG", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FLOAT", "FLOAT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DOUBLE", "DOUBLE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOOLEAN", "BOOLEAN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STRING", "STRING", scopePath);
-    }
-
-    // Register enumeration AnimationClip::Listener::EventType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("AnimationClip");
-        scopePath.push_back("Listener");
-        gameplay::ScriptUtil::registerConstantString("BEGIN", "BEGIN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("END", "END", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TIME", "TIME", scopePath);
-    }
-
-    // Register enumeration AudioSource::State.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("AudioSource");
-        gameplay::ScriptUtil::registerConstantString("INITIAL", "INITIAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PLAYING", "PLAYING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PAUSED", "PAUSED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STOPPED", "STOPPED", scopePath);
-    }
-
-    // Register enumeration Camera::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Camera");
-        gameplay::ScriptUtil::registerConstantString("PERSPECTIVE", "PERSPECTIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ORTHOGRAPHIC", "ORTHOGRAPHIC", scopePath);
-    }
-
-    // Register enumeration Container::Scroll.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Container");
-        gameplay::ScriptUtil::registerConstantString("SCROLL_NONE", "SCROLL_NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCROLL_HORIZONTAL", "SCROLL_HORIZONTAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCROLL_VERTICAL", "SCROLL_VERTICAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCROLL_BOTH", "SCROLL_BOTH", scopePath);
-    }
-
-    // Register enumeration Control::Alignment.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Control");
-        gameplay::ScriptUtil::registerConstantString("ALIGN_LEFT", "ALIGN_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_HCENTER", "ALIGN_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_RIGHT", "ALIGN_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP", "ALIGN_TOP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER", "ALIGN_VCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM", "ALIGN_BOTTOM", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_LEFT", "ALIGN_TOP_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_LEFT", "ALIGN_VCENTER_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_LEFT", "ALIGN_BOTTOM_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_HCENTER", "ALIGN_TOP_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_HCENTER", "ALIGN_VCENTER_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_HCENTER", "ALIGN_BOTTOM_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_RIGHT", "ALIGN_TOP_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_RIGHT", "ALIGN_VCENTER_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_RIGHT", "ALIGN_BOTTOM_RIGHT", scopePath);
-    }
-
-    // Register enumeration Control::AutoSize.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Control");
-        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_NONE", "AUTO_SIZE_NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_STRETCH", "AUTO_SIZE_STRETCH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_FIT", "AUTO_SIZE_FIT", scopePath);
-    }
-
-    // Register enumeration Control::Listener::EventType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Control");
-        scopePath.push_back("Listener");
-        gameplay::ScriptUtil::registerConstantString("PRESS", "PRESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RELEASE", "RELEASE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLICK", "CLICK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VALUE_CHANGED", "VALUE_CHANGED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXT_CHANGED", "TEXT_CHANGED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MIDDLE_CLICK", "MIDDLE_CLICK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RIGHT_CLICK", "RIGHT_CLICK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ENTER", "ENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LEAVE", "LEAVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FOCUS_GAINED", "FOCUS_GAINED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FOCUS_LOST", "FOCUS_LOST", scopePath);
-    }
-
-    // Register enumeration Control::State.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Control");
-        gameplay::ScriptUtil::registerConstantString("NORMAL", "NORMAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FOCUS", "FOCUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ACTIVE", "ACTIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DISABLED", "DISABLED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("HOVER", "HOVER", scopePath);
-    }
-
-    // Register enumeration Curve::InterpolationType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Curve");
-        gameplay::ScriptUtil::registerConstantString("BEZIER", "BEZIER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BSPLINE", "BSPLINE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FLAT", "FLAT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("HERMITE", "HERMITE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINEAR", "LINEAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SMOOTH", "SMOOTH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STEP", "STEP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUADRATIC_IN", "QUADRATIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUADRATIC_OUT", "QUADRATIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUADRATIC_IN_OUT", "QUADRATIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUADRATIC_OUT_IN", "QUADRATIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CUBIC_IN", "CUBIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CUBIC_OUT", "CUBIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CUBIC_IN_OUT", "CUBIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CUBIC_OUT_IN", "CUBIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUARTIC_IN", "QUARTIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUARTIC_OUT", "QUARTIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUARTIC_IN_OUT", "QUARTIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUARTIC_OUT_IN", "QUARTIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUINTIC_IN", "QUINTIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUINTIC_OUT", "QUINTIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUINTIC_IN_OUT", "QUINTIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("QUINTIC_OUT_IN", "QUINTIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SINE_IN", "SINE_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SINE_OUT", "SINE_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SINE_IN_OUT", "SINE_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SINE_OUT_IN", "SINE_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_IN", "EXPONENTIAL_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_OUT", "EXPONENTIAL_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_IN_OUT", "EXPONENTIAL_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_OUT_IN", "EXPONENTIAL_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CIRCULAR_IN", "CIRCULAR_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CIRCULAR_OUT", "CIRCULAR_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CIRCULAR_IN_OUT", "CIRCULAR_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CIRCULAR_OUT_IN", "CIRCULAR_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ELASTIC_IN", "ELASTIC_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ELASTIC_OUT", "ELASTIC_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ELASTIC_IN_OUT", "ELASTIC_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ELASTIC_OUT_IN", "ELASTIC_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_IN", "OVERSHOOT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_OUT", "OVERSHOOT_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_IN_OUT", "OVERSHOOT_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_OUT_IN", "OVERSHOOT_OUT_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOUNCE_IN", "BOUNCE_IN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOUNCE_OUT", "BOUNCE_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOUNCE_IN_OUT", "BOUNCE_IN_OUT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOUNCE_OUT_IN", "BOUNCE_OUT_IN", scopePath);
-    }
-
-    // Register enumeration DepthStencilTarget::Format.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("DepthStencilTarget");
-        gameplay::ScriptUtil::registerConstantString("DEPTH", "DEPTH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_STENCIL", "DEPTH_STENCIL", scopePath);
-    }
-
-    // Register enumeration Font::Format.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Font");
-        gameplay::ScriptUtil::registerConstantString("BITMAP", "BITMAP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DISTANCE_FIELD", "DISTANCE_FIELD", scopePath);
-    }
-
-    // Register enumeration Font::Justify.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Font");
-        gameplay::ScriptUtil::registerConstantString("ALIGN_LEFT", "ALIGN_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_HCENTER", "ALIGN_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_RIGHT", "ALIGN_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP", "ALIGN_TOP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER", "ALIGN_VCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM", "ALIGN_BOTTOM", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_LEFT", "ALIGN_TOP_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_LEFT", "ALIGN_VCENTER_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_LEFT", "ALIGN_BOTTOM_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_HCENTER", "ALIGN_TOP_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_HCENTER", "ALIGN_VCENTER_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_HCENTER", "ALIGN_BOTTOM_HCENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_RIGHT", "ALIGN_TOP_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_RIGHT", "ALIGN_VCENTER_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_RIGHT", "ALIGN_BOTTOM_RIGHT", scopePath);
-    }
-
-    // Register enumeration Font::Style.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Font");
-        gameplay::ScriptUtil::registerConstantString("PLAIN", "PLAIN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOLD", "BOLD", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ITALIC", "ITALIC", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BOLD_ITALIC", "BOLD_ITALIC", scopePath);
-    }
-
-    // Register enumeration Game::ClearFlags.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Game");
-        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR", "CLEAR_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_DEPTH", "CLEAR_DEPTH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_STENCIL", "CLEAR_STENCIL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_DEPTH", "CLEAR_COLOR_DEPTH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_STENCIL", "CLEAR_COLOR_STENCIL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_DEPTH_STENCIL", "CLEAR_DEPTH_STENCIL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_DEPTH_STENCIL", "CLEAR_COLOR_DEPTH_STENCIL", scopePath);
-    }
-
-    // Register enumeration Game::State.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Game");
-        gameplay::ScriptUtil::registerConstantString("UNINITIALIZED", "UNINITIALIZED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RUNNING", "RUNNING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PAUSED", "PAUSED", scopePath);
-    }
-
-    // Register enumeration Gamepad::ButtonMapping.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Gamepad");
-        gameplay::ScriptUtil::registerConstantString("BUTTON_A", "BUTTON_A", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_B", "BUTTON_B", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_C", "BUTTON_C", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_X", "BUTTON_X", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_Y", "BUTTON_Y", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_Z", "BUTTON_Z", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU1", "BUTTON_MENU1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU2", "BUTTON_MENU2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU3", "BUTTON_MENU3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU4", "BUTTON_MENU4", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_L1", "BUTTON_L1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_L2", "BUTTON_L2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_L3", "BUTTON_L3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_R1", "BUTTON_R1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_R2", "BUTTON_R2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_R3", "BUTTON_R3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_UP", "BUTTON_UP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_DOWN", "BUTTON_DOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_LEFT", "BUTTON_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_RIGHT", "BUTTON_RIGHT", scopePath);
-    }
-
-    // Register enumeration Gamepad::GamepadEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Gamepad");
-        gameplay::ScriptUtil::registerConstantString("CONNECTED_EVENT", "CONNECTED_EVENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DISCONNECTED_EVENT", "DISCONNECTED_EVENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BUTTON_EVENT", "BUTTON_EVENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("JOYSTICK_EVENT", "JOYSTICK_EVENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TRIGGER_EVENT", "TRIGGER_EVENT", scopePath);
-    }
-
-    // Register enumeration Gesture::GestureEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Gesture");
-        gameplay::ScriptUtil::registerConstantString("GESTURE_TAP", "GESTURE_TAP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GESTURE_SWIPE", "GESTURE_SWIPE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GESTURE_PINCH", "GESTURE_PINCH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GESTURE_LONG_TAP", "GESTURE_LONG_TAP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GESTURE_DRAG", "GESTURE_DRAG", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GESTURE_DROP", "GESTURE_DROP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GESTURE_ANY_SUPPORTED", "GESTURE_ANY_SUPPORTED", scopePath);
-    }
-
-    // Register enumeration Image::Format.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Image");
-        gameplay::ScriptUtil::registerConstantString("RGB", "RGB", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RGBA", "RGBA", scopePath);
-    }
-
-    // Register enumeration Keyboard::Key.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Keyboard");
-        gameplay::ScriptUtil::registerConstantString("KEY_NONE", "KEY_NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PAUSE", "KEY_PAUSE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SCROLL_LOCK", "KEY_SCROLL_LOCK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PRINT", "KEY_PRINT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SYSREQ", "KEY_SYSREQ", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BREAK", "KEY_BREAK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ESCAPE", "KEY_ESCAPE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BACKSPACE", "KEY_BACKSPACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_TAB", "KEY_TAB", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BACK_TAB", "KEY_BACK_TAB", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RETURN", "KEY_RETURN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPS_LOCK", "KEY_CAPS_LOCK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SHIFT", "KEY_SHIFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CTRL", "KEY_CTRL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ALT", "KEY_ALT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_MENU", "KEY_MENU", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_HYPER", "KEY_HYPER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_INSERT", "KEY_INSERT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_HOME", "KEY_HOME", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PG_UP", "KEY_PG_UP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_DELETE", "KEY_DELETE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_END", "KEY_END", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PG_DOWN", "KEY_PG_DOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_ARROW", "KEY_LEFT_ARROW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_ARROW", "KEY_RIGHT_ARROW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_UP_ARROW", "KEY_UP_ARROW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_DOWN_ARROW", "KEY_DOWN_ARROW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_NUM_LOCK", "KEY_NUM_LOCK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_PLUS", "KEY_KP_PLUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_MINUS", "KEY_KP_MINUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_MULTIPLY", "KEY_KP_MULTIPLY", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_DIVIDE", "KEY_KP_DIVIDE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_ENTER", "KEY_KP_ENTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_HOME", "KEY_KP_HOME", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_UP", "KEY_KP_UP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_PG_UP", "KEY_KP_PG_UP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_LEFT", "KEY_KP_LEFT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_FIVE", "KEY_KP_FIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_RIGHT", "KEY_KP_RIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_END", "KEY_KP_END", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_DOWN", "KEY_KP_DOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_PG_DOWN", "KEY_KP_PG_DOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_INSERT", "KEY_KP_INSERT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_KP_DELETE", "KEY_KP_DELETE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F1", "KEY_F1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F2", "KEY_F2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F3", "KEY_F3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F4", "KEY_F4", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F5", "KEY_F5", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F6", "KEY_F6", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F7", "KEY_F7", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F8", "KEY_F8", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F9", "KEY_F9", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F10", "KEY_F10", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F11", "KEY_F11", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F12", "KEY_F12", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SPACE", "KEY_SPACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_EXCLAM", "KEY_EXCLAM", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_QUOTE", "KEY_QUOTE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_NUMBER", "KEY_NUMBER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_DOLLAR", "KEY_DOLLAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PERCENT", "KEY_PERCENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CIRCUMFLEX", "KEY_CIRCUMFLEX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_AMPERSAND", "KEY_AMPERSAND", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_APOSTROPHE", "KEY_APOSTROPHE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_PARENTHESIS", "KEY_LEFT_PARENTHESIS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_PARENTHESIS", "KEY_RIGHT_PARENTHESIS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ASTERISK", "KEY_ASTERISK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PLUS", "KEY_PLUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_COMMA", "KEY_COMMA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_MINUS", "KEY_MINUS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_PERIOD", "KEY_PERIOD", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SLASH", "KEY_SLASH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ZERO", "KEY_ZERO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_ONE", "KEY_ONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_TWO", "KEY_TWO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_THREE", "KEY_THREE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_FOUR", "KEY_FOUR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_FIVE", "KEY_FIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SIX", "KEY_SIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SEVEN", "KEY_SEVEN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_EIGHT", "KEY_EIGHT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_NINE", "KEY_NINE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_COLON", "KEY_COLON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SEMICOLON", "KEY_SEMICOLON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LESS_THAN", "KEY_LESS_THAN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_EQUAL", "KEY_EQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_GREATER_THAN", "KEY_GREATER_THAN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_QUESTION", "KEY_QUESTION", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_AT", "KEY_AT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_A", "KEY_CAPITAL_A", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_B", "KEY_CAPITAL_B", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_C", "KEY_CAPITAL_C", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_D", "KEY_CAPITAL_D", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_E", "KEY_CAPITAL_E", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_F", "KEY_CAPITAL_F", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_G", "KEY_CAPITAL_G", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_H", "KEY_CAPITAL_H", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_I", "KEY_CAPITAL_I", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_J", "KEY_CAPITAL_J", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_K", "KEY_CAPITAL_K", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_L", "KEY_CAPITAL_L", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_M", "KEY_CAPITAL_M", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_N", "KEY_CAPITAL_N", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_O", "KEY_CAPITAL_O", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_P", "KEY_CAPITAL_P", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Q", "KEY_CAPITAL_Q", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_R", "KEY_CAPITAL_R", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_S", "KEY_CAPITAL_S", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_T", "KEY_CAPITAL_T", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_U", "KEY_CAPITAL_U", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_V", "KEY_CAPITAL_V", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_W", "KEY_CAPITAL_W", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_X", "KEY_CAPITAL_X", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Y", "KEY_CAPITAL_Y", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Z", "KEY_CAPITAL_Z", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_BRACKET", "KEY_LEFT_BRACKET", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BACK_SLASH", "KEY_BACK_SLASH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_BRACKET", "KEY_RIGHT_BRACKET", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_UNDERSCORE", "KEY_UNDERSCORE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_GRAVE", "KEY_GRAVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_A", "KEY_A", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_B", "KEY_B", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_C", "KEY_C", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_D", "KEY_D", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_E", "KEY_E", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_F", "KEY_F", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_G", "KEY_G", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_H", "KEY_H", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_I", "KEY_I", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_J", "KEY_J", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_K", "KEY_K", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_L", "KEY_L", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_M", "KEY_M", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_N", "KEY_N", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_O", "KEY_O", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_P", "KEY_P", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_Q", "KEY_Q", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_R", "KEY_R", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_S", "KEY_S", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_T", "KEY_T", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_U", "KEY_U", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_V", "KEY_V", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_W", "KEY_W", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_X", "KEY_X", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_Y", "KEY_Y", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_Z", "KEY_Z", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_BRACE", "KEY_LEFT_BRACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_BAR", "KEY_BAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_BRACE", "KEY_RIGHT_BRACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_TILDE", "KEY_TILDE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_EURO", "KEY_EURO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_POUND", "KEY_POUND", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_YEN", "KEY_YEN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_MIDDLE_DOT", "KEY_MIDDLE_DOT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_SEARCH", "KEY_SEARCH", scopePath);
-    }
-
-    // Register enumeration Keyboard::KeyEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Keyboard");
-        gameplay::ScriptUtil::registerConstantString("KEY_PRESS", "KEY_PRESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_RELEASE", "KEY_RELEASE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("KEY_CHAR", "KEY_CHAR", scopePath);
-    }
-
-    // Register enumeration Layout::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Layout");
-        gameplay::ScriptUtil::registerConstantString("LAYOUT_FLOW", "LAYOUT_FLOW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LAYOUT_VERTICAL", "LAYOUT_VERTICAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LAYOUT_ABSOLUTE", "LAYOUT_ABSOLUTE", scopePath);
-    }
-
-    // Register enumeration Light::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Light");
-        gameplay::ScriptUtil::registerConstantString("DIRECTIONAL", "DIRECTIONAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("POINT", "POINT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SPOT", "SPOT", scopePath);
-    }
-
-    // Register enumeration Logger::Level.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Logger");
-        gameplay::ScriptUtil::registerConstantString("LEVEL_INFO", "LEVEL_INFO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LEVEL_WARN", "LEVEL_WARN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LEVEL_ERROR", "LEVEL_ERROR", scopePath);
-    }
-
-    // Register enumeration Mesh::IndexFormat.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Mesh");
-        gameplay::ScriptUtil::registerConstantString("INDEX8", "INDEX8", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INDEX16", "INDEX16", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INDEX32", "INDEX32", scopePath);
-    }
-
-    // Register enumeration Mesh::PrimitiveType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Mesh");
-        gameplay::ScriptUtil::registerConstantString("TRIANGLES", "TRIANGLES", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TRIANGLE_STRIP", "TRIANGLE_STRIP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINES", "LINES", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINE_STRIP", "LINE_STRIP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("POINTS", "POINTS", scopePath);
-    }
-
-    // Register enumeration Mouse::MouseEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Mouse");
-        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_LEFT_BUTTON", "MOUSE_PRESS_LEFT_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_LEFT_BUTTON", "MOUSE_RELEASE_LEFT_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_MIDDLE_BUTTON", "MOUSE_PRESS_MIDDLE_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_MIDDLE_BUTTON", "MOUSE_RELEASE_MIDDLE_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_RIGHT_BUTTON", "MOUSE_PRESS_RIGHT_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_RIGHT_BUTTON", "MOUSE_RELEASE_RIGHT_BUTTON", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_MOVE", "MOUSE_MOVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MOUSE_WHEEL", "MOUSE_WHEEL", scopePath);
-    }
-
-    // Register enumeration Node::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Node");
-        gameplay::ScriptUtil::registerConstantString("NODE", "NODE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("JOINT", "JOINT", scopePath);
-    }
-
-    // Register enumeration ParticleEmitter::TextureBlending.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("ParticleEmitter");
-        gameplay::ScriptUtil::registerConstantString("BLEND_OPAQUE", "BLEND_OPAQUE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_TRANSPARENT", "BLEND_TRANSPARENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ADDITIVE", "BLEND_ADDITIVE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_MULTIPLIED", "BLEND_MULTIPLIED", scopePath);
-    }
-
-    // Register enumeration PhysicsCollisionObject::CollisionListener::EventType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("PhysicsCollisionObject");
-        scopePath.push_back("CollisionListener");
-        gameplay::ScriptUtil::registerConstantString("COLLIDING", "COLLIDING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NOT_COLLIDING", "NOT_COLLIDING", scopePath);
-    }
-
-    // Register enumeration PhysicsCollisionObject::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("PhysicsCollisionObject");
-        gameplay::ScriptUtil::registerConstantString("RIGID_BODY", "RIGID_BODY", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CHARACTER", "CHARACTER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("GHOST_OBJECT", "GHOST_OBJECT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VEHICLE", "VEHICLE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VEHICLE_WHEEL", "VEHICLE_WHEEL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
-    }
-
-    // Register enumeration PhysicsCollisionShape::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("PhysicsCollisionShape");
-        gameplay::ScriptUtil::registerConstantString("SHAPE_NONE", "SHAPE_NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_BOX", "SHAPE_BOX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_SPHERE", "SHAPE_SPHERE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_CAPSULE", "SHAPE_CAPSULE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_MESH", "SHAPE_MESH", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SHAPE_HEIGHTFIELD", "SHAPE_HEIGHTFIELD", scopePath);
-    }
-
-    // Register enumeration PhysicsController::Listener::EventType.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("PhysicsController");
-        scopePath.push_back("Listener");
-        gameplay::ScriptUtil::registerConstantString("ACTIVATED", "ACTIVATED", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEACTIVATED", "DEACTIVATED", scopePath);
-    }
-
-    // Register enumeration Properties::Type.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Properties");
-        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STRING", "STRING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NUMBER", "NUMBER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VECTOR2", "VECTOR2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VECTOR3", "VECTOR3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VECTOR4", "VECTOR4", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MATRIX", "MATRIX", scopePath);
-    }
-
-    // Register enumeration RenderState::AutoBinding.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("WORLD_MATRIX", "WORLD_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VIEW_MATRIX", "VIEW_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PROJECTION_MATRIX", "PROJECTION_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("WORLD_VIEW_MATRIX", "WORLD_VIEW_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("VIEW_PROJECTION_MATRIX", "VIEW_PROJECTION_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("WORLD_VIEW_PROJECTION_MATRIX", "WORLD_VIEW_PROJECTION_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INVERSE_TRANSPOSE_WORLD_MATRIX", "INVERSE_TRANSPOSE_WORLD_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX", "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CAMERA_WORLD_POSITION", "CAMERA_WORLD_POSITION", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CAMERA_VIEW_POSITION", "CAMERA_VIEW_POSITION", scopePath);
-        gameplay::ScriptUtil::registerConstantString("MATRIX_PALETTE", "MATRIX_PALETTE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("SCENE_AMBIENT_COLOR", "SCENE_AMBIENT_COLOR", scopePath);
-    }
-
-    // Register enumeration RenderState::Blend.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("BLEND_ZERO", "BLEND_ZERO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE", "BLEND_ONE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_COLOR", "BLEND_SRC_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_SRC_COLOR", "BLEND_ONE_MINUS_SRC_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_DST_COLOR", "BLEND_DST_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_DST_COLOR", "BLEND_ONE_MINUS_DST_COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_ALPHA", "BLEND_SRC_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_SRC_ALPHA", "BLEND_ONE_MINUS_SRC_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_DST_ALPHA", "BLEND_DST_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_DST_ALPHA", "BLEND_ONE_MINUS_DST_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_CONSTANT_ALPHA", "BLEND_CONSTANT_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_CONSTANT_ALPHA", "BLEND_ONE_MINUS_CONSTANT_ALPHA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_ALPHA_SATURATE", "BLEND_SRC_ALPHA_SATURATE", scopePath);
-    }
-
-    // Register enumeration RenderState::CullFaceSide.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_BACK", "CULL_FACE_SIDE_BACK", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_FRONT", "CULL_FACE_SIDE_FRONT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_FRONT_AND_BACK", "CULL_FACE_SIDE_FRONT_AND_BACK", scopePath);
-    }
-
-    // Register enumeration RenderState::DepthFunction.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("DEPTH_NEVER", "DEPTH_NEVER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_LESS", "DEPTH_LESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_EQUAL", "DEPTH_EQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_LEQUAL", "DEPTH_LEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_GREATER", "DEPTH_GREATER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_NOTEQUAL", "DEPTH_NOTEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_GEQUAL", "DEPTH_GEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("DEPTH_ALWAYS", "DEPTH_ALWAYS", scopePath);
-    }
-
-    // Register enumeration RenderState::FrontFace.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("FRONT_FACE_CW", "FRONT_FACE_CW", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FRONT_FACE_CCW", "FRONT_FACE_CCW", scopePath);
-    }
-
-    // Register enumeration RenderState::StencilFunction.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("STENCIL_NEVER", "STENCIL_NEVER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_ALWAYS", "STENCIL_ALWAYS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_LESS", "STENCIL_LESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_LEQUAL", "STENCIL_LEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_EQUAL", "STENCIL_EQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_GREATER", "STENCIL_GREATER", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_GEQUAL", "STENCIL_GEQUAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_NOTEQUAL", "STENCIL_NOTEQUAL", scopePath);
-    }
-
-    // Register enumeration RenderState::StencilOperation.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("RenderState");
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_KEEP", "STENCIL_OP_KEEP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_ZERO", "STENCIL_OP_ZERO", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_REPLACE", "STENCIL_OP_REPLACE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR", "STENCIL_OP_INCR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR", "STENCIL_OP_DECR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INVERT", "STENCIL_OP_INVERT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR_WRAP", "STENCIL_OP_INCR_WRAP", scopePath);
-        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR_WRAP", "STENCIL_OP_DECR_WRAP", scopePath);
-    }
-
-    // Register enumeration Terrain::Flags.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Terrain");
-        gameplay::ScriptUtil::registerConstantString("DEBUG_PATCHES", "DEBUG_PATCHES", scopePath);
-        gameplay::ScriptUtil::registerConstantString("FRUSTUM_CULLING", "FRUSTUM_CULLING", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LEVEL_OF_DETAIL", "LEVEL_OF_DETAIL", scopePath);
-    }
-
-    // Register enumeration TextBox::InputMode.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("TextBox");
-        gameplay::ScriptUtil::registerConstantString("TEXT", "TEXT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("PASSWORD", "PASSWORD", scopePath);
-    }
-
-    // Register enumeration Texture::Filter.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Texture");
-        gameplay::ScriptUtil::registerConstantString("NEAREST", "NEAREST", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINEAR", "LINEAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NEAREST_MIPMAP_NEAREST", "NEAREST_MIPMAP_NEAREST", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINEAR_MIPMAP_NEAREST", "LINEAR_MIPMAP_NEAREST", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NEAREST_MIPMAP_LINEAR", "NEAREST_MIPMAP_LINEAR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("LINEAR_MIPMAP_LINEAR", "LINEAR_MIPMAP_LINEAR", scopePath);
-    }
-
-    // Register enumeration Texture::Format.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Texture");
-        gameplay::ScriptUtil::registerConstantString("UNKNOWN", "UNKNOWN", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RGB", "RGB", scopePath);
-        gameplay::ScriptUtil::registerConstantString("RGBA", "RGBA", scopePath);
-        gameplay::ScriptUtil::registerConstantString("ALPHA", "ALPHA", scopePath);
-    }
-
-    // Register enumeration Texture::Wrap.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Texture");
-        gameplay::ScriptUtil::registerConstantString("REPEAT", "REPEAT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("CLAMP", "CLAMP", scopePath);
-    }
-
-    // Register enumeration Touch::TouchEvent.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("Touch");
-        gameplay::ScriptUtil::registerConstantString("TOUCH_PRESS", "TOUCH_PRESS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TOUCH_RELEASE", "TOUCH_RELEASE", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TOUCH_MOVE", "TOUCH_MOVE", scopePath);
-    }
-
-    // Register enumeration VertexFormat::Usage.
-    {
-        std::vector<std::string> scopePath;
-        scopePath.push_back("VertexFormat");
-        gameplay::ScriptUtil::registerConstantString("POSITION", "POSITION", scopePath);
-        gameplay::ScriptUtil::registerConstantString("NORMAL", "NORMAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("COLOR", "COLOR", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TANGENT", "TANGENT", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BINORMAL", "BINORMAL", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLENDWEIGHTS", "BLENDWEIGHTS", scopePath);
-        gameplay::ScriptUtil::registerConstantString("BLENDINDICES", "BLENDINDICES", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD0", "TEXCOORD0", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD1", "TEXCOORD1", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD2", "TEXCOORD2", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD3", "TEXCOORD3", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD4", "TEXCOORD4", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD5", "TEXCOORD5", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD6", "TEXCOORD6", scopePath);
-        gameplay::ScriptUtil::registerConstantString("TEXCOORD7", "TEXCOORD7", scopePath);
-    }
-}
-
-static const char* enumStringEmpty = "";
-
-const char* lua_stringFromEnumGlobal(std::string& enumname, unsigned int value)
-{
-    if (enumname == "AIMessage::ParameterType")
-        return lua_stringFromEnum_AIMessageParameterType((AIMessage::ParameterType)value);
-    if (enumname == "AnimationClip::Listener::EventType")
-        return lua_stringFromEnum_AnimationClipListenerEventType((AnimationClip::Listener::EventType)value);
-    if (enumname == "AudioSource::State")
-        return lua_stringFromEnum_AudioSourceState((AudioSource::State)value);
-    if (enumname == "Camera::Type")
-        return lua_stringFromEnum_CameraType((Camera::Type)value);
-    if (enumname == "Container::Scroll")
-        return lua_stringFromEnum_ContainerScroll((Container::Scroll)value);
-    if (enumname == "Control::Alignment")
-        return lua_stringFromEnum_ControlAlignment((Control::Alignment)value);
-    if (enumname == "Control::AutoSize")
-        return lua_stringFromEnum_ControlAutoSize((Control::AutoSize)value);
-    if (enumname == "Control::Listener::EventType")
-        return lua_stringFromEnum_ControlListenerEventType((Control::Listener::EventType)value);
-    if (enumname == "Control::State")
-        return lua_stringFromEnum_ControlState((Control::State)value);
-    if (enumname == "Curve::InterpolationType")
-        return lua_stringFromEnum_CurveInterpolationType((Curve::InterpolationType)value);
-    if (enumname == "DepthStencilTarget::Format")
-        return lua_stringFromEnum_DepthStencilTargetFormat((DepthStencilTarget::Format)value);
-    if (enumname == "Font::Format")
-        return lua_stringFromEnum_FontFormat((Font::Format)value);
-    if (enumname == "Font::Justify")
-        return lua_stringFromEnum_FontJustify((Font::Justify)value);
-    if (enumname == "Font::Style")
-        return lua_stringFromEnum_FontStyle((Font::Style)value);
-    if (enumname == "Game::ClearFlags")
-        return lua_stringFromEnum_GameClearFlags((Game::ClearFlags)value);
-    if (enumname == "Game::State")
-        return lua_stringFromEnum_GameState((Game::State)value);
-    if (enumname == "Gamepad::ButtonMapping")
-        return lua_stringFromEnum_GamepadButtonMapping((Gamepad::ButtonMapping)value);
-    if (enumname == "Gamepad::GamepadEvent")
-        return lua_stringFromEnum_GamepadGamepadEvent((Gamepad::GamepadEvent)value);
-    if (enumname == "Gesture::GestureEvent")
-        return lua_stringFromEnum_GestureGestureEvent((Gesture::GestureEvent)value);
-    if (enumname == "Image::Format")
-        return lua_stringFromEnum_ImageFormat((Image::Format)value);
-    if (enumname == "Keyboard::Key")
-        return lua_stringFromEnum_KeyboardKey((Keyboard::Key)value);
-    if (enumname == "Keyboard::KeyEvent")
-        return lua_stringFromEnum_KeyboardKeyEvent((Keyboard::KeyEvent)value);
-    if (enumname == "Layout::Type")
-        return lua_stringFromEnum_LayoutType((Layout::Type)value);
-    if (enumname == "Light::Type")
-        return lua_stringFromEnum_LightType((Light::Type)value);
-    if (enumname == "Logger::Level")
-        return lua_stringFromEnum_LoggerLevel((Logger::Level)value);
-    if (enumname == "Mesh::IndexFormat")
-        return lua_stringFromEnum_MeshIndexFormat((Mesh::IndexFormat)value);
-    if (enumname == "Mesh::PrimitiveType")
-        return lua_stringFromEnum_MeshPrimitiveType((Mesh::PrimitiveType)value);
-    if (enumname == "Mouse::MouseEvent")
-        return lua_stringFromEnum_MouseMouseEvent((Mouse::MouseEvent)value);
-    if (enumname == "Node::Type")
-        return lua_stringFromEnum_NodeType((Node::Type)value);
-    if (enumname == "ParticleEmitter::TextureBlending")
-        return lua_stringFromEnum_ParticleEmitterTextureBlending((ParticleEmitter::TextureBlending)value);
-    if (enumname == "PhysicsCollisionObject::CollisionListener::EventType")
-        return lua_stringFromEnum_PhysicsCollisionObjectCollisionListenerEventType((PhysicsCollisionObject::CollisionListener::EventType)value);
-    if (enumname == "PhysicsCollisionObject::Type")
-        return lua_stringFromEnum_PhysicsCollisionObjectType((PhysicsCollisionObject::Type)value);
-    if (enumname == "PhysicsCollisionShape::Type")
-        return lua_stringFromEnum_PhysicsCollisionShapeType((PhysicsCollisionShape::Type)value);
-    if (enumname == "PhysicsController::Listener::EventType")
-        return lua_stringFromEnum_PhysicsControllerListenerEventType((PhysicsController::Listener::EventType)value);
-    if (enumname == "Properties::Type")
-        return lua_stringFromEnum_PropertiesType((Properties::Type)value);
-    if (enumname == "RenderState::AutoBinding")
-        return lua_stringFromEnum_RenderStateAutoBinding((RenderState::AutoBinding)value);
-    if (enumname == "RenderState::Blend")
-        return lua_stringFromEnum_RenderStateBlend((RenderState::Blend)value);
-    if (enumname == "RenderState::CullFaceSide")
-        return lua_stringFromEnum_RenderStateCullFaceSide((RenderState::CullFaceSide)value);
-    if (enumname == "RenderState::DepthFunction")
-        return lua_stringFromEnum_RenderStateDepthFunction((RenderState::DepthFunction)value);
-    if (enumname == "RenderState::FrontFace")
-        return lua_stringFromEnum_RenderStateFrontFace((RenderState::FrontFace)value);
-    if (enumname == "RenderState::StencilFunction")
-        return lua_stringFromEnum_RenderStateStencilFunction((RenderState::StencilFunction)value);
-    if (enumname == "RenderState::StencilOperation")
-        return lua_stringFromEnum_RenderStateStencilOperation((RenderState::StencilOperation)value);
-    if (enumname == "Terrain::Flags")
-        return lua_stringFromEnum_TerrainFlags((Terrain::Flags)value);
-    if (enumname == "TextBox::InputMode")
-        return lua_stringFromEnum_TextBoxInputMode((TextBox::InputMode)value);
-    if (enumname == "Texture::Filter")
-        return lua_stringFromEnum_TextureFilter((Texture::Filter)value);
-    if (enumname == "Texture::Format")
-        return lua_stringFromEnum_TextureFormat((Texture::Format)value);
-    if (enumname == "Texture::Wrap")
-        return lua_stringFromEnum_TextureWrap((Texture::Wrap)value);
-    if (enumname == "Touch::TouchEvent")
-        return lua_stringFromEnum_TouchTouchEvent((Touch::TouchEvent)value);
-    if (enumname == "VertexFormat::Usage")
-        return lua_stringFromEnum_VertexFormatUsage((VertexFormat::Usage)value);
-
-    GP_ERROR("Unrecognized enumeration type '%s'.", enumname.c_str());
-    return enumStringEmpty;
-}
-
-}
+#include "ScriptController.h"
+#include "lua_Global.h"
+
+namespace gameplay
+{
+
+void luaRegister_lua_Global()
+{
+    gameplay::ScriptUtil::registerFunction("strcmpnocase", lua__strcmpnocase);
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Container");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Control");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "ImageControl");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Joystick");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Label");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "MaterialParameter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Node");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("AnimationTarget", "Transform");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Button", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Button", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Camera::Listener", "AudioListener");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Camera::Listener", "TerrainPatch");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Container", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Container");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "ImageControl");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Joystick");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Label");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Control", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Label", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "AbsoluteLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "FlowLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Layout", "VerticalLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Node", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsCharacter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsGhostObject");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsRigidBody");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsVehicle");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsCollisionObject", "PhysicsVehicleWheel");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsFixedConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsGenericConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsHingeConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsSocketConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsConstraint", "PhysicsSpringConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGenericConstraint", "PhysicsFixedConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGenericConstraint", "PhysicsSpringConstraint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("PhysicsGhostObject", "PhysicsCharacter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AIAgent");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AIState");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AbsoluteLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Animation");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AnimationClip");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AudioBuffer");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "AudioSource");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Bundle");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Camera");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Container");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Control");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Curve");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "DepthStencilTarget");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Effect");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "FlowLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Font");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "FrameBuffer");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "HeightField");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Image");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "ImageControl");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Joystick");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Label");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Layout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Light");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Material");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "MaterialParameter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Mesh");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Model");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Node");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "ParticleEmitter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Pass");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "PhysicsCollisionShape");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderState");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderState::StateBlock");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "RenderTarget");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Scene");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Technique");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Terrain");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Texture");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Texture::Sampler");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Theme");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "Theme::ThemeImage");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "VertexAttributeBinding");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Ref", "VerticalLayout");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Material");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Pass");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("RenderState", "Technique");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "AIAgent");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "AIState");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Button");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "CheckBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Container");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Control");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Form");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "ImageControl");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Joystick");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Label");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Node");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "PhysicsController");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "RadioButton");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Slider");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "TextBox");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("ScriptTarget", "Transform");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform", "Joint");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform", "Node");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "AudioSource");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "Camera");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "MeshSkin");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsCharacter");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsGhostObject");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "PhysicsRigidBody");
+    gameplay::ScriptUtil::setGlobalHierarchyPair("Transform::Listener", "Terrain");
+    gameplay::ScriptUtil::addStringFromEnumConversionFunction(&gameplay::lua_stringFromEnumGlobal);
+
+    // Register enumeration AIMessage::ParameterType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("AIMessage");
+        gameplay::ScriptUtil::registerConstantString("UNDEFINED", "UNDEFINED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INTEGER", "INTEGER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LONG", "LONG", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FLOAT", "FLOAT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DOUBLE", "DOUBLE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOOLEAN", "BOOLEAN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STRING", "STRING", scopePath);
+    }
+
+    // Register enumeration AnimationClip::Listener::EventType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("AnimationClip");
+        scopePath.push_back("Listener");
+        gameplay::ScriptUtil::registerConstantString("BEGIN", "BEGIN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("END", "END", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TIME", "TIME", scopePath);
+    }
+
+    // Register enumeration AudioSource::State.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("AudioSource");
+        gameplay::ScriptUtil::registerConstantString("INITIAL", "INITIAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PLAYING", "PLAYING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PAUSED", "PAUSED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STOPPED", "STOPPED", scopePath);
+    }
+
+    // Register enumeration Camera::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Camera");
+        gameplay::ScriptUtil::registerConstantString("PERSPECTIVE", "PERSPECTIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ORTHOGRAPHIC", "ORTHOGRAPHIC", scopePath);
+    }
+
+    // Register enumeration Container::Scroll.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Container");
+        gameplay::ScriptUtil::registerConstantString("SCROLL_NONE", "SCROLL_NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SCROLL_HORIZONTAL", "SCROLL_HORIZONTAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SCROLL_VERTICAL", "SCROLL_VERTICAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SCROLL_BOTH", "SCROLL_BOTH", scopePath);
+    }
+
+    // Register enumeration Control::Alignment.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Control");
+        gameplay::ScriptUtil::registerConstantString("ALIGN_LEFT", "ALIGN_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_HCENTER", "ALIGN_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_RIGHT", "ALIGN_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP", "ALIGN_TOP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER", "ALIGN_VCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM", "ALIGN_BOTTOM", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_LEFT", "ALIGN_TOP_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_LEFT", "ALIGN_VCENTER_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_LEFT", "ALIGN_BOTTOM_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_HCENTER", "ALIGN_TOP_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_HCENTER", "ALIGN_VCENTER_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_HCENTER", "ALIGN_BOTTOM_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_RIGHT", "ALIGN_TOP_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_RIGHT", "ALIGN_VCENTER_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_RIGHT", "ALIGN_BOTTOM_RIGHT", scopePath);
+    }
+
+    // Register enumeration Control::AutoSize.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Control");
+        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_NONE", "AUTO_SIZE_NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_STRETCH", "AUTO_SIZE_STRETCH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("AUTO_SIZE_FIT", "AUTO_SIZE_FIT", scopePath);
+    }
+
+    // Register enumeration Control::Listener::EventType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Control");
+        scopePath.push_back("Listener");
+        gameplay::ScriptUtil::registerConstantString("PRESS", "PRESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RELEASE", "RELEASE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLICK", "CLICK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VALUE_CHANGED", "VALUE_CHANGED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXT_CHANGED", "TEXT_CHANGED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MIDDLE_CLICK", "MIDDLE_CLICK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RIGHT_CLICK", "RIGHT_CLICK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ENTER", "ENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LEAVE", "LEAVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FOCUS_GAINED", "FOCUS_GAINED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FOCUS_LOST", "FOCUS_LOST", scopePath);
+    }
+
+    // Register enumeration Control::State.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Control");
+        gameplay::ScriptUtil::registerConstantString("NORMAL", "NORMAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FOCUS", "FOCUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ACTIVE", "ACTIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DISABLED", "DISABLED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("HOVER", "HOVER", scopePath);
+    }
+
+    // Register enumeration Curve::InterpolationType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Curve");
+        gameplay::ScriptUtil::registerConstantString("BEZIER", "BEZIER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BSPLINE", "BSPLINE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FLAT", "FLAT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("HERMITE", "HERMITE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINEAR", "LINEAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SMOOTH", "SMOOTH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STEP", "STEP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUADRATIC_IN", "QUADRATIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUADRATIC_OUT", "QUADRATIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUADRATIC_IN_OUT", "QUADRATIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUADRATIC_OUT_IN", "QUADRATIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CUBIC_IN", "CUBIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CUBIC_OUT", "CUBIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CUBIC_IN_OUT", "CUBIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CUBIC_OUT_IN", "CUBIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUARTIC_IN", "QUARTIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUARTIC_OUT", "QUARTIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUARTIC_IN_OUT", "QUARTIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUARTIC_OUT_IN", "QUARTIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUINTIC_IN", "QUINTIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUINTIC_OUT", "QUINTIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUINTIC_IN_OUT", "QUINTIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("QUINTIC_OUT_IN", "QUINTIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SINE_IN", "SINE_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SINE_OUT", "SINE_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SINE_IN_OUT", "SINE_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SINE_OUT_IN", "SINE_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_IN", "EXPONENTIAL_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_OUT", "EXPONENTIAL_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_IN_OUT", "EXPONENTIAL_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("EXPONENTIAL_OUT_IN", "EXPONENTIAL_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CIRCULAR_IN", "CIRCULAR_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CIRCULAR_OUT", "CIRCULAR_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CIRCULAR_IN_OUT", "CIRCULAR_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CIRCULAR_OUT_IN", "CIRCULAR_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ELASTIC_IN", "ELASTIC_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ELASTIC_OUT", "ELASTIC_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ELASTIC_IN_OUT", "ELASTIC_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ELASTIC_OUT_IN", "ELASTIC_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_IN", "OVERSHOOT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_OUT", "OVERSHOOT_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_IN_OUT", "OVERSHOOT_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("OVERSHOOT_OUT_IN", "OVERSHOOT_OUT_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOUNCE_IN", "BOUNCE_IN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOUNCE_OUT", "BOUNCE_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOUNCE_IN_OUT", "BOUNCE_IN_OUT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOUNCE_OUT_IN", "BOUNCE_OUT_IN", scopePath);
+    }
+
+    // Register enumeration DepthStencilTarget::Format.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("DepthStencilTarget");
+        gameplay::ScriptUtil::registerConstantString("DEPTH", "DEPTH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_STENCIL", "DEPTH_STENCIL", scopePath);
+    }
+
+    // Register enumeration Font::Format.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Font");
+        gameplay::ScriptUtil::registerConstantString("BITMAP", "BITMAP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DISTANCE_FIELD", "DISTANCE_FIELD", scopePath);
+    }
+
+    // Register enumeration Font::Justify.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Font");
+        gameplay::ScriptUtil::registerConstantString("ALIGN_LEFT", "ALIGN_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_HCENTER", "ALIGN_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_RIGHT", "ALIGN_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP", "ALIGN_TOP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER", "ALIGN_VCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM", "ALIGN_BOTTOM", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_LEFT", "ALIGN_TOP_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_LEFT", "ALIGN_VCENTER_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_LEFT", "ALIGN_BOTTOM_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_HCENTER", "ALIGN_TOP_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_HCENTER", "ALIGN_VCENTER_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_HCENTER", "ALIGN_BOTTOM_HCENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_TOP_RIGHT", "ALIGN_TOP_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_VCENTER_RIGHT", "ALIGN_VCENTER_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALIGN_BOTTOM_RIGHT", "ALIGN_BOTTOM_RIGHT", scopePath);
+    }
+
+    // Register enumeration Font::Style.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Font");
+        gameplay::ScriptUtil::registerConstantString("PLAIN", "PLAIN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOLD", "BOLD", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ITALIC", "ITALIC", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BOLD_ITALIC", "BOLD_ITALIC", scopePath);
+    }
+
+    // Register enumeration Game::ClearFlags.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Game");
+        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR", "CLEAR_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_DEPTH", "CLEAR_DEPTH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_STENCIL", "CLEAR_STENCIL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_DEPTH", "CLEAR_COLOR_DEPTH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_STENCIL", "CLEAR_COLOR_STENCIL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_DEPTH_STENCIL", "CLEAR_DEPTH_STENCIL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLEAR_COLOR_DEPTH_STENCIL", "CLEAR_COLOR_DEPTH_STENCIL", scopePath);
+    }
+
+    // Register enumeration Game::State.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Game");
+        gameplay::ScriptUtil::registerConstantString("UNINITIALIZED", "UNINITIALIZED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RUNNING", "RUNNING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PAUSED", "PAUSED", scopePath);
+    }
+
+    // Register enumeration Gamepad::ButtonMapping.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Gamepad");
+        gameplay::ScriptUtil::registerConstantString("BUTTON_A", "BUTTON_A", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_B", "BUTTON_B", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_C", "BUTTON_C", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_X", "BUTTON_X", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_Y", "BUTTON_Y", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_Z", "BUTTON_Z", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU1", "BUTTON_MENU1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU2", "BUTTON_MENU2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU3", "BUTTON_MENU3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_MENU4", "BUTTON_MENU4", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_L1", "BUTTON_L1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_L2", "BUTTON_L2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_L3", "BUTTON_L3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_R1", "BUTTON_R1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_R2", "BUTTON_R2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_R3", "BUTTON_R3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_UP", "BUTTON_UP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_DOWN", "BUTTON_DOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_LEFT", "BUTTON_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_RIGHT", "BUTTON_RIGHT", scopePath);
+    }
+
+    // Register enumeration Gamepad::GamepadEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Gamepad");
+        gameplay::ScriptUtil::registerConstantString("CONNECTED_EVENT", "CONNECTED_EVENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DISCONNECTED_EVENT", "DISCONNECTED_EVENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BUTTON_EVENT", "BUTTON_EVENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("JOYSTICK_EVENT", "JOYSTICK_EVENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TRIGGER_EVENT", "TRIGGER_EVENT", scopePath);
+    }
+
+    // Register enumeration Gesture::GestureEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Gesture");
+        gameplay::ScriptUtil::registerConstantString("GESTURE_TAP", "GESTURE_TAP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GESTURE_SWIPE", "GESTURE_SWIPE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GESTURE_PINCH", "GESTURE_PINCH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GESTURE_LONG_TAP", "GESTURE_LONG_TAP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GESTURE_DRAG", "GESTURE_DRAG", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GESTURE_DROP", "GESTURE_DROP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GESTURE_ANY_SUPPORTED", "GESTURE_ANY_SUPPORTED", scopePath);
+    }
+
+    // Register enumeration Image::Format.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Image");
+        gameplay::ScriptUtil::registerConstantString("RGB", "RGB", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RGBA", "RGBA", scopePath);
+    }
+
+    // Register enumeration Keyboard::Key.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Keyboard");
+        gameplay::ScriptUtil::registerConstantString("KEY_NONE", "KEY_NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PAUSE", "KEY_PAUSE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SCROLL_LOCK", "KEY_SCROLL_LOCK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PRINT", "KEY_PRINT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SYSREQ", "KEY_SYSREQ", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BREAK", "KEY_BREAK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ESCAPE", "KEY_ESCAPE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BACKSPACE", "KEY_BACKSPACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_TAB", "KEY_TAB", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BACK_TAB", "KEY_BACK_TAB", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RETURN", "KEY_RETURN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPS_LOCK", "KEY_CAPS_LOCK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SHIFT", "KEY_SHIFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CTRL", "KEY_CTRL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ALT", "KEY_ALT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_MENU", "KEY_MENU", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_HYPER", "KEY_HYPER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_INSERT", "KEY_INSERT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_HOME", "KEY_HOME", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PG_UP", "KEY_PG_UP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_DELETE", "KEY_DELETE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_END", "KEY_END", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PG_DOWN", "KEY_PG_DOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_ARROW", "KEY_LEFT_ARROW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_ARROW", "KEY_RIGHT_ARROW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_UP_ARROW", "KEY_UP_ARROW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_DOWN_ARROW", "KEY_DOWN_ARROW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_NUM_LOCK", "KEY_NUM_LOCK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_PLUS", "KEY_KP_PLUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_MINUS", "KEY_KP_MINUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_MULTIPLY", "KEY_KP_MULTIPLY", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_DIVIDE", "KEY_KP_DIVIDE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_ENTER", "KEY_KP_ENTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_HOME", "KEY_KP_HOME", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_UP", "KEY_KP_UP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_PG_UP", "KEY_KP_PG_UP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_LEFT", "KEY_KP_LEFT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_FIVE", "KEY_KP_FIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_RIGHT", "KEY_KP_RIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_END", "KEY_KP_END", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_DOWN", "KEY_KP_DOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_PG_DOWN", "KEY_KP_PG_DOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_INSERT", "KEY_KP_INSERT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_KP_DELETE", "KEY_KP_DELETE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F1", "KEY_F1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F2", "KEY_F2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F3", "KEY_F3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F4", "KEY_F4", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F5", "KEY_F5", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F6", "KEY_F6", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F7", "KEY_F7", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F8", "KEY_F8", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F9", "KEY_F9", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F10", "KEY_F10", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F11", "KEY_F11", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F12", "KEY_F12", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SPACE", "KEY_SPACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_EXCLAM", "KEY_EXCLAM", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_QUOTE", "KEY_QUOTE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_NUMBER", "KEY_NUMBER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_DOLLAR", "KEY_DOLLAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PERCENT", "KEY_PERCENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CIRCUMFLEX", "KEY_CIRCUMFLEX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_AMPERSAND", "KEY_AMPERSAND", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_APOSTROPHE", "KEY_APOSTROPHE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_PARENTHESIS", "KEY_LEFT_PARENTHESIS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_PARENTHESIS", "KEY_RIGHT_PARENTHESIS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ASTERISK", "KEY_ASTERISK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PLUS", "KEY_PLUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_COMMA", "KEY_COMMA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_MINUS", "KEY_MINUS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_PERIOD", "KEY_PERIOD", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SLASH", "KEY_SLASH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ZERO", "KEY_ZERO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_ONE", "KEY_ONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_TWO", "KEY_TWO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_THREE", "KEY_THREE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_FOUR", "KEY_FOUR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_FIVE", "KEY_FIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SIX", "KEY_SIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SEVEN", "KEY_SEVEN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_EIGHT", "KEY_EIGHT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_NINE", "KEY_NINE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_COLON", "KEY_COLON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SEMICOLON", "KEY_SEMICOLON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LESS_THAN", "KEY_LESS_THAN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_EQUAL", "KEY_EQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_GREATER_THAN", "KEY_GREATER_THAN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_QUESTION", "KEY_QUESTION", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_AT", "KEY_AT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_A", "KEY_CAPITAL_A", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_B", "KEY_CAPITAL_B", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_C", "KEY_CAPITAL_C", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_D", "KEY_CAPITAL_D", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_E", "KEY_CAPITAL_E", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_F", "KEY_CAPITAL_F", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_G", "KEY_CAPITAL_G", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_H", "KEY_CAPITAL_H", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_I", "KEY_CAPITAL_I", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_J", "KEY_CAPITAL_J", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_K", "KEY_CAPITAL_K", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_L", "KEY_CAPITAL_L", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_M", "KEY_CAPITAL_M", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_N", "KEY_CAPITAL_N", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_O", "KEY_CAPITAL_O", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_P", "KEY_CAPITAL_P", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Q", "KEY_CAPITAL_Q", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_R", "KEY_CAPITAL_R", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_S", "KEY_CAPITAL_S", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_T", "KEY_CAPITAL_T", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_U", "KEY_CAPITAL_U", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_V", "KEY_CAPITAL_V", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_W", "KEY_CAPITAL_W", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_X", "KEY_CAPITAL_X", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Y", "KEY_CAPITAL_Y", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CAPITAL_Z", "KEY_CAPITAL_Z", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_BRACKET", "KEY_LEFT_BRACKET", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BACK_SLASH", "KEY_BACK_SLASH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_BRACKET", "KEY_RIGHT_BRACKET", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_UNDERSCORE", "KEY_UNDERSCORE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_GRAVE", "KEY_GRAVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_A", "KEY_A", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_B", "KEY_B", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_C", "KEY_C", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_D", "KEY_D", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_E", "KEY_E", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_F", "KEY_F", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_G", "KEY_G", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_H", "KEY_H", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_I", "KEY_I", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_J", "KEY_J", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_K", "KEY_K", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_L", "KEY_L", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_M", "KEY_M", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_N", "KEY_N", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_O", "KEY_O", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_P", "KEY_P", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_Q", "KEY_Q", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_R", "KEY_R", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_S", "KEY_S", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_T", "KEY_T", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_U", "KEY_U", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_V", "KEY_V", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_W", "KEY_W", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_X", "KEY_X", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_Y", "KEY_Y", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_Z", "KEY_Z", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_LEFT_BRACE", "KEY_LEFT_BRACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_BAR", "KEY_BAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RIGHT_BRACE", "KEY_RIGHT_BRACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_TILDE", "KEY_TILDE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_EURO", "KEY_EURO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_POUND", "KEY_POUND", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_YEN", "KEY_YEN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_MIDDLE_DOT", "KEY_MIDDLE_DOT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_SEARCH", "KEY_SEARCH", scopePath);
+    }
+
+    // Register enumeration Keyboard::KeyEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Keyboard");
+        gameplay::ScriptUtil::registerConstantString("KEY_PRESS", "KEY_PRESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_RELEASE", "KEY_RELEASE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("KEY_CHAR", "KEY_CHAR", scopePath);
+    }
+
+    // Register enumeration Layout::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Layout");
+        gameplay::ScriptUtil::registerConstantString("LAYOUT_FLOW", "LAYOUT_FLOW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LAYOUT_VERTICAL", "LAYOUT_VERTICAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LAYOUT_ABSOLUTE", "LAYOUT_ABSOLUTE", scopePath);
+    }
+
+    // Register enumeration Light::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Light");
+        gameplay::ScriptUtil::registerConstantString("DIRECTIONAL", "DIRECTIONAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("POINT", "POINT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SPOT", "SPOT", scopePath);
+    }
+
+    // Register enumeration Logger::Level.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Logger");
+        gameplay::ScriptUtil::registerConstantString("LEVEL_INFO", "LEVEL_INFO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LEVEL_WARN", "LEVEL_WARN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LEVEL_ERROR", "LEVEL_ERROR", scopePath);
+    }
+
+    // Register enumeration Mesh::IndexFormat.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Mesh");
+        gameplay::ScriptUtil::registerConstantString("INDEX8", "INDEX8", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INDEX16", "INDEX16", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INDEX32", "INDEX32", scopePath);
+    }
+
+    // Register enumeration Mesh::PrimitiveType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Mesh");
+        gameplay::ScriptUtil::registerConstantString("TRIANGLES", "TRIANGLES", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TRIANGLE_STRIP", "TRIANGLE_STRIP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINES", "LINES", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINE_STRIP", "LINE_STRIP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("POINTS", "POINTS", scopePath);
+    }
+
+    // Register enumeration Mouse::MouseEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Mouse");
+        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_LEFT_BUTTON", "MOUSE_PRESS_LEFT_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_LEFT_BUTTON", "MOUSE_RELEASE_LEFT_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_MIDDLE_BUTTON", "MOUSE_PRESS_MIDDLE_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_MIDDLE_BUTTON", "MOUSE_RELEASE_MIDDLE_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_PRESS_RIGHT_BUTTON", "MOUSE_PRESS_RIGHT_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_RELEASE_RIGHT_BUTTON", "MOUSE_RELEASE_RIGHT_BUTTON", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_MOVE", "MOUSE_MOVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MOUSE_WHEEL", "MOUSE_WHEEL", scopePath);
+    }
+
+    // Register enumeration Node::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Node");
+        gameplay::ScriptUtil::registerConstantString("NODE", "NODE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("JOINT", "JOINT", scopePath);
+    }
+
+    // Register enumeration ParticleEmitter::TextureBlending.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("ParticleEmitter");
+        gameplay::ScriptUtil::registerConstantString("BLEND_OPAQUE", "BLEND_OPAQUE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_TRANSPARENT", "BLEND_TRANSPARENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ADDITIVE", "BLEND_ADDITIVE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_MULTIPLIED", "BLEND_MULTIPLIED", scopePath);
+    }
+
+    // Register enumeration PhysicsCollisionObject::CollisionListener::EventType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("PhysicsCollisionObject");
+        scopePath.push_back("CollisionListener");
+        gameplay::ScriptUtil::registerConstantString("COLLIDING", "COLLIDING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NOT_COLLIDING", "NOT_COLLIDING", scopePath);
+    }
+
+    // Register enumeration PhysicsCollisionObject::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("PhysicsCollisionObject");
+        gameplay::ScriptUtil::registerConstantString("RIGID_BODY", "RIGID_BODY", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CHARACTER", "CHARACTER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("GHOST_OBJECT", "GHOST_OBJECT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VEHICLE", "VEHICLE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VEHICLE_WHEEL", "VEHICLE_WHEEL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
+    }
+
+    // Register enumeration PhysicsCollisionShape::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("PhysicsCollisionShape");
+        gameplay::ScriptUtil::registerConstantString("SHAPE_NONE", "SHAPE_NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_BOX", "SHAPE_BOX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_SPHERE", "SHAPE_SPHERE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_CAPSULE", "SHAPE_CAPSULE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_MESH", "SHAPE_MESH", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SHAPE_HEIGHTFIELD", "SHAPE_HEIGHTFIELD", scopePath);
+    }
+
+    // Register enumeration PhysicsController::Listener::EventType.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("PhysicsController");
+        scopePath.push_back("Listener");
+        gameplay::ScriptUtil::registerConstantString("ACTIVATED", "ACTIVATED", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEACTIVATED", "DEACTIVATED", scopePath);
+    }
+
+    // Register enumeration Properties::Type.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Properties");
+        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STRING", "STRING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NUMBER", "NUMBER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VECTOR2", "VECTOR2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VECTOR3", "VECTOR3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VECTOR4", "VECTOR4", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MATRIX", "MATRIX", scopePath);
+    }
+
+    // Register enumeration RenderState::AutoBinding.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("NONE", "NONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("WORLD_MATRIX", "WORLD_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VIEW_MATRIX", "VIEW_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PROJECTION_MATRIX", "PROJECTION_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("WORLD_VIEW_MATRIX", "WORLD_VIEW_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("VIEW_PROJECTION_MATRIX", "VIEW_PROJECTION_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("WORLD_VIEW_PROJECTION_MATRIX", "WORLD_VIEW_PROJECTION_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INVERSE_TRANSPOSE_WORLD_MATRIX", "INVERSE_TRANSPOSE_WORLD_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX", "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CAMERA_WORLD_POSITION", "CAMERA_WORLD_POSITION", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CAMERA_VIEW_POSITION", "CAMERA_VIEW_POSITION", scopePath);
+        gameplay::ScriptUtil::registerConstantString("MATRIX_PALETTE", "MATRIX_PALETTE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("SCENE_AMBIENT_COLOR", "SCENE_AMBIENT_COLOR", scopePath);
+    }
+
+    // Register enumeration RenderState::Blend.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("BLEND_ZERO", "BLEND_ZERO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE", "BLEND_ONE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_COLOR", "BLEND_SRC_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_SRC_COLOR", "BLEND_ONE_MINUS_SRC_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_DST_COLOR", "BLEND_DST_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_DST_COLOR", "BLEND_ONE_MINUS_DST_COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_ALPHA", "BLEND_SRC_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_SRC_ALPHA", "BLEND_ONE_MINUS_SRC_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_DST_ALPHA", "BLEND_DST_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_DST_ALPHA", "BLEND_ONE_MINUS_DST_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_CONSTANT_ALPHA", "BLEND_CONSTANT_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_CONSTANT_ALPHA", "BLEND_ONE_MINUS_CONSTANT_ALPHA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLEND_SRC_ALPHA_SATURATE", "BLEND_SRC_ALPHA_SATURATE", scopePath);
+    }
+
+    // Register enumeration RenderState::CullFaceSide.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_BACK", "CULL_FACE_SIDE_BACK", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_FRONT", "CULL_FACE_SIDE_FRONT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CULL_FACE_SIDE_FRONT_AND_BACK", "CULL_FACE_SIDE_FRONT_AND_BACK", scopePath);
+    }
+
+    // Register enumeration RenderState::DepthFunction.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("DEPTH_NEVER", "DEPTH_NEVER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_LESS", "DEPTH_LESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_EQUAL", "DEPTH_EQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_LEQUAL", "DEPTH_LEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_GREATER", "DEPTH_GREATER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_NOTEQUAL", "DEPTH_NOTEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_GEQUAL", "DEPTH_GEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("DEPTH_ALWAYS", "DEPTH_ALWAYS", scopePath);
+    }
+
+    // Register enumeration RenderState::FrontFace.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("FRONT_FACE_CW", "FRONT_FACE_CW", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FRONT_FACE_CCW", "FRONT_FACE_CCW", scopePath);
+    }
+
+    // Register enumeration RenderState::StencilFunction.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("STENCIL_NEVER", "STENCIL_NEVER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_ALWAYS", "STENCIL_ALWAYS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_LESS", "STENCIL_LESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_LEQUAL", "STENCIL_LEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_EQUAL", "STENCIL_EQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_GREATER", "STENCIL_GREATER", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_GEQUAL", "STENCIL_GEQUAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_NOTEQUAL", "STENCIL_NOTEQUAL", scopePath);
+    }
+
+    // Register enumeration RenderState::StencilOperation.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("RenderState");
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_KEEP", "STENCIL_OP_KEEP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_ZERO", "STENCIL_OP_ZERO", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_REPLACE", "STENCIL_OP_REPLACE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR", "STENCIL_OP_INCR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR", "STENCIL_OP_DECR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INVERT", "STENCIL_OP_INVERT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_INCR_WRAP", "STENCIL_OP_INCR_WRAP", scopePath);
+        gameplay::ScriptUtil::registerConstantString("STENCIL_OP_DECR_WRAP", "STENCIL_OP_DECR_WRAP", scopePath);
+    }
+
+    // Register enumeration Terrain::Flags.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Terrain");
+        gameplay::ScriptUtil::registerConstantString("DEBUG_PATCHES", "DEBUG_PATCHES", scopePath);
+        gameplay::ScriptUtil::registerConstantString("FRUSTUM_CULLING", "FRUSTUM_CULLING", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LEVEL_OF_DETAIL", "LEVEL_OF_DETAIL", scopePath);
+    }
+
+    // Register enumeration TextBox::InputMode.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("TextBox");
+        gameplay::ScriptUtil::registerConstantString("TEXT", "TEXT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("PASSWORD", "PASSWORD", scopePath);
+    }
+
+    // Register enumeration Texture::Filter.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Texture");
+        gameplay::ScriptUtil::registerConstantString("NEAREST", "NEAREST", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINEAR", "LINEAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NEAREST_MIPMAP_NEAREST", "NEAREST_MIPMAP_NEAREST", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINEAR_MIPMAP_NEAREST", "LINEAR_MIPMAP_NEAREST", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NEAREST_MIPMAP_LINEAR", "NEAREST_MIPMAP_LINEAR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("LINEAR_MIPMAP_LINEAR", "LINEAR_MIPMAP_LINEAR", scopePath);
+    }
+
+    // Register enumeration Texture::Format.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Texture");
+        gameplay::ScriptUtil::registerConstantString("UNKNOWN", "UNKNOWN", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RGB", "RGB", scopePath);
+        gameplay::ScriptUtil::registerConstantString("RGBA", "RGBA", scopePath);
+        gameplay::ScriptUtil::registerConstantString("ALPHA", "ALPHA", scopePath);
+    }
+
+    // Register enumeration Texture::Wrap.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Texture");
+        gameplay::ScriptUtil::registerConstantString("REPEAT", "REPEAT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("CLAMP", "CLAMP", scopePath);
+    }
+
+    // Register enumeration Touch::TouchEvent.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("Touch");
+        gameplay::ScriptUtil::registerConstantString("TOUCH_PRESS", "TOUCH_PRESS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TOUCH_RELEASE", "TOUCH_RELEASE", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TOUCH_MOVE", "TOUCH_MOVE", scopePath);
+    }
+
+    // Register enumeration VertexFormat::Usage.
+    {
+        std::vector<std::string> scopePath;
+        scopePath.push_back("VertexFormat");
+        gameplay::ScriptUtil::registerConstantString("POSITION", "POSITION", scopePath);
+        gameplay::ScriptUtil::registerConstantString("NORMAL", "NORMAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("COLOR", "COLOR", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TANGENT", "TANGENT", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BINORMAL", "BINORMAL", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLENDWEIGHTS", "BLENDWEIGHTS", scopePath);
+        gameplay::ScriptUtil::registerConstantString("BLENDINDICES", "BLENDINDICES", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD0", "TEXCOORD0", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD1", "TEXCOORD1", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD2", "TEXCOORD2", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD3", "TEXCOORD3", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD4", "TEXCOORD4", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD5", "TEXCOORD5", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD6", "TEXCOORD6", scopePath);
+        gameplay::ScriptUtil::registerConstantString("TEXCOORD7", "TEXCOORD7", scopePath);
+    }
+}
+
+int lua__strcmpnocase(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_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
+                (lua_type(state, 2) == LUA_TSTRING || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                // Get parameter 2 off the stack.
+                const char* param2 = gameplay::ScriptUtil::getString(2, false);
+
+                int result = strcmpnocase(param1, param2);
+
+                // Push the return value onto the stack.
+                lua_pushinteger(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua__strcmpnocase - 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;
+}
+
+static const char* enumStringEmpty = "";
+
+const char* lua_stringFromEnumGlobal(std::string& enumname, unsigned int value)
+{
+    if (enumname == "AIMessage::ParameterType")
+        return lua_stringFromEnum_AIMessageParameterType((AIMessage::ParameterType)value);
+    if (enumname == "AnimationClip::Listener::EventType")
+        return lua_stringFromEnum_AnimationClipListenerEventType((AnimationClip::Listener::EventType)value);
+    if (enumname == "AudioSource::State")
+        return lua_stringFromEnum_AudioSourceState((AudioSource::State)value);
+    if (enumname == "Camera::Type")
+        return lua_stringFromEnum_CameraType((Camera::Type)value);
+    if (enumname == "Container::Scroll")
+        return lua_stringFromEnum_ContainerScroll((Container::Scroll)value);
+    if (enumname == "Control::Alignment")
+        return lua_stringFromEnum_ControlAlignment((Control::Alignment)value);
+    if (enumname == "Control::AutoSize")
+        return lua_stringFromEnum_ControlAutoSize((Control::AutoSize)value);
+    if (enumname == "Control::Listener::EventType")
+        return lua_stringFromEnum_ControlListenerEventType((Control::Listener::EventType)value);
+    if (enumname == "Control::State")
+        return lua_stringFromEnum_ControlState((Control::State)value);
+    if (enumname == "Curve::InterpolationType")
+        return lua_stringFromEnum_CurveInterpolationType((Curve::InterpolationType)value);
+    if (enumname == "DepthStencilTarget::Format")
+        return lua_stringFromEnum_DepthStencilTargetFormat((DepthStencilTarget::Format)value);
+    if (enumname == "Font::Format")
+        return lua_stringFromEnum_FontFormat((Font::Format)value);
+    if (enumname == "Font::Justify")
+        return lua_stringFromEnum_FontJustify((Font::Justify)value);
+    if (enumname == "Font::Style")
+        return lua_stringFromEnum_FontStyle((Font::Style)value);
+    if (enumname == "Game::ClearFlags")
+        return lua_stringFromEnum_GameClearFlags((Game::ClearFlags)value);
+    if (enumname == "Game::State")
+        return lua_stringFromEnum_GameState((Game::State)value);
+    if (enumname == "Gamepad::ButtonMapping")
+        return lua_stringFromEnum_GamepadButtonMapping((Gamepad::ButtonMapping)value);
+    if (enumname == "Gamepad::GamepadEvent")
+        return lua_stringFromEnum_GamepadGamepadEvent((Gamepad::GamepadEvent)value);
+    if (enumname == "Gesture::GestureEvent")
+        return lua_stringFromEnum_GestureGestureEvent((Gesture::GestureEvent)value);
+    if (enumname == "Image::Format")
+        return lua_stringFromEnum_ImageFormat((Image::Format)value);
+    if (enumname == "Keyboard::Key")
+        return lua_stringFromEnum_KeyboardKey((Keyboard::Key)value);
+    if (enumname == "Keyboard::KeyEvent")
+        return lua_stringFromEnum_KeyboardKeyEvent((Keyboard::KeyEvent)value);
+    if (enumname == "Layout::Type")
+        return lua_stringFromEnum_LayoutType((Layout::Type)value);
+    if (enumname == "Light::Type")
+        return lua_stringFromEnum_LightType((Light::Type)value);
+    if (enumname == "Logger::Level")
+        return lua_stringFromEnum_LoggerLevel((Logger::Level)value);
+    if (enumname == "Mesh::IndexFormat")
+        return lua_stringFromEnum_MeshIndexFormat((Mesh::IndexFormat)value);
+    if (enumname == "Mesh::PrimitiveType")
+        return lua_stringFromEnum_MeshPrimitiveType((Mesh::PrimitiveType)value);
+    if (enumname == "Mouse::MouseEvent")
+        return lua_stringFromEnum_MouseMouseEvent((Mouse::MouseEvent)value);
+    if (enumname == "Node::Type")
+        return lua_stringFromEnum_NodeType((Node::Type)value);
+    if (enumname == "ParticleEmitter::TextureBlending")
+        return lua_stringFromEnum_ParticleEmitterTextureBlending((ParticleEmitter::TextureBlending)value);
+    if (enumname == "PhysicsCollisionObject::CollisionListener::EventType")
+        return lua_stringFromEnum_PhysicsCollisionObjectCollisionListenerEventType((PhysicsCollisionObject::CollisionListener::EventType)value);
+    if (enumname == "PhysicsCollisionObject::Type")
+        return lua_stringFromEnum_PhysicsCollisionObjectType((PhysicsCollisionObject::Type)value);
+    if (enumname == "PhysicsCollisionShape::Type")
+        return lua_stringFromEnum_PhysicsCollisionShapeType((PhysicsCollisionShape::Type)value);
+    if (enumname == "PhysicsController::Listener::EventType")
+        return lua_stringFromEnum_PhysicsControllerListenerEventType((PhysicsController::Listener::EventType)value);
+    if (enumname == "Properties::Type")
+        return lua_stringFromEnum_PropertiesType((Properties::Type)value);
+    if (enumname == "RenderState::AutoBinding")
+        return lua_stringFromEnum_RenderStateAutoBinding((RenderState::AutoBinding)value);
+    if (enumname == "RenderState::Blend")
+        return lua_stringFromEnum_RenderStateBlend((RenderState::Blend)value);
+    if (enumname == "RenderState::CullFaceSide")
+        return lua_stringFromEnum_RenderStateCullFaceSide((RenderState::CullFaceSide)value);
+    if (enumname == "RenderState::DepthFunction")
+        return lua_stringFromEnum_RenderStateDepthFunction((RenderState::DepthFunction)value);
+    if (enumname == "RenderState::FrontFace")
+        return lua_stringFromEnum_RenderStateFrontFace((RenderState::FrontFace)value);
+    if (enumname == "RenderState::StencilFunction")
+        return lua_stringFromEnum_RenderStateStencilFunction((RenderState::StencilFunction)value);
+    if (enumname == "RenderState::StencilOperation")
+        return lua_stringFromEnum_RenderStateStencilOperation((RenderState::StencilOperation)value);
+    if (enumname == "Terrain::Flags")
+        return lua_stringFromEnum_TerrainFlags((Terrain::Flags)value);
+    if (enumname == "TextBox::InputMode")
+        return lua_stringFromEnum_TextBoxInputMode((TextBox::InputMode)value);
+    if (enumname == "Texture::Filter")
+        return lua_stringFromEnum_TextureFilter((Texture::Filter)value);
+    if (enumname == "Texture::Format")
+        return lua_stringFromEnum_TextureFormat((Texture::Format)value);
+    if (enumname == "Texture::Wrap")
+        return lua_stringFromEnum_TextureWrap((Texture::Wrap)value);
+    if (enumname == "Touch::TouchEvent")
+        return lua_stringFromEnum_TouchTouchEvent((Touch::TouchEvent)value);
+    if (enumname == "VertexFormat::Usage")
+        return lua_stringFromEnum_VertexFormatUsage((VertexFormat::Usage)value);
+
+    GP_ERROR("Unrecognized enumeration type '%s'.", enumname.c_str());
+    return enumStringEmpty;
+}
+
+}

+ 67 - 64
gameplay/src/lua/lua_Global.h

@@ -1,64 +1,67 @@
-#ifndef LUA_GLOBAL_H_
-#define LUA_GLOBAL_H_
-
-#include "lua_AIMessageParameterType.h"
-#include "lua_AnimationClipListenerEventType.h"
-#include "lua_AudioSourceState.h"
-#include "lua_CameraType.h"
-#include "lua_ContainerScroll.h"
-#include "lua_ControlAlignment.h"
-#include "lua_ControlAutoSize.h"
-#include "lua_ControlListenerEventType.h"
-#include "lua_ControlState.h"
-#include "lua_CurveInterpolationType.h"
-#include "lua_DepthStencilTargetFormat.h"
-#include "lua_FontFormat.h"
-#include "lua_FontJustify.h"
-#include "lua_FontStyle.h"
-#include "lua_GameClearFlags.h"
-#include "lua_GameState.h"
-#include "lua_GamepadButtonMapping.h"
-#include "lua_GamepadGamepadEvent.h"
-#include "lua_GestureGestureEvent.h"
-#include "lua_ImageFormat.h"
-#include "lua_KeyboardKey.h"
-#include "lua_KeyboardKeyEvent.h"
-#include "lua_LayoutType.h"
-#include "lua_LightType.h"
-#include "lua_LoggerLevel.h"
-#include "lua_MeshIndexFormat.h"
-#include "lua_MeshPrimitiveType.h"
-#include "lua_MouseMouseEvent.h"
-#include "lua_NodeType.h"
-#include "lua_ParticleEmitterTextureBlending.h"
-#include "lua_PhysicsCollisionObjectCollisionListenerEventType.h"
-#include "lua_PhysicsCollisionObjectType.h"
-#include "lua_PhysicsCollisionShapeType.h"
-#include "lua_PhysicsControllerListenerEventType.h"
-#include "lua_PropertiesType.h"
-#include "lua_RenderStateAutoBinding.h"
-#include "lua_RenderStateBlend.h"
-#include "lua_RenderStateCullFaceSide.h"
-#include "lua_RenderStateDepthFunction.h"
-#include "lua_RenderStateFrontFace.h"
-#include "lua_RenderStateStencilFunction.h"
-#include "lua_RenderStateStencilOperation.h"
-#include "lua_TerrainFlags.h"
-#include "lua_TextBoxInputMode.h"
-#include "lua_TextureFilter.h"
-#include "lua_TextureFormat.h"
-#include "lua_TextureWrap.h"
-#include "lua_TouchTouchEvent.h"
-#include "lua_VertexFormatUsage.h"
-
-namespace gameplay
-{
-
-// Global enum to string conversion function (used to pass enums to Lua from C++).
-const char* lua_stringFromEnumGlobal(std::string& enumname, unsigned int value);
-
-void luaRegister_lua_Global();
-
-}
-
-#endif
+#ifndef LUA_GLOBAL_H_
+#define LUA_GLOBAL_H_
+
+#include "lua_AIMessageParameterType.h"
+#include "lua_AnimationClipListenerEventType.h"
+#include "lua_AudioSourceState.h"
+#include "lua_CameraType.h"
+#include "lua_ContainerScroll.h"
+#include "lua_ControlAlignment.h"
+#include "lua_ControlAutoSize.h"
+#include "lua_ControlListenerEventType.h"
+#include "lua_ControlState.h"
+#include "lua_CurveInterpolationType.h"
+#include "lua_DepthStencilTargetFormat.h"
+#include "lua_FontFormat.h"
+#include "lua_FontJustify.h"
+#include "lua_FontStyle.h"
+#include "lua_GameClearFlags.h"
+#include "lua_GameState.h"
+#include "lua_GamepadButtonMapping.h"
+#include "lua_GamepadGamepadEvent.h"
+#include "lua_GestureGestureEvent.h"
+#include "lua_ImageFormat.h"
+#include "lua_KeyboardKey.h"
+#include "lua_KeyboardKeyEvent.h"
+#include "lua_LayoutType.h"
+#include "lua_LightType.h"
+#include "lua_LoggerLevel.h"
+#include "lua_MeshIndexFormat.h"
+#include "lua_MeshPrimitiveType.h"
+#include "lua_MouseMouseEvent.h"
+#include "lua_NodeType.h"
+#include "lua_ParticleEmitterTextureBlending.h"
+#include "lua_PhysicsCollisionObjectCollisionListenerEventType.h"
+#include "lua_PhysicsCollisionObjectType.h"
+#include "lua_PhysicsCollisionShapeType.h"
+#include "lua_PhysicsControllerListenerEventType.h"
+#include "lua_PropertiesType.h"
+#include "lua_RenderStateAutoBinding.h"
+#include "lua_RenderStateBlend.h"
+#include "lua_RenderStateCullFaceSide.h"
+#include "lua_RenderStateDepthFunction.h"
+#include "lua_RenderStateFrontFace.h"
+#include "lua_RenderStateStencilFunction.h"
+#include "lua_RenderStateStencilOperation.h"
+#include "lua_TerrainFlags.h"
+#include "lua_TextBoxInputMode.h"
+#include "lua_TextureFilter.h"
+#include "lua_TextureFormat.h"
+#include "lua_TextureWrap.h"
+#include "lua_TouchTouchEvent.h"
+#include "lua_VertexFormatUsage.h"
+
+namespace gameplay
+{
+
+// Lua bindings for global functions.
+int lua__strcmpnocase(lua_State* state);
+
+// Global enum to string conversion function (used to pass enums to Lua from C++).
+const char* lua_stringFromEnumGlobal(std::string& enumname, unsigned int value);
+
+void luaRegister_lua_Global();
+
+}
+
+#endif

+ 112 - 1
gameplay/src/lua/lua_ImageControl.cpp

@@ -12,6 +12,7 @@
 #include "Ref.h"
 #include "Ref.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"
@@ -71,6 +72,7 @@ void luaRegister_ImageControl()
         {"getTextAlignment", lua_ImageControl_getTextAlignment},
         {"getTextAlignment", lua_ImageControl_getTextAlignment},
         {"getTextColor", lua_ImageControl_getTextColor},
         {"getTextColor", lua_ImageControl_getTextColor},
         {"getTextRightToLeft", lua_ImageControl_getTextRightToLeft},
         {"getTextRightToLeft", lua_ImageControl_getTextRightToLeft},
+        {"getTheme", lua_ImageControl_getTheme},
         {"getTopLevelForm", lua_ImageControl_getTopLevelForm},
         {"getTopLevelForm", lua_ImageControl_getTopLevelForm},
         {"getType", lua_ImageControl_getType},
         {"getType", lua_ImageControl_getType},
         {"getWidth", lua_ImageControl_getWidth},
         {"getWidth", lua_ImageControl_getWidth},
@@ -107,6 +109,7 @@ void luaRegister_ImageControl()
         {"setFont", lua_ImageControl_setFont},
         {"setFont", lua_ImageControl_setFont},
         {"setFontSize", lua_ImageControl_setFontSize},
         {"setFontSize", lua_ImageControl_setFontSize},
         {"setHeight", lua_ImageControl_setHeight},
         {"setHeight", lua_ImageControl_setHeight},
+        {"setId", lua_ImageControl_setId},
         {"setImage", lua_ImageControl_setImage},
         {"setImage", lua_ImageControl_setImage},
         {"setImageColor", lua_ImageControl_setImageColor},
         {"setImageColor", lua_ImageControl_setImageColor},
         {"setImageRegion", lua_ImageControl_setImageRegion},
         {"setImageRegion", lua_ImageControl_setImageRegion},
@@ -2542,6 +2545,50 @@ int lua_ImageControl_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_ImageControl_getTheme(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))
+            {
+                ImageControl* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_ImageControl_getTheme - 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_ImageControl_getTopLevelForm(lua_State* state)
 int lua_ImageControl_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4073,6 +4120,42 @@ int lua_ImageControl_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_ImageControl_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                ImageControl* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_ImageControl_setId - 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_ImageControl_setImage(lua_State* state)
 int lua_ImageControl_setImage(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -5390,6 +5473,34 @@ int lua_ImageControl_static_create(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                void* returnPtr = (void*)ImageControl::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "ImageControl");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_ImageControl_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         case 2:
         case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
@@ -5430,7 +5541,7 @@ int lua_ImageControl_static_create(lua_State* state)
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 0
gameplay/src/lua/lua_ImageControl.h

@@ -51,6 +51,7 @@ int lua_ImageControl_getStyle(lua_State* state);
 int lua_ImageControl_getTextAlignment(lua_State* state);
 int lua_ImageControl_getTextAlignment(lua_State* state);
 int lua_ImageControl_getTextColor(lua_State* state);
 int lua_ImageControl_getTextColor(lua_State* state);
 int lua_ImageControl_getTextRightToLeft(lua_State* state);
 int lua_ImageControl_getTextRightToLeft(lua_State* state);
+int lua_ImageControl_getTheme(lua_State* state);
 int lua_ImageControl_getTopLevelForm(lua_State* state);
 int lua_ImageControl_getTopLevelForm(lua_State* state);
 int lua_ImageControl_getType(lua_State* state);
 int lua_ImageControl_getType(lua_State* state);
 int lua_ImageControl_getWidth(lua_State* state);
 int lua_ImageControl_getWidth(lua_State* state);
@@ -87,6 +88,7 @@ int lua_ImageControl_setFocusIndex(lua_State* state);
 int lua_ImageControl_setFont(lua_State* state);
 int lua_ImageControl_setFont(lua_State* state);
 int lua_ImageControl_setFontSize(lua_State* state);
 int lua_ImageControl_setFontSize(lua_State* state);
 int lua_ImageControl_setHeight(lua_State* state);
 int lua_ImageControl_setHeight(lua_State* state);
+int lua_ImageControl_setId(lua_State* state);
 int lua_ImageControl_setImage(lua_State* state);
 int lua_ImageControl_setImage(lua_State* state);
 int lua_ImageControl_setImageColor(lua_State* state);
 int lua_ImageControl_setImageColor(lua_State* state);
 int lua_ImageControl_setImageRegion(lua_State* state);
 int lua_ImageControl_setImageRegion(lua_State* state);

+ 112 - 1
gameplay/src/lua/lua_Joystick.cpp

@@ -12,6 +12,7 @@
 #include "Ref.h"
 #include "Ref.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"
@@ -72,6 +73,7 @@ void luaRegister_Joystick()
         {"getTextAlignment", lua_Joystick_getTextAlignment},
         {"getTextAlignment", lua_Joystick_getTextAlignment},
         {"getTextColor", lua_Joystick_getTextColor},
         {"getTextColor", lua_Joystick_getTextColor},
         {"getTextRightToLeft", lua_Joystick_getTextRightToLeft},
         {"getTextRightToLeft", lua_Joystick_getTextRightToLeft},
+        {"getTheme", lua_Joystick_getTheme},
         {"getTopLevelForm", lua_Joystick_getTopLevelForm},
         {"getTopLevelForm", lua_Joystick_getTopLevelForm},
         {"getType", lua_Joystick_getType},
         {"getType", lua_Joystick_getType},
         {"getValue", lua_Joystick_getValue},
         {"getValue", lua_Joystick_getValue},
@@ -110,6 +112,7 @@ void luaRegister_Joystick()
         {"setFont", lua_Joystick_setFont},
         {"setFont", lua_Joystick_setFont},
         {"setFontSize", lua_Joystick_setFontSize},
         {"setFontSize", lua_Joystick_setFontSize},
         {"setHeight", lua_Joystick_setHeight},
         {"setHeight", lua_Joystick_setHeight},
+        {"setId", lua_Joystick_setId},
         {"setImageColor", lua_Joystick_setImageColor},
         {"setImageColor", lua_Joystick_setImageColor},
         {"setImageRegion", lua_Joystick_setImageRegion},
         {"setImageRegion", lua_Joystick_setImageRegion},
         {"setInnerRegionSize", lua_Joystick_setInnerRegionSize},
         {"setInnerRegionSize", lua_Joystick_setInnerRegionSize},
@@ -2580,6 +2583,50 @@ int lua_Joystick_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Joystick_getTheme(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->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Joystick_getTheme - 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_getTopLevelForm(lua_State* state)
 int lua_Joystick_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4190,6 +4237,42 @@ int lua_Joystick_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Joystick_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                Joystick* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Joystick_setId - 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_setImageColor(lua_State* state)
 int lua_Joystick_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -5441,6 +5524,34 @@ int lua_Joystick_static_create(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                void* returnPtr = (void*)Joystick::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "Joystick");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Joystick_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         case 2:
         case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
@@ -5481,7 +5592,7 @@ int lua_Joystick_static_create(lua_State* state)
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 0
gameplay/src/lua/lua_Joystick.h

@@ -52,6 +52,7 @@ int lua_Joystick_getStyle(lua_State* state);
 int lua_Joystick_getTextAlignment(lua_State* state);
 int lua_Joystick_getTextAlignment(lua_State* state);
 int lua_Joystick_getTextColor(lua_State* state);
 int lua_Joystick_getTextColor(lua_State* state);
 int lua_Joystick_getTextRightToLeft(lua_State* state);
 int lua_Joystick_getTextRightToLeft(lua_State* state);
+int lua_Joystick_getTheme(lua_State* state);
 int lua_Joystick_getTopLevelForm(lua_State* state);
 int lua_Joystick_getTopLevelForm(lua_State* state);
 int lua_Joystick_getType(lua_State* state);
 int lua_Joystick_getType(lua_State* state);
 int lua_Joystick_getValue(lua_State* state);
 int lua_Joystick_getValue(lua_State* state);
@@ -90,6 +91,7 @@ int lua_Joystick_setFocusIndex(lua_State* state);
 int lua_Joystick_setFont(lua_State* state);
 int lua_Joystick_setFont(lua_State* state);
 int lua_Joystick_setFontSize(lua_State* state);
 int lua_Joystick_setFontSize(lua_State* state);
 int lua_Joystick_setHeight(lua_State* state);
 int lua_Joystick_setHeight(lua_State* state);
+int lua_Joystick_setId(lua_State* state);
 int lua_Joystick_setImageColor(lua_State* state);
 int lua_Joystick_setImageColor(lua_State* state);
 int lua_Joystick_setImageRegion(lua_State* state);
 int lua_Joystick_setImageRegion(lua_State* state);
 int lua_Joystick_setInnerRegionSize(lua_State* state);
 int lua_Joystick_setInnerRegionSize(lua_State* state);

+ 112 - 1
gameplay/src/lua/lua_Label.cpp

@@ -12,6 +12,7 @@
 #include "Ref.h"
 #include "Ref.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"
@@ -70,6 +71,7 @@ void luaRegister_Label()
         {"getTextAlignment", lua_Label_getTextAlignment},
         {"getTextAlignment", lua_Label_getTextAlignment},
         {"getTextColor", lua_Label_getTextColor},
         {"getTextColor", lua_Label_getTextColor},
         {"getTextRightToLeft", lua_Label_getTextRightToLeft},
         {"getTextRightToLeft", lua_Label_getTextRightToLeft},
+        {"getTheme", lua_Label_getTheme},
         {"getTopLevelForm", lua_Label_getTopLevelForm},
         {"getTopLevelForm", lua_Label_getTopLevelForm},
         {"getType", lua_Label_getType},
         {"getType", lua_Label_getType},
         {"getWidth", lua_Label_getWidth},
         {"getWidth", lua_Label_getWidth},
@@ -106,6 +108,7 @@ void luaRegister_Label()
         {"setFont", lua_Label_setFont},
         {"setFont", lua_Label_setFont},
         {"setFontSize", lua_Label_setFontSize},
         {"setFontSize", lua_Label_setFontSize},
         {"setHeight", lua_Label_setHeight},
         {"setHeight", lua_Label_setHeight},
+        {"setId", lua_Label_setId},
         {"setImageColor", lua_Label_setImageColor},
         {"setImageColor", lua_Label_setImageColor},
         {"setImageRegion", lua_Label_setImageRegion},
         {"setImageRegion", lua_Label_setImageRegion},
         {"setMargin", lua_Label_setMargin},
         {"setMargin", lua_Label_setMargin},
@@ -2486,6 +2489,50 @@ int lua_Label_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Label_getTheme(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))
+            {
+                Label* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Label_getTheme - 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_Label_getTopLevelForm(lua_State* state)
 int lua_Label_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4017,6 +4064,42 @@ int lua_Label_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Label_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                Label* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Label_setId - 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_Label_setImageColor(lua_State* state)
 int lua_Label_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -5184,6 +5267,34 @@ int lua_Label_static_create(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                void* returnPtr = (void*)Label::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "Label");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Label_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         case 2:
         case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
@@ -5224,7 +5335,7 @@ int lua_Label_static_create(lua_State* state)
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 0
gameplay/src/lua/lua_Label.h

@@ -50,6 +50,7 @@ int lua_Label_getText(lua_State* state);
 int lua_Label_getTextAlignment(lua_State* state);
 int lua_Label_getTextAlignment(lua_State* state);
 int lua_Label_getTextColor(lua_State* state);
 int lua_Label_getTextColor(lua_State* state);
 int lua_Label_getTextRightToLeft(lua_State* state);
 int lua_Label_getTextRightToLeft(lua_State* state);
+int lua_Label_getTheme(lua_State* state);
 int lua_Label_getTopLevelForm(lua_State* state);
 int lua_Label_getTopLevelForm(lua_State* state);
 int lua_Label_getType(lua_State* state);
 int lua_Label_getType(lua_State* state);
 int lua_Label_getWidth(lua_State* state);
 int lua_Label_getWidth(lua_State* state);
@@ -86,6 +87,7 @@ int lua_Label_setFocusIndex(lua_State* state);
 int lua_Label_setFont(lua_State* state);
 int lua_Label_setFont(lua_State* state);
 int lua_Label_setFontSize(lua_State* state);
 int lua_Label_setFontSize(lua_State* state);
 int lua_Label_setHeight(lua_State* state);
 int lua_Label_setHeight(lua_State* state);
+int lua_Label_setId(lua_State* state);
 int lua_Label_setImageColor(lua_State* state);
 int lua_Label_setImageColor(lua_State* state);
 int lua_Label_setImageRegion(lua_State* state);
 int lua_Label_setImageRegion(lua_State* state);
 int lua_Label_setMargin(lua_State* state);
 int lua_Label_setMargin(lua_State* state);

+ 36 - 0
gameplay/src/lua/lua_MeshBatch.cpp

@@ -18,6 +18,7 @@ void luaRegister_MeshBatch()
         {"finish", lua_MeshBatch_finish},
         {"finish", lua_MeshBatch_finish},
         {"getCapacity", lua_MeshBatch_getCapacity},
         {"getCapacity", lua_MeshBatch_getCapacity},
         {"getMaterial", lua_MeshBatch_getMaterial},
         {"getMaterial", lua_MeshBatch_getMaterial},
+        {"isStarted", lua_MeshBatch_isStarted},
         {"setCapacity", lua_MeshBatch_setCapacity},
         {"setCapacity", lua_MeshBatch_setCapacity},
         {"start", lua_MeshBatch_start},
         {"start", lua_MeshBatch_start},
         {NULL, NULL}
         {NULL, NULL}
@@ -316,6 +317,41 @@ int lua_MeshBatch_getMaterial(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_MeshBatch_isStarted(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))
+            {
+                MeshBatch* instance = getInstance(state);
+                bool result = instance->isStarted();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_MeshBatch_isStarted - 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_MeshBatch_setCapacity(lua_State* state)
 int lua_MeshBatch_setCapacity(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

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

@@ -11,6 +11,7 @@ int lua_MeshBatch_draw(lua_State* state);
 int lua_MeshBatch_finish(lua_State* state);
 int lua_MeshBatch_finish(lua_State* state);
 int lua_MeshBatch_getCapacity(lua_State* state);
 int lua_MeshBatch_getCapacity(lua_State* state);
 int lua_MeshBatch_getMaterial(lua_State* state);
 int lua_MeshBatch_getMaterial(lua_State* state);
+int lua_MeshBatch_isStarted(lua_State* state);
 int lua_MeshBatch_setCapacity(lua_State* state);
 int lua_MeshBatch_setCapacity(lua_State* state);
 int lua_MeshBatch_start(lua_State* state);
 int lua_MeshBatch_start(lua_State* state);
 int lua_MeshBatch_static_create(lua_State* state);
 int lua_MeshBatch_static_create(lua_State* state);

+ 112 - 1
gameplay/src/lua/lua_RadioButton.cpp

@@ -15,6 +15,7 @@
 #include "Ref.h"
 #include "Ref.h"
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"
@@ -75,6 +76,7 @@ void luaRegister_RadioButton()
         {"getTextAlignment", lua_RadioButton_getTextAlignment},
         {"getTextAlignment", lua_RadioButton_getTextAlignment},
         {"getTextColor", lua_RadioButton_getTextColor},
         {"getTextColor", lua_RadioButton_getTextColor},
         {"getTextRightToLeft", lua_RadioButton_getTextRightToLeft},
         {"getTextRightToLeft", lua_RadioButton_getTextRightToLeft},
+        {"getTheme", lua_RadioButton_getTheme},
         {"getTopLevelForm", lua_RadioButton_getTopLevelForm},
         {"getTopLevelForm", lua_RadioButton_getTopLevelForm},
         {"getType", lua_RadioButton_getType},
         {"getType", lua_RadioButton_getType},
         {"getWidth", lua_RadioButton_getWidth},
         {"getWidth", lua_RadioButton_getWidth},
@@ -113,6 +115,7 @@ void luaRegister_RadioButton()
         {"setFontSize", lua_RadioButton_setFontSize},
         {"setFontSize", lua_RadioButton_setFontSize},
         {"setGroupId", lua_RadioButton_setGroupId},
         {"setGroupId", lua_RadioButton_setGroupId},
         {"setHeight", lua_RadioButton_setHeight},
         {"setHeight", lua_RadioButton_setHeight},
+        {"setId", lua_RadioButton_setId},
         {"setImageColor", lua_RadioButton_setImageColor},
         {"setImageColor", lua_RadioButton_setImageColor},
         {"setImageRegion", lua_RadioButton_setImageRegion},
         {"setImageRegion", lua_RadioButton_setImageRegion},
         {"setImageSize", lua_RadioButton_setImageSize},
         {"setImageSize", lua_RadioButton_setImageSize},
@@ -2574,6 +2577,50 @@ int lua_RadioButton_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_RadioButton_getTheme(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))
+            {
+                RadioButton* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_RadioButton_getTheme - 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_RadioButton_getTopLevelForm(lua_State* state)
 int lua_RadioButton_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4176,6 +4223,42 @@ int lua_RadioButton_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_RadioButton_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                RadioButton* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_RadioButton_setId - 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_RadioButton_setImageColor(lua_State* state)
 int lua_RadioButton_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -5419,6 +5502,34 @@ int lua_RadioButton_static_create(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                void* returnPtr = (void*)RadioButton::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "RadioButton");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_RadioButton_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         case 2:
         case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
@@ -5459,7 +5570,7 @@ int lua_RadioButton_static_create(lua_State* state)
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 0
gameplay/src/lua/lua_RadioButton.h

@@ -52,6 +52,7 @@ int lua_RadioButton_getText(lua_State* state);
 int lua_RadioButton_getTextAlignment(lua_State* state);
 int lua_RadioButton_getTextAlignment(lua_State* state);
 int lua_RadioButton_getTextColor(lua_State* state);
 int lua_RadioButton_getTextColor(lua_State* state);
 int lua_RadioButton_getTextRightToLeft(lua_State* state);
 int lua_RadioButton_getTextRightToLeft(lua_State* state);
+int lua_RadioButton_getTheme(lua_State* state);
 int lua_RadioButton_getTopLevelForm(lua_State* state);
 int lua_RadioButton_getTopLevelForm(lua_State* state);
 int lua_RadioButton_getType(lua_State* state);
 int lua_RadioButton_getType(lua_State* state);
 int lua_RadioButton_getWidth(lua_State* state);
 int lua_RadioButton_getWidth(lua_State* state);
@@ -90,6 +91,7 @@ int lua_RadioButton_setFont(lua_State* state);
 int lua_RadioButton_setFontSize(lua_State* state);
 int lua_RadioButton_setFontSize(lua_State* state);
 int lua_RadioButton_setGroupId(lua_State* state);
 int lua_RadioButton_setGroupId(lua_State* state);
 int lua_RadioButton_setHeight(lua_State* state);
 int lua_RadioButton_setHeight(lua_State* state);
+int lua_RadioButton_setId(lua_State* state);
 int lua_RadioButton_setImageColor(lua_State* state);
 int lua_RadioButton_setImageColor(lua_State* state);
 int lua_RadioButton_setImageRegion(lua_State* state);
 int lua_RadioButton_setImageRegion(lua_State* state);
 int lua_RadioButton_setImageSize(lua_State* state);
 int lua_RadioButton_setImageSize(lua_State* state);

+ 64 - 0
gameplay/src/lua/lua_Rectangle.cpp

@@ -31,6 +31,7 @@ void luaRegister_Rectangle()
     {
     {
         {"combine", lua_Rectangle_static_combine},
         {"combine", lua_Rectangle_static_combine},
         {"empty", lua_Rectangle_static_empty},
         {"empty", lua_Rectangle_static_empty},
+        {"intersect", lua_Rectangle_static_intersect},
         {NULL, NULL}
         {NULL, NULL}
     };
     };
     std::vector<std::string> scopePath;
     std::vector<std::string> scopePath;
@@ -843,6 +844,69 @@ int lua_Rectangle_static_empty(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Rectangle_static_intersect(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 3:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TNIL) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
+                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Rectangle> param1 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(1, "Rectangle", true, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Rectangle'.");
+                    lua_error(state);
+                }
+
+                // Get parameter 2 off the stack.
+                bool param2Valid;
+                gameplay::ScriptUtil::LuaArray<Rectangle> param2 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(2, "Rectangle", true, &param2Valid);
+                if (!param2Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Rectangle'.");
+                    lua_error(state);
+                }
+
+                // Get parameter 3 off the stack.
+                bool param3Valid;
+                gameplay::ScriptUtil::LuaArray<Rectangle> param3 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(3, "Rectangle", false, &param3Valid);
+                if (!param3Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 3 to type 'Rectangle'.");
+                    lua_error(state);
+                }
+
+                bool result = Rectangle::intersect(*param1, *param2, param3);
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Rectangle_static_intersect - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 3).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Rectangle_top(lua_State* state)
 int lua_Rectangle_top(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

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

@@ -19,6 +19,7 @@ int lua_Rectangle_set(lua_State* state);
 int lua_Rectangle_setPosition(lua_State* state);
 int lua_Rectangle_setPosition(lua_State* state);
 int lua_Rectangle_static_combine(lua_State* state);
 int lua_Rectangle_static_combine(lua_State* state);
 int lua_Rectangle_static_empty(lua_State* state);
 int lua_Rectangle_static_empty(lua_State* state);
+int lua_Rectangle_static_intersect(lua_State* state);
 int lua_Rectangle_top(lua_State* state);
 int lua_Rectangle_top(lua_State* state);
 int lua_Rectangle_width(lua_State* state);
 int lua_Rectangle_width(lua_State* state);
 int lua_Rectangle_x(lua_State* state);
 int lua_Rectangle_x(lua_State* state);

+ 112 - 1
gameplay/src/lua/lua_Slider.cpp

@@ -13,6 +13,7 @@
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
 #include "Slider.h"
 #include "Slider.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"
@@ -74,6 +75,7 @@ void luaRegister_Slider()
         {"getTextAlignment", lua_Slider_getTextAlignment},
         {"getTextAlignment", lua_Slider_getTextAlignment},
         {"getTextColor", lua_Slider_getTextColor},
         {"getTextColor", lua_Slider_getTextColor},
         {"getTextRightToLeft", lua_Slider_getTextRightToLeft},
         {"getTextRightToLeft", lua_Slider_getTextRightToLeft},
+        {"getTheme", lua_Slider_getTheme},
         {"getTopLevelForm", lua_Slider_getTopLevelForm},
         {"getTopLevelForm", lua_Slider_getTopLevelForm},
         {"getType", lua_Slider_getType},
         {"getType", lua_Slider_getType},
         {"getValue", lua_Slider_getValue},
         {"getValue", lua_Slider_getValue},
@@ -114,6 +116,7 @@ void luaRegister_Slider()
         {"setFont", lua_Slider_setFont},
         {"setFont", lua_Slider_setFont},
         {"setFontSize", lua_Slider_setFontSize},
         {"setFontSize", lua_Slider_setFontSize},
         {"setHeight", lua_Slider_setHeight},
         {"setHeight", lua_Slider_setHeight},
+        {"setId", lua_Slider_setId},
         {"setImageColor", lua_Slider_setImageColor},
         {"setImageColor", lua_Slider_setImageColor},
         {"setImageRegion", lua_Slider_setImageRegion},
         {"setImageRegion", lua_Slider_setImageRegion},
         {"setMargin", lua_Slider_setMargin},
         {"setMargin", lua_Slider_setMargin},
@@ -2606,6 +2609,50 @@ int lua_Slider_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Slider_getTheme(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))
+            {
+                Slider* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Slider_getTheme - 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_Slider_getTopLevelForm(lua_State* state)
 int lua_Slider_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4277,6 +4324,42 @@ int lua_Slider_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Slider_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                Slider* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Slider_setId - 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_Slider_setImageColor(lua_State* state)
 int lua_Slider_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -5696,6 +5779,34 @@ int lua_Slider_static_create(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                void* returnPtr = (void*)Slider::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "Slider");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Slider_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         case 2:
         case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
@@ -5736,7 +5847,7 @@ int lua_Slider_static_create(lua_State* state)
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 0
gameplay/src/lua/lua_Slider.h

@@ -53,6 +53,7 @@ int lua_Slider_getText(lua_State* state);
 int lua_Slider_getTextAlignment(lua_State* state);
 int lua_Slider_getTextAlignment(lua_State* state);
 int lua_Slider_getTextColor(lua_State* state);
 int lua_Slider_getTextColor(lua_State* state);
 int lua_Slider_getTextRightToLeft(lua_State* state);
 int lua_Slider_getTextRightToLeft(lua_State* state);
+int lua_Slider_getTheme(lua_State* state);
 int lua_Slider_getTopLevelForm(lua_State* state);
 int lua_Slider_getTopLevelForm(lua_State* state);
 int lua_Slider_getType(lua_State* state);
 int lua_Slider_getType(lua_State* state);
 int lua_Slider_getValue(lua_State* state);
 int lua_Slider_getValue(lua_State* state);
@@ -93,6 +94,7 @@ int lua_Slider_setFocusIndex(lua_State* state);
 int lua_Slider_setFont(lua_State* state);
 int lua_Slider_setFont(lua_State* state);
 int lua_Slider_setFontSize(lua_State* state);
 int lua_Slider_setFontSize(lua_State* state);
 int lua_Slider_setHeight(lua_State* state);
 int lua_Slider_setHeight(lua_State* state);
+int lua_Slider_setId(lua_State* state);
 int lua_Slider_setImageColor(lua_State* state);
 int lua_Slider_setImageColor(lua_State* state);
 int lua_Slider_setImageRegion(lua_State* state);
 int lua_Slider_setImageRegion(lua_State* state);
 int lua_Slider_setMargin(lua_State* state);
 int lua_Slider_setMargin(lua_State* state);

+ 97 - 0
gameplay/src/lua/lua_SpriteBatch.cpp

@@ -19,6 +19,7 @@ void luaRegister_SpriteBatch()
         {"getProjectionMatrix", lua_SpriteBatch_getProjectionMatrix},
         {"getProjectionMatrix", lua_SpriteBatch_getProjectionMatrix},
         {"getSampler", lua_SpriteBatch_getSampler},
         {"getSampler", lua_SpriteBatch_getSampler},
         {"getStateBlock", lua_SpriteBatch_getStateBlock},
         {"getStateBlock", lua_SpriteBatch_getStateBlock},
+        {"isStarted", lua_SpriteBatch_isStarted},
         {"setProjectionMatrix", lua_SpriteBatch_setProjectionMatrix},
         {"setProjectionMatrix", lua_SpriteBatch_setProjectionMatrix},
         {"start", lua_SpriteBatch_start},
         {"start", lua_SpriteBatch_start},
         {NULL, NULL}
         {NULL, NULL}
@@ -587,6 +588,67 @@ int lua_SpriteBatch_draw(lua_State* state)
                 }
                 }
             } while (0);
             } while (0);
 
 
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                    lua_type(state, 2) == LUA_TNUMBER &&
+                    lua_type(state, 3) == LUA_TNUMBER &&
+                    lua_type(state, 4) == LUA_TNUMBER &&
+                    lua_type(state, 5) == LUA_TNUMBER &&
+                    lua_type(state, 6) == LUA_TNUMBER &&
+                    lua_type(state, 7) == LUA_TNUMBER &&
+                    lua_type(state, 8) == LUA_TNUMBER &&
+                    lua_type(state, 9) == LUA_TNUMBER &&
+                    lua_type(state, 10) == LUA_TNUMBER &&
+                    (lua_type(state, 11) == LUA_TUSERDATA || lua_type(state, 11) == LUA_TNIL) &&
+                    (lua_type(state, 12) == LUA_TUSERDATA || lua_type(state, 12) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    float param1 = (float)luaL_checknumber(state, 2);
+
+                    // Get parameter 2 off the stack.
+                    float param2 = (float)luaL_checknumber(state, 3);
+
+                    // Get parameter 3 off the stack.
+                    float param3 = (float)luaL_checknumber(state, 4);
+
+                    // Get parameter 4 off the stack.
+                    float param4 = (float)luaL_checknumber(state, 5);
+
+                    // Get parameter 5 off the stack.
+                    float param5 = (float)luaL_checknumber(state, 6);
+
+                    // Get parameter 6 off the stack.
+                    float param6 = (float)luaL_checknumber(state, 7);
+
+                    // Get parameter 7 off the stack.
+                    float param7 = (float)luaL_checknumber(state, 8);
+
+                    // Get parameter 8 off the stack.
+                    float param8 = (float)luaL_checknumber(state, 9);
+
+                    // Get parameter 9 off the stack.
+                    float param9 = (float)luaL_checknumber(state, 10);
+
+                    // Get parameter 10 off the stack.
+                    bool param10Valid;
+                    gameplay::ScriptUtil::LuaArray<Vector4> param10 = gameplay::ScriptUtil::getObjectPointer<Vector4>(11, "Vector4", true, &param10Valid);
+                    if (!param10Valid)
+                        break;
+
+                    // Get parameter 11 off the stack.
+                    bool param11Valid;
+                    gameplay::ScriptUtil::LuaArray<Rectangle> param11 = gameplay::ScriptUtil::getObjectPointer<Rectangle>(12, "Rectangle", true, &param11Valid);
+                    if (!param11Valid)
+                        break;
+
+                    SpriteBatch* instance = getInstance(state);
+                    instance->draw(param1, param2, param3, param4, param5, param6, param7, param8, param9, *param10, *param11);
+                    
+                    return 0;
+                }
+            } while (0);
+
             do
             do
             {
             {
                 if ((lua_type(state, 1) == LUA_TUSERDATA) &&
                 if ((lua_type(state, 1) == LUA_TUSERDATA) &&
@@ -1087,6 +1149,41 @@ int lua_SpriteBatch_getStateBlock(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_SpriteBatch_isStarted(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))
+            {
+                SpriteBatch* instance = getInstance(state);
+                bool result = instance->isStarted();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_SpriteBatch_isStarted - 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_SpriteBatch_setProjectionMatrix(lua_State* state)
 int lua_SpriteBatch_setProjectionMatrix(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

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

@@ -12,6 +12,7 @@ int lua_SpriteBatch_getMaterial(lua_State* state);
 int lua_SpriteBatch_getProjectionMatrix(lua_State* state);
 int lua_SpriteBatch_getProjectionMatrix(lua_State* state);
 int lua_SpriteBatch_getSampler(lua_State* state);
 int lua_SpriteBatch_getSampler(lua_State* state);
 int lua_SpriteBatch_getStateBlock(lua_State* state);
 int lua_SpriteBatch_getStateBlock(lua_State* state);
+int lua_SpriteBatch_isStarted(lua_State* state);
 int lua_SpriteBatch_setProjectionMatrix(lua_State* state);
 int lua_SpriteBatch_setProjectionMatrix(lua_State* state);
 int lua_SpriteBatch_start(lua_State* state);
 int lua_SpriteBatch_start(lua_State* state);
 int lua_SpriteBatch_static_create(lua_State* state);
 int lua_SpriteBatch_static_create(lua_State* state);

+ 112 - 54
gameplay/src/lua/lua_TextBox.cpp

@@ -13,6 +13,7 @@
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "ScriptTarget.h"
 #include "ScriptTarget.h"
 #include "TextBox.h"
 #include "TextBox.h"
+#include "Theme.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAlignment.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlAutoSize.h"
 #include "lua_ControlListenerEventType.h"
 #include "lua_ControlListenerEventType.h"
@@ -76,6 +77,7 @@ void luaRegister_TextBox()
         {"getTextAlignment", lua_TextBox_getTextAlignment},
         {"getTextAlignment", lua_TextBox_getTextAlignment},
         {"getTextColor", lua_TextBox_getTextColor},
         {"getTextColor", lua_TextBox_getTextColor},
         {"getTextRightToLeft", lua_TextBox_getTextRightToLeft},
         {"getTextRightToLeft", lua_TextBox_getTextRightToLeft},
+        {"getTheme", lua_TextBox_getTheme},
         {"getTopLevelForm", lua_TextBox_getTopLevelForm},
         {"getTopLevelForm", lua_TextBox_getTopLevelForm},
         {"getType", lua_TextBox_getType},
         {"getType", lua_TextBox_getType},
         {"getWidth", lua_TextBox_getWidth},
         {"getWidth", lua_TextBox_getWidth},
@@ -83,7 +85,6 @@ void luaRegister_TextBox()
         {"getY", lua_TextBox_getY},
         {"getY", lua_TextBox_getY},
         {"getZIndex", lua_TextBox_getZIndex},
         {"getZIndex", lua_TextBox_getZIndex},
         {"hasFocus", lua_TextBox_hasFocus},
         {"hasFocus", lua_TextBox_hasFocus},
-        {"initialize", lua_TextBox_initialize},
         {"isChild", lua_TextBox_isChild},
         {"isChild", lua_TextBox_isChild},
         {"isContainer", lua_TextBox_isContainer},
         {"isContainer", lua_TextBox_isContainer},
         {"isEnabled", lua_TextBox_isEnabled},
         {"isEnabled", lua_TextBox_isEnabled},
@@ -114,6 +115,7 @@ void luaRegister_TextBox()
         {"setFont", lua_TextBox_setFont},
         {"setFont", lua_TextBox_setFont},
         {"setFontSize", lua_TextBox_setFontSize},
         {"setFontSize", lua_TextBox_setFontSize},
         {"setHeight", lua_TextBox_setHeight},
         {"setHeight", lua_TextBox_setHeight},
+        {"setId", lua_TextBox_setId},
         {"setImageColor", lua_TextBox_setImageColor},
         {"setImageColor", lua_TextBox_setImageColor},
         {"setImageRegion", lua_TextBox_setImageRegion},
         {"setImageRegion", lua_TextBox_setImageRegion},
         {"setInputMode", lua_TextBox_setInputMode},
         {"setInputMode", lua_TextBox_setInputMode},
@@ -2636,6 +2638,50 @@ int lua_TextBox_getTextRightToLeft(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_TextBox_getTheme(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))
+            {
+                TextBox* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getTheme();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "Theme");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_TextBox_getTheme - 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_TextBox_getTopLevelForm(lua_State* state)
 int lua_TextBox_getTopLevelForm(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -2890,58 +2936,6 @@ int lua_TextBox_hasFocus(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
-int lua_TextBox_initialize(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 3:
-        {
-            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
-                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL) &&
-                (lua_type(state, 3) == LUA_TUSERDATA || lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TNIL))
-            {
-                // Get parameter 1 off the stack.
-                bool param1Valid;
-                gameplay::ScriptUtil::LuaArray<Theme::Style> param1 = gameplay::ScriptUtil::getObjectPointer<Theme::Style>(2, "ThemeStyle", false, &param1Valid);
-                if (!param1Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Theme::Style'.");
-                    lua_error(state);
-                }
-
-                // Get parameter 2 off the stack.
-                bool param2Valid;
-                gameplay::ScriptUtil::LuaArray<Properties> param2 = gameplay::ScriptUtil::getObjectPointer<Properties>(3, "Properties", false, &param2Valid);
-                if (!param2Valid)
-                {
-                    lua_pushstring(state, "Failed to convert parameter 2 to type 'Properties'.");
-                    lua_error(state);
-                }
-
-                TextBox* instance = getInstance(state);
-                instance->initialize(param1, param2);
-                
-                return 0;
-            }
-
-            lua_pushstring(state, "lua_TextBox_initialize - Failed to match the given parameters to a valid function signature.");
-            lua_error(state);
-            break;
-        }
-        default:
-        {
-            lua_pushstring(state, "Invalid number of parameters (expected 3).");
-            lua_error(state);
-            break;
-        }
-    }
-    return 0;
-}
-
 int lua_TextBox_isChild(lua_State* state)
 int lua_TextBox_isChild(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -4255,6 +4249,42 @@ int lua_TextBox_setHeight(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_TextBox_setId(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.
+                const char* param1 = gameplay::ScriptUtil::getString(2, false);
+
+                TextBox* instance = getInstance(state);
+                instance->setId(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_TextBox_setId - 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_TextBox_setImageColor(lua_State* state)
 int lua_TextBox_setImageColor(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -5494,6 +5524,34 @@ int lua_TextBox_static_create(lua_State* state)
     // Attempt to match the parameters to a valid binding.
     // Attempt to match the parameters to a valid binding.
     switch (paramCount)
     switch (paramCount)
     {
     {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                const char* param1 = gameplay::ScriptUtil::getString(1, false);
+
+                void* returnPtr = (void*)TextBox::create(param1);
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "TextBox");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_TextBox_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         case 2:
         case 2:
         {
         {
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
             if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL) &&
@@ -5534,7 +5592,7 @@ int lua_TextBox_static_create(lua_State* state)
         }
         }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }

+ 2 - 1
gameplay/src/lua/lua_TextBox.h

@@ -54,6 +54,7 @@ int lua_TextBox_getText(lua_State* state);
 int lua_TextBox_getTextAlignment(lua_State* state);
 int lua_TextBox_getTextAlignment(lua_State* state);
 int lua_TextBox_getTextColor(lua_State* state);
 int lua_TextBox_getTextColor(lua_State* state);
 int lua_TextBox_getTextRightToLeft(lua_State* state);
 int lua_TextBox_getTextRightToLeft(lua_State* state);
+int lua_TextBox_getTheme(lua_State* state);
 int lua_TextBox_getTopLevelForm(lua_State* state);
 int lua_TextBox_getTopLevelForm(lua_State* state);
 int lua_TextBox_getType(lua_State* state);
 int lua_TextBox_getType(lua_State* state);
 int lua_TextBox_getWidth(lua_State* state);
 int lua_TextBox_getWidth(lua_State* state);
@@ -61,7 +62,6 @@ int lua_TextBox_getX(lua_State* state);
 int lua_TextBox_getY(lua_State* state);
 int lua_TextBox_getY(lua_State* state);
 int lua_TextBox_getZIndex(lua_State* state);
 int lua_TextBox_getZIndex(lua_State* state);
 int lua_TextBox_hasFocus(lua_State* state);
 int lua_TextBox_hasFocus(lua_State* state);
-int lua_TextBox_initialize(lua_State* state);
 int lua_TextBox_isChild(lua_State* state);
 int lua_TextBox_isChild(lua_State* state);
 int lua_TextBox_isContainer(lua_State* state);
 int lua_TextBox_isContainer(lua_State* state);
 int lua_TextBox_isEnabled(lua_State* state);
 int lua_TextBox_isEnabled(lua_State* state);
@@ -92,6 +92,7 @@ int lua_TextBox_setFocusIndex(lua_State* state);
 int lua_TextBox_setFont(lua_State* state);
 int lua_TextBox_setFont(lua_State* state);
 int lua_TextBox_setFontSize(lua_State* state);
 int lua_TextBox_setFontSize(lua_State* state);
 int lua_TextBox_setHeight(lua_State* state);
 int lua_TextBox_setHeight(lua_State* state);
+int lua_TextBox_setId(lua_State* state);
 int lua_TextBox_setImageColor(lua_State* state);
 int lua_TextBox_setImageColor(lua_State* state);
 int lua_TextBox_setImageRegion(lua_State* state);
 int lua_TextBox_setImageRegion(lua_State* state);
 int lua_TextBox_setInputMode(lua_State* state);
 int lua_TextBox_setInputMode(lua_State* state);

+ 84 - 0
gameplay/src/lua/lua_Theme.cpp

@@ -2,6 +2,7 @@
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "lua_Theme.h"
 #include "lua_Theme.h"
 #include "Base.h"
 #include "Base.h"
+#include "FileSystem.h"
 #include "Game.h"
 #include "Game.h"
 #include "Ref.h"
 #include "Ref.h"
 #include "Theme.h"
 #include "Theme.h"
@@ -17,6 +18,7 @@ void luaRegister_Theme()
         {"addRef", lua_Theme_addRef},
         {"addRef", lua_Theme_addRef},
         {"getEmptyStyle", lua_Theme_getEmptyStyle},
         {"getEmptyStyle", lua_Theme_getEmptyStyle},
         {"getRefCount", lua_Theme_getRefCount},
         {"getRefCount", lua_Theme_getRefCount},
+        {"getSpriteBatch", lua_Theme_getSpriteBatch},
         {"getStyle", lua_Theme_getStyle},
         {"getStyle", lua_Theme_getStyle},
         {"release", lua_Theme_release},
         {"release", lua_Theme_release},
         {NULL, NULL}
         {NULL, NULL}
@@ -24,6 +26,7 @@ void luaRegister_Theme()
     const luaL_Reg lua_statics[] = 
     const luaL_Reg lua_statics[] = 
     {
     {
         {"create", lua_Theme_static_create},
         {"create", lua_Theme_static_create},
+        {"getDefault", lua_Theme_static_getDefault},
         {NULL, NULL}
         {NULL, NULL}
     };
     };
     std::vector<std::string> scopePath;
     std::vector<std::string> scopePath;
@@ -187,6 +190,50 @@ int lua_Theme_getRefCount(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Theme_getSpriteBatch(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))
+            {
+                Theme* instance = getInstance(state);
+                void* returnPtr = (void*)instance->getSpriteBatch();
+                if (returnPtr)
+                {
+                    gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = false;
+                    luaL_getmetatable(state, "SpriteBatch");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+
+            lua_pushstring(state, "lua_Theme_getSpriteBatch - 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_Theme_getStyle(lua_State* state)
 int lua_Theme_getStyle(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -313,4 +360,41 @@ int lua_Theme_static_create(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Theme_static_getDefault(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 0:
+        {
+            void* returnPtr = (void*)Theme::getDefault();
+            if (returnPtr)
+            {
+                gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                object->instance = returnPtr;
+                object->owns = false;
+                luaL_getmetatable(state, "Theme");
+                lua_setmetatable(state, -2);
+            }
+            else
+            {
+                lua_pushnil(state);
+            }
+
+            return 1;
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 }
 }

+ 2 - 0
gameplay/src/lua/lua_Theme.h

@@ -9,9 +9,11 @@ int lua_Theme__gc(lua_State* state);
 int lua_Theme_addRef(lua_State* state);
 int lua_Theme_addRef(lua_State* state);
 int lua_Theme_getEmptyStyle(lua_State* state);
 int lua_Theme_getEmptyStyle(lua_State* state);
 int lua_Theme_getRefCount(lua_State* state);
 int lua_Theme_getRefCount(lua_State* state);
+int lua_Theme_getSpriteBatch(lua_State* state);
 int lua_Theme_getStyle(lua_State* state);
 int lua_Theme_getStyle(lua_State* state);
 int lua_Theme_release(lua_State* state);
 int lua_Theme_release(lua_State* state);
 int lua_Theme_static_create(lua_State* state);
 int lua_Theme_static_create(lua_State* state);
+int lua_Theme_static_getDefault(lua_State* state);
 
 
 void luaRegister_Theme();
 void luaRegister_Theme();
 
 

+ 1 - 0
gameplay/src/lua/lua_ThemeSideRegions.cpp

@@ -2,6 +2,7 @@
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "lua_ThemeSideRegions.h"
 #include "lua_ThemeSideRegions.h"
 #include "Base.h"
 #include "Base.h"
+#include "FileSystem.h"
 #include "Game.h"
 #include "Game.h"
 #include "Ref.h"
 #include "Ref.h"
 #include "Theme.h"
 #include "Theme.h"

+ 1 - 0
gameplay/src/lua/lua_ThemeThemeImage.cpp

@@ -2,6 +2,7 @@
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "lua_ThemeThemeImage.h"
 #include "lua_ThemeThemeImage.h"
 #include "Base.h"
 #include "Base.h"
+#include "FileSystem.h"
 #include "Game.h"
 #include "Game.h"
 #include "Ref.h"
 #include "Ref.h"
 #include "Theme.h"
 #include "Theme.h"

+ 1 - 0
gameplay/src/lua/lua_ThemeUVs.cpp

@@ -2,6 +2,7 @@
 #include "ScriptController.h"
 #include "ScriptController.h"
 #include "lua_ThemeUVs.h"
 #include "lua_ThemeUVs.h"
 #include "Base.h"
 #include "Base.h"
+#include "FileSystem.h"
 #include "Game.h"
 #include "Game.h"
 #include "Ref.h"
 #include "Ref.h"
 #include "Theme.h"
 #include "Theme.h"

+ 5 - 0
samples/browser/game.config

@@ -16,3 +16,8 @@ gamepad
 {
 {
     form = res/common/gamepad.form
     form = res/common/gamepad.form
 }
 }
+
+ui
+{
+    defaultTheme = res/common/default.theme
+}

BIN
samples/browser/res/common/arial.gpb


+ 414 - 393
samples/browser/res/common/default.theme

@@ -1,393 +1,414 @@
-theme mainMenu
-{
-    texture = res/png/default-theme.png
-
-    imageList normalImages
-    {
-        color = #4A8799ff
-
-        image unchecked
-        {
-            region = 78, 1, 46, 46
-        }
-
-        image checked
-        {
-            region = 78, 46, 46, 46
-        }
-
-        image unselected
-        {
-            region = 127, 1, 46, 46
-        }
-
-        image selected
-        {
-            region = 127, 46, 46, 46
-        }
-
-        image minCap
-        {
-            region = 3, 115, 8, 11
-        }
-
-        image maxCap
-        {
-            region = 3, 115, 8, 11
-        }
-
-        image marker
-        {
-            region = 16, 113, 18, 18
-        }
-
-        image track
-        {
-            region = 42, 119, 26, 6
-        }
-
-        image textCaret
-        {
-            region = 5, 149, 11, 25
-            color = #C3D9BFff
-        }
-
-        image scrollBarTopCap
-        {
-            region = 0, 99, 12, 5
-        }
-
-        image verticalScrollBar
-        {
-            region = 0, 104, 12, 19
-        }
-
-        image scrollBarBottomCap
-        {
-            region = 0, 138, 12, 5
-        }
-
-        image scrollBarLeftCap
-        {
-            region = 35, 115, 5, 12
-        }
-
-        image horizontalScrollBar
-        {
-            region = 43, 115, 19, 12
-        }
-
-        image scrollBarRightCap
-        {
-            region = 65, 115, 5, 12
-        }
-    }
-
-    imageList activeImages : normalImages
-    {
-        color = #C3D9BFff
-
-        image unchecked
-        {
-            region = 78, 91, 46, 46
-        }
-
-        image checked
-        {
-            region = 78, 91, 46, 46
-        }
-
-        image unselected
-        {
-            region = 127, 91, 46, 46
-        }
-
-        image selected
-        {
-            region = 127, 91, 46, 46
-        }
-    }
-
-    skin mainNormal
-    {
-        border
-        {
-            left = 10
-            right = 10
-            top = 10
-            bottom = 10
-        }
-        
-        region = 1, 1, 74, 74
-        color = #4A8799ff
-    }
-
-    skin mainActive : mainNormal
-    {
-        color = #C3D9BFff
-    }
-
-	skin mainFocus : mainNormal
-	{
-		color = #2A6779ff
-	}
-
-    skin formEntry : mainNormal
-    {
-        region = 78, 1, 46, 46
-        color = #35535Cff
-    }
-
-	skin formFocus : formEntry
-	{
-        color = #15333Cff
-	}
-    
-    skin underliner
-    {
-        border
-        {
-            bottom = 10
-        }
-        
-        region = 4, 82, 68, 5
-        color = #ffffffff
-    }
-
-    skin plusNormal
-    {
-        region = 81, 139, 40, 40
-        color = #4A8799ff
-    }
-
-    skin plusActive : plusNormal
-    {
-        color = #C3D9BFff
-    }
-
-    skin minusNormal
-    {
-        region = 81, 184, 40, 40
-        color = #4A8799ff
-    }
-
-    skin minusActive : minusNormal
-    {
-        color = #C3D9BFff
-    }
-
-    style plus
-    {
-        stateNormal
-        {
-            skin = plusNormal
-        }
-
-        stateActive
-        {
-            skin = plusActive
-        }
-    }
-
-    style minus
-    {
-        stateNormal
-        {
-            skin = minusNormal
-        }
-
-        stateActive
-        {
-            skin = minusActive
-        }
-    }
-
-    style underlined
-    {
-        padding
-        {
-            top = 5
-        }
-    
-        stateNormal
-        {
-            skin = underliner
-            textColor = #ffffffff
-            font = res/common/arial.gpb
-            fontSize = 24
-            textAlignment = ALIGN_BOTTOM_HCENTER
-        }
-    }
-
-    style leftAlignedUnderlined : underlined
-    {
-        stateNormal
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-    }
-	
-	style basicContainer
-	{
-		stateNormal
-        {
-            skin = mainNormal
-            imageList = normalImages
-
-            font = res/common/arial.gpb
-            textColor = #ffffffff
-            fontSize = 18
-            textAlignment = ALIGN_VCENTER_HCENTER
-        }
-
-		stateFocus
-		{
-			skin = mainFocus
-		}
-		
-		stateDisabled
-		{
-			opacity = 0.6
-		}
-	}
-
-    style basic : basicContainer
-    {
-        stateActive
-        {
-            imageList = activeImages
-        }
-		
-		stateFocus
-		{
-			skin = mainNormal
-			textColor = #aaa000ff
-		}
-    }
-
-    style topLeftAlignedEntry : basic
-    {
-        stateNormal
-        {
-            skin = formEntry
-            textAlignment = ALIGN_TOP_LEFT
-        }
-
-        stateFocus
-        {
-            skin = formFocus
-        }
-    }
-
-    style buttonStyle : basic
-    {
-        padding
-        {
-            top = -10
-            bottom = -10
-        }
-
-        stateNormal
-        {
-            font = res/common/arial.gpb
-            fontSize = 20
-        }
-
-        stateActive
-        {
-            skin = mainActive
-        }
-    }
-	
-	style buttonHover : buttonStyle
-	{
-		stateHover
-		{
-			textColor = #ff0000ff
-		}
-	}
-
-    style noBorder
-    {
-        stateNormal
-        {
-            imageList = normalImages
-            font = res/common/arial.gpb
-            textColor = #ffffffff
-            fontSize = 14
-            textAlignment = ALIGN_VCENTER_HCENTER
-        }
-		
-		stateFocus
-		{
-			textColor = #aaa000ff
-		}
-
-        stateActive
-        {
-            imageList = activeImages
-            textAlignment = ALIGN_VCENTER_HCENTER
-        }
-    }
-
-    style iconNoBorder : noBorder
-    {
-        stateNormal
-        {
-            font = res/common/arial.gpb
-            fontSize = 20
-            textAlignment = ALIGN_VCENTER_LEFT
-        }
-
-        stateFocus
-		{
-			textAlignment = ALIGN_VCENTER_LEFT
-		}
-
-        stateActive
-        {
-            font = res/common/arial.gpb
-            fontSize = 20
-            textAlignment = ALIGN_VCENTER_LEFT
-        }
-    }
-
-    style topLeftNoBorder : iconNoBorder
-    {
-        stateNormal
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-
-        stateActive
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-
-        stateFocus
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-
-        stateHover
-        {
-            textAlignment = ALIGN_TOP_LEFT
-        }
-    }
-
-    style title
-    {
-        stateNormal
-        {
-            textColor = #ffffffff
-            font = res/common/arial.gpb
-            fontSize = 26
-            textAlignment = ALIGN_BOTTOM_HCENTER
-        }
-
-        stateActive
-        {
-            textColor = #C3D9BFff
-        }
-    }
-}
+theme mainMenu
+{
+    texture = res/png/default-theme.png
+
+    imageList normalImages
+    {
+        color = #4A8799ff
+
+        image unchecked
+        {
+            region = 78, 1, 46, 46
+        }
+
+        image checked
+        {
+            region = 78, 46, 46, 46
+        }
+
+        image unselected
+        {
+            region = 127, 1, 46, 46
+        }
+
+        image selected
+        {
+            region = 127, 46, 46, 46
+        }
+
+        image minCap
+        {
+            region = 3, 115, 8, 11
+        }
+
+        image maxCap
+        {
+            region = 3, 115, 8, 11
+        }
+
+        image marker
+        {
+            region = 16, 113, 18, 18
+        }
+
+        image track
+        {
+            region = 42, 119, 26, 6
+        }
+
+        image textCaret
+        {
+            region = 5, 149, 11, 25
+            color = #C3D9BFff
+        }
+
+        image scrollBarTopCap
+        {
+            region = 0, 99, 12, 5
+        }
+
+        image verticalScrollBar
+        {
+            region = 0, 104, 12, 19
+        }
+
+        image scrollBarBottomCap
+        {
+            region = 0, 138, 12, 5
+        }
+
+        image scrollBarLeftCap
+        {
+            region = 35, 115, 5, 12
+        }
+
+        image horizontalScrollBar
+        {
+            region = 43, 115, 19, 12
+        }
+
+        image scrollBarRightCap
+        {
+            region = 65, 115, 5, 12
+        }
+    }
+
+    imageList activeImages : normalImages
+    {
+        color = #C3D9BFff
+
+        image unchecked
+        {
+            region = 78, 91, 46, 46
+        }
+
+        image checked
+        {
+            region = 78, 91, 46, 46
+        }
+
+        image unselected
+        {
+            region = 127, 91, 46, 46
+        }
+
+        image selected
+        {
+            region = 127, 91, 46, 46
+        }
+    }
+
+    skin mainNormal
+    {
+        border
+        {
+            left = 10
+            right = 10
+            top = 10
+            bottom = 10
+        }
+        
+        region = 1, 1, 74, 74
+        color = #4A8799ff
+    }
+
+    skin mainActive : mainNormal
+    {
+        color = #C3D9BFff
+    }
+
+	skin mainFocus : mainNormal
+	{
+		color = #2A6779ff
+	}
+
+    skin formEntry : mainNormal
+    {
+        region = 78, 1, 46, 46
+        color = #35535Cff
+    }
+
+	skin formFocus : formEntry
+	{
+        color = #15333Cff
+	}
+    
+    skin underliner
+    {
+        border
+        {
+            bottom = 10
+        }
+        
+        region = 4, 82, 68, 5
+        color = #ffffffff
+    }
+
+    skin plusNormal
+    {
+        region = 81, 139, 40, 40
+        color = #4A8799ff
+    }
+
+    skin plusActive : plusNormal
+    {
+        color = #C3D9BFff
+    }
+
+    skin minusNormal
+    {
+        region = 81, 184, 40, 40
+        color = #4A8799ff
+    }
+
+    skin minusActive : minusNormal
+    {
+        color = #C3D9BFff
+    }
+
+    style plus
+    {
+        stateNormal
+        {
+            skin = plusNormal
+        }
+
+        stateActive
+        {
+            skin = plusActive
+        }
+    }
+
+    style minus
+    {
+        stateNormal
+        {
+            skin = minusNormal
+        }
+
+        stateActive
+        {
+            skin = minusActive
+        }
+    }
+
+    style underlined
+    {
+        padding
+        {
+            top = 5
+        }
+    
+        stateNormal
+        {
+            skin = underliner
+            textColor = #ffffffff
+            font = res/common/arial.gpb
+            fontSize = 16
+            textAlignment = ALIGN_BOTTOM_HCENTER
+        }
+    }
+
+    style leftAlignedUnderlined : underlined
+    {
+        stateNormal
+        {
+            textAlignment = ALIGN_TOP_LEFT
+        }
+    }
+	
+	style basicContainer
+	{
+		stateNormal
+        {
+            skin = mainNormal
+            imageList = normalImages
+
+            font = res/common/arial.gpb
+            textColor = #ffffffff
+            fontSize = 16
+            textAlignment = ALIGN_VCENTER_HCENTER
+        }
+
+		stateFocus
+		{
+			skin = mainFocus
+		}
+		
+		stateDisabled
+		{
+			opacity = 0.6
+		}
+	}
+
+    style basic : basicContainer
+    {
+        stateActive
+        {
+            imageList = activeImages
+        }
+		
+		stateFocus
+		{
+			skin = mainNormal
+			textColor = #aaa000ff
+		}
+    }
+
+    style topLeftAlignedEntry : basic
+    {
+        stateNormal
+        {
+            skin = formEntry
+            textAlignment = ALIGN_TOP_LEFT
+        }
+
+        stateFocus
+        {
+            skin = formFocus
+        }
+    }
+
+    style buttonStyle : basic
+    {
+        padding
+        {
+            top = -10
+            bottom = -10
+        }
+
+        stateNormal
+        {
+            font = res/common/arial.gpb
+            fontSize = 16
+        }
+
+        stateActive
+        {
+            skin = mainActive
+        }
+    }
+	
+	style buttonHover : buttonStyle
+	{
+		stateHover
+		{
+			textColor = #ff0000ff
+		}
+	}
+
+    style noBorder
+    {
+        stateNormal
+        {
+            imageList = normalImages
+            font = res/common/arial.gpb
+            textColor = #ffffffff
+            fontSize = 16
+            textAlignment = ALIGN_VCENTER_HCENTER
+        }
+		
+		stateFocus
+		{
+			textColor = #aaa000ff
+		}
+
+        stateActive
+        {
+            imageList = activeImages
+            textAlignment = ALIGN_VCENTER_HCENTER
+        }
+    }
+
+    style iconNoBorder : noBorder
+    {
+        stateNormal
+        {
+            font = res/common/arial.gpb
+            fontSize = 16
+            textAlignment = ALIGN_VCENTER_LEFT
+        }
+
+        stateActive
+        {
+            font = res/common/arial.gpb
+            fontSize = 16
+            textAlignment = ALIGN_VCENTER_LEFT
+        }
+    }
+
+    style topLeftNoBorder : iconNoBorder
+    {
+        stateNormal
+        {
+            textAlignment = ALIGN_TOP_LEFT
+        }
+
+        stateActive
+        {
+            textAlignment = ALIGN_TOP_LEFT
+        }
+    }
+
+    style title
+    {
+        stateNormal
+        {
+            textColor = #ffffffff
+            font = res/common/title.gpb
+            fontSize = 24
+            textAlignment = ALIGN_BOTTOM_HCENTER
+        }
+
+        stateActive
+        {
+            textColor = #C3D9BFff
+        }
+    }
+
+    style Form : basicContainer
+    {
+    }
+
+    style Container
+    {
+    }
+
+    style Label : iconNoBorder
+    {
+    }
+
+    style Button : buttonStyle
+    {
+    }
+
+    style CheckBox : iconNoBorder
+    {
+    }
+
+    style RadioButton : iconNoBorder
+    {
+    }
+
+    style TextBox : topLeftAlignedEntry
+    {
+    }
+
+    style Slider : topLeftNoBorder
+    {
+    }
+
+    style Image
+    {
+    }
+}

+ 12 - 23
samples/browser/res/common/forms/formBasicControls.form

@@ -1,14 +1,12 @@
 form basicControls
 form basicControls
 {
 {
-    theme = res/common/default.theme
     layout = LAYOUT_ABSOLUTE
     layout = LAYOUT_ABSOLUTE
-    style = basicContainer
     size = 600, 600
     size = 600, 600
 	consumeInputEvents = true
 	consumeInputEvents = true
+    batchingEnabled = false
     	
     	
 	label title
 	label title
 	{
 	{
-		style = underlined
 		position = 185, 0
 		position = 185, 0
 		size = 200, 50
 		size = 200, 50
 		text = This is a label.
 		text = This is a label.
@@ -16,7 +14,6 @@ form basicControls
 		
 		
 	button testButton
 	button testButton
 	{
 	{
-		style = buttonHover
 		position = 20, 80
 		position = 20, 80
 		size = 200, 100
 		size = 200, 100
 		text = This is a button with a hover state.
 		text = This is a button with a hover state.
@@ -24,7 +21,6 @@ form basicControls
 
 
 	checkbox testCheckbox
 	checkbox testCheckbox
 	{
 	{
-		style = iconNoBorder
 		position = 20, 220
 		position = 20, 220
 		size = 200, 40
 		size = 200, 40
 		text = This is a checkbox.
 		text = This is a checkbox.
@@ -32,7 +28,6 @@ form basicControls
 	
 	
 	slider testSlider
 	slider testSlider
 	{
 	{
-		style = topLeftNoBorder
 		position = 25, 315
 		position = 25, 315
 		size = 190, 60
 		size = 190, 60
 		orientation = HORIZONTAL
 		orientation = HORIZONTAL
@@ -47,7 +42,7 @@ form basicControls
 
 
     label textBoxLabel
     label textBoxLabel
     {
     {
-        style = iconNoBorder
+        //style = iconNoBorder
         position = 25, 400
         position = 25, 400
         size = 200, 60
         size = 200, 60
         text = Label:
         text = Label:
@@ -55,7 +50,6 @@ form basicControls
 
 
     textBox testTextBox
     textBox testTextBox
     {
     {
-        style = topLeftAlignedEntry
         position = 20, 450
         position = 20, 450
         size = 250, 80
         size = 250, 80
         text = This is a text box.
         text = This is a text box.
@@ -64,7 +58,6 @@ form basicControls
 
 
     textBox testPasswordTextBox
     textBox testPasswordTextBox
     {
     {
-        style = topLeftAlignedEntry
         position = 20, 540
         position = 20, 540
         size = 250, 40
         size = 250, 40
         text = PASSWORD
         text = PASSWORD
@@ -75,42 +68,39 @@ form basicControls
 	container radioButtonContainer
 	container radioButtonContainer
 	{
 	{
 		layout = LAYOUT_VERTICAL
 		layout = LAYOUT_VERTICAL
-		style = basic
-		position = 330, 100
-		size = 200, 140
-		
+		position = 330, 75
+		autoWidth = AUTO_SIZE_FIT
+        autoHeight = AUTO_SIZE_FIT
+
 		radioButton choice1
 		radioButton choice1
 		{
 		{
-			style = iconNoBorder
 			text = Radio button 1.
 			text = Radio button 1.
 			group = testRadio
 			group = testRadio
-			//position = 350, 80
-			size = 180, 40
+            autoWidth = AUTO_SIZE_FIT
+            autoHeight = AUTO_SIZE_FIT
 			selected = true
 			selected = true
 		}
 		}
 
 
 		radioButton choice2 : choice1
 		radioButton choice2 : choice1
 		{
 		{
 			text = Radio button 2.
 			text = Radio button 2.
-			//position = 350, 130
 			selected = false
 			selected = false
 		}
 		}
 
 
 		radioButton choice3 : choice2
 		radioButton choice3 : choice2
 		{
 		{
 			text = Radio button 3.
 			text = Radio button 3.
-			//position = 350, 180
 		}
 		}
 	}
 	}
 	
 	
 	image testImage
 	image testImage
 	{
 	{
 		position = 300, 250
 		position = 300, 250
-		style = basic
-		size = 256, 256
+        autoWidth = AUTO_SIZE_FIT
+        autoHeight = AUTO_SIZE_FIT
 		path = res/png/logo.png
 		path = res/png/logo.png
 	}
 	}
-	
+
 	button alignedButton
 	button alignedButton
     {
     {
 		margin
 		margin
@@ -118,8 +108,7 @@ form basicControls
 			right = 50
 			right = 50
 			bottom = 100
 			bottom = 100
 		}
 		}
-	
-        style = buttonStyle
+
         alignment = ALIGN_BOTTOM_RIGHT
         alignment = ALIGN_BOTTOM_RIGHT
         size = 200, 100
         size = 200, 100
         text = Alignment: bottom-right. Right margin: 50. Bottom margin: 100.
         text = Alignment: bottom-right. Right margin: 50. Bottom margin: 100.

+ 1 - 3
samples/browser/res/common/forms/formFlowLayout.form

@@ -1,15 +1,13 @@
 form flowLayout
 form flowLayout
 {
 {
-    theme = res/common/default.theme
     layout = LAYOUT_FLOW
     layout = LAYOUT_FLOW
-    style = basicContainer
     size = 600, 600
     size = 600, 600
     scroll = SCROLL_BOTH
     scroll = SCROLL_BOTH
 	consumeInputEvents = true
 	consumeInputEvents = true
 
 
     label label1
     label label1
     {
     {
-        style = basic
+        style = Button
         size = 200, 200
         size = 200, 200
         text = Flow Layout
         text = Flow Layout
     }
     }

+ 1 - 3
samples/browser/res/common/forms/formScrolling.form

@@ -1,8 +1,6 @@
 form scrolling
 form scrolling
 {
 {
-    theme = res/common/default.theme
     layout = LAYOUT_VERTICAL
     layout = LAYOUT_VERTICAL
-    style = basicContainer
     size = 600, 600
     size = 600, 600
     scroll = SCROLL_BOTH
     scroll = SCROLL_BOTH
     scrollBarsAutoHide = true
     scrollBarsAutoHide = true
@@ -10,7 +8,7 @@ form scrolling
 
 
     label label1
     label label1
     {
     {
-        style = basic
+        style = Button
         width = 4000
         width = 4000
         height = 200
         height = 200
         text = Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!
         text = Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!  Label!

+ 5 - 6
samples/browser/res/common/forms/formSelect.form

@@ -1,19 +1,18 @@
 form formSelect
 form formSelect
 {
 {
-    theme = res/common/default.theme
     layout = LAYOUT_VERTICAL
     layout = LAYOUT_VERTICAL
-    style = basicContainer
     alignment = ALIGN_TOP_LEFT
     alignment = ALIGN_TOP_LEFT
-    width = 200
-    autoHeight = true
+    width = 220
+    autoHeight = AUTO_SIZE_FIT
 	consumeInputEvents = false
 	consumeInputEvents = false
 
 
 	radioButton form0
 	radioButton form0
 	{
 	{
-		style = basic
+		style = Button
 		text = Basic Controls
 		text = Basic Controls
 		group = formSelection
 		group = formSelection
-		size = 180, 60
+        autoWidth = AUTO_SIZE_STRETCH
+		height = 60
 		textAlignment = ALIGN_VCENTER_LEFT
 		textAlignment = ALIGN_VCENTER_LEFT
 		selected = true
 		selected = true
 	}
 	}

+ 1 - 3
samples/browser/res/common/forms/formVerticalLayout.form

@@ -1,15 +1,13 @@
 form verticalLayout
 form verticalLayout
 {
 {
-    theme = res/common/default.theme
     layout = LAYOUT_VERTICAL
     layout = LAYOUT_VERTICAL
-    style = basicContainer
     size = 600, 600
     size = 600, 600
     scroll = SCROLL_BOTH
     scroll = SCROLL_BOTH
 	consumeInputEvents = true
 	consumeInputEvents = true
 
 
     label label2
     label label2
     {
     {
-        style = basic
+        style = Button
         size = 200, 200
         size = 200, 200
         text = Vertical Layout
         text = Vertical Layout
     }
     }

+ 4 - 3
samples/browser/res/common/forms/formZOrder.form

@@ -1,14 +1,15 @@
 form zOrder
 form zOrder
 {
 {
-    theme = res/common/default.theme
-    style = basicContainer
+    //theme = res/common/default.theme
+    //style = basicContainer
     size = 600, 600
     size = 600, 600
     scroll = SCROLL_BOTH
     scroll = SCROLL_BOTH
 	consumeInputEvents = true
 	consumeInputEvents = true
+    batchingEnabled = false
 	
 	
     label label1
     label label1
     {
     {
-        style = basic
+        style = Button
         size = 400, 200
         size = 400, 200
         text = TOP
         text = TOP
         zIndex = 3
         zIndex = 3

+ 8 - 0
samples/browser/res/common/gamepad.theme

@@ -79,4 +79,12 @@ theme gamepad
 			skin = buttonBActiveSkin
 			skin = buttonBActiveSkin
 		}
 		}
 	}
 	}
+
+    style form
+    {
+    }
+
+    style container
+    {
+    }
 }
 }

+ 1 - 1
samples/browser/res/common/inputs.form

@@ -27,7 +27,7 @@ form inputTestControls
     label restoreMouseLabel
     label restoreMouseLabel
     {
     {
         style = underlined
         style = underlined
-        position = 10, 290
+        position = 10, 250
         size = 160, 60
         size = 160, 60
         text = Press space to restore mouse
         text = Press space to restore mouse
     }
     }

+ 8 - 10
samples/browser/res/common/terrain/terrain.form

@@ -2,7 +2,7 @@ form terrainForm
 {
 {
     theme = res/common/default.theme
     theme = res/common/default.theme
 
 
-    style = noBorder
+    style = Container
     autoWidth = true
     autoWidth = true
     autoHeight = true
     autoHeight = true
     consumeInputEvents = false
     consumeInputEvents = false
@@ -17,7 +17,7 @@ form terrainForm
 
 
     container main
     container main
     {
     {
-        style = basic
+        style = Form
         width = 230
         width = 230
         height = 395
         height = 395
         consumeInputEvents = false
         consumeInputEvents = false
@@ -45,20 +45,18 @@ form terrainForm
 
 
         container settings
         container settings
         {
         {
-            style = noBorder
             autoWidth = true
             autoWidth = true
             autoHeight = true
             autoHeight = true
             consumeInputEvents = false
             consumeInputEvents = false
 
 
             checkbox wireframe
             checkbox wireframe
 		    {
 		    {
-			    style = noBorder
 			    imageSize = 35, 35
 			    imageSize = 35, 35
 			    size = 200, 40
 			    size = 200, 40
                 position = 10, 50
                 position = 10, 50
 			    text = Wireframe (1)
 			    text = Wireframe (1)
                 textAlignment = ALIGN_VCENTER_LEFT
                 textAlignment = ALIGN_VCENTER_LEFT
-                fontSize = 20
+                fontSize = 16
                 checked = false
                 checked = false
 		    }
 		    }
 
 
@@ -101,7 +99,7 @@ form terrainForm
 
 
     container physicsSettings
     container physicsSettings
     {
     {
-        style = basic
+        style = Form
         position = 0, 395
         position = 0, 395
         width = 230
         width = 230
         height = 165
         height = 165
@@ -118,7 +116,6 @@ form terrainForm
 
 
         button dropSphere
         button dropSphere
         {
         {
-            style = buttonStyle
             autoWidth = true
             autoWidth = true
             text = Drop Sphere
             text = Drop Sphere
             height = 45
             height = 45
@@ -137,7 +134,7 @@ form terrainForm
 
 
     container messageBox
     container messageBox
     {
     {
-        style = basic
+        style = Form
         alignment = ALIGN_VCENTER_HCENTER
         alignment = ALIGN_VCENTER_HCENTER
         width = 500
         width = 500
         height = 50
         height = 50
@@ -146,10 +143,11 @@ form terrainForm
 
 
         label message
         label message
         {
         {
-            style = noBorder
+            consumeInputEvents = false
             autoWidth = true
             autoWidth = true
             autoHeight = true
             autoHeight = true
-            fontSize = 30
+            font = res/common/title.gpb
+            fontSize = 24
             textAlignment = ALIGN_VCENTER_HCENTER
             textAlignment = ALIGN_VCENTER_HCENTER
         }
         }
     }
     }

BIN
samples/browser/res/common/title.gpb


+ 6 - 6
samples/browser/src/FormsSample.cpp

@@ -95,14 +95,14 @@ void FormsSample::initialize()
     form5Button->addListener(this, Control::Listener::CLICK);
     form5Button->addListener(this, Control::Listener::CLICK);
     for (unsigned int i = 0; i < _formFiles.size(); i++)
     for (unsigned int i = 0; i < _formFiles.size(); i++)
     {
     {
-        Form* form = Form::create(_formFiles[i]);
+		Form* form = Form::create(_formFiles[i]);
         form->setEnabled(false);
         form->setEnabled(false);
         _forms.push_back(form);
         _forms.push_back(form);
     }
     }
     _formIndex = 0;
     _formIndex = 0;
 
 
     // Create a form programmatically.
     // Create a form programmatically.
-    createSampleForm(_forms[0]->getTheme());
+    createSampleForm();
 
 
     Button* button = static_cast<Button*>(_forms[0]->getControl("testButton"));
     Button* button = static_cast<Button*>(_forms[0]->getControl("testButton"));
     button->setFocus();
     button->setFocus();
@@ -153,19 +153,19 @@ void FormsSample::formChanged()
     _formNode->setForm(_activeForm);
     _formNode->setForm(_activeForm);
 }
 }
 
 
-void FormsSample::createSampleForm(Theme* theme)
+void FormsSample::createSampleForm()
 {
 {
-    Form* form = Form::create("testForm", theme->getStyle("basicContainer"));
+    Form* form = Form::create("testForm", NULL);
     form->setSize(600, 600);
     form->setSize(600, 600);
 
 
-    Label* label = Label::create("testLabel", theme->getStyle("iconNoBorder"));
+    Label* label = Label::create("testLabel");
     label->setPosition(50, 50);
     label->setPosition(50, 50);
     label->setSize(200, 50);
     label->setSize(200, 50);
     label->setText("Label:");
     label->setText("Label:");
     form->addControl(label);
     form->addControl(label);
     label->release();
     label->release();
 
 
-    Button* button = Button::create("opacityButton", theme->getStyle("buttonStyle"));
+    Button* button = Button::create("opacityButton");
     button->setPosition(45, 100);
     button->setPosition(45, 100);
     button->setSize(200, 100);
     button->setSize(200, 100);
     button->setText("This is a button.  Click to change its opacity.");
     button->setText("This is a button.  Click to change its opacity.");

+ 3 - 3
samples/browser/src/FormsSample.h

@@ -33,7 +33,7 @@ private:
     
     
     void formChanged();
     void formChanged();
     
     
-    void createSampleForm(Theme* theme);
+    void createSampleForm();
     
     
     Scene* _scene;
     Scene* _scene;
     Node* _formNode;
     Node* _formNode;
@@ -46,10 +46,10 @@ private:
     bool _touched;
     bool _touched;
     int _touchX;
     int _touchX;
     unsigned int _formIndex;
     unsigned int _formIndex;
-    std::vector<const char*> _formFiles;
+    std::vector<const char*> _formFiles;
     std::string _sampleString;
     std::string _sampleString;
     Vector2 _joysticks[2];
     Vector2 _joysticks[2];
-
+
 };
 };
 
 
 #endif
 #endif

+ 1 - 1
samples/browser/src/InputSample.cpp

@@ -58,7 +58,7 @@ void InputSample::initialize()
     _formNode = Node::create("Form");
     _formNode = Node::create("Form");
     _formNodeParent->addChild(_formNode);
     _formNodeParent->addChild(_formNode);
     Theme* theme = _inputSampleControls->getTheme();
     Theme* theme = _inputSampleControls->getTheme();
-    Form* form = Form::create("testForm", theme->getStyle("basicContainer"));
+    Form* form = Form::create("testForm", theme->getStyle("basicContainer"), Layout::LAYOUT_ABSOLUTE);
     form->setSize(225, 100);
     form->setSize(225, 100);
     Label* label = Label::create("sensorLabel", theme->getStyle("iconNoBorder"));
     Label* label = Label::create("sensorLabel", theme->getStyle("iconNoBorder"));
     label->setPosition(25, 15);
     label->setPosition(25, 15);

+ 1 - 1
samples/browser/src/LightSample.cpp

@@ -97,7 +97,7 @@ void LightSample::initialize()
 	_model->setMaterial(_lighting);
 	_model->setMaterial(_lighting);
 
 
     // Create and initialize ui form
     // Create and initialize ui form
-	_form = Form::create("res/common/light.form");
+    _form = Form::create("res/common/light.form");
     _properties = static_cast<Container*>(_form->getControl("lightProperties"));
     _properties = static_cast<Container*>(_form->getControl("lightProperties"));
 	_redSlider = static_cast<Slider*>(_form->getControl("redSlider"));
 	_redSlider = static_cast<Slider*>(_form->getControl("redSlider"));
 	_redSlider->addListener(this, Control::Listener::VALUE_CHANGED);
 	_redSlider->addListener(this, Control::Listener::VALUE_CHANGED);

+ 301 - 309
samples/browser/src/SamplesGame.cpp

@@ -1,210 +1,202 @@
-#include "SamplesGame.h"
-
-using std::string;
-using std::pair;
-
-std::vector<std::string>* SamplesGame::_categories = NULL;
-std::vector<SamplesGame::SampleRecordList>* SamplesGame::_samples = NULL;
-
-// Declare our game instance
-SamplesGame game;
-
-SamplesGame::SamplesGame()
-    : _activeSample(NULL), _font(NULL),  _sampleSelectForm(NULL)
-{
-}
-
-void SamplesGame::initialize()
-{
-    _font = Font::create("res/common/arial.gpb");
-
-    for (size_t i = 0; i < _categories->size(); ++i)
-    {
-        std::sort((*_samples)[i].begin(), (*_samples)[i].end());
-    }
-
-    // Load camera script
-    getScriptController()->loadScript("res/common/camera.lua");
-
-    // Construct a form for selecting which sample to run.
-    Theme* theme = Theme::create("res/common/default.theme");
-    Theme::Style* formStyle = theme->getStyle("basicContainer");
-    Theme::Style* buttonStyle = theme->getStyle("buttonStyle");
-    Theme::Style* titleStyle = theme->getStyle("title");
-
-    // Note: this calls addRef() on formStyle's Theme, which we created above.
-    _sampleSelectForm = Form::create("sampleSelect", formStyle, Layout::LAYOUT_VERTICAL);
-    theme->release();   // So we can release it once we're done creating forms with it.
-
-    _sampleSelectForm->setAutoHeight(true);
-    _sampleSelectForm->setWidth(200.0f);
-    _sampleSelectForm->setScroll(Container::SCROLL_VERTICAL);
-    _sampleSelectForm->setConsumeInputEvents(true);
-
-    const size_t size = _samples->size();
-    for (size_t i = 0; i < size; ++i)
-    {
-        Label* categoryLabel = Label::create((*_categories)[i].c_str(), titleStyle);
-        categoryLabel->setAutoWidth(true);
-        categoryLabel->setTextAlignment(Font::ALIGN_BOTTOM_LEFT);
-        categoryLabel->setHeight(40);
-        categoryLabel->setText((*_categories)[i].c_str());
-        categoryLabel->setConsumeInputEvents(false);
-        _sampleSelectForm->addControl(categoryLabel);
-        categoryLabel->release();
-
-        SampleRecordList list = (*_samples)[i];
-        const size_t listSize = list.size();
-        for (size_t j = 0; j < listSize; ++j)
-        {
-            SampleRecord sampleRecord = list[j];
-            Button* sampleButton = Button::create(sampleRecord.title.c_str(), buttonStyle);
-            sampleButton->setText(sampleRecord.title.c_str());
-            sampleButton->setAutoWidth(true);
-            sampleButton->setHeight(60);      // Tall enough to touch easily on a BB10 device.
-            sampleButton->addListener(this, Control::Listener::CLICK);
-            _sampleSelectForm->addControl(sampleButton);
-            sampleButton->release();
-        }
-    }
-    _sampleSelectForm->setFocus();
-
-    // Disable virtual gamepads.
-    unsigned int gamepadCount = getGamepadCount();
-
-    for (unsigned int i = 0; i < gamepadCount; i++)
-    {
-        Gamepad* gamepad = getGamepad(i, false);
-        if (gamepad->isVirtual())
-        {
-            gamepad->getForm()->setEnabled(false);
-        }
-    }
-}
-
-void SamplesGame::finalize()
-{
-    SAFE_RELEASE(_font);
-    if (_activeSample)
-        _activeSample->finalize();
-    SAFE_DELETE(_activeSample);
-    SAFE_DELETE(_categories);
-    SAFE_DELETE(_samples);
-    SAFE_RELEASE(_sampleSelectForm);
-}
-
-void SamplesGame::update(float elapsedTime)
-{
-    if (_activeSample)
-    {
-        Gamepad* gamepad = getGamepad(0);
-        if (gamepad && gamepad->isButtonDown(Gamepad::BUTTON_MENU2))
-        {
-            exitActiveSample();
-            return;
-        }
-
-        getScriptController()->executeFunction<void>("camera_update", "f", elapsedTime);
-        _activeSample->update(elapsedTime);
-        return;
-    }
-
-    _sampleSelectForm->update(elapsedTime);
-}
-
-void SamplesGame::render(float elapsedTime)
-{
-    if (_activeSample)
-    {
-        _activeSample->render(elapsedTime);
-        
-        // Draw back arrow
-        _font->start();
-        _font->drawText("<<", getWidth() - 40, 20, Vector4::one(), 28);
-        _font->finish();
-        return;
-    }
-    // Clear the color and depth buffers
-    clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
-    _sampleSelectForm->draw();
-}
-
-void SamplesGame::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
-{
-    if (_activeSample)
-    {
-        if (evt == Touch::TOUCH_PRESS && x >= ((int)getWidth() - 80) && y <= 80)
-        {
-            exitActiveSample();
-        }
-        else
-        {
-            getScriptController()->executeFunction<void>("camera_touchEvent", "[Touch::TouchEvent]iiui", evt, x, y, contactIndex);
-            _activeSample->touchEvent(evt, x, y, contactIndex);
-        }
-        return;
-    }
-}
-
-void SamplesGame::keyEvent(Keyboard::KeyEvent evt, int key)
-{
-    if (_activeSample)
-    {
-        if (key == Keyboard::KEY_MENU || (evt == Keyboard::KEY_PRESS && (key == Keyboard::KEY_ESCAPE)))
-        {
-            // Pressing escape exits the active sample
-            exitActiveSample();
-        }
-        else
-        {
-            getScriptController()->executeFunction<void>("camera_keyEvent", "[Keyboard::KeyEvent][Keyboard::Key]", evt, key);
-            _activeSample->keyEvent(evt, key);
-        }
-        return;
-    }
-    if (evt == Keyboard::KEY_PRESS)
-    {
-        switch (key)
-        {
-        case Keyboard::KEY_ESCAPE:
-            exit();
-            break;
-        }
-    }
-}
-
-bool SamplesGame::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
-{
-    if (_activeSample)
-    {
-        return _activeSample->mouseEvent(evt, x, y, wheelDelta);
-    }
-    return false;
-}
-
-void SamplesGame::menuEvent()
-{
-    exitActiveSample();
-}
-
-void SamplesGame::gestureSwipeEvent(int x, int y, int direction)
-{
-    if (_activeSample)
-        _activeSample->gestureSwipeEvent(x, y, direction);
-}
-
-void SamplesGame::gesturePinchEvent(int x, int y, float scale)
-{
-    if (_activeSample)
-        _activeSample->gesturePinchEvent(x, y, scale);
-}
-    
-void SamplesGame::gestureTapEvent(int x, int y)
-{
-    if (_activeSample)
-        _activeSample->gestureTapEvent(x, y);
-}
-
+#include "SamplesGame.h"
+
+using std::string;
+using std::pair;
+
+std::vector<std::string>* SamplesGame::_categories = NULL;
+std::vector<SamplesGame::SampleRecordList>* SamplesGame::_samples = NULL;
+
+// Declare our game instance
+SamplesGame game;
+
+SamplesGame::SamplesGame()
+    : _activeSample(NULL), _font(NULL),  _sampleSelectForm(NULL)
+{
+}
+
+void SamplesGame::initialize()
+{
+    _font = Font::create("res/common/arial.gpb");
+
+    for (size_t i = 0; i < _categories->size(); ++i)
+    {
+        std::sort((*_samples)[i].begin(), (*_samples)[i].end());
+    }
+
+    // Load camera script
+    getScriptController()->loadScript("res/common/camera.lua");
+
+    // Create the selection form
+    Font* titleFont = Font::create("res/common/title.gpb");
+    _sampleSelectForm = Form::create("sampleSelect", NULL, Layout::LAYOUT_VERTICAL);
+    _sampleSelectForm->setWidth(200);
+    _sampleSelectForm->setAutoHeight(Control::AUTO_SIZE_STRETCH);
+    _sampleSelectForm->setScroll(Container::SCROLL_VERTICAL);
+    const size_t size = _samples->size();
+    for (size_t i = 0; i < size; ++i)
+    {
+		Label* categoryLabel = Label::create((*_categories)[i].c_str());
+        categoryLabel->setAutoWidth(Control::AUTO_SIZE_FIT);
+        categoryLabel->setAutoHeight(Control::AUTO_SIZE_FIT);
+        categoryLabel->setFont(titleFont);
+        categoryLabel->setFontSize(22);
+        categoryLabel->setText((*_categories)[i].c_str());
+        _sampleSelectForm->addControl(categoryLabel);
+        categoryLabel->release();
+
+        SampleRecordList list = (*_samples)[i];
+        const size_t listSize = list.size();
+        for (size_t j = 0; j < listSize; ++j)
+        {
+            SampleRecord sampleRecord = list[j];
+			Button* sampleButton = Button::create(sampleRecord.title.c_str());
+            sampleButton->setText(sampleRecord.title.c_str());
+            sampleButton->setAutoWidth(Control::AUTO_SIZE_STRETCH);
+            sampleButton->setHeight(50);
+            sampleButton->addListener(this, Control::Listener::CLICK);
+            _sampleSelectForm->addControl(sampleButton);
+            sampleButton->release();
+        }
+    }
+    _sampleSelectForm->setFocus();
+    SAFE_RELEASE(titleFont);
+
+    // Disable virtual gamepads.
+    unsigned int gamepadCount = getGamepadCount();
+
+    for (unsigned int i = 0; i < gamepadCount; i++)
+    {
+        Gamepad* gamepad = getGamepad(i, false);
+        if (gamepad->isVirtual())
+        {
+            gamepad->getForm()->setEnabled(false);
+        }
+    }
+}
+
+void SamplesGame::finalize()
+{
+    SAFE_RELEASE(_font);
+    if (_activeSample)
+        _activeSample->finalize();
+    SAFE_DELETE(_activeSample);
+    SAFE_DELETE(_categories);
+    SAFE_DELETE(_samples);
+    SAFE_RELEASE(_sampleSelectForm);
+}
+
+void SamplesGame::update(float elapsedTime)
+{
+    if (_activeSample)
+    {
+        Gamepad* gamepad = getGamepad(0);
+        if (gamepad && gamepad->isButtonDown(Gamepad::BUTTON_MENU2))
+        {
+            exitActiveSample();
+            return;
+        }
+
+        getScriptController()->executeFunction<void>("camera_update", "f", elapsedTime);
+        _activeSample->update(elapsedTime);
+        return;
+    }
+
+    _sampleSelectForm->update(elapsedTime);
+}
+
+void SamplesGame::render(float elapsedTime)
+{
+    if (_activeSample)
+    {
+        _activeSample->render(elapsedTime);
+        
+        // Draw back arrow
+        _font->start();
+        _font->drawText("<<", getWidth() - 40, 20, Vector4::one(), 28);
+        _font->finish();
+        return;
+    }
+    // Clear the color and depth buffers
+    clear(CLEAR_COLOR_DEPTH, Vector4::zero(), 1.0f, 0);
+    _sampleSelectForm->draw();
+}
+
+void SamplesGame::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
+{
+    if (_activeSample)
+    {
+        if (evt == Touch::TOUCH_PRESS && x >= ((int)getWidth() - 80) && y <= 80)
+        {
+            exitActiveSample();
+        }
+        else
+        {
+            getScriptController()->executeFunction<void>("camera_touchEvent", "[Touch::TouchEvent]iiui", evt, x, y, contactIndex);
+            _activeSample->touchEvent(evt, x, y, contactIndex);
+        }
+        return;
+    }
+}
+
+void SamplesGame::keyEvent(Keyboard::KeyEvent evt, int key)
+{
+    if (_activeSample)
+    {
+        if (key == Keyboard::KEY_MENU || (evt == Keyboard::KEY_PRESS && (key == Keyboard::KEY_ESCAPE)))
+        {
+            // Pressing escape exits the active sample
+            exitActiveSample();
+        }
+        else
+        {
+            getScriptController()->executeFunction<void>("camera_keyEvent", "[Keyboard::KeyEvent][Keyboard::Key]", evt, key);
+            _activeSample->keyEvent(evt, key);
+        }
+        return;
+    }
+    if (evt == Keyboard::KEY_PRESS)
+    {
+        switch (key)
+        {
+        case Keyboard::KEY_ESCAPE:
+            exit();
+            break;
+        }
+    }
+}
+
+bool SamplesGame::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
+{
+    if (_activeSample)
+    {
+        return _activeSample->mouseEvent(evt, x, y, wheelDelta);
+    }
+    return false;
+}
+
+void SamplesGame::menuEvent()
+{
+    exitActiveSample();
+}
+
+void SamplesGame::gestureSwipeEvent(int x, int y, int direction)
+{
+    if (_activeSample)
+        _activeSample->gestureSwipeEvent(x, y, direction);
+}
+
+void SamplesGame::gesturePinchEvent(int x, int y, float scale)
+{
+    if (_activeSample)
+        _activeSample->gesturePinchEvent(x, y, scale);
+}
+    
+void SamplesGame::gestureTapEvent(int x, int y)
+{
+    if (_activeSample)
+        _activeSample->gestureTapEvent(x, y);
+}
+
 void SamplesGame::gestureLongTapEvent(int x, int y, float duration)
 void SamplesGame::gestureLongTapEvent(int x, int y, float duration)
 {
 {
 	if (_activeSample)
 	if (_activeSample)
@@ -223,105 +215,105 @@ void SamplesGame::gestureDropEvent(int x, int y)
 		_activeSample->gestureDropEvent(x, y);
 		_activeSample->gestureDropEvent(x, y);
 }
 }
 
 
-void SamplesGame::controlEvent(Control* control, EventType evt)
-{
-    const size_t size = _samples->size();
-    for (size_t i = 0; i < size; ++i)
-    {
-        SampleRecordList list = (*_samples)[i];
-        const size_t listSize = list.size();
-        for (size_t j = 0; j < listSize; ++j)
-        {
-            SampleRecord sampleRecord = list[j];
-            if (sampleRecord.title.compare(control->getId()) == 0)
-            {
-                _sampleSelectForm->setEnabled(false);
-                runSample(sampleRecord.funcPtr);
-                return;
-            }
-        }
-    }
-}
-
-void SamplesGame::gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad, unsigned int analogIndex)
-{
-    if (_activeSample)
-        _activeSample->gamepadEvent(evt, gamepad);
-}
-
-void SamplesGame::runSample(void* func)
-{
-    exitActiveSample();
-    
-    SampleGameCreatePtr p = (SampleGameCreatePtr)func;
-
-    _activeSample = reinterpret_cast<Sample*>(p());
-    _activeSample->initialize();
-    resume();
-}
-
-void SamplesGame::exitActiveSample()
-{
-    Gamepad* virtualGamepad = getGamepad(0, false);
-    if (virtualGamepad && virtualGamepad->isVirtual())
-    {
-        virtualGamepad->getForm()->setEnabled(false);
-    }
-
-    if (_activeSample)
-    {
-        _activeSample->finalize();
-        SAFE_DELETE(_activeSample);
-
-        _sampleSelectForm->setEnabled(true);
-        _sampleSelectForm->setFocus();
-    }
-
-    // Reset some game options
-    setMultiTouch(false);
-}
-
-void SamplesGame::addSample(const char* category, const char* title, void* func, unsigned int order)
-{
-    if (_samples == NULL)
-        _samples = new std::vector<SampleRecordList>();
-    if (_categories == NULL)
-    {
-        _categories = new std::vector<std::string>();
-        _categories->push_back("Graphics");
-        _categories->push_back("Scene");
-        _categories->push_back("Input");
-        _categories->push_back("Physics");
-        _categories->push_back("Audio");
-        _samples->resize(_categories->size());
-    }
-
-    string categoryString(category);
-    string titleString(title);
-    
-    int index = -1;
-    const int size = (int)_categories->size();
-    for (int i = 0; i < size; ++i)
-    {
-        if ((*_categories)[i].compare(categoryString) == 0)
-        {
-            index = i;
-        }
-    }
-    if (index < 0)
-    {
-        _categories->push_back(categoryString);
-        index = (int)_categories->size() - 1;
-    }
-
-    if (index <= (int)_samples->size())
-    {
-        _samples->resize(_categories->size());
-    }
-    (*_samples)[index].push_back(SampleRecord(titleString, func, order));
-}
-
-SamplesGame* SamplesGame::getInstance()
-{
-    return &game;
-}
+void SamplesGame::controlEvent(Control* control, EventType evt)
+{
+    const size_t size = _samples->size();
+    for (size_t i = 0; i < size; ++i)
+    {
+        SampleRecordList list = (*_samples)[i];
+        const size_t listSize = list.size();
+        for (size_t j = 0; j < listSize; ++j)
+        {
+            SampleRecord sampleRecord = list[j];
+            if (sampleRecord.title.compare(control->getId()) == 0)
+            {
+                _sampleSelectForm->setEnabled(false);
+                runSample(sampleRecord.funcPtr);
+                return;
+            }
+        }
+    }
+}
+
+void SamplesGame::gamepadEvent(Gamepad::GamepadEvent evt, Gamepad* gamepad, unsigned int analogIndex)
+{
+    if (_activeSample)
+        _activeSample->gamepadEvent(evt, gamepad);
+}
+
+void SamplesGame::runSample(void* func)
+{
+    exitActiveSample();
+    
+    SampleGameCreatePtr p = (SampleGameCreatePtr)func;
+
+    _activeSample = reinterpret_cast<Sample*>(p());
+    _activeSample->initialize();
+    resume();
+}
+
+void SamplesGame::exitActiveSample()
+{
+    Gamepad* virtualGamepad = getGamepad(0, false);
+    if (virtualGamepad && virtualGamepad->isVirtual())
+    {
+        virtualGamepad->getForm()->setEnabled(false);
+    }
+
+    if (_activeSample)
+    {
+        _activeSample->finalize();
+        SAFE_DELETE(_activeSample);
+
+        _sampleSelectForm->setEnabled(true);
+        _sampleSelectForm->setFocus();
+    }
+
+    // Reset some game options
+    setMultiTouch(false);
+}
+
+void SamplesGame::addSample(const char* category, const char* title, void* func, unsigned int order)
+{
+    if (_samples == NULL)
+        _samples = new std::vector<SampleRecordList>();
+    if (_categories == NULL)
+    {
+        _categories = new std::vector<std::string>();
+        _categories->push_back("Graphics");
+        _categories->push_back("Scene");
+        _categories->push_back("Input");
+        _categories->push_back("Physics");
+        _categories->push_back("Audio");
+        _samples->resize(_categories->size());
+    }
+
+    string categoryString(category);
+    string titleString(title);
+    
+    int index = -1;
+    const int size = (int)_categories->size();
+    for (int i = 0; i < size; ++i)
+    {
+        if ((*_categories)[i].compare(categoryString) == 0)
+        {
+            index = i;
+        }
+    }
+    if (index < 0)
+    {
+        _categories->push_back(categoryString);
+        index = (int)_categories->size() - 1;
+    }
+
+    if (index <= (int)_samples->size())
+    {
+        _samples->resize(_categories->size());
+    }
+    (*_samples)[index].push_back(SampleRecord(titleString, func, order));
+}
+
+SamplesGame* SamplesGame::getInstance()
+{
+    return &game;
+}

+ 1 - 1
samples/browser/src/TextSample.cpp

@@ -18,7 +18,7 @@ std::string _fontNames[] =
 };
 };
 
 
 TextSample::TextSample()
 TextSample::TextSample()
-    : _form(NULL), _stateBlock(NULL), _size(18), _wrap(true), _ignoreClip(false), _useViewport(true), _rightToLeft(false), _simple(false), _alignment(Font::ALIGN_LEFT),
+    : _form(NULL), _stateBlock(NULL), _size(16), _wrap(true), _ignoreClip(false), _useViewport(true), _rightToLeft(false), _simple(false), _alignment(Font::ALIGN_LEFT),
       _fontsCount(FONT_COUNT), _fontIndex(0), _font(NULL), _viewport(250, 100, 512, 200)
       _fontsCount(FONT_COUNT), _fontIndex(0), _font(NULL), _viewport(250, 100, 512, 200)
 {
 {
 }
 }

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است