Преглед на файлове

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

setaylor преди 13 години
родител
ревизия
9513774d19
променени са 5 файла, в които са добавени 40 реда и са изтрити 12 реда
  1. 2 2
      gameplay-template/gameplay-template.vcxproj
  2. 17 4
      gameplay/src/Font.cpp
  3. 6 4
      gameplay/src/Joystick.cpp
  4. 14 1
      gameplay/src/Model.cpp
  5. 1 1
      gameplay/src/PlatformQNX.cpp

+ 2 - 2
gameplay-template/gameplay-template.vcxproj

@@ -169,8 +169,8 @@
     <None Include="res\box.dae" />
     <None Include="res\box.gpb" />
     <None Include="res\box.material" />
-    <None Include="res\colored.fsh" />
-    <None Include="res\colored.vsh" />
+    <None Include="res\colored.frag" />
+    <None Include="res\colored.vert" />
   </ItemGroup> 
   <ItemGroup>
     <ClCompile Include="src\TemplateGame.cpp" />

+ 17 - 4
gameplay/src/Font.cpp

@@ -751,12 +751,19 @@ void Font::measureText(const char* text, unsigned int size, unsigned int* width,
     GP_ASSERT(width);
     GP_ASSERT(height);
 
-    float scale = (float)size / _size;
     const int length = strlen(text);
+    if (length == 0)
+    {
+        *width = 0;
+        *height = 0;
+        return;
+    }
+
+    float scale = (float)size / _size;
     const char* token = text;
 
     *width = 0;
-    *height = 0;
+    *height = size;
 
     // Measure a line at a time.
     while (token[0] != 0)
@@ -784,6 +791,12 @@ void Font::measureText(const char* text, const Rectangle& clip, unsigned int siz
     GP_ASSERT(text);
     GP_ASSERT(out);
 
+    if (strlen(text) == 0)
+    {
+        out->set(0, 0, 0, 0);
+        return;
+    }
+
     float scale = (float)size / _size;
     Justify vAlign = static_cast<Justify>(justify & 0xF0);
     if (vAlign == 0)
@@ -802,8 +815,8 @@ void Font::measureText(const char* text, const Rectangle& clip, unsigned int siz
     std::vector<Vector2> lines;
 
     unsigned int lineWidth = 0;
-    int yPos = clip.y;
-    const float viewportHeight = clip.height - size;
+    int yPos = clip.y + size;
+    const float viewportHeight = clip.height;
 
     if (wrap)
     {

+ 6 - 4
gameplay/src/Joystick.cpp

@@ -112,7 +112,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
                 {
                     _value.set(value);
                     _dirty = true;
-                    notifyListeners(Control::Listener::VALUE_CHANGED);
+                    notifyListeners(Listener::VALUE_CHANGED);
                 }
 
                 _state = ACTIVE;
@@ -138,7 +138,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
                 {
                     _value.set(value);
                     _dirty = true;
-                    notifyListeners(Control::Listener::VALUE_CHANGED);
+                    notifyListeners(Listener::VALUE_CHANGED);
                 }
             }
             else
@@ -151,7 +151,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
                 {
                     _value.set(value);
                     _dirty = true;
-                    notifyListeners(Control::Listener::VALUE_CHANGED);
+                    notifyListeners(Listener::VALUE_CHANGED);
                 }
             }
 
@@ -163,6 +163,8 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
         {
             _contactIndex = INVALID_CONTACT_INDEX;
 
+            notifyListeners(Listener::RELEASE);
+
             // Reset displacement and direction vectors.
             _displacement.set(0.0f, 0.0f);
 
@@ -171,7 +173,7 @@ bool Joystick::touchEvent(Touch::TouchEvent touchEvent, int x, int y, unsigned i
             {
                 _value.set(value);
                 _dirty = true;
-                notifyListeners(Control::Listener::VALUE_CHANGED);
+                notifyListeners(Listener::VALUE_CHANGED);
             }
 
             _state = NORMAL;

+ 14 - 1
gameplay/src/Model.cpp

@@ -393,9 +393,22 @@ Model* Model::clone(NodeCloneContext &context)
             GP_ERROR("Failed to clone material for model.");
             return model;
         }
-        model->setMaterial(materialClone); // TODO: Don't forget material parts
+        model->setMaterial(materialClone);
         materialClone->release();
     }
+    if (_partMaterials)
+    {
+        GP_ASSERT(_partCount == model->_partCount);
+        for (unsigned int i = 0; i < _partCount; ++i)
+        {
+            if (_partMaterials[i])
+            {
+                Material* materialClone = _partMaterials[i]->clone(context);
+                model->setMaterial(materialClone, i);
+                materialClone->release();
+            }
+        }
+    }
     return model;
 }
 

+ 1 - 1
gameplay/src/PlatformQNX.cpp

@@ -957,7 +957,7 @@ int Platform::enterMessagePump(bool loop)
                 switch (bps_event_get_code(event))
                 {
                 case NAVIGATOR_SWIPE_DOWN:
-                    _game->menu();
+                    _game->menuEvent();
                     break;
                 case NAVIGATOR_WINDOW_STATE:
                 {