Explorar o código

Merge pull request #409 from blackberry-gaming/next-setaylor

Next setaylor
Sean Paul Taylor %!s(int64=13) %!d(string=hai) anos
pai
achega
02c8a6fce9
Modificáronse 2 ficheiros con 12 adicións e 18 borrados
  1. 10 16
      gameplay/src/Font.cpp
  2. 2 2
      gameplay/src/Font.h

+ 10 - 16
gameplay/src/Font.cpp

@@ -242,9 +242,7 @@ Font::Text* Font::createText(const char* text, const Rectangle& area, const Vect
         }
 
         // Wrap if necessary.
-        if (wrap &&
-            xPos + (int)tokenWidth > area.x + area.width ||
-            (rightToLeft && currentLineLength > lineLength))
+        if (wrap && (xPos + (int)tokenWidth > area.x + area.width || (rightToLeft && currentLineLength > lineLength)))
         {
             yPos += (int)size;
             currentLineLength = tokenLength;
@@ -303,11 +301,11 @@ Font::Text* Font::createText(const char* text, const Rectangle& area, const Vect
                         if (batch->_vertexCount == 0)
                         {
                             // Simply copy values directly into the start of the index array
-                            //memcpy(_indicesPtr, indices, indexCount * sizeof(unsigned short));
-                            batch->_indices[batch->_vertexCount] = batch->_vertexCount++;
-                            batch->_indices[batch->_vertexCount] = batch->_vertexCount++;
-                            batch->_indices[batch->_vertexCount] = batch->_vertexCount++;
-                            batch->_indices[batch->_vertexCount] = batch->_vertexCount++;
+                            batch->_indices[batch->_vertexCount] = batch->_vertexCount;
+                            batch->_indices[batch->_vertexCount] = batch->_vertexCount + 1;
+                            batch->_indices[batch->_vertexCount] = batch->_vertexCount + 2;
+                            batch->_indices[batch->_vertexCount] = batch->_vertexCount + 3;
+                            batch->_vertexCount += 4;
                             batch->_indexCount += 4;
                         }
                         else
@@ -506,6 +504,7 @@ void Font::drawText(const char* text, int x, int y, const Vector4& color, unsign
                     xPos += floor(g.width * scale + (float)(size >> 3));
                     break;
                 }
+                break;
             }
         }
 
@@ -586,9 +585,7 @@ void Font::drawText(const char* text, const Rectangle& area, const Vector4& colo
         }
 
         // Wrap if necessary.
-        if (wrap &&
-            xPos + (int)tokenWidth > area.x + area.width ||
-            (rightToLeft && currentLineLength > lineLength))
+        if (wrap && (xPos + (int)tokenWidth > area.x + area.width || (rightToLeft && currentLineLength > lineLength)))
         {
             yPos += (int)size;
             currentLineLength = tokenLength;
@@ -1353,9 +1350,7 @@ int Font::getIndexOrLocation(const char* text, const Rectangle& area, unsigned i
         }
 
         // Wrap if necessary.
-        if (wrap &&
-            xPos + (int)tokenWidth > area.x + area.width ||
-            (rightToLeft && currentLineLength > lineLength))
+        if (wrap && (xPos + (int)tokenWidth > area.x + area.width || (rightToLeft && currentLineLength > lineLength)))
         {
             yPos += size;
             currentLineLength = tokenLength;
@@ -1714,9 +1709,8 @@ Font::Justify Font::getJustify(const char* justify)
     return Font::ALIGN_TOP_LEFT;
 }
 
-Font::Text::Text(const char* text) : _vertexCount(0), _indexCount(0)
+Font::Text::Text(const char* text) : _text(text), _vertexCount(0), _vertices(NULL), _indexCount(0), _indices(NULL)
 {
-    _text = text;
     const int length = strlen(text);
     _vertices = new SpriteBatch::SpriteVertex[length * 4];
     _indices = new unsigned short[((length - 1) * 6) + 4];

+ 2 - 2
gameplay/src/Font.h

@@ -103,10 +103,10 @@ public:
 
     private:
         std::string _text;
-        SpriteBatch::SpriteVertex* _vertices;
-        unsigned short* _indices;
         unsigned int _vertexCount;
+        SpriteBatch::SpriteVertex* _vertices;
         unsigned int _indexCount;
+        unsigned short* _indices;
         Vector4 _color;
     };