5d1672cb |
1 | /* |
2 | * (C) GraÅžvydas "notaz" Ignotas, 2006-2010 |
3 | * |
4 | * This work is licensed under the terms of any of these licenses |
5 | * (at your option): |
6 | * - GNU GPL, version 2 or later. |
7 | * - GNU LGPL, version 2.1 or later. |
8 | * See the COPYING file in the top-level directory. |
9 | */ |
e5f426aa |
10 | |
e5f426aa |
11 | typedef enum |
12 | { |
13 | MB_NONE = 1, /* no auto processing */ |
1fb0dd88 |
14 | MB_OPT_ONOFF, /* ON/OFF setting */ |
15 | MB_OPT_RANGE, /* [min-max] setting */ |
713c9224 |
16 | MB_OPT_CUSTOM, /* custom value */ |
17 | MB_OPT_CUSTONOFF, |
18 | MB_OPT_CUSTRANGE, |
fcdefcf6 |
19 | MB_OPT_ENUM, |
e5f426aa |
20 | } menu_behavior; |
21 | |
e5f426aa |
22 | typedef struct |
23 | { |
42171343 |
24 | const char *name; |
e5f426aa |
25 | menu_behavior beh; |
d2fd8a7a |
26 | int id; |
1fb0dd88 |
27 | void *var; /* for on-off/range settings */ |
28 | int mask; /* bit to toggle for on/off */ |
713c9224 |
29 | signed short min; /* for ranged integer settings, to be sign-extended */ |
30 | signed short max; |
c7eb229a |
31 | unsigned int enabled:1; |
32 | unsigned int need_to_save:1; |
33 | unsigned int selectable:1; |
d2fd8a7a |
34 | int (*handler)(int id, int keys); |
35 | const char * (*generate_name)(int id, int *offs); |
fcdefcf6 |
36 | const void *data; |
37 | const char *help; |
e5f426aa |
38 | } menu_entry; |
39 | |
5d1672cb |
40 | #define mee_handler_id_h(name, id, handler, help) \ |
41 | { name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, NULL, NULL, help } |
42 | |
713c9224 |
43 | #define mee_handler_id(name, id, handler) \ |
5d1672cb |
44 | mee_handler_id_h(name, id, handler, NULL) |
1fb0dd88 |
45 | |
713c9224 |
46 | #define mee_handler(name, handler) \ |
47 | mee_handler_id(name, MA_NONE, handler) |
48 | |
5d1672cb |
49 | #define mee_handler_h(name, handler, help) \ |
50 | mee_handler_id_h(name, MA_NONE, handler, help) |
51 | |
713c9224 |
52 | #define mee_label(name) \ |
fcdefcf6 |
53 | { name, MB_NONE, MA_NONE, NULL, 0, 0, 0, 1, 0, 0, NULL, NULL, NULL, NULL } |
713c9224 |
54 | |
55 | #define mee_label_mk(id, name_func) \ |
fcdefcf6 |
56 | { "", MB_NONE, id, NULL, 0, 0, 0, 1, 0, 0, NULL, name_func, NULL, NULL } |
57 | |
58 | #define mee_onoff_h(name, id, var, mask, help) \ |
59 | { name, MB_OPT_ONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, NULL, NULL, help } |
713c9224 |
60 | |
61 | #define mee_onoff(name, id, var, mask) \ |
fcdefcf6 |
62 | mee_onoff_h(name, id, var, mask, NULL) |
713c9224 |
63 | |
4187c0ea |
64 | #define mee_range_h(name, id, var, min, max, help) \ |
65 | { name, MB_OPT_RANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, NULL, NULL, help } |
66 | |
713c9224 |
67 | #define mee_range(name, id, var, min, max) \ |
4187c0ea |
68 | mee_range_h(name, id, var, min, max, NULL) |
fcdefcf6 |
69 | |
c7eb229a |
70 | #define mee_range_hide(name, id, var, min, max) \ |
71 | { name, MB_OPT_RANGE, id, &(var), 0, min, max, 0, 1, 0, NULL, NULL, NULL, NULL } |
72 | |
fcdefcf6 |
73 | #define mee_cust_s_h(name, id, need_save, handler, name_func, help) \ |
74 | { name, MB_OPT_CUSTOM, id, NULL, 0, 0, 0, 1, need_save, 1, handler, name_func, NULL, help } |
75 | |
76 | #define mee_cust_h(name, id, handler, name_func, help) \ |
77 | mee_cust_s_h(name, id, 1, handler, name_func, help) |
713c9224 |
78 | |
79 | #define mee_cust(name, id, handler, name_func) \ |
fcdefcf6 |
80 | mee_cust_h(name, id, handler, name_func, NULL) |
81 | |
82 | #define mee_cust_nosave(name, id, handler, name_func) \ |
83 | mee_cust_s_h(name, id, 0, handler, name_func, NULL) |
713c9224 |
84 | |
85 | #define mee_onoff_cust(name, id, var, mask, name_func) \ |
fcdefcf6 |
86 | { name, MB_OPT_CUSTONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, name_func, NULL, NULL } |
713c9224 |
87 | |
88 | #define mee_range_cust(name, id, var, min, max, name_func) \ |
fcdefcf6 |
89 | { name, MB_OPT_CUSTRANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, name_func, NULL, NULL } |
90 | |
91 | #define mee_enum_h(name, id, var, names_list, help) \ |
92 | { name, MB_OPT_ENUM, id, &(var), 0, 0, 0, 1, 1, 1, NULL, NULL, names_list, help } |
93 | |
94 | #define mee_enum(name, id, var, names_list) \ |
95 | mee_enum_h(name, id, var, names_list, NULL) |
1fb0dd88 |
96 | |
97 | #define mee_end \ |
fcdefcf6 |
98 | { NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL } |
1fb0dd88 |
99 | |
1ca2ea4f |
100 | typedef struct |
101 | { |
102 | char *name; |
103 | int mask; |
104 | } me_bind_action; |
105 | |
d2fd8a7a |
106 | extern me_bind_action me_ctrl_actions[]; |
1ca2ea4f |
107 | extern me_bind_action emuctrl_actions[]; // platform code |
108 | |
c7eb229a |
109 | extern void *g_menubg_src_ptr; |
697746df |
110 | extern void *g_menubg_ptr; |
c7eb229a |
111 | extern void *g_menuscreen_ptr; |
d40231e2 |
112 | #if MSCREEN_SIZE_FIXED |
c7eb229a |
113 | #define g_menuscreen_w MSCREEN_WIDTH |
114 | #define g_menuscreen_h MSCREEN_HEIGHT |
115 | #else |
116 | extern int g_menuscreen_w; |
117 | extern int g_menuscreen_h; |
118 | #endif |
697746df |
119 | |
c6c6c9cd |
120 | void menu_init(void); |
121 | void text_out16(int x, int y, const char *texto, ...); |
122 | void me_update_msg(const char *msg); |
123 | |
823b9004 |
124 | void menu_romload_prepare(const char *rom_name); |
125 | void menu_romload_end(void); |
126 | |
74f5e726 |
127 | void menu_loop(void); |
128 | int menu_loop_tray(void); |
129 | |
713c9224 |
130 | menu_entry *me_list_get_first(void); |
131 | menu_entry *me_list_get_next(void); |
e5f426aa |
132 | |