TODO update
[supertux.git] / src / menu.h
index 43aee85..74a8669 100644 (file)
 #include "type.h"
 #include "mousecursor.h"
 
+/* IDs for menus */
+
+enum MainMenuIDs {
+  MNID_STARTGAME,
+  MNID_CONTRIB,
+  MNID_OPTIONMENU,
+  MNID_LEVELEDITOR,
+  MNID_CREDITS,
+  MNID_QUITMAINMENU
+  };
+
+enum OptionsMenuIDs {
+  MNID_OPENGL,
+  MNID_FULLSCREEN,
+  MNID_SOUND,
+  MNID_MUSIC,
+  MNID_SHOWFPS
+  };
+
+enum GameMenuIDs {
+  MNID_CONTINUE,
+  MNID_ABORTLEVEL
+  };
+
+enum WorldMapMenuIDs {
+  MNID_RETURNWORLDMAP,
+  MNID_SAVEGAME,
+  MNID_QUITWORLDMAP
+  };
+
+enum LevelEditorMainMenuIDs {
+  MNID_RETURNLEVELEDITOR,
+  MNID_SUBSETSETTINGS,
+  MNID_QUITLEVELEDITOR
+  };
+
+enum LevelEditorSettingsMenuIDs {
+  MNID_APPLY
+  };
+
+bool confirm_dialog(char *text);
+
 /* Kinds of menu items */
 enum MenuItemKind {
   MN_ACTION,
@@ -52,13 +94,19 @@ public:
   char *text;
   char *input;
   int *int_p;   // used for setting keys (can be used for more stuff...)
+  int id;   // item id
   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, int* int_p);
+  static MenuItem* create(MenuItemKind kind, const char *text, int init_toggle, Menu* target_menu, int id, int* int_p);
+
+  std::string get_input_with_symbol(bool active_item);   // returns the text with an input symbol
+private:
+  bool input_flickering;
+  Timer input_flickering_timer;
 };
 
 class Menu
@@ -97,7 +145,6 @@ private:
   // position of the menu (ie. center of the menu, not top/left)
   int pos_x;
   int pos_y;
-  bool has_backitem;
 
   /** input event for the menu (up, down, left, right, etc.) */
   MenuAction menuaction;
@@ -117,7 +164,7 @@ public:
   ~Menu();
 
   void additem(MenuItem* pmenu_item);
-  void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu, int *int_p = NULL);
+  void additem(MenuItemKind kind, const std::string& text, int init_toggle, Menu* target_menu, int id = -1, int *int_p = NULL);
   
   void  action ();
   
@@ -129,6 +176,11 @@ public:
   int  check  ();
 
   MenuItem& get_item(int index) { return item[index]; }
+  MenuItem& get_item_by_id(int id);
+
+  int get_active_item_id();
+
+  bool isToggled(int id);
 
   void Menu::get_controlfield_key_into_input(MenuItem *item);
 
@@ -141,6 +193,8 @@ public:
 
   int get_width() const;
   int get_height() const;
+
+  bool is_toggled(int id) const;
 };
 
 extern Surface* checkbox;