-#include "shaders/menu.h"
-
-static mdl_header *menu_model;
-static glmesh menu_glmesh;
-static m4x3f menu_mdl_mtx;
-static float menu_opacity = 0.0f;
-static float menu_input_cooldown = 0.0f;
-static float menu_fov_target = 97.0f;
-static v2f menu_extra_angles;
-
-static int menu_loc = 1,
- menu_loc_last = 1;
-static u32 menu_page = 0;
-
-static int cl_menu = 0,
- cl_menu_go_away = 0;
-static int cl_playermdl_id = 0;
-
-static const char *playermodels[] = { "ch_new", "ch_jordan", "ch_outlaw" };
-
-static void menu_btn_paused( int event );
-static void menu_btn_quit( int event );
-static void menu_btn_skater( int event );
-static void menu_btn_map( int event );
-static void menu_btn_map_a( int event );
-static void menu_btn_map_b( int event );
-static void menu_btn_map_c( int event );
-static void menu_btn_fuckoff( int event );
-
-struct menu_button
-{
- const char *name;
- u32 areas;
-
- void (*fn_press)(int event);
- int links[4];
- mdl_node *pnode;
-
- float falpha, fsize;
-}
-static menu_buttons[] =
-{
-/*0*/{"text_paused", 1, menu_btn_paused },
-/*1*/{"text_quit", 9, menu_btn_quit, {3,-1,4,2}},
-/*2*/{"text_skater", 3, menu_btn_skater, {3,1,4,-1}},
-/*3*/{"text_map", 5, menu_btn_map, {-1,-1,2,-1}},
-/*4*/{"text_about_game", 1, NULL, {2,-1,-1,-1}},
-/*5*/{"skater_left", 2, NULL, {-1,-1,-1,-1}},
-/*6*/{"skater_right", 2, NULL, {-1,-1,-1,-1}},
-/*7*/{"map_a", 4, menu_btn_map_a,{8, -1, 9, 9 }},
-/*8*/{"map_b", 4, menu_btn_map_b,{-1,7,7,-1}},
-/*9*/{"map_c", 4, menu_btn_map_c,{7,7,-1,8}},
-/*a*/{"g_map", 5, NULL },
-/*b*/{"g_controls", 1, NULL },
-/*c*/{"text_quitty", 8, NULL },
-/*d*/{"text_yes", 8, menu_btn_fuckoff,{-1,-1,-1,-1} },
-};
-
-static void menu_btn_map_a( int event ){}
-static void menu_btn_map_b( int event ){}
-static void menu_btn_map_c( int event ){}
-
-static void menu_btn_paused( int event )
-{
-
-}
-
-static void menu_btn_fuckoff( int event )
-{
- glfwSetWindowShouldClose( vg.window, 1 );
-}
-
-static void menu_btn_quit( int event )
-{
- menu_page = 0x8;
- menu_loc = 0xd;
-}
-
-static void menu_btn_map( int event )
-{
- menu_page = 0x4;
- menu_loc = 7;
-}
-
-static void menu_btn_skater( int event )
-{
- menu_page = 0x2;
-}
-
-static void menu_init(void)
-{
- menu_model = mdl_load( "models/rs_menu.mdl" );
-
- if( !menu_model )
- vg_fatal_exit_loop( "No menu model" );
-
- 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" );
- }
-
- vg_convar_push( (struct vg_convar){
- .name = "cl_playermdl_id",
- .data = &cl_playermdl_id,
- .data_type = k_convar_dtype_i32,
- .opt_i32 = { .min=0, .max=2, .clamp=1 },
- .persistent = 1
- });
-
- vg_acquire_thread_sync();
- mdl_unpack_glmesh( menu_model, &menu_glmesh );
- vg_release_thread_sync();
-
- shader_menu_register();
-}
-
-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;
- }
- }
- }
-}
-
-static int menu_page_should_backout(void)
-{
- return vg_get_button_down( "break" );
-}
-
-static void menu_close(void)
-{
- cl_menu_go_away = 1;
- menu_page = 0;
-}
-
-static void menu_page_main(void)
-{
- if( menu_page_should_backout() )
- {
- menu_close();
- return;
- }
-
- menu_fov_target = 112.0f;
- menu_run_directional();
-}
-
-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();
-}
-
-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();
-}
-
-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) )
- {
- 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;
- player_load_model( playermodels[ cl_playermdl_id ], 1 );
- }
- 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;
- player_load_model( playermodels[ cl_playermdl_id ], 1 );
- }
- }
-}
-
-static void menu_update(void)