]> git.localhorst.tv Git - l2e.git/blobdiff - src/graphics/Font.cpp
added right aligning font drawing functions
[l2e.git] / src / graphics / Font.cpp
index be96a2c104b860f0e9dda819388c92c0fa206d81..59059e07436d1893da0a9fc7dc73612fe5c79a92 100644 (file)
@@ -39,6 +39,18 @@ void Font::DrawString(const char *s, SDL_Surface *dest, const Vector<int> &posit
        }
 }
 
+void Font::DrawStringRight(const char *s, SDL_Surface *dest, const Vector<int> &positionIn, int maxChars) const {
+       if (!sprite) return;
+
+       int length(0);
+       while (length < maxChars && s[length] != '\0') {
+               ++length;
+       }
+       Vector<int> position(positionIn.X() - length * CharWidth(), positionIn.Y());
+
+       DrawString(s, dest, position, length);
+}
+
 void Font::DrawDigit(int digit, SDL_Surface *dest, const Vector<int> &position) const {
        if (!sprite) return;
 
@@ -76,6 +88,14 @@ void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Vector<int> &positi
        }
 }
 
+void Font::DrawNumberRight(int number, SDL_Surface *dest, const Vector<int> &positionIn, int digits) const {
+       if (!sprite) return;
+
+       Vector<int> position(positionIn.X() - digits * CharWidth(), positionIn.Y());
+
+       DrawNumber(number, dest, position, digits);
+}
+
 
 void Font::CreateTypeDescription() {
        Font f;