-VG_STATIC int menu_get_loc( const char *loc )
-{
- for( int i=0; i<vg_list_size(menu_buttons); i++ )
- if( !strcmp( menu_buttons[i].name, loc ) )
- return i;
-
- assert(0);
- return 0;
-}
-
-VG_STATIC void menu_btn_reset( int event )
-{
- localplayer_cmd_respawn( 0, NULL );
- cl_menu_go_away = 1;
- game_menu.page = 0;
-}
-
-VG_STATIC void menu_btn_fuckoff( int event )
-{
- vg.window_should_close = 1;
-}
-
-VG_STATIC void menu_btn_quit( int event )
-{
- game_menu.page = k_menu_page_quit;
- game_menu.loc = menu_get_loc( "text_yes" );
-}
-
-VG_STATIC void menu_btn_settings( int event )
-{
- game_menu.page = k_menu_page_settings;
- game_menu.loc = menu_get_loc( "fov_slider" );
-}
-
-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_invert_y( int event )
-{
- cl_invert_y ^= 0x1;
-}
-
-VG_STATIC void menu_btn_map( int event )
-{
- game_menu.page = k_menu_page_map;
- game_menu.map_count = 0;
- game_menu.selected_map = 0;
-
- tinydir_dir dir;
- tinydir_open( &dir, "maps" );
-
- while( dir.has_next ){
- tinydir_file file;
- tinydir_readfile( &dir, &file );
-
- if( file.is_reg ){
- struct menu_map_file *mf = &game_menu.maps_list[ game_menu.map_count ];
-
- vg_strncpy( file.name, mf->name,
- vg_list_size(game_menu.maps_list[0].name),
- k_strncpy_always_add_null );
-
- game_menu.map_count ++;
- if( game_menu.map_count == vg_list_size(game_menu.maps_list) )
- break;
- }
-
- tinydir_next( &dir );
- }
-
- tinydir_close(&dir);
-}
-
-VG_STATIC void menu_crap_ui(void)
-{
-#if 0
- if( cl_menu && (game_menu.page == k_menu_page_map) ){
- ui_rect box;
- box[0] = vg.window_x/2 - 150;
- box[1] = vg.window_y/2 - 300;
- box[2] = 300;
- box[3] = 600;
-
- ui_fill_rect( box, 0xa0000000 );
-
- if( game_menu.map_count == 0 ){
- ui_text( (ui_rect){ vg.window_x/2, box[1]+8, 0,0 }, "No maps found", 1,
- k_text_align_center );
- }
- else{
- ui_rect_pad( box, 4 );
- box[3] = 16;
-
- for( int i=0; i<game_menu.map_count; i++ ){
- struct menu_map_file *mf = &game_menu.maps_list[ i ];
-
- ui_fill_rect( box, game_menu.selected_map == i? 0xa0ffffff:
- 0xa0808080 );
- ui_text( (ui_rect){ vg.window_x/2, box[1]+2, 0,0 },
- mf->name, 1, k_text_align_center );
- box[1] += 16+4;
- }
- }
- }
-#endif
-}
-
-VG_STATIC void steam_on_game_overlay( CallbackMsg_t *msg )
-{
- GameOverlayActivated_t *inf = (GameOverlayActivated_t *)msg->m_pubParam;
- vg_info( "Steam game overlay activated; pausing\n" );
-
- if( inf->m_bActive ){
- cl_menu = 1;
- game_menu.page = k_menu_page_main;
- game_menu.loc = menu_get_loc( "text_skater" );
- }
-}
-
-VG_STATIC void menu_init(void)
-{
-#if 0
- vg_apply_bind_str( &input_menu_h, "", "gp-ls-h" );
- vg_apply_bind_str( &input_menu_h, "+", "right" );
- vg_apply_bind_str( &input_menu_h, "-", "left" );
- vg_apply_bind_str( &input_menu_v, "", "-gp-ls-v" );
- vg_apply_bind_str( &input_menu_v, "+", "up" );
- vg_apply_bind_str( &input_menu_v, "-", "down" );
- vg_apply_bind_str( &input_menu_press, "", "gp-a" );
- vg_apply_bind_str( &input_menu_press, "", "\2enter" );
- vg_apply_bind_str( &input_menu_back, "", "gp-b" );
- vg_apply_bind_str( &input_menu_back, "", "\2escape" );
- vg_apply_bind_str( &input_menu_toggle_kbm, "", "\2escape" );
- vg_apply_bind_str( &input_menu_toggle, "", "\2gp-menu" );
-#endif
-
- vg_linear_clear( vg_mem.scratch );
-
- mdl_open( &menu_model, "models/rs_menu.mdl", vg_mem.rtmemory );
- mdl_load_metadata_block( &menu_model, vg_mem.rtmemory );
- mdl_load_array( &menu_model, &menu_markers, "ent_marker", vg_mem.rtmemory );
- //mdl_invert_uv_coordinates( &menu_model );
- mdl_async_load_glmesh( &menu_model, &menu_glmesh );
- mdl_close( &menu_model );
-
- vg_tex2d_load_qoi_async_file( "textures/menu.qoi",
- VG_TEX2D_CLAMP|VG_TEX2D_NEAREST,
- &tex_menu );
-
-
- for( int i=0; i<vg_list_size(menu_buttons); i++ ){
- struct menu_button *btn = &menu_buttons[i];
- btn->mesh = mdl_find_mesh( &menu_model, btn->name );
-
- if( !btn->mesh ){
- vg_info( "info: %s\n", btn->name );
- vg_fatal_error( "Menu programming error" );
- }
- }
-
- menu_mark_fov_max =
- ent_find_marker( &menu_model, &menu_markers, "fov_slider_max" );
- menu_mark_fov_min =
- ent_find_marker( &menu_model, &menu_markers, "fov_slider_min" );
- menu_mark_vol_max =
- ent_find_marker( &menu_model, &menu_markers, "vol_slider_max" );
- menu_mark_vol_min =
- ent_find_marker( &menu_model, &menu_markers, "vol_slider_min" );
- menu_mark_res_max =
- ent_find_marker( &menu_model, &menu_markers, "res_slider_max" );
- menu_mark_res_min =
- ent_find_marker( &menu_model, &menu_markers, "res_slider_min" );
-
- menu_mesh_fov_slider = mdl_find_mesh( &menu_model, "fov_slider" );
- menu_mesh_vol_slider = mdl_find_mesh( &menu_model, "vol_slider" );
- menu_mesh_res_slider = mdl_find_mesh( &menu_model, "res_slider" );
-
- shader_model_menu_register();
-
-#ifdef SR_NETWORKED
- steam_register_callback( k_iGameOverlayActivated, steam_on_game_overlay );
-#endif
-}
-
-VG_STATIC void menu_run_directional(void)
-{
-#if 0
- struct menu_button *btn = &menu_buttons[ game_menu.loc ];
-
- if( vg_input_button_down( &input_menu_press ) ){
- if( btn->fn_press ){
- audio_lock();
- audio_oneshot( &audio_ui[0], 1.0f, 0.0f );
- audio_unlock();
-
- btn->fn_press( 1 );
- return;
- }
- }
-
- if( menu_input_cooldown <= 0.0f ){
- v2f dir = { input_menu_h.axis.value,
- -input_menu_v.axis.value };
-
- if( v2_length2( dir ) > 0.8f*0.8f ){
- const char *link = NULL;
-
- if( fabsf(dir[0]) > fabsf(dir[1]) ){
- if( dir[0] > 0.0f ) link = btn->lr;
- else link = btn->ll;
- }
- else{
- if( dir[1] > 0.0f ) link = btn->ld;
- else link = btn->lu;
- }
-
- if( link ){
- game_menu.loc = menu_get_loc( link );
- menu_input_cooldown = 0.25f;
- }
- }
- }
-#endif
-}
-
-VG_STATIC int menu_page_should_backout(void)
-{
- return 0;
-#if 0
- return vg_input_button_down( &input_menu_back );
-#endif
-}
-
-VG_STATIC void menu_close(void)
-{
- cl_menu_go_away = 1;
- game_menu.page = 0;
- game_menu.loc = menu_get_loc( "text_skater" );
-}
-
-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() ){
- game_menu.page = k_menu_page_main;
- game_menu.loc = menu_get_loc( "text_map" );
- }
-
- if( game_menu.map_count > 0 ){
-#if 0
- float v = input_menu_v.axis.value;
- if( (fabsf(v) > 0.7f) && (menu_input_cooldown <= 0.0f) ){
- audio_lock();
- audio_oneshot( &audio_rewind[4], 1.0f, 0.0f );
- audio_unlock();
-
- if( v > 0.0f ){
- game_menu.selected_map --;
-
- if( game_menu.selected_map < 0 )
- game_menu.selected_map = game_menu.map_count-1;
-
- menu_input_cooldown = 0.25f;
- }
- else{
- game_menu.selected_map ++;
-
- if( game_menu.selected_map >= game_menu.map_count )
- game_menu.selected_map = 0;
-
- menu_input_cooldown = 0.25f;
- }
- }
-
- if( vg_input_button_down( &input_menu_press ) ){
-#if 0
- /* load map */
- char temp[256];
- strcpy( temp, "maps/" );
- strcat( temp, game_menu.maps_list[game_menu.selected_map].name );
-
- world_change_world( 1, (const char *[]){ temp } );
- menu_close();
-#endif
- }
-#endif
- }
-
- menu_fov_target = 80.0f;
-}
-
-VG_STATIC void menu_page_quit(void)
-{
- if( menu_page_should_backout() ){
- game_menu.page = k_menu_page_main;
- game_menu.loc = menu_get_loc( "text_quit" );
- }
-
- menu_fov_target = 90.0f;
- menu_run_directional();
-}
-
-void temp_update_playermodel(void);
-VG_STATIC void menu_page_skater(void)
-{
-#if 0
- float h = input_menu_h.axis.value;
- menu_fov_target = 97.0f;
-
- if( menu_page_should_backout() ){
- game_menu.page = k_menu_page_main;
- game_menu.loc = menu_get_loc( "text_skater" );
- return;
- }
-
- if( (fabsf(h) > 0.7f) && (menu_input_cooldown <= 0.0f) ){
- audio_lock();
- audio_oneshot( &audio_rewind[4], 1.0f, 0.0f );
- audio_unlock();
-
- vg_info( "%f\n", h );
-
- if( h < 0.0f ){
- cl_playermdl_id --;
- if( cl_playermdl_id < 0 )
- cl_playermdl_id = 2;
-
- int li = menu_get_loc( "skater_left" );
-
- menu_buttons[li].fsize = 0.4f;
- menu_buttons[li].falpha = 1.0f;
-
- menu_input_cooldown = 0.25f;
- }
- else{
- cl_playermdl_id ++;
- if( cl_playermdl_id > 2 )
- cl_playermdl_id = 0;
-
- int ri = menu_get_loc( "skater_right" );
-
- menu_buttons[ri].fsize = 0.4f;
- menu_buttons[ri].falpha = 1.0f;
-
- menu_input_cooldown = 0.25f;
- }
-
- temp_update_playermodel();
- }
-#endif
-}
-
-VG_STATIC void menu_slider( float *value, int set_value,
- mdl_mesh *slider, v3f co_min, v3f co_max )
-{
-#if 0
- if( set_value ){
- float h = input_menu_h.axis.value;
- if( fabsf(h) > 0.04f )
- *value += h * vg.time_frame_delta;
- *value = vg_clampf( *value, 0.0f, 1.0f );
- }
-
- v3_lerp( co_min, co_max, *value, slider->transform.co );
-#endif
-}
-
-VG_STATIC void menu_page_settings(void)
-{
- menu_run_directional();
-
- int fov_select = game_menu.loc == menu_get_loc( "fov_slider" );
- menu_slider( &cl_fov, fov_select,
- menu_mesh_fov_slider, menu_mark_fov_min->transform.co,
- menu_mark_fov_max->transform.co );
-
- if( fov_select )
- menu_fov_target = vg_lerpf( 97.0f, 135.0f, cl_fov ) * 0.8f;
-
- menu_slider( &vg_audio.external_global_volume,
- (game_menu.loc == menu_get_loc( "vol_slider" )),
- menu_mesh_vol_slider, menu_mark_vol_min->transform.co,
- menu_mark_vol_max->transform.co );
-
- menu_slider( &gpipeline.view_render_scale,
- (game_menu.loc == menu_get_loc( "res_slider" )),
- menu_mesh_res_slider, menu_mark_res_min->transform.co,
- menu_mark_res_max->transform.co );
-
- if( menu_page_should_backout() ){
- game_menu.page = k_menu_page_main;
- game_menu.loc = menu_get_loc( "text_settings" );
- return;
- }
-}
-
-VG_STATIC void menu_update(void)