X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FFont.cpp;h=59059e07436d1893da0a9fc7dc73612fe5c79a92;hb=67817384452d1d8955169c0dc648774e71ea3abe;hp=be96a2c104b860f0e9dda819388c92c0fa206d81;hpb=1907ca03c5e865c4d398170042aa384c67ffff29;p=l2e.git diff --git a/src/graphics/Font.cpp b/src/graphics/Font.cpp index be96a2c..59059e0 100644 --- a/src/graphics/Font.cpp +++ b/src/graphics/Font.cpp @@ -39,6 +39,18 @@ void Font::DrawString(const char *s, SDL_Surface *dest, const Vector &posit } } +void Font::DrawStringRight(const char *s, SDL_Surface *dest, const Vector &positionIn, int maxChars) const { + if (!sprite) return; + + int length(0); + while (length < maxChars && s[length] != '\0') { + ++length; + } + Vector position(positionIn.X() - length * CharWidth(), positionIn.Y()); + + DrawString(s, dest, position, length); +} + void Font::DrawDigit(int digit, SDL_Surface *dest, const Vector &position) const { if (!sprite) return; @@ -76,6 +88,14 @@ void Font::DrawNumber(int numberIn, SDL_Surface *dest, const Vector &positi } } +void Font::DrawNumberRight(int number, SDL_Surface *dest, const Vector &positionIn, int digits) const { + if (!sprite) return; + + Vector position(positionIn.X() - digits * CharWidth(), positionIn.Y()); + + DrawNumber(number, dest, position, digits); +} + void Font::CreateTypeDescription() { Font f;