From: grumbel Date: Thu, 19 Nov 2009 04:33:45 +0000 (+0000) Subject: Turned stuff in supertux/resources.cpp into a class Resources X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=8d6b67e339af57fd54b2ed5891d4379b52332616;p=supertux.git Turned stuff in supertux/resources.cpp into a class Resources git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6041 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 66754c9ff..5761e19e3 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -453,15 +453,15 @@ Menu::draw_item(DrawingContext& context, int index) float x_pos = pos_x; float y_pos = pos_y + 24*index - menu_height/2 + 12; int shadow_size = 2; - int text_width = int(normal_font->get_text_width(pitem.text)); - int input_width = int(normal_font->get_text_width(pitem.input) + 10); + int text_width = int(Resources::normal_font->get_text_width(pitem.text)); + int input_width = int(Resources::normal_font->get_text_width(pitem.input) + 10); int list_width = 0; float left = pos_x - menu_width/2 + 16; float right = pos_x + menu_width/2 - 16; if(pitem.list.size() > 0) { - list_width = (int) normal_font->get_text_width(pitem.list[pitem.selected]); + list_width = (int) Resources::normal_font->get_text_width(pitem.list[pitem.selected]); } if (arrange_left) @@ -492,8 +492,8 @@ Menu::draw_item(DrawingContext& context, int index) { case MN_INACTIVE: { - context.draw_text(normal_font, pitem.text, - Vector(pos_x, y_pos - int(normal_font->get_height()/2)), + context.draw_text(Resources::normal_font, pitem.text, + Vector(pos_x, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_CENTER, LAYER_GUI, inactive_color); break; } @@ -514,8 +514,8 @@ Menu::draw_item(DrawingContext& context, int index) } case MN_LABEL: { - context.draw_text(big_font, pitem.text, - Vector(pos_x, y_pos - int(big_font->get_height()/2)), + context.draw_text(Resources::big_font, pitem.text, + Vector(pos_x, y_pos - int(Resources::big_font->get_height()/2)), ALIGN_CENTER, LAYER_GUI, label_color); break; } @@ -526,23 +526,23 @@ Menu::draw_item(DrawingContext& context, int index) if(pitem.kind == MN_TEXTFIELD || pitem.kind == MN_NUMFIELD) { if(active_item == index) - context.draw_text(normal_font, + context.draw_text(Resources::normal_font, pitem.get_input_with_symbol(true), - Vector(right, y_pos - int(normal_font->get_height()/2)), + Vector(right, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_RIGHT, LAYER_GUI, field_color); else - context.draw_text(normal_font, + context.draw_text(Resources::normal_font, pitem.get_input_with_symbol(false), - Vector(right, y_pos - int(normal_font->get_height()/2)), + Vector(right, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_RIGHT, LAYER_GUI, field_color); } else - context.draw_text(normal_font, pitem.input, - Vector(right, y_pos - int(normal_font->get_height()/2)), + context.draw_text(Resources::normal_font, pitem.input, + Vector(right, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_RIGHT, LAYER_GUI, field_color); - context.draw_text(normal_font, pitem.text, - Vector(left, y_pos - int(normal_font->get_height()/2)), + context.draw_text(Resources::normal_font, pitem.text, + Vector(left, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_LEFT, LAYER_GUI, text_color); break; } @@ -550,8 +550,8 @@ Menu::draw_item(DrawingContext& context, int index) { float roff = arrow_left->get_width(); // Draw left side - context.draw_text(normal_font, pitem.text, - Vector(left, y_pos - int(normal_font->get_height()/2)), + context.draw_text(Resources::normal_font, pitem.text, + Vector(left, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_LEFT, LAYER_GUI, text_color); // Draw right side @@ -561,15 +561,15 @@ Menu::draw_item(DrawingContext& context, int index) context.draw_surface(arrow_right.get(), Vector(right - roff, y_pos - 8), LAYER_GUI); - context.draw_text(normal_font, pitem.list[pitem.selected], - Vector(right - roff, y_pos - int(normal_font->get_height()/2)), + context.draw_text(Resources::normal_font, pitem.list[pitem.selected], + Vector(right - roff, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_RIGHT, LAYER_GUI, text_color); break; } case MN_BACK: { - context.draw_text(normal_font, pitem.text, - Vector(pos_x, y_pos - int(normal_font->get_height()/2)), + context.draw_text(Resources::Resources::normal_font, pitem.text, + Vector(pos_x, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_CENTER, LAYER_GUI, text_color); context.draw_surface(back.get(), Vector(x_pos + text_width/2 + 16, y_pos - 8), @@ -579,8 +579,8 @@ Menu::draw_item(DrawingContext& context, int index) case MN_TOGGLE: { - context.draw_text(normal_font, pitem.text, - Vector(pos_x - menu_width/2 + 16, y_pos - (normal_font->get_height()/2)), + context.draw_text(Resources::normal_font, pitem.text, + Vector(pos_x - menu_width/2 + 16, y_pos - (Resources::normal_font->get_height()/2)), ALIGN_LEFT, LAYER_GUI, text_color); if(pitem.toggled) @@ -594,14 +594,14 @@ Menu::draw_item(DrawingContext& context, int index) break; } case MN_ACTION: - context.draw_text(normal_font, pitem.text, - Vector(pos_x, y_pos - int(normal_font->get_height()/2)), + context.draw_text(Resources::normal_font, pitem.text, + Vector(pos_x, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_CENTER, LAYER_GUI, text_color); break; case MN_GOTO: - context.draw_text(normal_font, pitem.text, - Vector(pos_x, y_pos - int(normal_font->get_height()/2)), + context.draw_text(Resources::normal_font, pitem.text, + Vector(pos_x, y_pos - int(Resources::normal_font->get_height()/2)), ALIGN_CENTER, LAYER_GUI, text_color); break; } @@ -615,12 +615,12 @@ Menu::get_width() const float menu_width = 0; for(unsigned int i = 0; i < items.size(); ++i) { - Font* font = normal_font; + Font* font = Resources::Resources::normal_font; if(items[i]->kind == MN_LABEL) - font = big_font; + font = Resources::big_font; float w = font->get_text_width(items[i]->text) + - big_font->get_text_width(items[i]->input) + 16; + Resources::big_font->get_text_width(items[i]->input) + 16; if(items[i]->kind == MN_TOGGLE) w += 32; @@ -683,8 +683,8 @@ Menu::draw(DrawingContext& context) if (!items[active_item]->help.empty()) { - int text_width = (int) normal_font->get_text_width(items[active_item]->help); - int text_height = (int) normal_font->get_text_height(items[active_item]->help); + int text_width = (int) Resources::normal_font->get_text_width(items[active_item]->help); + int text_height = (int) Resources::normal_font->get_text_height(items[active_item]->help); Rect text_rect(pos_x - text_width/2 - 8, SCREEN_HEIGHT - 48 - text_height/2 - 4, @@ -702,7 +702,7 @@ Menu::draw(DrawingContext& context) 16.0f, LAYER_GUI-10); - context.draw_text(normal_font, items[active_item]->help, + context.draw_text(Resources::normal_font, items[active_item]->help, Vector(pos_x, SCREEN_HEIGHT - 48 - text_height/2), ALIGN_CENTER, LAYER_GUI); } diff --git a/src/gui/menu_item.cpp b/src/gui/menu_item.cpp index fd599d790..f25a4d7e2 100644 --- a/src/gui/menu_item.cpp +++ b/src/gui/menu_item.cpp @@ -55,11 +55,11 @@ void MenuItem::set_help(const std::string& help_text) { std::string overflow; - help = normal_font->wrap_to_width(help_text, 600, &overflow); + help = Resources::normal_font->wrap_to_width(help_text, 600, &overflow); while (!overflow.empty()) { help += "\n"; - help += normal_font->wrap_to_width(overflow, 600, &overflow); + help += Resources::normal_font->wrap_to_width(overflow, 600, &overflow); } } diff --git a/src/gui/menu_manager.hpp b/src/gui/menu_manager.hpp index be4a875b1..de384eb69 100644 --- a/src/gui/menu_manager.hpp +++ b/src/gui/menu_manager.hpp @@ -22,7 +22,7 @@ class Menu; -class MenuManager // FIXME: temporary name +class MenuManager { public: static std::vector last_menus; diff --git a/src/object/floating_text.cpp b/src/object/floating_text.cpp index 217da5c71..34a1f0826 100644 --- a/src/object/floating_text.cpp +++ b/src/object/floating_text.cpp @@ -69,7 +69,7 @@ FloatingText::draw(DrawingContext& context) context.push_transform(); context.set_alpha(alpha); - context.draw_text(normal_font, text, position, ALIGN_LEFT, LAYER_OBJECTS+1, FloatingText::text_color); + context.draw_text(Resources::normal_font, text, position, ALIGN_LEFT, LAYER_OBJECTS+1, FloatingText::text_color); context.pop_transform(); } diff --git a/src/object/level_time.cpp b/src/object/level_time.cpp index 26de88d5c..7c39d89ab 100644 --- a/src/object/level_time.cpp +++ b/src/object/level_time.cpp @@ -90,9 +90,9 @@ LevelTime::draw(DrawingContext& context) Surface* time_surf = time_surface.get(); if (time_surf) { - float all_width = time_surf->get_width() + normal_font->get_text_width(time_text); + float all_width = time_surf->get_width() + Resources::normal_font->get_text_width(time_text); context.draw_surface(time_surf, Vector((SCREEN_WIDTH - all_width)/2, BORDER_Y + 1), LAYER_FOREGROUND1); - context.draw_text(normal_font, time_text, Vector((SCREEN_WIDTH - all_width)/2 + time_surf->get_width(), BORDER_Y), ALIGN_LEFT, LAYER_FOREGROUND1, LevelTime::text_color); + context.draw_text(Resources::normal_font, time_text, Vector((SCREEN_WIDTH - all_width)/2 + time_surf->get_width(), BORDER_Y), ALIGN_LEFT, LAYER_FOREGROUND1, LevelTime::text_color); } } diff --git a/src/object/text_object.cpp b/src/object/text_object.cpp index d40bfbf93..be2276b07 100644 --- a/src/object/text_object.cpp +++ b/src/object/text_object.cpp @@ -32,7 +32,7 @@ TextObject::TextObject(std::string name) : pos(0, 0) { this->name = name; - font = normal_font; + font = Resources::normal_font; centered = false; } @@ -62,14 +62,14 @@ void TextObject::set_font(const std::string& name) { if(name == "normal") { - font = normal_font; + font = Resources::normal_font; } else if(name == "big") { - font = big_font; + font = Resources::big_font; } else if(name == "small") { - font = small_font; + font = Resources::small_font; } else { log_warning << "Unknown font '" << name << "'." << std::endl; - font = normal_font; + font = Resources::normal_font; } } diff --git a/src/supertux/info_box_line.cpp b/src/supertux/info_box_line.cpp index c4142524e..19bf347c3 100644 --- a/src/supertux/info_box_line.cpp +++ b/src/supertux/info_box_line.cpp @@ -30,19 +30,19 @@ Font* get_font_by_format_char(char format_char) { switch(format_char) { case ' ': - return small_font; + return Resources::small_font; break; case '-': - return big_font; + return Resources::big_font; break; case '\t': case '*': case '#': case '!': - return normal_font; + return Resources::normal_font; break; default: - return normal_font; + return Resources::normal_font; log_warning << "Unknown format_char: '" << format_char << "'" << std::endl; break; } @@ -103,7 +103,7 @@ InfoBoxLine::LineType get_linetype_by_format_char(char format_char) { InfoBoxLine::InfoBoxLine(char format_char, const std::string& text) : lineType(NORMAL), - font(normal_font), + font(Resources::normal_font), color(), text(text), image(0) diff --git a/src/supertux/levelintro.cpp b/src/supertux/levelintro.cpp index 16df722fd..821699576 100644 --- a/src/supertux/levelintro.cpp +++ b/src/supertux/levelintro.cpp @@ -76,20 +76,20 @@ void LevelIntro::draw(DrawingContext& context) { const Statistics& stats = level->stats; - int py = static_cast(SCREEN_HEIGHT / 2 - normal_font->get_height() / 2); + int py = static_cast(SCREEN_HEIGHT / 2 - Resources::normal_font->get_height() / 2); context.draw_filled_rect(Vector(0, 0), Vector(SCREEN_WIDTH, SCREEN_HEIGHT), Color(0.0f, 0.0f, 0.0f, 1.0f), 0); { - context.draw_center_text(normal_font, level->get_name(), Vector(0, py), LAYER_FOREGROUND1, LevelIntro::header_color); - py += static_cast(normal_font->get_height()); + context.draw_center_text(Resources::normal_font, level->get_name(), Vector(0, py), LAYER_FOREGROUND1, LevelIntro::header_color); + py += static_cast(Resources::normal_font->get_height()); } std::string author = level->get_author(); if ((author != "") && (author != "SuperTux Team")) { std::string author_text = std::string(_("contributed by ")) + author; - context.draw_center_text(small_font, author_text, Vector(0, py), LAYER_FOREGROUND1, LevelIntro::author_color); - py += static_cast(small_font->get_height()); + context.draw_center_text(Resources::small_font, author_text, Vector(0, py), LAYER_FOREGROUND1, LevelIntro::author_color); + py += static_cast(Resources::small_font->get_height()); } py += 32; @@ -102,29 +102,29 @@ LevelIntro::draw(DrawingContext& context) py += 32; { - context.draw_center_text(normal_font, std::string("- ") + _("Best Level Statistics") + std::string(" -"), Vector(0, py), LAYER_FOREGROUND1, LevelIntro::stat_hdr_color); - py += static_cast(normal_font->get_height()); + context.draw_center_text(Resources::normal_font, std::string("- ") + _("Best Level Statistics") + std::string(" -"), Vector(0, py), LAYER_FOREGROUND1, LevelIntro::stat_hdr_color); + py += static_cast(Resources::normal_font->get_height()); } { std::stringstream ss; ss << _("Coins") << ": " << Statistics::coins_to_string((best_level_statistics && (best_level_statistics->coins >= 0)) ? best_level_statistics->coins : 0, stats.total_coins); - context.draw_center_text(normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1, LevelIntro::stat_color); - py += static_cast(normal_font->get_height()); + context.draw_center_text(Resources::normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1, LevelIntro::stat_color); + py += static_cast(Resources::normal_font->get_height()); } { std::stringstream ss; ss << _("Secrets") << ": " << Statistics::secrets_to_string((best_level_statistics && (best_level_statistics->coins >= 0)) ? best_level_statistics->secrets : 0, stats.total_secrets); - context.draw_center_text(normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1,LevelIntro::stat_color); - py += static_cast(normal_font->get_height()); + context.draw_center_text(Resources::normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1,LevelIntro::stat_color); + py += static_cast(Resources::normal_font->get_height()); } { std::stringstream ss; ss << _("Time") << ": " << Statistics::time_to_string((best_level_statistics && (best_level_statistics->coins >= 0)) ? best_level_statistics->time : 0); - context.draw_center_text(normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1,LevelIntro::stat_color); - py += static_cast(normal_font->get_height()); + context.draw_center_text(Resources::normal_font, ss.str(), Vector(0, py), LAYER_FOREGROUND1,LevelIntro::stat_color); + py += static_cast(Resources::normal_font->get_height()); } } diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp index 497987138..cfb3d08d1 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp @@ -574,7 +574,7 @@ int supertux_main(int argc, char** argv) Scripting::init_squirrel(g_config->enable_script_debugger); timelog("resources"); - load_shared(); + Resources::load_shared(); timelog(0); @@ -625,7 +625,7 @@ int supertux_main(int argc, char** argv) delete g_main_loop; g_main_loop = NULL; - unload_shared(); + Resources::unload_shared(); quit_audio(); if(g_config) diff --git a/src/supertux/mainloop.cpp b/src/supertux/mainloop.cpp index 2b6ee997f..3fd159020 100644 --- a/src/supertux/mainloop.cpp +++ b/src/supertux/mainloop.cpp @@ -134,8 +134,10 @@ MainLoop::draw_fps(DrawingContext& context, float fps_fps) char str[60]; snprintf(str, sizeof(str), "%3.1f", fps_fps); const char* fpstext = "FPS"; - context.draw_text(small_font, fpstext, Vector(SCREEN_WIDTH - small_font->get_text_width(fpstext) - small_font->get_text_width(" 99999") - BORDER_X, BORDER_Y + 20), ALIGN_LEFT, LAYER_HUD); - context.draw_text(small_font, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y + 20), ALIGN_RIGHT, LAYER_HUD); + context.draw_text(Resources::small_font, fpstext, + Vector(SCREEN_WIDTH - Resources::small_font->get_text_width(fpstext) - Resources::small_font->get_text_width(" 99999") - BORDER_X, + BORDER_Y + 20), ALIGN_LEFT, LAYER_HUD); + context.draw_text(Resources::small_font, str, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y + 20), ALIGN_RIGHT, LAYER_HUD); } void diff --git a/src/supertux/player_status.cpp b/src/supertux/player_status.cpp index 281c809e4..24bde7029 100644 --- a/src/supertux/player_status.cpp +++ b/src/supertux/player_status.cpp @@ -147,9 +147,10 @@ PlayerStatus::draw(DrawingContext& context) Surface* coin_surf = coin_surface.get(); if (coin_surf) { - context.draw_surface(coin_surf, Vector(SCREEN_WIDTH - BORDER_X - coin_surf->get_width() - fixed_font->get_text_width(coins_text), BORDER_Y + 1), LAYER_HUD); + context.draw_surface(coin_surf, Vector(SCREEN_WIDTH - BORDER_X - coin_surf->get_width() - Resources::fixed_font->get_text_width(coins_text), + BORDER_Y + 1), LAYER_HUD); } - context.draw_text(fixed_font, coins_text, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y), ALIGN_RIGHT, LAYER_HUD, PlayerStatus::text_color); + context.draw_text(Resources::fixed_font, coins_text, Vector(SCREEN_WIDTH - BORDER_X, BORDER_Y), ALIGN_RIGHT, LAYER_HUD, PlayerStatus::text_color); context.pop_transform(); } diff --git a/src/supertux/resources.cpp b/src/supertux/resources.cpp index 9391eaa12..9d573799c 100644 --- a/src/supertux/resources.cpp +++ b/src/supertux/resources.cpp @@ -14,9 +14,8 @@ // // You should have received a copy of the GNU General Public License // along with this program. If not, see . -//#include -//#include "supertux/resources.hpp" +#include "supertux/resources.hpp" #include "gui/mousecursor.hpp" #include "sprite/sprite_manager.hpp" @@ -24,15 +23,16 @@ #include "supertux/tile_manager.hpp" #include "video/font.hpp" -MouseCursor* mouse_cursor = NULL; +MouseCursor* Resources::mouse_cursor = NULL; -Font* fixed_font = NULL; -Font* normal_font = NULL; -Font* small_font = NULL; -Font* big_font = NULL; +Font* Resources::fixed_font = NULL; +Font* Resources::normal_font = NULL; +Font* Resources::small_font = NULL; +Font* Resources::big_font = NULL; /* Load graphics/sounds shared between all levels: */ -void load_shared() +void +Resources::load_shared() { /* Load the mouse-cursor */ mouse_cursor = new MouseCursor("images/engine/menu/mousecursor.png"); @@ -51,7 +51,8 @@ void load_shared() } /* Free shared data: */ -void unload_shared() +void +Resources::unload_shared() { /* Free global images: */ delete normal_font; diff --git a/src/supertux/resources.hpp b/src/supertux/resources.hpp index d61fa3e8a..06124c73e 100644 --- a/src/supertux/resources.hpp +++ b/src/supertux/resources.hpp @@ -21,15 +21,20 @@ class Font; class MouseCursor; -extern MouseCursor* mouse_cursor; +class Resources +{ +public: + static MouseCursor* mouse_cursor; -extern Font* fixed_font; -extern Font* normal_font; -extern Font* small_font; -extern Font* big_font; + static Font* fixed_font; + static Font* normal_font; + static Font* small_font; + static Font* big_font; -void load_shared(); -void unload_shared(); +public: + static void load_shared(); + static void unload_shared(); +}; #endif diff --git a/src/supertux/statistics.cpp b/src/supertux/statistics.cpp index 3cea415a7..b3aa2e036 100644 --- a/src/supertux/statistics.cpp +++ b/src/supertux/statistics.cpp @@ -129,7 +129,9 @@ Statistics::draw_worldmap_info(DrawingContext& context) // skip draw if stats were declared invalid if (!valid) return; - context.draw_text(small_font, std::string("- ") + _("Best Level Statistics") + " -", Vector((WMAP_INFO_LEFT_X + WMAP_INFO_RIGHT_X) / 2, WMAP_INFO_TOP_Y1), ALIGN_CENTER, LAYER_GUI,Statistics::header_color); + context.draw_text(Resources::small_font, std::string("- ") + _("Best Level Statistics") + " -", + Vector((WMAP_INFO_LEFT_X + WMAP_INFO_RIGHT_X) / 2, WMAP_INFO_TOP_Y1), + ALIGN_CENTER, LAYER_GUI,Statistics::header_color); std::string caption_buf; std::string stat_buf; @@ -158,9 +160,9 @@ Statistics::draw_worldmap_info(DrawingContext& context) break; } - context.draw_text(small_font, caption_buf, Vector(WMAP_INFO_LEFT_X, posy), ALIGN_LEFT, LAYER_GUI, Statistics::header_color); - context.draw_text(small_font, stat_buf, Vector(WMAP_INFO_RIGHT_X, posy), ALIGN_RIGHT, LAYER_GUI, Statistics::header_color); - posy += small_font->get_height() + 2; + context.draw_text(Resources::small_font, caption_buf, Vector(WMAP_INFO_LEFT_X, posy), ALIGN_LEFT, LAYER_GUI, Statistics::header_color); + context.draw_text(Resources::small_font, stat_buf, Vector(WMAP_INFO_RIGHT_X, posy), ALIGN_RIGHT, LAYER_GUI, Statistics::header_color); + posy += Resources::small_font->get_height() + 2; } } @@ -202,25 +204,25 @@ Statistics::draw_endseq_panel(DrawingContext& context, Statistics* best_stats, S context.draw_surface(backdrop, Vector(bd_x, bd_y), LAYER_GUI); context.pop_transform(); - context.draw_text(normal_font, _("You"), Vector(col2_x, row1_y), ALIGN_LEFT, LAYER_GUI, Statistics::header_color); - context.draw_text(normal_font, _("Best"), Vector(col3_x, row1_y), ALIGN_LEFT, LAYER_GUI, Statistics::header_color); + context.draw_text(Resources::normal_font, _("You"), Vector(col2_x, row1_y), ALIGN_LEFT, LAYER_GUI, Statistics::header_color); + context.draw_text(Resources::normal_font, _("Best"), Vector(col3_x, row1_y), ALIGN_LEFT, LAYER_GUI, Statistics::header_color); - context.draw_text(normal_font, _("Coins"), Vector(col2_x-16, row3_y), ALIGN_RIGHT, LAYER_GUI, Statistics::header_color); + context.draw_text(Resources::normal_font, _("Coins"), Vector(col2_x-16, row3_y), ALIGN_RIGHT, LAYER_GUI, Statistics::header_color); int coins_best = (best_stats && (best_stats->coins > coins)) ? best_stats->coins : coins; int total_coins_best = (best_stats && (best_stats->total_coins > total_coins)) ? best_stats->total_coins : total_coins; - context.draw_text(normal_font, coins_to_string(coins, total_coins), Vector(col2_x, row3_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); - context.draw_text(normal_font, coins_to_string(coins_best, total_coins_best), Vector(col3_x, row3_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); + context.draw_text(Resources::normal_font, coins_to_string(coins, total_coins), Vector(col2_x, row3_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); + context.draw_text(Resources::normal_font, coins_to_string(coins_best, total_coins_best), Vector(col3_x, row3_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); - context.draw_text(normal_font, _("Secrets"), Vector(col2_x-16, row4_y), ALIGN_RIGHT, LAYER_GUI, Statistics::header_color); + context.draw_text(Resources::normal_font, _("Secrets"), Vector(col2_x-16, row4_y), ALIGN_RIGHT, LAYER_GUI, Statistics::header_color); int secrets_best = (best_stats && (best_stats->secrets > secrets)) ? best_stats->secrets : secrets; int total_secrets_best = (best_stats && (best_stats->total_secrets > total_secrets)) ? best_stats->total_secrets : total_secrets; - context.draw_text(normal_font, secrets_to_string(secrets, total_secrets), Vector(col2_x, row4_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); - context.draw_text(normal_font, secrets_to_string(secrets_best, total_secrets_best), Vector(col3_x, row4_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); + context.draw_text(Resources::normal_font, secrets_to_string(secrets, total_secrets), Vector(col2_x, row4_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); + context.draw_text(Resources::normal_font, secrets_to_string(secrets_best, total_secrets_best), Vector(col3_x, row4_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); - context.draw_text(normal_font, _("Time"), Vector(col2_x-16, row2_y), ALIGN_RIGHT, LAYER_GUI, Statistics::header_color); + context.draw_text(Resources::normal_font, _("Time"), Vector(col2_x-16, row2_y), ALIGN_RIGHT, LAYER_GUI, Statistics::header_color); float time_best = (best_stats && (best_stats->time < time)) ? best_stats->time : time; - context.draw_text(normal_font, time_to_string(time), Vector(col2_x, row2_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); - context.draw_text(normal_font, time_to_string(time_best), Vector(col3_x, row2_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); + context.draw_text(Resources::normal_font, time_to_string(time), Vector(col2_x, row2_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); + context.draw_text(Resources::normal_font, time_to_string(time_best), Vector(col3_x, row2_y), ALIGN_LEFT, LAYER_GUI, Statistics::text_color); } void diff --git a/src/supertux/title_screen.cpp b/src/supertux/title_screen.cpp index 457667235..177328867 100644 --- a/src/supertux/title_screen.cpp +++ b/src/supertux/title_screen.cpp @@ -381,15 +381,15 @@ TitleScreen::draw(DrawingContext& context) // FIXME: Add something to scale the frame to the resolution of the screen context.draw_surface(frame.get(), Vector(0,0),LAYER_FOREGROUND1); - context.draw_text(small_font, "SuperTux " PACKAGE_VERSION "\n", + context.draw_text(Resources::small_font, "SuperTux " PACKAGE_VERSION "\n", Vector(5, SCREEN_HEIGHT - 50), ALIGN_LEFT, LAYER_FOREGROUND1); - context.draw_text(small_font, + context.draw_text(Resources::small_font, _( "Copyright (c) 2007 SuperTux Devel Team\n" "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to\n" "redistribute it under certain conditions; see the file COPYING for details.\n" ), - Vector(5, SCREEN_HEIGHT - 50 + small_font->get_height() + 5), + Vector(5, SCREEN_HEIGHT - 50 + Resources::small_font->get_height() + 5), ALIGN_LEFT, LAYER_FOREGROUND1); } diff --git a/src/trigger/climbable.cpp b/src/trigger/climbable.cpp index 6fc957fa2..fc0cd6790 100644 --- a/src/trigger/climbable.cpp +++ b/src/trigger/climbable.cpp @@ -74,8 +74,8 @@ Climbable::draw(DrawingContext& context) if (climbed_by) { context.push_transform(); context.set_translation(Vector(0, 0)); - Vector pos = Vector(0, SCREEN_HEIGHT/2 - normal_font->get_height()/2); - context.draw_center_text(normal_font, _("Up we go..."), pos, LAYER_GUI, Climbable::text_color); + Vector pos = Vector(0, SCREEN_HEIGHT/2 - Resources::normal_font->get_height()/2); + context.draw_center_text(Resources::normal_font, _("Up we go..."), pos, LAYER_GUI, Climbable::text_color); context.pop_transform(); } } diff --git a/src/trigger/secretarea_trigger.cpp b/src/trigger/secretarea_trigger.cpp index d333eab08..182e78fbf 100644 --- a/src/trigger/secretarea_trigger.cpp +++ b/src/trigger/secretarea_trigger.cpp @@ -63,8 +63,8 @@ SecretAreaTrigger::draw(DrawingContext& context) if (message_timer.started()) { context.push_transform(); context.set_translation(Vector(0, 0)); - Vector pos = Vector(0, SCREEN_HEIGHT/2 - normal_font->get_height()/2); - context.draw_center_text(normal_font, _("You found a secret area!"), pos, LAYER_GUI, SecretAreaTrigger::text_color); + Vector pos = Vector(0, SCREEN_HEIGHT/2 - Resources::normal_font->get_height()/2); + context.draw_center_text(Resources::normal_font, _("You found a secret area!"), pos, LAYER_GUI, SecretAreaTrigger::text_color); context.pop_transform(); } if (message_timer.check()) { diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index c8fbfd227..0a0c50f0a 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -878,9 +878,9 @@ WorldMap::draw_status(DrawingContext& context) if(level->title == "") get_level_title(*level); - context.draw_text(normal_font, level->title, + context.draw_text(Resources::normal_font, level->title, Vector(SCREEN_WIDTH/2, - SCREEN_HEIGHT - normal_font->get_height() - 30), + SCREEN_HEIGHT - Resources::normal_font->get_height() - 30), ALIGN_CENTER, LAYER_FOREGROUND1, WorldMap::level_title_color); // if level is solved, draw level picture behind stats @@ -908,9 +908,9 @@ WorldMap::draw_status(DrawingContext& context) if (special_tile->pos == tux->get_tile_pos()) { /* Display an in-map message in the map, if any as been selected */ if(!special_tile->map_message.empty() && !special_tile->passive_message) - context.draw_text(normal_font, special_tile->map_message, + context.draw_text(Resources::normal_font, special_tile->map_message, Vector(SCREEN_WIDTH/2, - SCREEN_HEIGHT - normal_font->get_height() - 60), + SCREEN_HEIGHT - Resources::normal_font->get_height() - 60), ALIGN_CENTER, LAYER_FOREGROUND1, WorldMap::message_color); break; } @@ -919,16 +919,16 @@ WorldMap::draw_status(DrawingContext& context) // display teleporter messages Teleporter* teleporter = at_teleporter(tux->get_tile_pos()); if (teleporter && (teleporter->message != "")) { - Vector pos = Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - normal_font->get_height() - 30); - context.draw_text(normal_font, teleporter->message, pos, ALIGN_CENTER, LAYER_FOREGROUND1, WorldMap::teleporter_message_color); + Vector pos = Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - Resources::normal_font->get_height() - 30); + context.draw_text(Resources::normal_font, teleporter->message, pos, ALIGN_CENTER, LAYER_FOREGROUND1, WorldMap::teleporter_message_color); } } /* Display a passive message in the map, if needed */ if(passive_message_timer.started()) - context.draw_text(normal_font, passive_message, - Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - normal_font->get_height() - 60), + context.draw_text(Resources::normal_font, passive_message, + Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT - Resources::normal_font->get_height() - 60), ALIGN_CENTER, LAYER_FOREGROUND1, WorldMap::message_color); context.pop_transform();