X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=menu.c;h=ed69945eaebd64cb9ba8b8f85122fcec967a043e;hb=494c85703c76c4123c49937a32584840b6be1470;hp=b98f5d40e27ec991431890a7082d00f534b3d54e;hpb=5f6a4f9df6c8accc89f1920bfe9ace3cbac4c4b6;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/menu.c b/menu.c index b98f5d4..ed69945 100644 --- a/menu.c +++ b/menu.c @@ -11,7 +11,7 @@ #include "gui.h" #include "shaders/model_menu.h" -struct global_menu menu; +struct global_menu menu = { .skip_starter = 0 }; /* * Attaches memory locations to the various items in the menu @@ -124,6 +124,18 @@ void menu_init(void) } mdl_close( &menu.model ); + + vg_console_reg_var( "skip_starter_menu", &menu.skip_starter, + k_var_dtype_i32, VG_VAR_PERSISTENT ); +} + +void menu_at_begin(void) +{ + if( menu.skip_starter ) return; + + skaterift.activity = k_skaterift_menu; + menu.page = 0xffffffff; + menu_open_page( "Starter", k_ent_menuitem_stack_append ); } /* @@ -203,11 +215,18 @@ void menu_open_page( const char *name, /* * activate a pressable type */ -static void menu_trigger_item( ent_menuitem *item ){ - if ( item->type == k_ent_menuitem_type_event_button ){ +static void menu_trigger_item( ent_menuitem *item ) +{ + audio_lock(); + audio_oneshot( &audio_ui[0], 1.0f, 0.0f ); + audio_unlock(); + + if ( item->type == k_ent_menuitem_type_event_button ) + { u32 q = item->button.pstr; - if( MDL_CONST_PSTREQ( &menu.model, q, "quit" ) ){ + if( MDL_CONST_PSTREQ( &menu.model, q, "quit" ) ) + { vg.window_should_close = 1; } else if( MDL_CONST_PSTREQ( &menu.model, q, "map" ) ){ @@ -237,12 +256,21 @@ static void menu_trigger_item( ent_menuitem *item ){ else if( MDL_CONST_PSTREQ( &menu.model, q, "prem_nevermind" ) ){ menu_close(); } + else if( MDL_CONST_PSTREQ( &menu.model, q, "starter_enter" ) ) + { + if( network_client.auto_connect ) + network_client.user_intent = k_server_intent_online; + + menu_close(); + } } - else if( item->type == k_ent_menuitem_type_page_button ){ + else if( item->type == k_ent_menuitem_type_page_button ) + { menu_open_page( mdl_pstr( &menu.model, item->button.pstr ), item->button.stack_behaviour ); } - else if( item->type == k_ent_menuitem_type_toggle ){ + else if( item->type == k_ent_menuitem_type_toggle ) + { if( item->pi32 ){ *item->pi32 = *item->pi32 ^ 0x1; } @@ -276,20 +304,32 @@ static void menu_setitem_type( ent_menuitem *item, */ void menu_update(void) { + static f32 repeater = 0.0f; + if( repeater > 0.0f ) + repeater -= vg.time_frame_delta; + if( workshop_form.page != k_workshop_form_hidden ){ return; } - int escape = button_down( k_srbind_mback ); - if( menu.credits_open || vg.settings_open ){ - if( escape ){ + bool escape = 0; + + if( menu.credits_open || vg.settings_open ) + { + vg_exec_input_program( k_vg_input_type_button_u8, + input_button_list[k_srbind_mback], &escape ); + if( escape ) + { menu.credits_open = 0; if( vg.settings_open ) vg_settings_close(); + + srinput.state = k_input_state_resume; } return; } + escape = button_down( k_srbind_mback ); if( button_down( k_srbind_mopen ) ){ if( skaterift.activity == k_skaterift_default ){ @@ -447,7 +487,8 @@ void menu_update(void) menu_back_page(); } else if( menu.loc ){ - if( ui_click_down( UI_MOUSE_LEFT ) ){ + if( ui_click_down( UI_MOUSE_LEFT ) ) + { menu_trigger_item( menu.loc ); } } @@ -488,16 +529,21 @@ void menu_update(void) mh = 0; } - if( escape ){ + if( escape ) + { menu_back_page(); + audio_lock(); + audio_oneshot( &audio_ui[3], 1.0f, 0.0f ); + audio_unlock(); } - else if( enter ){ + else if( enter ) + { menu_trigger_item( menu.loc ); } else if( mh||mv ){ v3f opt; v3_zero( opt ); - f32 best = 0.707f; + f32 best = 0.5f; ent_menuitem *nextpos = NULL; opt[0] += mh; @@ -521,8 +567,13 @@ void menu_update(void) } } - if( nextpos ){ + if( nextpos && (repeater <= 0.0f) ) + { menu.loc = nextpos; + audio_lock(); + audio_oneshot( &audio_ui[3], 1.0f, 0.0f ); + audio_unlock(); + repeater += 0.1f; } } } @@ -648,7 +699,7 @@ void menu_render(void) ent_menuitem *text_list[ 8 ]; u32 text_count = 0; - u32 current_tex = 0xffffffff; + u32 current_mat = 0xffffffff; for( u32 i=0; isubmesh_count; j++ ){ + for( u32 j=0; jsubmesh_count; j++ ) + { u32 index = item->submesh_start + j; mdl_submesh *sm = mdl_arritm( &menu.model.submeshs, index ); - - mdl_material *mat = mdl_arritm( &menu.model.materials, - sm->material_id-1 ); - if( mat->tex_diffuse != current_tex ){ + if( sm->material_id != current_mat ) + { + mdl_material *mat = mdl_arritm( &menu.model.materials, + sm->material_id-1 ); glActiveTexture( GL_TEXTURE1 ); - glBindTexture( GL_TEXTURE_2D, menu.textures[ mat->tex_diffuse ] ); - current_tex = mat->tex_diffuse; + + if( mat->shader == k_shader_standard ) + { + struct shader_props_standard *props = mat->props.compiled; + + /* FIXME: why does menu have its own texture array?? */ + glBindTexture( GL_TEXTURE_2D, + menu.textures[ props->tex_diffuse ] ); + } + else + { + glBindTexture( GL_TEXTURE_2D, vg.tex_missing ); + } + + current_mat = sm->material_id; } mdl_draw_submesh( sm );