Limitated the number of bullets to be shot at the same time.
[supertux.git] / src / menu.h
index 8c30c44..8342a46 100644 (file)
@@ -22,7 +22,6 @@
 
 #include <SDL.h>
 #include <vector>
-#include <stack>
 #include "texture.h"
 #include "timer.h"
 #include "type.h"
@@ -52,20 +51,24 @@ public:
   int toggled;
   char *text;
   char *input;
+  int *int_p;   // used for setting keys (can be used for more stuff...)
   string_list_type* list;
   Menu* target_menu;
 
   void change_text (const char *text);
   void change_input(const char *text);
 
-  static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu);
+  static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu, int* int_p);
 };
 
 class Menu
 {
 private:  
-  static std::stack<Menu*> last_menus;
+  static std::vector<Menu*> last_menus;
   static Menu* current_;
+
+  static void push_current(Menu* pmenu);
+  static void pop_current();
 public:
   /** Set the current menu, if pmenu is NULL, hide the current menu */
   static void set_current(Menu* pmenu);
@@ -86,6 +89,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;
@@ -98,9 +105,6 @@ private:
   int delete_character;
   char mn_input_char;
   
-  int width();
-  int height();
-
 public:
   Timer effect;
   int arrange_left;
@@ -112,23 +116,28 @@ public:
   ~Menu();
 
   void additem(MenuItem* pmenu_item);
-  void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu);
-  void action ();
+  void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu, int *int_p = NULL);
+  
+  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;