From f6504762d01217fbbba3923b8e7f3b84d30c088c Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Sun, 25 May 2008 15:59:10 +0000 Subject: [PATCH] Fixed menu position on resize SVN-Revision: 5517 --- src/gui/menu.cpp | 7 ++++++- src/gui/menu.hpp | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 3db37460e..97f7086d6 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -48,6 +48,7 @@ static const float FLICK_CURSOR_TIME = 0.5f; extern SDL_Surface* screen; std::vector Menu::last_menus; +std::list Menu::all_menus; Menu* Menu::current_ = 0; Menu* Menu::previous = 0; Font* Menu::default_font; @@ -168,7 +169,7 @@ Menu::recalc_pos() if (current_) current_->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2); - for(std::vector::iterator i = last_menus.begin(); i != last_menus.end(); ++i) + for(std::list::iterator i = all_menus.begin(); i != all_menus.end(); ++i) { // FIXME: This is of course not quite right, since it ignores any previous set_pos() calls (*i)->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2); @@ -228,6 +229,8 @@ std::string MenuItem::get_input_with_symbol(bool active_item) Menu::~Menu() { + all_menus.remove(this); + for(std::vector::iterator i = items.begin(); i != items.end(); ++i) delete *i; @@ -241,6 +244,8 @@ Menu::~Menu() Menu::Menu() { + all_menus.push_back(this); + hit_item = -1; menuaction = MENU_ACTION_NONE; delete_character = 0; diff --git a/src/gui/menu.hpp b/src/gui/menu.hpp index 6eea51d03..0fa35fc65 100644 --- a/src/gui/menu.hpp +++ b/src/gui/menu.hpp @@ -21,6 +21,7 @@ #define SUPERTUX_MENU_H #include +#include #include #include #include @@ -92,6 +93,10 @@ class Menu { private: static std::vector last_menus; + + /** Pointers to all currently available menus, used to handle repositioning on window resize */ + static std::list all_menus; + static Menu* previous; static Menu* current_; -- 2.11.0