Browse Source

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

Conflicts:
	gameplay-tests/src/GamepadTest.cpp
	gameplay-tests/src/GamepadTest.h
setaylor 13 years ago
parent
commit
34c206f840

+ 7 - 7
README.md

@@ -8,17 +8,17 @@ GamePlay3D is an open-source, cross-platform 3D native C++ game framework making
 - [Forums](http://www.gameplay3d.org/forums/)
 - [Wiki](https://github.com/blackberry/GamePlay/wiki)
 - [API Reference](http://www.gameplay3d.org/api.php)
-- [Documentation](http://www.gameplay3d.org/docs.php)
+- [Development Guide](https://github.com/blackberry/GamePlay/wiki#wiki-Development_Guide)
 
 ## Supported Mobile Platforms
-- BlackBerry 10 and PlayBook (using [BlackBerry Native SDK](http://developer.blackberry.com/native/))
-- Apple iOS 5 (using Apple XCode 4)
-- Google Android 2.3+ (using Google Android NDK)
+- [BlackBerry 10 and PlayBook](https://github.com/blackberry/GamePlay/wiki/BlackBerry-Setup) (using BlackBerry Native SDK)
+- [Apple iOS 5](https://github.com/blackberry/GamePlay/wiki/Apple-Xcode-Setup) (using Apple XCode 4)
+- [Google Android 2.3+](https://github.com/blackberry/GamePlay/wiki/Android-NDK-Setup) (using Google Android NDK)
 
 ## Supported Desktop Platforms
-- Microsoft Windows 7 (using Microsoft Visual Studio 2010)
-- Apple MacOS X (using Apple XCode 4)
-- Linux (using CMake)
+- [Microsoft Windows 7](https://github.com/blackberry/GamePlay/wiki/Visual-Studio-Setup) (using Microsoft Visual Studio 2010)
+- [Apple MacOS X](https://github.com/blackberry/GamePlay/wiki/Apple-Xcode-Setup) (using Apple XCode 4)
+- [Linux](https://github.com/blackberry/GamePlay/wiki/Linux-Setup) (using CMake)
 
 ## Roadmap for 'next' branch
 - [Version 1.7.0 Milestone](https://github.com/blackberry/GamePlay/issues?milestone=4)

+ 0 - 3
gameplay/src/Button.cpp

@@ -41,9 +41,6 @@ Button* Button::create(Theme::Style* style, Properties* properties)
 
 bool Button::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
-    if (!isEnabled())
-        return false;
-
     switch (evt)
     {
     case Touch::TOUCH_PRESS:

+ 0 - 5
gameplay/src/CheckBox.cpp

@@ -76,11 +76,6 @@ void CheckBox::addListener(Control::Listener* listener, int eventFlags)
 
 bool CheckBox::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     {
     case Touch::TOUCH_RELEASE:

+ 7 - 5
gameplay/src/Container.cpp

@@ -167,7 +167,9 @@ void Container::addControls(Theme* theme, Properties* properties)
         }
         else
         {
-            GP_ERROR("Failed to create control; unrecognized control name '%s'.", controlName.c_str());
+            // Ignore - not a valid control name.
+            // This used to fail, but I see no reason to hard fail here (this also fixes not being able
+            // to set padding on containers).
         }
 
         // Add the new control to the form.
@@ -608,7 +610,7 @@ bool Container::keyEvent(Keyboard::KeyEvent evt, int key)
     {
         Control* control = *it;
         GP_ASSERT(control);
-        if (!control->isEnabled())
+        if (!control->isEnabled() || !control->isVisible())
         {
             continue;
         }
@@ -1024,7 +1026,7 @@ bool Container::mouseEventScroll(Mouse::MouseEvent evt, int x, int y, int wheelD
 
 bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
 {
-    if (!isEnabled())
+    if (!isEnabled() || !isVisible())
     {
         return false;
     }
@@ -1051,7 +1053,7 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
     {
         Control* control = *it;
         GP_ASSERT(control);
-        if (!control->isEnabled())
+        if (!control->isEnabled() || !control->isVisible())
         {
             continue;
         }
@@ -1085,7 +1087,7 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
         }
     }
 
-    if (!isEnabled())
+    if (!isEnabled() || !isVisible())
     {
         release();
         return (_consumeInputEvents | eventConsumed);

+ 0 - 8
gameplay/src/Control.cpp

@@ -760,9 +760,6 @@ void Control::addSpecificListener(Control::Listener* listener, Listener::EventTy
 
 bool Control::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
-    if (!isEnabled())
-        return false;
-
     switch (evt)
     {
     case Touch::TOUCH_PRESS:
@@ -816,11 +813,6 @@ bool Control::keyEvent(Keyboard::KeyEvent evt, int key)
 
 bool Control::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     // By default, mouse events are either interpreted as touch events or ignored.
     switch (evt)
     {

+ 3 - 3
gameplay/src/Form.cpp

@@ -590,7 +590,7 @@ bool Form::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int
         Form* form = __forms[i];
         GP_ASSERT(form);
 
-        if (form->isEnabled())
+        if (form->isEnabled() && form->isVisible())
         {
             if (form->_node)
             {
@@ -636,7 +636,7 @@ bool Form::keyEventInternal(Keyboard::KeyEvent evt, int key)
     {
         Form* form = __forms[i];
         GP_ASSERT(form);
-        if (form->isEnabled())
+        if (form->isEnabled() && form->isVisible())
         {
             if (form->keyEvent(evt, key))
                 return true;
@@ -654,7 +654,7 @@ bool Form::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelt
         Form* form = __forms[i];
         GP_ASSERT(form);
 
-        if (form->isEnabled())
+        if (form->isEnabled() && form->isVisible())
         {
             if (form->_node)
             {

+ 7 - 3
gameplay/src/Gamepad.cpp

@@ -15,7 +15,6 @@ Gamepad::Gamepad(const char* formPath)
     _form = Form::create(formPath);
     GP_ASSERT(_form);
     _form->setConsumeInputEvents(false);
-    _id = _form->getId();
     _vendorString = "None";
     _productString = "Virtual";
 
@@ -76,6 +75,7 @@ void Gamepad::remove(GamepadHandle handle)
         if (gamepad->_handle == handle)
         {
             Game::getInstance()->gamepadEvent(DISCONNECTED_EVENT, gamepad);
+            SAFE_DELETE(gamepad);
             it = __gamepads.erase(it);
         }
         else
@@ -94,6 +94,7 @@ void Gamepad::remove(Gamepad* gamepad)
         if (g == gamepad)
         {
             Game::getInstance()->gamepadEvent(DISCONNECTED_EVENT, g);
+            SAFE_DELETE(gamepad);
             it = __gamepads.erase(it);
         }
         else
@@ -211,9 +212,12 @@ const char* Gamepad::getProductString() const
 
 void Gamepad::update(float elapsedTime)
 {
-    if (_form && _form->isEnabled())
+    if (_form)
     {
-        _form->update(elapsedTime);
+        if (_form->isEnabled())
+        {
+            _form->update(elapsedTime);
+        }
     }
     else
     {

+ 3 - 5
gameplay/src/Gamepad.h

@@ -225,16 +225,14 @@ private:
 
     static unsigned int getIndexFromMapping(Gamepad::ButtonMapping mapping);
 
-    std::string _id;
     GamepadHandle _handle;        // The handle of the Gamepad.
+    unsigned int _buttonCount;    // Number of buttons.
+    unsigned int _joystickCount;  // Number of joysticks.
+    unsigned int _triggerCount;   // Number of triggers.
     unsigned int _vendorId;
     unsigned int _productId;
     std::string _vendorString;
     std::string _productString;
-
-    unsigned int _buttonCount;    // Number of buttons.
-    unsigned int _joystickCount;  // Number of joysticks.
-    unsigned int _triggerCount;   // Number of triggers.
     
     // Data needed for virtual gamepads.
     Form* _form;

+ 1 - 1
gameplay/src/PlatformAndroid.cpp

@@ -1255,7 +1255,7 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
 void Platform::gamepadEventConnectedInternal(GamepadHandle handle,  unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
                                              unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
 {
-    Gamepad::add(GamepadHandle handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
+    Gamepad::add(handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
 }
 
 void Platform::gamepadEventDisconnectedInternal(GamepadHandle handle)

+ 2 - 2
gameplay/src/PlatformBlackBerry.cpp

@@ -1242,7 +1242,7 @@ int Platform::enterMessagePump()
                                 int vendorId;
                                 char productString[64];
                                 char vendorString[64];
-                                loadGamepad(device, &buttonCount, &joystickCount, &productId, &vendorId, productString, vendorString);
+                                queryGamepad(device, &buttonCount, &joystickCount, &productId, &vendorId, productString, vendorString);
                                 Platform::gamepadEventConnectedInternal(device, buttonCount, joystickCount, 0, vendorId, productId, vendorString, productString);
                             }
                         }
@@ -1520,7 +1520,7 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
 void Platform::gamepadEventConnectedInternal(GamepadHandle handle,  unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
                                              unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
 {
-    Gamepad::add(GamepadHandle handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
+    Gamepad::add(handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
 }
 
 void Platform::gamepadEventDisconnectedInternal(GamepadHandle handle)

+ 0 - 5
gameplay/src/RadioButton.cpp

@@ -91,11 +91,6 @@ void RadioButton::addListener(Control::Listener* listener, int eventFlags)
 
 bool RadioButton::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     {
     case Touch::TOUCH_RELEASE:

+ 0 - 10
gameplay/src/Slider.cpp

@@ -135,11 +135,6 @@ void Slider::addListener(Control::Listener* listener, int eventFlags)
 
 bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     {
     case Touch::TOUCH_PRESS:
@@ -243,11 +238,6 @@ bool Slider::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contac
 
 bool Slider::mouseEvent(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
 {
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     {
         case Mouse::MOUSE_PRESS_LEFT_BUTTON:

+ 3 - 3
gameplay/src/TerrainPatch.cpp

@@ -482,15 +482,15 @@ bool TerrainPatch::updateMaterial()
 
         // Set material parameter bindings
         material->getParameter("u_worldViewProjectionMatrix")->bindValue(_terrain, &Terrain::getWorldViewProjectionMatrix);
-        if (!_terrain->_normalMap)
+        if (_terrain->_normalMap)
+            material->getParameter("u_normalMap")->setValue(_terrain->_normalMap);
+        else
             material->getParameter("u_normalMatrix")->bindValue(_terrain, &Terrain::getNormalMatrix);
         material->getParameter("u_ambientColor")->bindValue(this, &TerrainPatch::getAmbientColor);
         material->getParameter("u_lightColor")->bindValue(this, &TerrainPatch::getLightColor);
         material->getParameter("u_lightDirection")->bindValue(this, &TerrainPatch::getLightDirection);
         if (_layers.size() > 0)
             material->getParameter("u_samplers")->setValue((const Texture::Sampler**)&_samplers[0], (unsigned int)_samplers.size());
-        if (_terrain->_normalMap)
-            material->getParameter("u_normalMap")->setValue(_terrain->_normalMap);
 
         if (_terrain->isFlagSet(Terrain::DEBUG_PATCHES))
         {

+ 0 - 5
gameplay/src/TextBox.cpp

@@ -49,11 +49,6 @@ void TextBox::addListener(Control::Listener* listener, int eventFlags)
 
 bool TextBox::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {   
-    if (!isEnabled())
-    {
-        return false;
-    }
-
     switch (evt)
     {
     case Touch::TOUCH_PRESS: