X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fcommon%2Fmenu.h;h=3f776039aa4d4441b371e44451df24b5bf46bb9d;hb=c6c6c9cde2d6ea12e8e38b75da02f8b0bb162766;hp=0227d52c942531a219ddb705ccc7ee68e5464f9e;hpb=1fb0dd88aa0c2a05a54f1f3aead0542521285f6c;p=picodrive.git diff --git a/platform/common/menu.h b/platform/common/menu.h index 0227d52..3f77603 100644 --- a/platform/common/menu.h +++ b/platform/common/menu.h @@ -1,21 +1,13 @@ -// (c) Copyright 2006-2008 notaz, All rights reserved. - - -void menu_init(void); -void text_out16(int x, int y, const char *texto, ...); -void smalltext_out16(int x, int y, const char *texto, int color); -void smalltext_out16_lim(int x, int y, const char *texto, int color, int max); -void menu_draw_selection(int x, int y, int w); -void debug_menu_loop(void); - -extern char menuErrorMsg[64]; +// (c) Copyright 2006-2009 notaz, All rights reserved. typedef enum { MB_NONE = 1, /* no auto processing */ MB_OPT_ONOFF, /* ON/OFF setting */ MB_OPT_RANGE, /* [min-max] setting */ - MB_OPT_CUSTOM, + MB_OPT_CUSTOM, /* custom value */ + MB_OPT_CUSTONOFF, + MB_OPT_CUSTRANGE, } menu_behavior; typedef enum @@ -97,6 +89,8 @@ typedef enum MA_CTRL_PLAYER2, MA_CTRL_EMU, MA_CTRL_TURBO_RATE, + MA_CTRL_DEV_FIRST, + MA_CTRL_DEV_NEXT, MA_CTRL_DONE, } menu_id; @@ -107,22 +101,47 @@ typedef struct menu_id id; void *var; /* for on-off/range settings */ int mask; /* bit to toggle for on/off */ - signed char min; /* for ranged integer settings, to be sign-extended */ - signed char max; - char enabled; - char need_to_save; - int (*submenu_handler)(menu_id id); - const char * (*generate_name)(int is_left); + signed short min; /* for ranged integer settings, to be sign-extended */ + signed short max; + int enabled:1; + int need_to_save:1; + int selectable:1; + int (*handler)(menu_id id, int keys); + const char * (*generate_name)(menu_id id, int *offs); } menu_entry; -#define mee_submenu_id(name, id, handler) \ - { name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, handler, NULL } +#define mee_handler_id(name, id, handler) \ + { name, MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, NULL } + +#define mee_handler(name, handler) \ + mee_handler_id(name, MA_NONE, handler) + +#define mee_handler_mkname_id(id, handler, name_func) \ + { "", MB_NONE, id, NULL, 0, 0, 0, 1, 0, 1, handler, name_func } + +#define mee_label(name) \ + { name, MB_NONE, MA_NONE, NULL, 0, 0, 0, 1, 0, 0, NULL, NULL } + +#define mee_label_mk(id, name_func) \ + { "", MB_NONE, id, NULL, 0, 0, 0, 1, 0, 0, NULL, name_func } -#define mee_submenu(name, handler) \ - mee_submenu_id(name, MA_NONE, handler) +#define mee_onoff(name, id, var, mask) \ + { name, MB_OPT_ONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, NULL } + +#define mee_range(name, id, var, min, max) \ + { name, MB_OPT_RANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, NULL } + +#define mee_cust(name, id, handler, name_func) \ + { name, MB_OPT_CUSTOM, id, NULL, 0, 0, 0, 1, 1, 1, handler, name_func } + +#define mee_onoff_cust(name, id, var, mask, name_func) \ + { name, MB_OPT_CUSTONOFF, id, &(var), mask, 0, 0, 1, 1, 1, NULL, name_func } + +#define mee_range_cust(name, id, var, min, max, name_func) \ + { name, MB_OPT_CUSTRANGE, id, &(var), 0, min, max, 1, 1, 1, NULL, name_func } #define mee_end \ - { NULL, 0, 0, NULL, 0, 0, 0, 0, 0, NULL, NULL } + { NULL, 0, 0, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL } typedef struct { @@ -133,18 +152,12 @@ typedef struct extern me_bind_action me_ctrl_actions[15]; extern me_bind_action emuctrl_actions[]; // platform code +void menu_init(void); +void text_out16(int x, int y, const char *texto, ...); +void me_update_msg(const char *msg); -typedef void (me_draw_custom_f)(const menu_entry *entry, int x, int y, void *param); - -/* TODO: move? */ -int me_id2offset(const menu_entry *entries, menu_id id); -void me_enable(menu_entry *entries, menu_id id, int enable); -int me_count_enabled(const menu_entry *ent); -menu_id me_index2id(const menu_entry *entries, int index); -void me_draw(const menu_entry *entries, int count, int x, int y, me_draw_custom_f *cust_draw, void *param); -int me_process(menu_entry *entries, menu_id id, int is_next); - -const char *me_region_name(unsigned int code, int auto_order); +menu_entry *me_list_get_first(void); +menu_entry *me_list_get_next(void); void menu_darken_bg(void *dst, int pixels, int darker);