#include "../loader/TypeDescription.h"
#include <cmath>
+#include <cstring>
#include <iostream>
using geometry::Vector;
if (!sprite) return;
int length(0);
- while (length < maxWidth && s[length] != '\0') {
- ++length;
+ if (maxWidth > 0) {
+ while (length < maxWidth && s[length] != '\0') {
+ ++length;
+ }
+ } else {
+ length = std::strlen(s);
}
Vector<int> position(positionIn.X() - length * CharWidth(), positionIn.Y());
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());
+ Vector<int> position(positionIn);
+ if (digits > 0) {
+ position.X() -= digits * CharWidth();
+ } else if (number == 0) {
+ position.X() -= CharWidth();
+ } else {
+ for (int i = number; i > 0; i /= 10) {
+ position.X() -= CharWidth();
+ }
+ }
DrawNumber(number, dest, position, digits);
}