Added a new allignment argument for draw_text(). draw_text_center() is draw_text() with CENTER_ALLIGN in point Vector(screen->w/2, ...).
SVN-Revision: 1927
i = rect.w + (int)info_font->get_text_width(info);
if(!info.empty())
- context.draw_text(info_font, info, Vector(i + rect.x - info_font->get_text_width(info), rect.y), LAYER_GUI);
+ context.draw_text(info_font, info, Vector(i + rect.x - info_font->get_text_width(info), rect.y), LEFT_ALLIGN, LAYER_GUI);
sprintf(str,"(%s)", SDL_GetKeyName(shortcut));
- context.draw_text(info_font, str, Vector(i + rect.x - info_font->get_text_width(str), rect.y + info_font->get_height()+2), LAYER_GUI);
+ context.draw_text(info_font, str, Vector(i + rect.x - info_font->get_text_width(str), rect.y + info_font->get_height()+2), LEFT_ALLIGN, LAYER_GUI);
}
if(state == BUTTON_PRESSED || state == BUTTON_DEACTIVE)
fillrect(rect.x,rect.y,rect.w,rect.h,75,75,75,200);
{
case MN_DEACTIVE:
{
- context.draw_text_center(deactive_font, pitem.text,
- Vector(0, y_pos - int(deactive_font->get_height()/2)),
- LAYER_GUI);
+ context.draw_text(deactive_font, pitem.text,
+ Vector(screen->w/2, y_pos - int(deactive_font->get_height()/2)),
+ CENTER_ALLIGN, LAYER_GUI);
break;
}
}
case MN_LABEL:
{
- context.draw_text_center(label_font,
- pitem.text, Vector(0, y_pos - int(label_font->get_height()/2)),
- LAYER_GUI);
+ context.draw_text(label_font, pitem.text,
+ Vector(screen->w/2, y_pos - int(label_font->get_height()/2)),
+ CENTER_ALLIGN, LAYER_GUI);
break;
}
case MN_TEXTFIELD:
context.draw_text(field_font,
pitem.get_input_with_symbol(true),
Vector(input_pos, y_pos - int(field_font->get_height()/2)),
- LAYER_GUI);
+ LEFT_ALLIGN, LAYER_GUI);
else
context.draw_text(field_font,
pitem.get_input_with_symbol(false),
Vector(input_pos, y_pos - int(field_font->get_height()/2)),
- LAYER_GUI);
+ LEFT_ALLIGN, LAYER_GUI);
}
else
context.draw_text(field_font, pitem.input,
Vector(input_pos, y_pos - int(field_font->get_height()/2)),
- LAYER_GUI);
+ LEFT_ALLIGN, LAYER_GUI);
context.draw_text(text_font, pitem.text,
Vector(text_pos, y_pos - int(text_font->get_height()/2)),
- LAYER_GUI);
+ LEFT_ALLIGN, LAYER_GUI);
break;
}
case MN_STRINGSELECT:
Vector(list_pos_2, 18),
Color(0,0,0,128), LAYER_GUI - 5);
- context.draw_text_center(text_font, (*pitem.list.second),
- Vector(text_pos, y_pos - int(text_font->get_height()/2)),
- LAYER_GUI);
- context.draw_text_center(text_font, pitem.text,
- Vector(list_pos_2/2, y_pos - int(text_font->get_height()/2)),
- LAYER_GUI);
+ context.draw_text(text_font, (*pitem.list.second),
+ Vector(screen->w/2 + text_pos, y_pos - int(text_font->get_height()/2)),
+ CENTER_ALLIGN, LAYER_GUI);
+ context.draw_text(text_font, pitem.text,
+ Vector(screen->w/2 + list_pos_2/2, y_pos - int(text_font->get_height()/2)),
+ CENTER_ALLIGN, LAYER_GUI);
break;
}
case MN_BACK:
{
- context.draw_text_center(text_font, pitem.text,
- Vector(0, y_pos - int(text_font->get_height()/2)),
- LAYER_GUI);
+ context.draw_text(text_font, pitem.text,
+ Vector(screen->w/2, y_pos - int(text_font->get_height()/2)),
+ CENTER_ALLIGN, LAYER_GUI);
context.draw_surface(back,
Vector(x_pos + text_width/2 + 16, y_pos - 8),
LAYER_GUI);
case MN_TOGGLE:
{
- context.draw_text_center(text_font, pitem.text,
- Vector(0, y_pos - (text_font->get_height()/2)),
- LAYER_GUI);
+ context.draw_text(text_font, pitem.text,
+ Vector(screen->w/2, y_pos - (text_font->get_height()/2)),
+ CENTER_ALLIGN, LAYER_GUI);
if(pitem.toggled)
context.draw_surface(checkbox_checked,
break;
}
case MN_ACTION:
- context.draw_text_center(text_font, pitem.text,
- Vector(0, y_pos - int(text_font->get_height()/2)),
- LAYER_GUI);
+ context.draw_text(text_font, pitem.text,
+ Vector(screen->w/2, y_pos - int(text_font->get_height()/2)),
+ CENTER_ALLIGN, LAYER_GUI);
break;
case MN_GOTO:
- context.draw_text_center(text_font, pitem.text,
- Vector(0, y_pos - int(text_font->get_height()/2)),
- LAYER_GUI);
+ context.draw_text(text_font, pitem.text,
+ Vector(screen->w/2, y_pos - int(text_font->get_height()/2)),
+ CENTER_ALLIGN, LAYER_GUI);
break;
}
}
void
DrawingContext::draw_text(Font* font, const std::string& text,
- const Vector& position, int layer, Uint32 drawing_effect, int alpha)
+ const Vector& position, int allignment, int layer,
+ Uint32 drawing_effect, int alpha)
{
DrawingRequest request;
TextRequest* textrequest = new TextRequest;
textrequest->font = font;
textrequest->text = text;
- textrequest->center = false;
- textrequest->alpha = alpha;
- request.request_data = textrequest;
-
- drawingrequests.push_back(request);
-}
-
-void
-DrawingContext::draw_text_center(Font* font, const std::string& text,
- const Vector& position, int layer, Uint32 drawing_effect, int alpha)
-{
- DrawingRequest request;
-
- request.type = TEXT;
- request.layer = layer;
- request.pos = transform.apply(position);
- request.drawing_effect = drawing_effect;
-
- TextRequest* textrequest = new TextRequest;
- textrequest->font = font;
- textrequest->text = text;
- textrequest->center = true;
+ textrequest->allignment = allignment;
textrequest->alpha = alpha;
request.request_data = textrequest;
{
TextRequest* textrequest = (TextRequest*) request.request_data;
- if(textrequest->center)
- textrequest->font->draw_center(textrequest->text, request.pos, request.drawing_effect, textrequest->alpha);
- else
- textrequest->font->draw(textrequest->text, request.pos, request.drawing_effect, textrequest->alpha);
+ textrequest->font->draw(textrequest->text, request.pos, textrequest->allignment, request.drawing_effect, textrequest->alpha);
delete textrequest;
}
Uint32 drawing_effect = NONE_EFFECT);
/// Draws a text.
void draw_text(Font* font, const std::string& text, const Vector& position,
- int layer, Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
- /// Draws aligned text.
- void draw_text_center(Font* font, const std::string& text,
- const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
+ int allignment, int layer,
+ Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
/// Draws a color gradient onto the whole screen */
void draw_gradient(Color from, Color to, int layer);
/// Fills a rectangle.
{
Font* font;
std::string text;
- bool center;
+ int allignment;
int alpha;
};
}
void
-Font::draw(const std::string& text, const Vector& pos, Uint32 drawing_effect, int alpha)
+Font::draw(const std::string& text, const Vector& pos_, int allignment, Uint32 drawing_effect, int alpha)
{
- if(shadowsize > 0)
- draw_chars(shadow_chars, text, pos + Vector(shadowsize, shadowsize),
- drawing_effect, alpha);
-
- draw_chars(chars, text, pos, drawing_effect, alpha);
-}
-
-void
-Font::draw_center(const std::string& text, const Vector& pos, Uint32 drawing_effect, int alpha)
-{
- /* Cut lines changes into seperate strings, needed to support centering text
- with break lines.
+ // calculate X positions based on the allignment type
+ Vector pos = Vector(pos_);
+ if(allignment == CENTER_ALLIGN)
+ pos.x -= get_text_width(text) / 2;
+ else if(allignment == RIGHT_ALLIGN)
+ pos.x -= get_text_width(text);
+
+ /* Cut lines changes into seperate strings, needed to support center/right text
+ allignments with break lines.
Feel free to replace this hack with a more elegant solution
*/
char temp[1024];
unsigned int i, l, y;
i = y = 0;
+
while(true)
{
l = text.find("\n", i);
if(l == std::string::npos)
{
temp[text.copy(temp, text.size() - i, i)] = '\0';
- draw(temp, Vector(screen->w/2 - get_text_width(temp)/2 + pos.x, pos.y + y),
- drawing_effect, alpha);
+ draw_text(temp, pos + Vector(0,y), drawing_effect, alpha);
break;
}
temp[text.copy(temp, l - i, i)] = '\0';
- draw(temp, Vector(screen->w/2 - get_text_width(temp)/2 + pos.x, pos.y + y),
- drawing_effect, alpha);
+ draw_text(temp, pos + Vector(0,y), drawing_effect, alpha);
i = l+1;
y += h + 2;
}
void
+Font::draw_text(const std::string& text, const Vector& pos, Uint32 drawing_effect, int alpha)
+{
+ if(shadowsize > 0)
+ draw_chars(shadow_chars, text, pos + Vector(shadowsize, shadowsize),
+ drawing_effect, alpha);
+
+ draw_chars(chars, text, pos, drawing_effect, alpha);
+}
+
+void
Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos,
Uint32 drawing_effect, int alpha)
{
default: font = reference_font; break;
}
- context.draw_text_center(font,
+ context.draw_text(font,
names[i].substr(1, names[i].size()-1),
- Vector(0, screen->h + y - scroll), LAYER_FOREGROUND1);
+ Vector(screen->w/2, screen->h + y - scroll), CENTER_ALLIGN, LAYER_FOREGROUND1);
y += font->get_height() + ITEMS_SPACE;
}
namespace SuperTux
{
+ enum {
+ LEFT_ALLIGN,
+ CENTER_ALLIGN,
+ RIGHT_ALLIGN
+ };
+
/// Font
class Font
{
/// returns the height of the font.
float get_height() const;
+ /** Draws the given text to the screen. Also needs the position.
+ * Type of alignment, drawing effect and alpha are optional. */
+ void draw(const std::string& text, const Vector& pos,
+ int allignment = LEFT_ALLIGN,
+ Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
+
private:
friend class DrawingContext;
- void draw(const std::string& text, const Vector& pos,
- Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
- void draw_center(const std::string& text, const Vector& pos,
+ void draw_text(const std::string& text, const Vector& pos,
Uint32 drawing_effect = NONE_EFFECT, int alpha = 255);
+
void draw_chars(Surface* pchars, const std::string& text,
const Vector& position, Uint32 drawing_effect, int alpha);
DrawingContext context;
currentsector->background->draw(context);
- context.draw_text_center(gold_text, level->get_name(), Vector(0, 220),
- LAYER_FOREGROUND1);
+ context.draw_text(gold_text, level->get_name(), Vector(screen->w/2, 160),
+ CENTER_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, "TUX x %d", player_status.lives);
- context.draw_text_center(white_text, str, Vector(0, 240),
- LAYER_FOREGROUND1);
+ context.draw_text(white_text, str, Vector(screen->w/2, 210),
+ CENTER_ALLIGN, LAYER_FOREGROUND1);
if(level->get_author().size())
- context.draw_text_center(white_small_text,
+ context.draw_text(white_small_text,
std::string(_("by ")) + level->get_author(),
- Vector(0, 360), LAYER_FOREGROUND1);
+ Vector(screen->w/2, 350), CENTER_ALLIGN, LAYER_FOREGROUND1);
if(flip_level)
- context.draw_text_center(white_text,
+ context.draw_text(white_text,
_("Level Vertically Flipped!"),
- Vector(0, 310), LAYER_FOREGROUND1);
+ Vector(screen->w/2, 310), CENTER_ALLIGN, LAYER_FOREGROUND1);
if(best_level_statistics != NULL)
best_level_statistics->draw_message_info(context, _("Best Level Statistics"));
tux.base.x, tux.base.y);
context->draw_text(white_text, buf,
Vector(0, screen->h - white_text->get_height()),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
context->do_drawing();
SDL_Delay(1000);
}
context->draw_filled_rect(
Vector(0,0), Vector(screen->w, screen->h),
Color(rand() % 50, rand() % 50, rand() % 50, 128), LAYER_FOREGROUND1);
- context->draw_text_center(blue_text, _("PAUSE - Press 'P' To Play"),
- Vector(0, 230), LAYER_FOREGROUND1+2);
+ context->draw_text(blue_text, _("PAUSE - Press 'P' To Play"),
+ Vector(screen->w/2, 230), CENTER_ALLIGN, LAYER_FOREGROUND1+2);
char str1[60];
char str2[124];
context->draw_text(blue_text, str1,
Vector((screen->w - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2, 340),
- LAYER_FOREGROUND1+2);
+ LEFT_ALLIGN, LAYER_FOREGROUND1+2);
context->draw_text(white_text, str2,
Vector(((screen->w - (blue_text->get_text_width(str1) + white_text->get_text_width(str2)))/2)+blue_text->get_text_width(str1), 340),
- LAYER_FOREGROUND1+2);
+ LEFT_ALLIGN, LAYER_FOREGROUND1+2);
}
if(Menu::current())
char str[60];
snprintf(str, 60, " %d", global_stats.get_points(SCORE_STAT));
- context.draw_text(white_text, _("SCORE"), Vector(0, 0), LAYER_FOREGROUND1);
- context.draw_text(gold_text, str, Vector(96, 0), LAYER_FOREGROUND1);
+ context.draw_text(white_text, _("SCORE"), Vector(0, 0), LEFT_ALLIGN, LAYER_FOREGROUND1);
+ context.draw_text(gold_text, str, Vector(96, 0), LEFT_ALLIGN, LAYER_FOREGROUND1);
if(st_gl_mode == ST_GL_TEST)
{
context.draw_text(white_text, _("Press ESC To Return"), Vector(0,20),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
}
if(!time_left.check()) {
- context.draw_text_center(white_text, _("TIME's UP"), Vector(0, 0),
- LAYER_FOREGROUND1);
+ context.draw_text(white_text, _("TIME's UP"), Vector(screen->w/2, 0),
+ CENTER_ALLIGN, LAYER_FOREGROUND1);
} else if (time_left.get_left() > TIME_WARNING || (global_frame_counter % 10) < 5) {
sprintf(str, " %d", time_left.get_left() / 1000 );
- context.draw_text_center(white_text, _("TIME"),
- Vector(0, 0), LAYER_FOREGROUND1);
- context.draw_text_center(gold_text, str,
- Vector(4*16, 0), LAYER_FOREGROUND1);
+ context.draw_text(white_text, _("TIME"),
+ Vector(screen->w/2, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
+ context.draw_text(gold_text, str,
+ Vector(screen->w/2 + 4*16, 0), CENTER_ALLIGN, LAYER_FOREGROUND1);
}
sprintf(str, " %d", player_status.distros);
context.draw_text(white_text, _("COINS"),
Vector(screen->w - white_text->get_text_width(_("COINS"))-white_text->get_text_width(" 99"), 0),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(gold_text, str,
- Vector(screen->w - gold_text->get_text_width(" 99"), 0),LAYER_FOREGROUND1);
+ Vector(screen->w - gold_text->get_text_width(" 99"), 0),LEFT_ALLIGN, LAYER_FOREGROUND1);
if (player_status.lives >= 5)
{
sprintf(str, "%dx", player_status.lives);
float x = screen->w - gold_text->get_text_width(str) - tux_life->w;
- context.draw_text(gold_text, str, Vector(x, 20), LAYER_FOREGROUND1);
+ context.draw_text(gold_text, str, Vector(x, 20), LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_surface(tux_life, Vector(screen->w - 16, 20),
LAYER_FOREGROUND1);
}
context.draw_text(white_text, _("LIVES"),
Vector(screen->w - white_text->get_text_width(_("LIVES")) - white_text->get_text_width(" 99"), 20),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
if(show_fps)
{
sprintf(str, "%2.1f", fps_fps);
context.draw_text(white_text, "FPS",
Vector(screen->w - white_text->get_text_width("FPS "), 40),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(gold_text, str,
- Vector(screen->w-4*16, 40), LAYER_FOREGROUND1);
+ Vector(screen->w-4*16, 40), LEFT_ALLIGN, LAYER_FOREGROUND1);
}
}
DrawingContext context;
currentsector->background->draw(context);
- context.draw_text_center(blue_text, _("Result:"), Vector(0, 200),
- LAYER_FOREGROUND1);
+ context.draw_text(blue_text, _("Result:"), Vector(screen->w/2, 200),
+ CENTER_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, _("SCORE: %d"), global_stats.get_points(SCORE_STAT));
- context.draw_text_center(gold_text, str, Vector(0, 224), LAYER_FOREGROUND1);
+ context.draw_text(gold_text, str, Vector(screen->w/2, 224), CENTER_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, _("COINS: %d"), player_status.distros);
- context.draw_text_center(gold_text, str, Vector(0, 256), LAYER_FOREGROUND1);
+ context.draw_text(gold_text, str, Vector(screen->w/2, 256), CENTER_ALLIGN, LAYER_FOREGROUND1);
context.do_drawing();
fadeout(256);
DrawingContext context;
- context.draw_text_center(white_text, "Loading...",
- Vector(0, screen->h/2), LAYER_FOREGROUND1);
+ context.draw_text(white_text, "Loading...",
+ Vector(screen->w/2, screen->h/2), CENTER_ALLIGN, LAYER_FOREGROUND1);
context.do_drawing();
WorldMapNS::WorldMap worldmap;
void
FloatingScore::draw(DrawingContext& context)
{
- context.draw_text(gold_text, str, position, LAYER_OBJECTS);
+ context.draw_text(gold_text, str, position, LEFT_ALLIGN, LAYER_OBJECTS);
}
/* Trampoline */
{
context.draw_surface(bkgd, Vector(0, 0), LAYER_BACKGROUND0);
- context.draw_text_center(blue_text, "Congratulations",
- Vector(0, 130), LAYER_FOREGROUND1);
+ context.draw_text(blue_text, "Congratulations",
+ Vector(screen->w/2, 130), CENTER_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(blue_text, "Your score:", Vector(150, 180),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, "%d", hs_score);
- context.draw_text(yellow_nums, str, Vector(250, 170), LAYER_FOREGROUND1);
+ context.draw_text(yellow_nums, str, Vector(250, 170), LEFT_ALLIGN, LAYER_FOREGROUND1);
Menu::current()->draw(context);
Menu::current()->action();
}
sprintf(str, "%d/%d", le_levelnb, le_level_subset->get_num_levels());
- context.draw_text(white_text, str, Vector((le_level_subset->get_num_levels() < 10) ? -10 : 0, 16), LAYER_GUI);
+ context.draw_text(white_text, str, Vector((le_level_subset->get_num_levels() < 10) ? -10 : 0, 16), LEFT_ALLIGN, LAYER_GUI);
if(!le_help_shown)
- context.draw_text(white_small_text, "F1 for Help", Vector(10, 430), LAYER_GUI);
+ context.draw_text(white_small_text, "F1 for Help", Vector(10, 430), LEFT_ALLIGN, LAYER_GUI);
if(display_level_info.check())
- context.draw_text_center(white_text, le_level->name.c_str(), Vector(0, 0), LAYER_GUI);
+ context.draw_text(white_text, le_level->name.c_str(), Vector(screen->w/2, 0), CENTER_ALLIGN, LAYER_GUI);
}
else
{
if(!Menu::current())
- context.draw_text(white_small_text, "No Level Subset loaded - Press ESC and choose one in the menu", Vector(10, 430), LAYER_GUI);
+ context.draw_text(white_small_text, "No Level Subset loaded - Press ESC and choose one in the menu", Vector(10, 430), LEFT_ALLIGN, LAYER_GUI);
else
- context.draw_text(white_small_text, "No Level Subset loaded", Vector(10, 430), LAYER_GUI);
+ context.draw_text(white_small_text, "No Level Subset loaded", Vector(10, 430), LEFT_ALLIGN, LAYER_GUI);
}
}
context.draw_gradient(Color(0,0,0), Color(255,255,255), LAYER_BACKGROUND0);
drawinterface(context);
- context.draw_text_center(blue_text, "- Help -", Vector(0, 30), LAYER_GUI);
+ context.draw_text(blue_text, "- Help -", Vector(screen->w/2, 30), CENTER_ALLIGN, LAYER_GUI);
for(unsigned int t = 0; t < sizeof(text[i])/sizeof(char *); t++)
- context.draw_text(white_text, text[i][t], Vector(5, 80+(t*white_text->get_height())), LAYER_GUI);
+ context.draw_text(white_text, text[i][t], Vector(5, 80+(t*white_text->get_height())), LEFT_ALLIGN, LAYER_GUI);
sprintf(str,"Press any key to continue - Page %d/%d?", i, static_cast<int>(sizeof(text)));
- context.draw_text(gold_text, str, Vector(0, 0), LAYER_GUI);
+ context.draw_text(gold_text, str, Vector(0, 0), LEFT_ALLIGN, LAYER_GUI);
context.do_drawing();
#include "statistics.h"
#include "video/drawing_context.h"
#include "app/gettext.h"
+#include "app/globals.h"
#include "resources.h"
Statistics global_stats;
char str[128];
- context.draw_text(white_small_text, _("Level Statistics"), Vector(550, 490), LAYER_GUI);
+ context.draw_text(white_small_text, _("Level Statistics"), Vector(550, 490), LEFT_ALLIGN, LAYER_GUI);
sprintf(str, _("Max score: %d"), stats[SCORE_STAT]);
- context.draw_text(white_small_text, str, Vector(560, 506), LAYER_GUI);
+ context.draw_text(white_small_text, str, Vector(560, 506), LEFT_ALLIGN, LAYER_GUI);
if(display_stat == BADGUYS_SQUISHED_STAT)
sprintf(str, _("Max fragging: %d"), stats[BADGUYS_SQUISHED_STAT]);
else// if(display_stat == JUMPS_STAT)
sprintf(str, _("Min jumps: %d"), stats[JUMPS_STAT]);
- context.draw_text(white_small_text, str, Vector(560, 522), LAYER_GUI, NONE_EFFECT, alpha);
+ context.draw_text(white_small_text, str, Vector(560, 522), LAYER_GUI, LEFT_ALLIGN, NONE_EFFECT, alpha);
}
void
if(stats[SCORE_STAT] == -1) // not initialized yet
return;
- context.draw_text_center(gold_text, title, Vector(0, 400), LAYER_GUI);
+ context.draw_text(gold_text, title, Vector(screen->w/2, 400), CENTER_ALLIGN, LAYER_GUI);
char str[128];
for(int i = 0; i < NUM_STATS; i++)
else// if(i == JUMPS_STAT)
sprintf(str, _("Min jumps: %d"), stats[JUMPS_STAT]);
- context.draw_text_center(white_text, str, Vector(0, 430 + i*22), LAYER_GUI);
+ context.draw_text(white_text, str, Vector(screen->w/2, 430 + i*22), CENTER_ALLIGN, LAYER_GUI);
}
}
context.draw_surface(logo, Vector(screen->w/2 - logo->w/2, 30),
LAYER_FOREGROUND1+1);
- context.draw_text(white_small_text, " SuperTux " VERSION "\n", Vector(0, screen->h - 70), LAYER_FOREGROUND1);
+ context.draw_text(white_small_text, " SuperTux " VERSION "\n", Vector(0, screen->h - 70), LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(white_small_text,
_("Copyright (c) 2003 SuperTux Devel Team\n"
"This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n"
"are welcome to redistribute it under certain conditions; see the file COPYING\n"
- "for details.\n"), Vector(0, screen->h - 70 + white_small_text->get_height()), LAYER_FOREGROUND1);
+ "for details.\n"), Vector(0, screen->h - 70 + white_small_text->get_height()), LEFT_ALLIGN, LAYER_FOREGROUND1);
/* Don't draw menu, if quit is true */
Menu* menu = Menu::current();
context.draw_gradient(Color (200,240,220), Color(200,200,220),
LAYER_BACKGROUND0);
- context.draw_text_center(blue_text, _("GAMEOVER"),
- Vector(0, 200), LAYER_FOREGROUND1);
-
-// sprintf(str, _("SCORE: %d"), total_stats.get_points(SCORE_STAT));
-// context.draw_text_center(gold_text, str,
-// Vector(0, 230), LAYER_FOREGROUND1);
+ context.draw_text(blue_text, _("GAMEOVER"),
+ Vector(screen->w/2, 200), CENTER_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, _("COINS: %d"), player_status.distros);
- context.draw_text_center(gold_text, str,
- Vector(0, screen->w - 32), LAYER_FOREGROUND1);
+ context.draw_text(gold_text, str,
+ Vector(screen->w/2, screen->w - 32), CENTER_ALLIGN, LAYER_FOREGROUND1);
total_stats.draw_message_info(context, _("Total Statistics"));
char str[80];
sprintf(str, " %d", total_stats.get_points(SCORE_STAT));
- context.draw_text(white_text, _("SCORE"), Vector(0, 0), LAYER_FOREGROUND1);
- context.draw_text(gold_text, str, Vector(96, 0), LAYER_FOREGROUND1);
+ context.draw_text(white_text, _("SCORE"), Vector(0, 0), LEFT_ALLIGN, LAYER_FOREGROUND1);
+ context.draw_text(gold_text, str, Vector(96, 0), LEFT_ALLIGN, LAYER_FOREGROUND1);
sprintf(str, "%d", player_status.distros);
context.draw_text(white_text, _("COINS"), Vector(screen->w/2 - 16*5, 0),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_text(gold_text, str, Vector(screen->w/2 + (16*5)/2, 0),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
if (player_status.lives >= 5)
{
sprintf(str, "%dx", player_status.lives);
context.draw_text(gold_text, str,
Vector(screen->w - gold_text->get_text_width(str) - tux_life->w, 0),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
context.draw_surface(tux_life, Vector(screen->w -
- gold_text->get_text_width("9"), 0), LAYER_FOREGROUND1);
+ gold_text->get_text_width("9"), 0), LEFT_ALLIGN, LAYER_FOREGROUND1);
}
else
{
}
context.draw_text(white_text, _("LIVES"),
Vector(screen->w - white_text->get_text_width(_("LIVES")) - white_text->get_text_width(" 99"), 0),
- LAYER_FOREGROUND1);
+ LEFT_ALLIGN, LAYER_FOREGROUND1);
if (!tux->is_moving())
{
if(i->title == "")
get_level_title(*i);
- context.draw_text_center(white_text, i->title,
- Vector(0, screen->h - white_text->get_height() - 30),
- LAYER_FOREGROUND1);
+ context.draw_text(white_text, i->title,
+ Vector(screen->w/2, screen->h - white_text->get_height() - 30),
+ CENTER_ALLIGN, LAYER_FOREGROUND1);
i->statistics.draw_worldmap_info(context);
}
/* Display an in-map message in the map, if any as been selected */
if(!i->map_message.empty() && !i->passive_message)
- context.draw_text_center(gold_text, i->map_message,
- Vector(0, screen->h - white_text->get_height() - 60),
- LAYER_FOREGROUND1);
+ context.draw_text(gold_text, i->map_message,
+ Vector(screen->w/2, screen->h - white_text->get_height() - 60),
+ CENTER_ALLIGN, LAYER_FOREGROUND1);
break;
}
}
}
/* Display a passive message in the map, if needed */
if(passive_message_timer.check())
- context.draw_text_center(gold_text, passive_message,
- Vector(0, screen->h - white_text->get_height() - 60),
- LAYER_FOREGROUND1);
+ context.draw_text(gold_text, passive_message,
+ Vector(screen->w/2, screen->h - white_text->get_height() - 60),
+ CENTER_ALLIGN, LAYER_FOREGROUND1);
}
void