-VG_STATIC void menu_btn_map_a( int event ){}
-VG_STATIC void menu_btn_map_b( int event ){}
-VG_STATIC void menu_btn_map_c( int event ){}
-
-VG_STATIC void menu_btn_paused( int event )
-{
-
-}
-
-VG_STATIC void menu_btn_reset( int event )
-{
- reset_player(0,NULL);
- world_routes_clear();
-
- cl_menu_go_away = 1;
- menu_page = 0;
-}
-
-VG_STATIC void menu_btn_fuckoff( int event )
-{
- glfwSetWindowShouldClose( vg.window, 1 );
-}
-
-VG_STATIC void menu_btn_quit( int event )
-{
- menu_page = 0x8;
- menu_loc = 0xa;
-}
-
-VG_STATIC void menu_btn_map( int event )
-{
- menu_page = 0x4;
- menu_loc = 7;
-}
-
-VG_STATIC void menu_btn_skater( int event )
-{
- menu_page = 0x2;
-}
-
-VG_STATIC void menu_init(void)
-{
- vg_linear_clear( vg_mem.scratch );
-
- mdl_open( &menu_model, "models/rs_menu.mdl" );
- mdl_load_metadata( &menu_model, vg_mem.rtmemory );
- mdl_load_mesh_data( &menu_model, vg_mem.scratch );
- mdl_close( &menu_model );
-
- vg_acquire_thread_sync();
- {
- mdl_unpack_glmesh( &menu_model, &menu_glmesh );
- vg_tex2d_init( (vg_tex2d *[]){ &tex_menu }, 1 );
- }
- vg_release_thread_sync();
-
- for( int i=0; i<vg_list_size(menu_buttons); i++ )
- {
- struct menu_button *btn = &menu_buttons[i];
- btn->pnode = mdl_node_from_name( &menu_model, btn->name );
-
- if( !btn->pnode )
- vg_fatal_exit_loop( "Menu programming error" );
- }
-
- shader_menu_register();
-}
-
-VG_STATIC void menu_run_directional(void)
-{
- struct menu_button *btn = &menu_buttons[ menu_loc ];
-
- if( vg_get_button_down( "jump" ) )
- {
- if( btn->fn_press )
- {
- audio_lock();
- audio_play_oneshot( &audio_ui[0], 1.0f );
- audio_unlock();
-
- btn->fn_press( 1 );
- return;
- }
- }
-
- if( menu_input_cooldown <= 0.0f )
- {
- v2f dir = { vg_get_axis( "lookh" ), vg_get_axis( "lookv" ) };
-
- if( v2_length2( dir ) > 0.8f*0.8f )
- {
- int idir = 0;
-
- if( fabsf(dir[0]) > fabsf(dir[1]) )
- {
- if( dir[0] > 0.0f ) idir = 2;
- else idir = 0;
- }
- else
- {
- if( dir[1] > 0.0f ) idir = 3;
- else idir = 1;
- }
-
- int link = btn->links[idir];
-
- if( link != -1 )
- {
- menu_loc_last = menu_loc;
- menu_loc = link;
- menu_input_cooldown = 0.25f;
- }
- }
- }
-}
-
-VG_STATIC int menu_page_should_backout(void)
-{
- return vg_get_button_down( "break" );
-}
-
-VG_STATIC void menu_close(void)
-{
- cl_menu_go_away = 1;
- menu_page = 0;
-}
-
-VG_STATIC void menu_page_main(void)
-{
- if( menu_page_should_backout() )
- {
- menu_close();
- return;
- }
-
- menu_fov_target = 112.0f;
- menu_run_directional();
-}
-
-VG_STATIC void menu_page_map(void)
-{
- if( menu_page_should_backout() )
- {
- menu_page = 1;
- menu_loc = 3;
- }
-
- menu_fov_target = 80.0f;
- menu_run_directional();
-}
-
-VG_STATIC void menu_page_quit(void)
-{
- if( menu_page_should_backout() )
- {
- menu_page = 1;
- menu_loc = 1;
- }
-
- menu_fov_target = 90.0f;
- menu_run_directional();
-}
-
-VG_STATIC void menu_page_skater(void)
-{
- float h = vg_get_axis( "lookh" );
- menu_fov_target = 97.0f;
-
- if( menu_page_should_backout() )
- {
- menu_page = 1;
- menu_loc = 2;
- return;
- }
-
- if( (fabsf(h) > 0.7f) && (menu_input_cooldown <= 0.0f) )
- {
- audio_lock();
- audio_play_oneshot( &audio_rewind[4], 1.0f );
- audio_unlock();
-
- if( h < 0.0f )
- {
- cl_playermdl_id --;
- if( cl_playermdl_id < 0 )
- cl_playermdl_id = 2;
-
- menu_buttons[5].fsize = 0.4f;
- menu_buttons[5].falpha = 1.0f;
-
- menu_input_cooldown = 0.25f;
- }
- else
- {
- cl_playermdl_id ++;
- if( cl_playermdl_id > 2 )
- cl_playermdl_id = 0;
-
- menu_buttons[6].fsize = 0.4f;
- menu_buttons[6].falpha = 1.0f;
-
- menu_input_cooldown = 0.25f;
- }
- }
-}
-
-VG_STATIC void menu_update(void)
-{
- if( vg_get_button_down( "menu" ) )
- {
- if( cl_menu )
- {
- cl_menu_go_away = 1;
- menu_page = 0;
- }
- else
- {
- cl_menu = 1;
- menu_page = 1;
- }
- }
-
- if( menu_page == 1 )
- menu_page_main();
- else if( menu_page == 2 )
- menu_page_skater();
- else if( menu_page == 4 )
- menu_page_map();
- else if( menu_page == 8 )
- menu_page_quit();
-
- struct menu_button *btn = &menu_buttons[ menu_loc ];
-
- v3f pos;
- v2f angles;
-
- /* Base */
- {
- v3f lookdir;
- v3f *mtx = player.mdl.sk.final_mtx[player.mdl.id_head];
- m3x3_mulv( mtx, (v3f){-1.0f,0.0f,0.0f}, lookdir );
-
- lookdir[1] = 0.0f;
- v3_normalize( lookdir );
-
- v3f center_rough;
-
- if( player.is_dead )
- {
- v3_copy(player.mdl.ragdoll[ player.mdl.id_hip-1 ].rb.co, center_rough);
- }
- else
- {
- v3_add( player.camera_pos, player.visual_transform[3], center_rough );
- v3_muls( center_rough, 0.5f, center_rough );
- }
-
- v3_muladds( center_rough, lookdir, 1.5f, pos );
- v3_add( (v3f){ 0.0f,0.8f,0.0f}, pos, pos );
-
- angles[1] = 0.0f;
- angles[0] = -atan2f( lookdir[0], lookdir[2] );
-
- /* setup model matrix */
- v4f qmenu_mdl;
- q_axis_angle( qmenu_mdl, (v3f){0.0f,1.0f,0.0f}, -angles[0] );
-
- q_m3x3( qmenu_mdl, menu_mdl_mtx );
- v3_copy( center_rough, menu_mdl_mtx[3] );
- }
-
- /* Extra */
- {
- v3f delta;
- v3_sub( btn->pnode->co, (v3f){ 0.0f,1.5f,-1.5f }, delta );
- v3_normalize( delta );
-
- float y = atan2f( delta[0], delta[2] ),
- p = -sinf(delta[1]),
- dt = vg.frame_delta;
-
- menu_extra_angles[0] = vg_lerpf( menu_extra_angles[0], y, dt );
- menu_extra_angles[1] = vg_lerpf( menu_extra_angles[1], p, dt );
-
- v2_muladds( angles, menu_extra_angles, 0.8f, angles );
- angles[0] = fmodf( angles[0], VG_TAUf );
- }
-
- /* Update camera */
- {
- 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();
- }
-
- float dt = vg.frame_delta * 6.0f;
- menu_opacity = vg_lerpf( menu_opacity, cl_menu&&!cl_menu_go_away, dt );
-
- if( menu_opacity <= 0.01f )
- {
- cl_menu = 0;
- cl_menu_go_away = 0;
- }
-
- vg.time_rate = 1.0-(double)menu_opacity;
-
- if( cl_menu )
- {
- menu_input_cooldown -= vg.frame_delta;
- }
-}
-
-/* https://iquilezles.org/articles/functions/ */
-float expSustainedImpulse( float x, float f, float k )