[Super-tux-commit] supertux/src gameloop.cpp,1.181,1.182 gameobjs.cpp,1.49,1.50 high_scores.cpp,1.26
Brought to you by:
wkendrick
From: Ricardo C. <rm...@us...> - 2004-09-16 15:04:28
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18913/src Modified Files: gameloop.cpp gameobjs.cpp high_scores.cpp leveleditor.cpp statistics.cpp title.cpp worldmap.cpp Log Message: Changed behavior of centered text drawing and added right allignment, as well. Added a new allignment argument for draw_text(). draw_text_center() is draw_text() with CENTER_ALLIGN in point Vector(screen->w/2, ...). Index: statistics.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/statistics.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- statistics.cpp 15 Sep 2004 21:59:30 -0000 1.4 +++ statistics.cpp 16 Sep 2004 15:04:17 -0000 1.5 @@ -22,6 +22,7 @@ #include "statistics.h" #include "video/drawing_context.h" #include "app/gettext.h" +#include "app/globals.h" #include "resources.h" Statistics global_stats; @@ -108,10 +109,10 @@ 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]); @@ -122,7 +123,7 @@ 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 @@ -131,7 +132,7 @@ 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++) @@ -147,7 +148,7 @@ 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); } } Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.149 retrieving revision 1.150 diff -u -d -r1.149 -r1.150 --- leveleditor.cpp 12 Aug 2004 22:05:23 -0000 1.149 +++ leveleditor.cpp 16 Sep 2004 15:04:17 -0000 1.150 @@ -827,20 +827,20 @@ } 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); } } @@ -1782,13 +1782,13 @@ 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(); Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.49 retrieving revision 1.50 diff -u -d -r1.49 -r1.50 --- gameobjs.cpp 14 Sep 2004 10:27:05 -0000 1.49 +++ gameobjs.cpp 16 Sep 2004 15:04:17 -0000 1.50 @@ -133,7 +133,7 @@ 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 */ Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.116 retrieving revision 1.117 diff -u -d -r1.116 -r1.117 --- title.cpp 6 Aug 2004 11:43:10 -0000 1.116 +++ title.cpp 16 Sep 2004 15:04:17 -0000 1.117 @@ -328,12 +328,12 @@ 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(); Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.118 retrieving revision 1.119 diff -u -d -r1.118 -r1.119 --- worldmap.cpp 15 Sep 2004 21:59:30 -0000 1.118 +++ worldmap.cpp 16 Sep 2004 15:04:18 -0000 1.119 @@ -906,16 +906,12 @@ 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")); @@ -1068,23 +1064,23 @@ 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 { @@ -1095,7 +1091,7 @@ } 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()) { @@ -1109,27 +1105,27 @@ 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 Index: high_scores.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/high_scores.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- high_scores.cpp 28 Jul 2004 23:06:12 -0000 1.26 +++ high_scores.cpp 16 Sep 2004 15:04:17 -0000 1.27 @@ -102,12 +102,12 @@ { 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(); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.181 retrieving revision 1.182 diff -u -d -r1.181 -r1.182 --- gameloop.cpp 16 Sep 2004 11:56:39 -0000 1.181 +++ gameloop.cpp 16 Sep 2004 15:04:16 -0000 1.182 @@ -175,23 +175,23 @@ 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")); @@ -357,7 +357,7 @@ 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); } @@ -630,8 +630,8 @@ 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]; @@ -640,10 +640,10 @@ 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()) @@ -810,38 +810,38 @@ 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); } @@ -855,16 +855,16 @@ 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); } } @@ -876,14 +876,14 @@ 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(); @@ -940,8 +940,8 @@ 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; |