- replaced YES/NO with true/false
[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 typedef struct menu_item_type
36   {
37     MenuItemKind kind;
38     int toggled;
39     char *text;
40     char *input;
41     string_list_type* list;
42     void* target_menu;
43   }
44 menu_item_type;
45
46 menu_item_type* menu_item_create(MenuItemKind kind, char *text, int init_toggle, void* target_menu);
47 void menu_item_change_text (menu_item_type* pmenu_item, const char *text);
48 void menu_item_change_input(menu_item_type* pmenu_item, const char *text);
49
50 typedef struct menu_type
51 {
52   // center of the menu on the screen
53   int x;
54   int y;
55
56   int num_items;
57   int active_item;
58   int arrange_left;
59   menu_item_type *item;
60   timer_type effect;
61 }
62 menu_type;
63
64 void menu_init   (menu_type* pmenu);
65 void menu_free   (menu_type* pmenu);
66 void menu_additem(menu_type* pmenu, menu_item_type* pmenu_item);
67 menu_item_type* menu_additem(menu_type* pmenu, MenuItemKind kind, char *text, int init_toggle, void* target_menu);
68 void menu_action (menu_type* pmenu);
69 int  menu_check  (menu_type* pmenu);
70 void menu_draw   (menu_type* pmenu);
71 void menu_set_current(menu_type* pmenu);
72
73 /* Action done on the menu */
74 enum MenuAction {
75   MENU_ACTION_NONE = -1,
76   MENU_ACTION_UP,
77   MENU_ACTION_DOWN,
78   MENU_ACTION_LEFT,
79   MENU_ACTION_RIGHT,
80   MENU_ACTION_HIT,
81   MENU_ACTION_INPUT,
82   MENU_ACTION_REMOVE
83 };
84
85 /* (global) menu variables */
86 extern MenuAction menuaction;
87 extern bool show_menu;
88 extern bool menu_change;
89 extern texture_type checkbox, checkbox_checked, back, arrow_left, arrow_right;
90
91 extern menu_type main_menu, game_menu, options_menu, highscore_menu, load_game_menu, save_game_menu;
92 extern menu_type* current_menu, * last_menu;
93
94 /* input implementation variables */
95 extern int delete_character;
96 extern char mn_input_char;
97
98 /* Reset the global menu variables */
99 void menu_reset(void);
100
101 /* "Calculate" and draw the menu */
102 void menu_process_current(void);
103
104 /* Check for a menu event */
105 void menu_event(SDL_keysym* keysym);
106
107 #endif /*SUPERTUX_MENU_H*/
108