- removed dn_tilemap
[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
21 /* Kinds of menu items */
22 enum MenuItemKind {
23   MN_ACTION,
24   MN_GOTO,
25   MN_TOGGLE,
26   MN_BACK,
27   MN_DEACTIVE,
28   MN_TEXTFIELD,
29   MN_NUMFIELD,
30   MN_STRINGSELECT,
31   MN_LABEL,
32   MN_HL /* horizontal line */
33 };
34
35 class Menu;
36
37 struct menu_item_type
38   {
39     MenuItemKind kind;
40     int toggled;
41     char *text;
42     char *input;
43     string_list_type* list;
44     Menu* target_menu;
45 };
46
47 menu_item_type* menu_item_create(MenuItemKind kind, char *text, int init_toggle, Menu* target_menu);
48 void menu_item_change_text (menu_item_type* pmenu_item, const char *text);
49 void menu_item_change_input(menu_item_type* pmenu_item, const char *text);
50
51 class Menu
52 {
53 private:
54   // position of the menu (ie. center of the menu, not top/left)
55   int pos_x;
56   int pos_y;
57   
58   int num_items;
59
60 public:
61   timer_type effect;
62   int arrange_left;
63   int active_item;
64   menu_item_type *item;
65
66   static void set_current(Menu* pmenu);
67
68   Menu();
69   ~Menu();
70
71   void additem(menu_item_type* pmenu_item);
72   void additem(MenuItemKind kind, char *text, int init_toggle, Menu* target_menu);
73   void action ();
74   int  check  ();
75   void draw   ();
76   void draw_item(int index, int menu_width, int menu_height);
77 };
78
79
80 /* Action done on the menu */
81 enum MenuAction {
82   MENU_ACTION_NONE = -1,
83   MENU_ACTION_UP,
84   MENU_ACTION_DOWN,
85   MENU_ACTION_LEFT,
86   MENU_ACTION_RIGHT,
87   MENU_ACTION_HIT,
88   MENU_ACTION_INPUT,
89   MENU_ACTION_REMOVE
90 };
91
92 /* (global) menu variables */
93 extern MenuAction menuaction;
94 extern bool show_menu;
95 extern bool menu_change;
96 extern texture_type checkbox, checkbox_checked, back, arrow_left, arrow_right;
97
98 extern Menu* main_menu;
99 extern Menu* game_menu;
100 extern Menu* options_menu;
101 extern Menu* highscore_menu;
102 extern Menu* load_game_menu;
103 extern Menu* save_game_menu;
104 extern Menu* current_menu;
105 extern Menu* last_menu;
106
107 /* input implementation variables */
108 extern int delete_character;
109 extern char mn_input_char;
110
111 /* Reset the global menu variables */
112 void menu_reset(void);
113
114 /* "Calculate" and draw the menu */
115 void menu_process_current(void);
116
117 /* Check for a menu event */
118 void menu_event(SDL_keysym* keysym);
119
120 #endif /*SUPERTUX_MENU_H*/
121
122 /* Local Variables: */
123 /* mode:c++ */
124 /* End */