fov slider input maps menu stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / menu.h
diff --git a/menu.h b/menu.h
index d83538e8f28134f54331662178d14b6229cf8bcc..2945449fff77fdadad516a5d5281009dee813354 100644 (file)
--- a/menu.h
+++ b/menu.h
 #include "player.h"
 
 #include "shaders/menu.h"
+#include "vg/vg_steam_friends.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 );
+#define CUTE_FILES_IMPLEMENTATION
+#include "vg/dep/randygaul/cute_files.h"
+
+VG_STATIC mdl_context menu_model;
+VG_STATIC glmesh      menu_glmesh;
+VG_STATIC m4x3f       menu_mdl_mtx;
+VG_STATIC float       menu_opacity = 0.0f;
+VG_STATIC float       menu_input_cooldown = 0.0f;
+VG_STATIC float       menu_fov_target = 97.0f;
+VG_STATIC v2f         menu_extra_angles;
+
+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_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;
+
+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
+};
+
+VG_STATIC int menu_vis( int group_mask )
+{
+   if( group_mask & game_menu.page )
+      return 1;
+   else
+      return 0;
+}
+
+VG_STATIC int menu_controller( int ctr )
+{
+   if( (game_menu.page & (k_menu_page_main|k_menu_page_settings)) 
+         && (ctr == menu_display_controller) )
+      return 1;
+   return 0;
+}
+
+VG_STATIC int menu_controller_inf( int ctr )
+{
+   if( (game_menu.page & k_menu_page_settings) && (ctr == menu_display_controller) )
+      return 1;
+   return 0;
+}
 
 struct menu_button
 {
    const char *name;
-   u32 areas;
 
-   void (*fn_press)(int event);
-   int links[4];
-   mdl_node *pnode;
+   int (*fn_visibility)( int user );
+   int   user;
+
+   void (*fn_press)( int event );
+
+   const char *ll,
+              *lu,
+              *lr,
+              *ld;
 
+   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 },
+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_quitty", menu_vis, k_menu_page_quit
+   },
+   {
+      "text_yes", menu_vis, k_menu_page_quit,
+         .fn_press = menu_btn_fuckoff
+   },
+{
+   "text_reset", menu_vis, 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, 
+   .fn_press = menu_btn_skater,
+      .lu="text_reset", .ll="text_map", .lr="text_settings"
+},
+{
+   "text_map", menu_vis, k_menu_page_main,
+   .fn_press = menu_btn_map,
+      .lr="text_skater"
+},
+{
+   "text_settings", menu_vis, k_menu_page_main|k_menu_page_settings,
+   .fn_press = menu_btn_settings,
+      .ll="text_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 },
+{ "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 
+},
 };
 
-static void menu_btn_map_a( int event ){}
-static void menu_btn_map_b( int event ){}
-static void menu_btn_map_c( int event ){}
+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;
 
-static void menu_btn_paused( int event )
+   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;
 }
 
-static void menu_btn_fuckoff( int event )
+VG_STATIC void menu_btn_fuckoff( int event )
 {
    glfwSetWindowShouldClose( vg.window, 1 );
 }
 
-static void menu_btn_quit( int event )
+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 )
 {
-   menu_page = 0x8;
-   menu_loc = 0xd;
+   game_menu.page = k_menu_page_skater;
 }
 
-static void menu_btn_map( int event )
+VG_STATIC void menu_btn_map( int event )
 {
-   menu_page = 0x4;
-   menu_loc = 7;
+   game_menu.page = k_menu_page_map;
+   game_menu.map_count = 0;
+   game_menu.selected_map = 0;
+
+   cf_dir_t dir;
+   cf_dir_open( &dir, "maps" );
+
+   while( dir.has_next )
+   {
+      cf_file_t file;
+      cf_read_file( &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)-1 );
+
+         game_menu.map_count ++;
+         if( game_menu.map_count == vg_list_size(game_menu.maps_list) )
+            break;
+      }
+
+      cf_dir_next( &dir );
+   }
+
+   cf_dir_close(&dir);
+}
+
+VG_STATIC void menu_crap_ui(void)
+{
+   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;
+         }
+      }
+   }
 }
 
-static void menu_btn_skater( int event )
+VG_STATIC void steam_on_game_overlay( CallbackMsg_t *msg )
 {
-   menu_page = 0x2;
+   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" );
+   }
 }
 
-static void menu_init(void)
+VG_STATIC void menu_init(void)
 {
-   menu_model = mdl_load( "models/rs_menu.mdl" );
+   vg_create_unnamed_input( &input_menu_h, k_input_type_axis );
+   vg_create_unnamed_input( &input_menu_v, k_input_type_axis );
+   vg_create_unnamed_input( &input_menu_back, k_input_type_button );
+   vg_create_unnamed_input( &input_menu_press, k_input_type_button );
+   vg_create_unnamed_input( &input_menu_toggle, k_input_type_button );
+   vg_create_unnamed_input( &input_menu_toggle_kbm, k_input_type_button );
+
+   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" );
+
+   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_invert_uv_coordinates( &menu_model );
+   mdl_close( &menu_model );
 
-   if( !menu_model )
-      vg_fatal_exit_loop( "No 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 );
+      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();
+   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" );
 
    shader_menu_register();
+
+#ifdef SR_NETWORKED
+   steam_register_callback( k_iGameOverlayActivated, steam_on_game_overlay );
+#endif
 }
 
-static void menu_run_directional(void)
+VG_STATIC void menu_run_directional(void)
 {
-   struct menu_button *btn = &menu_buttons[ menu_loc ];
+   struct menu_button *btn = &menu_buttons[ game_menu.loc ];
 
-   if( vg_get_button_down( "jump" ) )
+   if( vg_input_button_down( &input_menu_press ) )
    {
       if( btn->fn_press )
       {
+         audio_lock();
+         audio_play_oneshot( &audio_ui[0], 1.0f );
+         audio_unlock();
+
          btn->fn_press( 1 );
          return;
       }
@@ -141,47 +371,46 @@ static void menu_run_directional(void)
 
    if( menu_input_cooldown <= 0.0f )
    {
-      v2f dir = { vg_get_axis( "lookh" ), vg_get_axis( "lookv" ) };
+      v2f dir = {  input_menu_h.axis.value,
+                  -input_menu_v.axis.value };
 
       if( v2_length2( dir ) > 0.8f*0.8f )
       {
-         int idir = 0;
+         const char *link = NULL;
 
          if( fabsf(dir[0]) > fabsf(dir[1]) )
          {
-            if( dir[0] > 0.0f ) idir = 2;
-            else idir = 0;
+            if( dir[0] > 0.0f ) link = btn->lr;
+            else link = btn->ll;
          }
          else
          {
-            if( dir[1] > 0.0f ) idir = 3;
-            else idir = 1;
+            if( dir[1] > 0.0f ) link = btn->ld;
+            else link = btn->lu;
          }
 
-         int link = btn->links[idir];
-
-         if( link != -1 )
+         if( link )
          {
-            menu_loc_last = menu_loc;
-            menu_loc = link;
+            game_menu.loc = menu_get_loc( link );
             menu_input_cooldown = 0.25f;
          }
       }
    }
 }
 
-static int menu_page_should_backout(void)
+VG_STATIC int menu_page_should_backout(void)
 {
-   return vg_get_button_down( "break" );
+   return vg_input_button_down( &input_menu_back );
 }
 
-static void menu_close(void)
+VG_STATIC void menu_close(void)
 {
    cl_menu_go_away = 1;
-   menu_page = 0;
+   game_menu.page = 0;
+   game_menu.loc = menu_get_loc( "text_skater" );
 }
 
-static void menu_page_main(void)
+VG_STATIC void menu_page_main(void)
 {
    if( menu_page_should_backout() )
    {
@@ -193,55 +422,100 @@ static void menu_page_main(void)
    menu_run_directional();
 }
 
-static void menu_page_map(void)
+VG_STATIC void menu_page_map(void)
 {
    if( menu_page_should_backout() )
    {
-      menu_page = 1;
-      menu_loc = 3;
+      game_menu.page = k_menu_page_main;
+      game_menu.loc = menu_get_loc( "text_map" );
+   }
+
+   if( game_menu.map_count > 0 )
+   {
+      float v = input_menu_v.axis.value;
+      if( (fabsf(v) > 0.7f) && (menu_input_cooldown <= 0.0f) )
+      {
+         audio_lock();
+         audio_play_oneshot( &audio_rewind[4], 1.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 ) )
+      {
+         /* 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();
+      }
    }
 
    menu_fov_target = 80.0f;
-   menu_run_directional();
 }
 
-static void menu_page_quit(void)
+VG_STATIC void menu_page_quit(void)
 {
    if( menu_page_should_backout() )
    {
-      menu_page = 1;
-      menu_loc = 1;
+      game_menu.page = k_menu_page_main;
+      game_menu.loc = menu_get_loc( "text_quit" );
    }
 
    menu_fov_target = 90.0f;
    menu_run_directional();
 }
 
-static void menu_page_skater(void)
+VG_STATIC void menu_page_skater(void)
 {
-   float h = vg_get_axis( "lookh" );
+   float h = input_menu_h.axis.value;
    menu_fov_target = 97.0f;
 
    if( menu_page_should_backout() )
    {
-      menu_page = 1;
-      menu_loc = 2;
+      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_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;
+         int li = menu_get_loc( "skater_left" );
+
+         menu_buttons[li].fsize = 0.4f;
+         menu_buttons[li].falpha = 1.0f;
 
          menu_input_cooldown = 0.25f;
-         player_load_model( playermodels[ cl_playermdl_id ], 1 );
       }
       else
       {
@@ -249,41 +523,83 @@ static void menu_page_skater(void)
          if( cl_playermdl_id > 2 )
             cl_playermdl_id = 0;
          
-         menu_buttons[6].fsize = 0.4f;
-         menu_buttons[6].falpha = 1.0f;
+         int ri = menu_get_loc( "skater_left" );
+
+         menu_buttons[ri].fsize = 0.4f;
+         menu_buttons[ri].falpha = 1.0f;
 
          menu_input_cooldown = 0.25f;
-         player_load_model( playermodels[ cl_playermdl_id ], 1 );
       }
    }
 }
 
-static void menu_update(void)
+VG_STATIC void menu_page_settings(void)
 {
-   if( vg_get_button_down( "menu" ) )
+   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 );
+
+   v3_lerp( menu_pnode_fov_min->co, menu_pnode_fov_max->co, g_fov_option,
+            menu_pnode_fov_slider->co );
+
+   menu_fov_target = vg_lerpf( 97.0f, 135.0f, g_fov_option ) * 0.8f;
+
+   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)
+{
+   vg_input_update( 1, &input_menu_h );
+   vg_input_update( 1, &input_menu_v );
+   vg_input_update( 1, &input_menu_back );
+   vg_input_update( 1, &input_menu_press );
+   vg_input_update( 1, &input_menu_toggle );
+   vg_input_update( 1, &input_menu_toggle_kbm );
+
+   int toggle_gp = vg_input_button_down( &input_menu_toggle ),
+       toggle_kb = vg_input_button_down( &input_menu_toggle_kbm ),
+       wait_for_a_sec = 0;
+
+   if( toggle_gp || toggle_kb )
    {
       if( cl_menu )
       {
-         cl_menu_go_away = 1;
-         menu_page = 0;
+         if( toggle_gp )
+         {
+            menu_close();
+         }
       }
       else
       {
+         if( toggle_kb )
+            wait_for_a_sec = 1;
+
          cl_menu = 1;
-         menu_page = 1;
+         game_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();
+   if( !wait_for_a_sec && cl_menu )
+   {
+      if( game_menu.page == k_menu_page_main )
+         menu_page_main();
+      else if( game_menu.page == k_menu_page_skater )
+         menu_page_skater();
+      else if( game_menu.page == k_menu_page_quit )
+         menu_page_quit();
+      else if( game_menu.page == k_menu_page_settings )
+         menu_page_settings();
+      else if( game_menu.page == k_menu_page_map )
+         menu_page_map();
+   }
 
-   struct menu_button *btn = &menu_buttons[ menu_loc ];
+   struct menu_button *btn = &menu_buttons[ game_menu.loc ];
 
    v3f pos;
    v2f angles;
@@ -372,7 +688,7 @@ float expSustainedImpulse( float x, float f, float k )
     return fminf( x*x/(f*f), 1.0f+(2.0f/f)*s*expf(-k*s));
 }
 
-static void menu_render( m4x4f projection )
+VG_STATIC void menu_render( m4x4f projection )
 {
    glEnable(GL_BLEND);
    glDisable(GL_DEPTH_TEST);
@@ -391,7 +707,7 @@ static void menu_render( m4x4f projection )
    shader_menu_use();
    shader_menu_uColour( (v4f){ 1.0f,1.0f,1.0f,1.0f} );
    shader_menu_uTexMain( 1 );
-   vg_tex2d_bind( &tex_graffiti, 1 );
+   vg_tex2d_bind( &tex_menu, 1 );
 
    shader_menu_uPv( projection );
    mesh_bind( &menu_glmesh );
@@ -399,9 +715,9 @@ static void menu_render( m4x4f projection )
    for( int i=0; i<vg_list_size(menu_buttons); i++ )
    {
       struct menu_button *btn = &menu_buttons[i];
-      float talpha = i==menu_loc? 1.0f: 0.0f,
-            tsize0 = btn->areas & menu_page? 1.0f: 0.0f,
-            tsize1 = i==menu_loc? 0.07f: 0.0f,
+      float talpha = i==game_menu.loc? 1.0f: 0.0f,
+            tsize0 = btn->fn_visibility( btn->user )? 1.0f: 0.0f,
+            tsize1 = i==game_menu.loc? 0.07f: 0.0f,
             tsize  = tsize0+tsize1;
 
       btn->falpha = vg_lerpf( btn->falpha, talpha, vg.frame_delta * 14.0f );
@@ -427,7 +743,7 @@ static void menu_render( m4x4f projection )
       for( int j=0; j<btn->pnode->submesh_count; j++ )
       {
          mdl_submesh *sm = 
-            mdl_submesh_from_id( menu_model, btn->pnode->submesh_start+j );
+            &menu_model.submesh_buffer[ btn->pnode->submesh_start+j ];
          mdl_draw_submesh( sm );
       }
    }
@@ -452,9 +768,4 @@ static void menu_render( m4x4f projection )
    */
 }
 
-static void menu_free(void *_)
-{
-   mesh_free( &menu_glmesh );
-}
-
 #endif /* MENU_H */