X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmenu.h;h=56e1a360fc215cf8772ffe3158771c651e630277;hb=b6543ef22bd7e4193d03cadac0c6e0dc75e3bd66;hp=36e533fc11e65393a1f50c908ec2d6d76e6ecd6c;hpb=ea5dc9e3b1dc4f387eba638378a9f2945cbc5815;p=supertux.git diff --git a/src/menu.h b/src/menu.h index 36e533fc1..56e1a360f 100644 --- a/src/menu.h +++ b/src/menu.h @@ -22,7 +22,6 @@ #include #include -#include #include "texture.h" #include "timer.h" #include "type.h" @@ -64,7 +63,7 @@ public: class Menu { private: - static std::stack last_menus; + static std::vector last_menus; static Menu* current_; static void push_current(Menu* pmenu); @@ -89,6 +88,10 @@ private: MENU_ACTION_REMOVE }; + /** Number of the item that got 'hit' (ie. pressed) in the last + event()/action() call, -1 if none */ + int hit_item; + // position of the menu (ie. center of the menu, not top/left) int pos_x; int pos_y; @@ -101,9 +104,6 @@ private: int delete_character; char mn_input_char; - int width(); - int height(); - public: Timer effect; int arrange_left; @@ -116,22 +116,27 @@ public: void additem(MenuItem* pmenu_item); void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu); - void action (); + + void action (); /** Remove all entries from the menu */ void clear(); - /** Check, if the value of the active menu item has changed. FIXME: - Somebody should document the exact meaning of this function a - bit more */ + /** Return the index of the menu item that was 'hit' (ie. the user + clicked on it) in the last event() call */ int check (); + MenuItem& get_item(int index) { return item[index]; } + void draw (); void draw_item(int index, int menu_width, int menu_height); void set_pos(int x, int y, float rw = 0, float rh = 0); /** translate a SDL_Event into a menu_action */ void event(SDL_Event& event); + + int get_width() const; + int get_height() const; }; extern Surface* checkbox;