int disable_open;
u32 page, /* current page index */
- page_depth;
+ page_depth,
+ controls_page_id;
+
+ ent_menuitem *ctr_kbm,
+ *ctr_deck,
+ *ctr_ps,
+ *ctr_steam,
+ *ctr_xbox;
enum menu_input_mode{
k_menu_input_mode_keys,
/*
* Attaches memory locations to the various items in the menu
*/
-static void menu_link(void)
-{
+static void menu_link(void){
/* link data locations */
for( u32 i=0; i<mdl_arrcount(&menu.items); i++ ){
ent_menuitem *item = mdl_arritm( &menu.items, i );
item->pvoid = NULL;
}
}
+
+ /* link controllers */
+ menu.ctr_deck = NULL;
+ menu.ctr_kbm = NULL;
+ menu.ctr_ps = NULL;
+ menu.ctr_steam = NULL;
+ menu.ctr_xbox = NULL;
+
+ for( u32 i=0; i<mdl_arrcount(&menu.items); i++ ){
+ ent_menuitem *item = mdl_arritm( &menu.items, i );
+
+ if( MDL_CONST_PSTREQ( &menu.model, item->visual.pstr_name, "deck" ) )
+ menu.ctr_deck = item;
+ if( MDL_CONST_PSTREQ( &menu.model, item->visual.pstr_name, "kbm" ) )
+ menu.ctr_kbm = item;
+ if( MDL_CONST_PSTREQ( &menu.model, item->visual.pstr_name, "ps" ) )
+ menu.ctr_ps = item;
+ if( MDL_CONST_PSTREQ( &menu.model, item->visual.pstr_name, "steam" ) )
+ menu.ctr_steam = item;
+ if( MDL_CONST_PSTREQ( &menu.model, item->visual.pstr_name, "xbox" ) )
+ menu.ctr_xbox = item;
+ }
}
static void menu_close(void){
/*
* Drop back a page until we're at the bottom which then we jus quit
*/
-static void menu_back_page(void)
-{
+static void menu_back_page(void){
vg_info( "menu_back_page()\n" );
menu.page_depth --;
if( menu.page_depth == 0 ){
/*
* Open page to the string identifier
*/
-static void menu_open_page( const char *name )
-{
+static void menu_open_page( const char *name ){
if( menu.page_depth >= MENU_STACK_SIZE )
vg_fatal_error( "Stack overflow\n" );
/*
* activate a pressable type
*/
-static void menu_trigger_item( ent_menuitem *item )
-{
+static void menu_trigger_item( ent_menuitem *item ){
if ( item->type == k_ent_menuitem_type_event_button ){
u32 q = item->button.pstr;
}
}
-static f32 menu_slider_snap( f32 value, f32 old, f32 notch )
-{
+static f32 menu_slider_snap( f32 value, f32 old, f32 notch ){
f32 const k_epsilon = 0.0125f;
if( fabsf(notch-value) < k_epsilon ){
return value;
}
+static void menu_setitem_type( ent_menuitem *item,
+ enum ent_menuitem_type type ){
+ if( !item ) return;
+ item->type = type;
+}
+
/*
* Run from vg_gui every frame
*/
}
}
}
+
+ menu_setitem_type( menu.ctr_deck, k_ent_menuitem_type_disabled );
+ menu_setitem_type( menu.ctr_ps, k_ent_menuitem_type_disabled );
+ menu_setitem_type( menu.ctr_kbm, k_ent_menuitem_type_disabled );
+ menu_setitem_type( menu.ctr_xbox, k_ent_menuitem_type_disabled );
+ menu_setitem_type( menu.ctr_steam, k_ent_menuitem_type_disabled );
+
+ if( vg_input.display_input_method == k_input_method_kbm )
+ menu_setitem_type( menu.ctr_kbm, k_ent_menuitem_type_visual );
+ else{
+ if( vg_input.display_input_type == SDL_CONTROLLER_TYPE_PS3 ||
+ vg_input.display_input_type == SDL_CONTROLLER_TYPE_PS4 ||
+ vg_input.display_input_type == SDL_CONTROLLER_TYPE_PS5 ){
+ menu_setitem_type( menu.ctr_ps, k_ent_menuitem_type_visual );
+ }
+ else {
+ menu_setitem_type( menu.ctr_xbox, k_ent_menuitem_type_visual );
+ }
+ /* FIXME: Steam/Deck controller detection? */
+ }
}
/*
screen = { 0,0, vg.window_x,vg.window_y };
ui_rect_center( screen, panel );
ui_fill( panel, ui_colour(k_ui_bg) );
- ui_outline( panel, 1, ui_colour(k_ui_fg) );
+ ui_outline( panel, 1, ui_colour(k_ui_fg), 0 );
ui_rect_pad( panel, (ui_px[]){8,8} );
ui_rect title;
for( u32 i=0; i<mdl_arrcount(&menu.items); i++ ){
ent_menuitem *item = mdl_arritm( &menu.items, i );
+ if( item->type == k_ent_menuitem_type_disabled ) continue;
if( item->type == k_ent_menuitem_type_page ) continue;
if( !(item->groups & (0x1 << menu.page)) ) continue;