+VG_STATIC int cl_menu = 0,
+ cl_menu_go_away = 0;
+
+VG_STATIC int menu_enabled(void){ return cl_menu; }
+
+VG_STATIC const char *playermodels[] = { "ch_new", "ch_jordan", "ch_outlaw" };
+
+vg_tex2d tex_menu = { .path = "textures/menu.qoi",.flags = VG_TEXTURE_NEAREST };
+
+VG_STATIC struct input_binding input_menu_h,
+ input_menu_v,
+ input_menu_press,
+ input_menu_back,
+ input_menu_toggle,
+ input_menu_toggle_kbm;
+
+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 );
+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_vol_slider,
+ *menu_pnode_vol_min,
+ *menu_pnode_vol_max;
+
+struct
+{
+ /* state */
+ int loc;
+ u32 page;
+
+ /* map browser */
+ struct menu_map_file
+ {
+ char name[ 64 ];
+ }
+ maps_list[ 16 ];
+
+ int selected_map,
+ map_count;
+}
+VG_STATIC game_menu;
+
+enum menu_page
+{
+ k_menu_page_main = 0x1,
+ k_menu_page_skater = 0x2,
+ k_menu_page_quit = 0x4,
+ k_menu_page_settings = 0x8,
+ k_menu_page_map = 0x10
+};
+
+struct menu_btn_userdata
+{
+ 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( struct menu_btn_userdata ud )
+{
+ if( (game_menu.page & (k_menu_page_main|k_menu_page_settings))
+ && (ud.i == menu_display_controller) )
+ return 1;
+ return 0;
+}
+
+VG_STATIC int menu_controller_inf( struct menu_btn_userdata ud )
+{
+ if( (game_menu.page & k_menu_page_settings)
+ && (ud.i == menu_display_controller) )
+ return 1;
+ return 0;
+}
+
+struct menu_button
+{
+ const char *name;
+
+ int (*fn_visibility)( struct menu_btn_userdata ud );
+ struct menu_btn_userdata user;
+
+ void (*fn_press)( int event );
+
+ const char *ll,
+ *lu,
+ *lr,
+ *ld;
+
+ mdl_node *pnode;
+ float falpha, fsize;
+}
+VG_STATIC menu_buttons[] =
+{
+ {
+ "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, {.i=k_menu_page_quit}
+ },
+ {
+ "text_yes", menu_vis, {.i=k_menu_page_quit},
+ .fn_press = menu_btn_fuckoff
+ },
+{
+ "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, {.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, {.i=k_menu_page_main},
+ .fn_press = menu_btn_map,
+ .lr="text_reset"
+},
+{
+ "text_settings", menu_vis, {.i=k_menu_page_main|k_menu_page_settings},
+ .fn_press = menu_btn_settings,
+ .ll="text_reset"
+},
+{
+ "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"
+},
+{
+ "text_blur_check", menu_settings_if, {.ptr_generic=&cl_blur}
+},
+
+{ "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}
+},
+};
+
+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 )
+{
+ reset_player(0,NULL);
+ world_routes_clear();
+
+ 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 )