Browse Source

Display mashed monsterz statistics, up to 12 icons.

legacy
Sam Hocevar sam 14 years ago
parent
commit
e9e1390454
3 changed files with 11 additions and 11 deletions
  1. +8
    -8
      src/font.cpp
  2. +2
    -2
      src/font.h
  3. +1
    -1
      src/text.cpp

+ 8
- 8
src/font.cpp View File

@@ -132,7 +132,7 @@ char const *Font::GetName()
return data->name; return data->name;
} }


void Font::Print(int x, int y, char const *str)
void Font::Print(int3 pos, char const *str)
{ {
if (data->img) if (data->img)
return; return;
@@ -148,21 +148,21 @@ void Font::Print(int x, int y, char const *str)
if (ch != ' ') if (ch != ' ')
{ {
glTexCoord2f(tx, ty + data->ty); glTexCoord2f(tx, ty + data->ty);
glVertex2f(x, y);
glVertex2f(pos.x, pos.y);
glTexCoord2f(tx + data->tx, ty + data->ty); glTexCoord2f(tx + data->tx, ty + data->ty);
glVertex2f(x + data->width, y);
glVertex2f(pos.x + data->width, pos.y);
glTexCoord2f(tx + data->tx, ty); glTexCoord2f(tx + data->tx, ty);
glVertex2f(x + data->width, y + data->height);
glVertex2f(pos.x + data->width, pos.y + data->height);
glTexCoord2f(tx, ty); glTexCoord2f(tx, ty);
glVertex2f(x, y + data->height);
glVertex2f(pos.x, pos.y + data->height);
} }


x += data->width;
pos.x += data->width;
} }
glEnd(); glEnd();
} }


void Font::PrintBold(int x, int y, char const *str)
void Font::PrintBold(int3 pos, char const *str)
{ {
static struct { int dx, dy; float r, g, b; } tab[] = static struct { int dx, dy; float r, g, b; } tab[] =
{ {
@@ -183,7 +183,7 @@ void Font::PrintBold(int x, int y, char const *str)
for (unsigned int i = 0; i < sizeof(tab) / sizeof(*tab); i++) for (unsigned int i = 0; i < sizeof(tab) / sizeof(*tab); i++)
{ {
glColor3f(tab[i].r, tab[i].g, tab[i].b); glColor3f(tab[i].r, tab[i].g, tab[i].b);
Print(x + tab[i].dx, y + tab[i].dy, str);
Print(pos + int3(tab[i].dx, tab[i].dy, 0), str);
} }
glPopAttrib(); glPopAttrib();
} }


+ 2
- 2
src/font.h View File

@@ -33,8 +33,8 @@ protected:


public: public:
/* New methods */ /* New methods */
void Print(int x, int y, char const *str);
void PrintBold(int x, int y, char const *str);
void Print(int3 pos, char const *str);
void PrintBold(int3 pos, char const *str);


private: private:
FontData *data; FontData *data;


+ 1
- 1
src/text.cpp View File

@@ -65,7 +65,7 @@ void Text::TickDraw(float deltams)
if (data->text) if (data->text)
{ {
Font *font = Forge::GetFont(data->font); Font *font = Forge::GetFont(data->font);
font->Print(data->pos.x, data->pos.y, data->text);
font->Print(data->pos, data->text);
} }
} }




Loading…
Cancel
Save