X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=menu.h;h=4f6564407990d6346ac91320bd051036dd836309;hb=8f83be5a31728cd6bf95020e729367cc44308763;hp=e52f3d7faa8265a34d37aea146ee7a55ea0085ca;hpb=e591be4b2ed26bbaaea79eff64e7b6070362a6ef;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/menu.h b/menu.h index e52f3d7..4f65644 100644 --- a/menu.h +++ b/menu.h @@ -36,6 +36,7 @@ VG_STATIC struct input_binding input_menu_h, VG_STATIC void menu_btn_quit( int event ); VG_STATIC void menu_btn_skater( int event ); +VG_STATIC void menu_btn_blur( int event ); VG_STATIC void menu_btn_fuckoff( int event ); VG_STATIC void menu_btn_reset( int event ); VG_STATIC void menu_btn_map( int event ); @@ -43,7 +44,10 @@ VG_STATIC void menu_btn_settings( int event ); VG_STATIC mdl_node *menu_pnode_fov_slider, *menu_pnode_fov_min, - *menu_pnode_fov_max; + *menu_pnode_fov_max, + *menu_pnode_vol_slider, + *menu_pnode_vol_min, + *menu_pnode_vol_max; struct { @@ -72,25 +76,43 @@ enum menu_page k_menu_page_map = 0x10 }; -VG_STATIC int menu_vis( int group_mask ) +struct menu_btn_userdata { - if( group_mask & game_menu.page ) + int i; + void *ptr_generic; +}; + +VG_STATIC int menu_settings_if( struct menu_btn_userdata ud ) +{ + if( game_menu.page & k_menu_page_settings ) + { + int *ptr = ud.ptr_generic; + return *ptr; + } + else + return 0; +} + +VG_STATIC int menu_vis( struct menu_btn_userdata ud ) +{ + if( ud.i & game_menu.page ) return 1; else return 0; } -VG_STATIC int menu_controller( int ctr ) +VG_STATIC int menu_controller( struct menu_btn_userdata ud ) { if( (game_menu.page & (k_menu_page_main|k_menu_page_settings)) - && (ctr == menu_display_controller) ) + && (ud.i == menu_display_controller) ) return 1; return 0; } -VG_STATIC int menu_controller_inf( int ctr ) +VG_STATIC int menu_controller_inf( struct menu_btn_userdata ud ) { - if( (game_menu.page & k_menu_page_settings) && (ctr == menu_display_controller) ) + if( (game_menu.page & k_menu_page_settings) + && (ud.i == menu_display_controller) ) return 1; return 0; } @@ -99,8 +121,8 @@ struct menu_button { const char *name; - int (*fn_visibility)( int user ); - int user; + int (*fn_visibility)( struct menu_btn_userdata ud ); + struct menu_btn_userdata user; void (*fn_press)( int event ); @@ -114,60 +136,78 @@ struct menu_button } VG_STATIC menu_buttons[] = { -{ - "text_quit", menu_vis, k_menu_page_main|k_menu_page_quit, - .fn_press = menu_btn_quit, - .ld="text_reset", .lr="text_settings", .ll="text_map" -}, + { + "text_quit", menu_vis, {.i=k_menu_page_main|k_menu_page_quit}, + .fn_press = menu_btn_quit, + .ld="text_reset", .lr="text_settings", .ll="text_map" + }, { - "text_quitty", menu_vis, k_menu_page_quit + "text_quitty", menu_vis, {.i=k_menu_page_quit} }, { - "text_yes", menu_vis, k_menu_page_quit, + "text_yes", menu_vis, {.i=k_menu_page_quit}, .fn_press = menu_btn_fuckoff }, { - "text_reset", menu_vis, k_menu_page_main, + "text_reset", menu_vis, {.i=k_menu_page_main}, .fn_press = menu_btn_reset, .lu="text_quit", .ld="text_skater", .ll="text_map", .lr="text_settings" }, { - "text_skater", menu_vis, k_menu_page_main|k_menu_page_skater, + "text_skater", menu_vis, {.i=k_menu_page_main|k_menu_page_skater}, .fn_press = menu_btn_skater, .lu="text_reset", .ll="text_map", .lr="text_settings" }, { - "text_map", menu_vis, k_menu_page_main, + "text_map", menu_vis, {.i=k_menu_page_main}, .fn_press = menu_btn_map, - .lr="text_skater" + .lr="text_reset" }, { - "text_settings", menu_vis, k_menu_page_main|k_menu_page_settings, + "text_settings", menu_vis, {.i=k_menu_page_main|k_menu_page_settings}, .fn_press = menu_btn_settings, - .ll="text_skater" + .ll="text_reset" +}, +{ + "skater_left", menu_vis, {k_menu_page_skater} }, { - "skater_left", menu_vis, k_menu_page_skater + "skater_right", menu_vis, {k_menu_page_skater} +}, + +{ + "fov_slider", menu_vis, {k_menu_page_settings}, + .ld="text_blur" +}, +{ "fov_info", menu_vis, {k_menu_page_settings} }, + +{ + "vol_slider", menu_vis, {k_menu_page_settings}, + .lu="text_blur" +}, +{ "vol_info", menu_vis, {k_menu_page_settings} }, + +{ + "text_blur", menu_vis, {k_menu_page_settings}, + .fn_press = menu_btn_blur, + .lu="fov_slider", .ld="vol_slider" }, { - "skater_right", menu_vis, k_menu_page_skater + "text_blur_check", menu_settings_if, {.ptr_generic=&cl_blur} }, -{ "fov_slider", menu_vis, k_menu_page_settings }, -{ "fov_info", menu_vis, k_menu_page_settings }, - -{ "ctr_xbox", menu_controller_inf, k_menu_controller_type_xbox, }, -{ "ctr_xbox_text", menu_controller_inf, k_menu_controller_type_xbox }, -{ "ctr_steam", menu_controller_inf, k_menu_controller_type_steam }, -{ "ctr_steam_text", menu_controller_inf, k_menu_controller_type_steam }, -{ "ctr_deck", menu_controller_inf, k_menu_controller_type_steam_deck }, -{ "ctr_deck_text", menu_controller_inf, k_menu_controller_type_steam_deck }, -{ "ctr_ps", menu_controller_inf, k_menu_controller_type_playstation }, -{ "ctr_ps_text", menu_controller_inf, k_menu_controller_type_playstation }, -{ "ctr_kbm", menu_controller_inf, k_menu_controller_type_keyboard }, -{ "ctr_kbm_text", menu_controller_inf, k_menu_controller_type_keyboard }, -{ - "text_paused", menu_vis, k_menu_page_main +{ "ctr_xbox", menu_controller_inf, {k_menu_controller_type_xbox}}, +{ "ctr_xbox_text", menu_controller_inf, {k_menu_controller_type_xbox}}, +{ "ctr_steam", menu_controller_inf, {k_menu_controller_type_steam}}, +{ "ctr_steam_text", menu_controller_inf, {k_menu_controller_type_steam}}, +{ "ctr_deck", menu_controller_inf, {k_menu_controller_type_steam_deck}}, +{ "ctr_deck_text", menu_controller_inf, {k_menu_controller_type_steam_deck}}, +{ "ctr_ps", menu_controller_inf, {k_menu_controller_type_playstation}}, +{ "ctr_ps_text", menu_controller_inf, {k_menu_controller_type_playstation}}, +{ "ctr_kbm", menu_controller_inf, {k_menu_controller_type_keyboard}}, +{ "ctr_kbm_text", menu_controller_inf, {k_menu_controller_type_keyboard}}, +{ + "text_paused", menu_vis, {k_menu_page_main} }, }; @@ -212,6 +252,11 @@ VG_STATIC void menu_btn_skater( int event ) game_menu.page = k_menu_page_skater; } +VG_STATIC void menu_btn_blur( int event ) +{ + cl_blur ^= 0x1; +} + VG_STATIC void menu_btn_map( int event ) { game_menu.page = k_menu_page_map; @@ -336,12 +381,18 @@ VG_STATIC void menu_init(void) btn->pnode = mdl_node_from_name( &menu_model, btn->name ); if( !btn->pnode ) + { + vg_info( "info: %s\n", btn->name ); vg_fatal_exit_loop( "Menu programming error" ); + } } menu_pnode_fov_max = mdl_node_from_name( &menu_model, "fov_slider_max" ); menu_pnode_fov_min = mdl_node_from_name( &menu_model, "fov_slider_min" ); menu_pnode_fov_slider = mdl_node_from_name( &menu_model, "fov_slider" ); + menu_pnode_vol_max = mdl_node_from_name( &menu_model, "vol_slider_max" ); + menu_pnode_vol_min = mdl_node_from_name( &menu_model, "vol_slider_min" ); + menu_pnode_vol_slider = mdl_node_from_name( &menu_model, "vol_slider" ); shader_menu_register(); @@ -437,7 +488,7 @@ VG_STATIC void menu_page_map(void) audio_play_oneshot( &audio_rewind[4], 1.0f ); audio_unlock(); - if( v < 0.0f ) + if( v > 0.0f ) { game_menu.selected_map --; @@ -531,17 +582,36 @@ VG_STATIC void menu_page_skater(void) } } +VG_STATIC void menu_slider( float *value, int set_value, + mdl_node *slider, mdl_node *pmin, mdl_node *pmax ) +{ + if( set_value ) + { + float h = input_menu_h.axis.value; + if( fabsf(h) > 0.04f ) + *value += h * vg.frame_delta; + *value = vg_clampf( *value, 0.0f, 1.0f ); + } + + v3_lerp( pmin->co, pmax->co, *value, slider->co ); +} + VG_STATIC void menu_page_settings(void) { - float h = input_menu_h.axis.value; - if( fabsf(h) > 0.04f ) - g_fov_option += h * vg.frame_delta; - g_fov_option = vg_clampf( g_fov_option, 0.0f, 1.0f ); + menu_run_directional(); + + int fov_select = game_menu.loc == menu_get_loc( "fov_slider" ); + menu_slider( &cl_fov, fov_select, + menu_pnode_fov_slider, menu_pnode_fov_min, + menu_pnode_fov_max ); - v3_lerp( menu_pnode_fov_min->co, menu_pnode_fov_max->co, g_fov_option, - menu_pnode_fov_slider->co ); + if( fov_select ) + menu_fov_target = vg_lerpf( 97.0f, 135.0f, cl_fov ) * 0.8f; - menu_fov_target = vg_lerpf( 97.0f, 135.0f, g_fov_option ) * 0.8f; + menu_slider( &vg_audio.volume_console, + (game_menu.loc == menu_get_loc( "vol_slider" )), + menu_pnode_vol_slider, menu_pnode_vol_min, + menu_pnode_vol_max ); if( menu_page_should_backout() ) { @@ -655,12 +725,17 @@ VG_STATIC void menu_update(void) } /* Update camera */ +#if 0 { - camera_angles[0] = vg_alerpf( camera_angles[0], angles[0], menu_opacity ); - camera_angles[1] = vg_lerpf ( camera_angles[1], angles[1], menu_opacity ); - v3_lerp( camera_pos, pos, menu_opacity, camera_pos ); - camera_update(); + main_camera.angles[0] = + vg_alerpf( main_camera.angles[0], angles[0], menu_opacity ); + main_camera.angles[1] = + vg_lerpf ( main_camera.angles[1], angles[1], menu_opacity ); + v3_lerp( main_camera.pos, pos, menu_opacity, main_camera.pos ); + + camera_update_transform( &main_camera ); } +#endif float dt = vg.frame_delta * 6.0f; menu_opacity = vg_lerpf( menu_opacity, cl_menu&&!cl_menu_go_away, dt ); @@ -686,15 +761,15 @@ float expSustainedImpulse( float x, float f, float k ) return fminf( x*x/(f*f), 1.0f+(2.0f/f)*s*expf(-k*s)); } -VG_STATIC void menu_render( m4x4f projection ) +VG_STATIC void menu_render( camera *cam ) { glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glBlendEquation(GL_FUNC_ADD); - shader_fscolour_use(); - shader_fscolour_uColour( (v4f){ 0.1f, 0.1f, 0.3f, menu_opacity*0.5f } ); + shader_blitcolour_use(); + shader_blitcolour_uColour( (v4f){ 0.1f, 0.1f, 0.3f, menu_opacity*0.5f } ); render_fsquad(); glEnable( GL_DEPTH_TEST ); @@ -707,7 +782,8 @@ VG_STATIC void menu_render( m4x4f projection ) shader_menu_uTexMain( 1 ); vg_tex2d_bind( &tex_menu, 1 ); - shader_menu_uPv( projection ); + shader_menu_uPv( cam->mtx.pv ); + shader_menu_uPvmPrev( cam->mtx_prev.pv ); mesh_bind( &menu_glmesh ); for( int i=0; i