removed title from main menu
[supertux.git] / src / menu.h
1 /*
2   menu.h
3   
4   Super Tux - Menu
5   
6   by Tobias Glaesser
7   tobi.web@gmx.de
8   http://www.newbreedsoftware.com/supertux/
9   
10   December 20, 2003
11 */
12
13 #ifndef SUPERTUX_MENU_H
14 #define SUPERTUX_MENU_H
15
16 #include <SDL.h>
17 #include "texture.h"
18 #include "timer.h"
19 #include "type.h"
20 #include "mousecursor.h"
21
22 /* Kinds of menu items */
23 enum MenuItemKind {
24   MN_ACTION,
25   MN_GOTO,
26   MN_TOGGLE,
27   MN_BACK,
28   MN_DEACTIVE,
29   MN_TEXTFIELD,
30   MN_NUMFIELD,
31   MN_CONTROLFIELD,
32   MN_STRINGSELECT,
33   MN_LABEL,
34   MN_HL, /* horizontal line */
35 };
36
37 class Menu;
38
39 struct menu_item_type
40   {
41     MenuItemKind kind;
42     int toggled;
43     char *text;
44     char *input;
45     string_list_type* list;
46     Menu* target_menu;
47 };
48
49 menu_item_type* menu_item_create(MenuItemKind kind, char *text, int init_toggle, Menu* target_menu);
50 void menu_item_change_text (menu_item_type* pmenu_item, const char *text);
51 void menu_item_change_input(menu_item_type* pmenu_item, const char *text);
52
53 class Menu
54 {
55 friend void menu_event(SDL_Event& event);
56
57 private:
58   // position of the menu (ie. center of the menu, not top/left)
59   int pos_x;
60   int pos_y;
61   
62   int num_items;
63   Menu* last_menu;
64   int width();
65   int height();
66   
67   
68 public:
69   timer_type effect;
70   int arrange_left;
71   int active_item;
72   menu_item_type *item;
73
74   static void set_current(Menu* pmenu);
75
76   Menu();
77   ~Menu();
78
79   void additem(menu_item_type* pmenu_item);
80   void additem(MenuItemKind kind, char *text, int init_toggle, Menu* target_menu);
81   void action ();
82
83   /** Check, if the value of the active menu item has changed. */
84   int  check  ();
85   void draw   ();
86   void draw_item(int index, int menu_width, int menu_height);
87   void set_pos(int x, int y, float rw = 0, float rh = 0);
88 };
89
90
91 /* Action done on the menu */
92 enum MenuAction {
93   MENU_ACTION_NONE = -1,
94   MENU_ACTION_UP,
95   MENU_ACTION_DOWN,
96   MENU_ACTION_LEFT,
97   MENU_ACTION_RIGHT,
98   MENU_ACTION_HIT,
99   MENU_ACTION_INPUT,
100   MENU_ACTION_REMOVE
101 };
102
103 /* (global) menu variables */
104 extern MenuAction menuaction;
105 extern bool show_menu;
106 extern bool menu_change;
107 extern texture_type checkbox, checkbox_checked, back, arrow_left, arrow_right;
108
109 extern Menu* main_menu;
110 extern Menu* game_menu;
111 extern Menu* options_menu;
112 extern Menu* options_controls_menu;
113 extern Menu* highscore_menu;
114 extern Menu* load_game_menu;
115 extern Menu* save_game_menu;
116 extern Menu* current_menu;
117
118 /* input implementation variables */
119 extern int delete_character;
120 extern char mn_input_char;
121
122 /* Reset the global menu variables */
123 void menu_reset(void);
124
125 /* "Calculate" and draw the menu */
126 void menu_process_current(void);
127
128 /* Check for a menu event */
129 void menu_event(SDL_Event& event);
130
131 #endif /*SUPERTUX_MENU_H*/
132
133 /* Local Variables: */
134 /* mode:c++ */
135 /* End */