Просмотр исходного кода

Merge pull request #200 from blackberry-gaming/next

Next
Sean Paul Taylor 13 лет назад
Родитель
Сommit
23bf74d5d1
2 измененных файлов с 23 добавлено и 8 удалено
  1. 17 4
      gameplay/src/Font.cpp
  2. 6 4
      gameplay/src/Joystick.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;