From: Tobias Markus Date: Sat, 17 Aug 2013 19:18:50 +0000 (-1000) Subject: Partial resolution of bug 952 X-Git-Url: https://git.octo.it/?a=commitdiff_plain;h=789f328dd33efdbdc59162166ea1c8a7205456c3;p=supertux.git Partial resolution of bug 952 --- diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 21df675cb..2c6f81cdd 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -46,12 +46,7 @@ Menu::Menu() : effect_progress(), effect_start_time(), arrange_left(), - active_item(), - checkbox(), - checkbox_checked(), - back(), - arrow_left(), - arrow_right() + active_item() { MenuManager::all_menus.push_back(this); @@ -67,12 +62,6 @@ Menu::Menu() : effect_progress = 0.0f; effect_start_time = 0.0f; - - checkbox = Surface::create("images/engine/menu/checkbox-unchecked.png"); - checkbox_checked = Surface::create("images/engine/menu/checkbox-checked.png"); - back = Surface::create("images/engine/menu/arrow-back.png"); - arrow_left = Surface::create("images/engine/menu/arrow-left.png"); - arrow_right = Surface::create("images/engine/menu/arrow-right.png"); } Menu::~Menu() @@ -547,17 +536,17 @@ Menu::draw_item(DrawingContext& context, int index) } case MN_STRINGSELECT: { - float roff = arrow_left->get_width(); + float roff = Resources::arrow_left->get_width(); // Draw left side 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 - context.draw_surface(arrow_left, + context.draw_surface(Resources::arrow_left, Vector(right - list_width - roff - roff, y_pos - 8), LAYER_GUI); - context.draw_surface(arrow_right, + context.draw_surface(Resources::arrow_right, Vector(right - roff, y_pos - 8), LAYER_GUI); context.draw_text(Resources::normal_font, pitem.list[pitem.selected], @@ -570,7 +559,7 @@ Menu::draw_item(DrawingContext& context, int index) 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, + context.draw_surface(Resources::back, Vector(x_pos + text_width/2 + 16, y_pos - 8), LAYER_GUI); break; @@ -583,12 +572,12 @@ Menu::draw_item(DrawingContext& context, int index) ALIGN_LEFT, LAYER_GUI, text_color); if(pitem.toggled) - context.draw_surface(checkbox_checked, - Vector(x_pos + (menu_width/2-16) - checkbox->get_width(), y_pos - 8), + context.draw_surface(Resources::checkbox_checked, + Vector(x_pos + (menu_width/2-16) - Resources::checkbox->get_width(), y_pos - 8), LAYER_GUI + 1); else - context.draw_surface(checkbox, - Vector(x_pos + (menu_width/2-16) - checkbox->get_width(), y_pos - 8), + context.draw_surface(Resources::checkbox, + Vector(x_pos + (menu_width/2-16) - Resources::checkbox->get_width(), y_pos - 8), LAYER_GUI + 1); break; } diff --git a/src/gui/menu.hpp b/src/gui/menu.hpp index b00c9c890..ab9f6e123 100644 --- a/src/gui/menu.hpp +++ b/src/gui/menu.hpp @@ -137,12 +137,6 @@ public: private: int arrange_left; int active_item; - - SurfacePtr checkbox; - SurfacePtr checkbox_checked; - SurfacePtr back; - SurfacePtr arrow_left; - SurfacePtr arrow_right; }; #endif diff --git a/src/supertux/resources.cpp b/src/supertux/resources.cpp index 7d2e14784..0b09aa57e 100644 --- a/src/supertux/resources.cpp +++ b/src/supertux/resources.cpp @@ -30,6 +30,12 @@ FontPtr Resources::normal_font; FontPtr Resources::small_font; FontPtr Resources::big_font; +SurfacePtr Resources::checkbox; +SurfacePtr Resources::checkbox_checked; +SurfacePtr Resources::back; +SurfacePtr Resources::arrow_left; +SurfacePtr Resources::arrow_right; + /* Load graphics/sounds shared between all levels: */ void Resources::load_shared() @@ -44,6 +50,13 @@ Resources::load_shared() small_font.reset(new Font(Font::VARIABLE, "fonts/white-small.stf", 1)); big_font.reset(new Font(Font::VARIABLE, "fonts/white-big.stf", 3)); + /* Load menu images */ + checkbox = Surface::create("images/engine/menu/checkbox-unchecked.png"); + checkbox_checked = Surface::create("images/engine/menu/checkbox-checked.png"); + back = Surface::create("images/engine/menu/arrow-back.png"); + arrow_left = Surface::create("images/engine/menu/arrow-left.png"); + arrow_right = Surface::create("images/engine/menu/arrow-right.png"); + tile_manager = new TileManager(); sprite_manager = new SpriteManager(); } @@ -52,6 +65,13 @@ Resources::load_shared() void Resources::unload_shared() { + /* Free menu images */ + checkbox.reset(); + checkbox_checked.reset(); + back.reset(); + arrow_left.reset(); + arrow_right.reset(); + /* Free global images: */ fixed_font.reset(); normal_font.reset(); diff --git a/src/supertux/resources.hpp b/src/supertux/resources.hpp index f63c56a31..8648a91fb 100644 --- a/src/supertux/resources.hpp +++ b/src/supertux/resources.hpp @@ -19,6 +19,7 @@ #define HEADER_SUPERTUX_SUPERTUX_RESOURCES_HPP #include "video/font_ptr.hpp" +#include "video/surface_ptr.hpp" class MouseCursor; @@ -32,6 +33,12 @@ public: static FontPtr small_font; static FontPtr big_font; + static SurfacePtr checkbox; + static SurfacePtr checkbox_checked; + static SurfacePtr back; + static SurfacePtr arrow_left; + static SurfacePtr arrow_right; + public: static void load_shared(); static void unload_shared();