| 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 | */ |
| 10 | |
| 11 | typedef enum |
| 12 | { |
| 13 | MB_NONE = 1, /* no auto processing */ |
| 14 | MB_OPT_ONOFF, /* ON/OFF setting */ |
| 15 | MB_OPT_RANGE, /* [min-max] setting */ |
| 16 | MB_OPT_CUSTOM, /* custom value */ |
| 17 | MB_OPT_CUSTONOFF, |
| 18 | MB_OPT_CUSTRANGE, |
| 19 | MB_OPT_ENUM, |
| 20 | } menu_behavior; |
| 21 | |
| 22 | typedef struct |
| 23 | { |
| 24 | const char *name; |
| 25 | menu_behavior beh; |
| 26 | int id; |
| 27 | void *var; /* for on-off/range settings */ |
| 28 | int mask; /* bit to toggle for on/off */ |
| 29 | signed short min; /* for ranged integer settings, to be sign-extended */ |
| 30 | signed short max; |
| 31 | unsigned int enabled:1; |
| 32 | unsigned int need_to_save:1; |
| 33 | unsigned int selectable:1; |
| 34 | int (*handler)(int id, int keys); |
| 35 | const char * (*generate_name)(int id, int *offs); |
| 36 | const void *data; |
| 37 | const char *help; |
| 38 | } menu_entry; |
| 39 | |
| 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 | |
| 43 | #define mee_handler_id(name, id, handler) \ |
| 44 | mee_handler_id_h(name, id, handler, NULL) |
| 45 | |
| 46 | #define mee_handler(name, handler) \ |
| 47 | mee_handler_id(name, MA_NONE, handler) |
| 48 | |
| 49 | #define mee_handler_h(name, handler, help) \ |
| 50 | mee_handler_id_h(name, MA_NONE, handler, help) |
| 51 | |
| 52 | #define mee_label(name) \ |
| 53 | { name, MB_NONE, MA_NONE, NULL, 0, 0, 0, 1, 0, 0, NULL, NULL, NULL, NULL } |
| 54 | |
| 55 | #define mee_label_mk(id, name_func) \ |
| 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 } |
| 60 | |
| 61 | #define mee_onoff(name, id, var, mask) \ |
| 62 | mee_onoff_h(name, id, var, mask, NULL) |
| 63 | |
| 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 | |
| 67 | #define mee_range(name, id, var, min, max) \ |
| 68 | mee_range_h(name, id, var, min, max, NULL) |
| 69 | |
| 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 | |
| 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) |
| 78 | |
| 79 | #define mee_cust(name, id, handler, name_func) \ |
| 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) |
| 84 | |
| 85 | #define mee_onoff_cust(name, id, var, mask, name_func) \ |
| 86 | { name, MB_OPT_CUSTONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, name_func, NULL, NULL } |
| 87 | |
| 88 | #define mee_range_cust(name, id, var, min, max, name_func) \ |
| 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) |
| 96 | |
| 97 | #define mee_end \ |
| 98 | { NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL } |
| 99 | |
| 100 | typedef struct |
| 101 | { |
| 102 | char *name; |
| 103 | int mask; |
| 104 | } me_bind_action; |
| 105 | |
| 106 | extern me_bind_action me_ctrl_actions[]; |
| 107 | extern me_bind_action emuctrl_actions[]; // platform code |
| 108 | |
| 109 | extern void *g_menubg_src_ptr; |
| 110 | extern void *g_menubg_ptr; |
| 111 | extern void *g_menuscreen_ptr; |
| 112 | #if MSCREEN_SIZE_FIXED |
| 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 |
| 119 | |
| 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 | |
| 124 | void menu_romload_prepare(const char *rom_name); |
| 125 | void menu_romload_end(void); |
| 126 | |
| 127 | void menu_loop(void); |
| 128 | int menu_loop_tray(void); |
| 129 | |
| 130 | menu_entry *me_list_get_first(void); |
| 131 | menu_entry *me_list_get_next(void); |
| 132 | |