imgui stuff
[carveJwlIkooP6JGAAIwe30JlM.git] / menu.h
diff --git a/menu.h b/menu.h
index d8b686452f73015bb1d47e7844ed2eb55c5e38ab..6612494a8492a899c8733878b68d32a4599459ec 100644 (file)
--- a/menu.h
+++ b/menu.h
@@ -5,18 +5,22 @@
 #include "model.h"
 #include "world_render.h"
 #include "player.h"
+#include "conf.h"
 
-#include "shaders/menu.h"
+#include "shaders/model_menu.h"
 #include "vg_steam_friends.h"
-#include "submodules/tinydir/tinydir.h"
 
 VG_STATIC mdl_context menu_model;
+VG_STATIC mdl_array_ptr   menu_markers;
 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 float       menu_fov_target = 97.0f,
+                      menu_smooth_fov = 97.0f;
 VG_STATIC v2f         menu_extra_angles;
+VG_STATIC v3f         menu_camera_pos;
+VG_STATIC v2f         menu_camera_angles;
 
 VG_STATIC int         cl_menu         = 0,
                       cl_menu_go_away = 0;
@@ -25,14 +29,16 @@ 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 };
+GLuint tex_menu;
 
+#if 0
 VG_STATIC struct input_binding input_menu_h,
                                input_menu_v,
                                input_menu_press,
                                input_menu_back,
                                input_menu_toggle,
                                input_menu_toggle_kbm;
+#endif
 
 VG_STATIC void menu_btn_quit( int event );
 VG_STATIC void menu_btn_skater( int event );
@@ -41,23 +47,27 @@ 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 void menu_btn_invert_y( 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;
+VG_STATIC mdl_mesh *menu_mesh_fov_slider,
+                   *menu_mesh_vol_slider,
+                   *menu_mesh_res_slider;
 
-struct
-{
+VG_STATIC ent_marker
+                   *menu_mark_fov_min,
+                   *menu_mark_fov_max,
+                   *menu_mark_vol_min,
+                   *menu_mark_vol_max,
+                   *menu_mark_res_min,
+                   *menu_mark_res_max;
+
+struct{
    /* state */
    int loc;
    u32 page;
 
    /* map browser */
-   struct menu_map_file
-   {
+   struct menu_map_file{
       char name[ 64 ];
    }
    maps_list[ 16 ];
@@ -67,8 +77,7 @@ struct
 }
 VG_STATIC game_menu;
 
-enum menu_page
-{
+enum menu_page{
    k_menu_page_main     = 0x1,
    k_menu_page_skater   = 0x2,
    k_menu_page_quit     = 0x4,
@@ -76,16 +85,14 @@ enum menu_page
    k_menu_page_map      = 0x10
 };
 
-struct menu_btn_userdata
-{
+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 )
-   {
+   if( game_menu.page & k_menu_page_settings ){
       int *ptr = ud.ptr_generic;
       return *ptr;
    }
@@ -101,10 +108,11 @@ VG_STATIC int menu_vis( struct menu_btn_userdata ud )
       return 0;
 }
 
+#if 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) )
+         && (ud.i == steam_display_controller) )
       return 1;
    return 0;
 }
@@ -112,10 +120,11 @@ VG_STATIC int menu_controller( struct menu_btn_userdata ud )
 VG_STATIC int menu_controller_inf( struct menu_btn_userdata ud )
 {
    if( (game_menu.page & k_menu_page_settings) 
-        && (ud.i == menu_display_controller) )
+        && (ud.i == steam_display_controller) )
       return 1;
    return 0;
 }
+#endif
 
 struct menu_button
 {
@@ -131,7 +140,7 @@ struct menu_button
               *lr,
               *ld;
 
-   mdl_node *pnode;
+   mdl_mesh *mesh;
    float falpha, fsize;
 }
 VG_STATIC menu_buttons[] = 
@@ -139,7 +148,7 @@ 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"
+         .ld="text_reset", .lr="text_settings", /*.ll="text_map"*/
    },
    {
       "text_quitty", menu_vis, {.i=k_menu_page_quit}
@@ -151,18 +160,20 @@ VG_STATIC menu_buttons[] =
 {
    "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"
+      .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"
+      .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,
@@ -177,35 +188,51 @@ VG_STATIC menu_buttons[] =
 
 { 
    "fov_slider",     menu_vis, {k_menu_page_settings},
-   .ld="text_blur
+   .ld="text_invert_y
 },
 { "fov_info",        menu_vis, {k_menu_page_settings} },
 
 { 
    "vol_slider",     menu_vis, {k_menu_page_settings},
-   .lu="text_blur"
+   .lu="res_slider"
 },
 { "vol_info",        menu_vis, {k_menu_page_settings} },
 
+{
+   "text_invert_y",  menu_vis, {k_menu_page_settings},
+   .fn_press = menu_btn_invert_y,
+   .lu = "fov_slider", .ld="text_blur"
+},
+{
+   "text_invert_y_check", menu_settings_if, {.ptr_generic=&cl_invert_y}
+},
 { 
    "text_blur",      menu_vis, {k_menu_page_settings},
    .fn_press = menu_btn_blur, 
-   .lu="fov_slider", .ld="vol_slider"
+   .lu="text_invert_y", .ld="res_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}},
+{
+   "res_slider",     menu_vis, {k_menu_page_settings},
+   .ld = "vol_slider", .lu = "text_blur"
+},
+{
+   "res_info", menu_vis, {k_menu_page_settings},
+},
+#if 0
+{ "ctr_xbox",       menu_controller_inf, {k_steam_controller_type_xbox}},
+{ "ctr_xbox_text",  menu_controller_inf, {k_steam_controller_type_xbox}},
+{ "ctr_steam",      menu_controller_inf, {k_steam_controller_type_steam}},
+{ "ctr_steam_text", menu_controller_inf, {k_steam_controller_type_steam}},
+{ "ctr_deck",       menu_controller_inf, {k_steam_controller_type_steam_deck}},
+{ "ctr_deck_text",  menu_controller_inf, {k_steam_controller_type_steam_deck}},
+{ "ctr_ps",         menu_controller_inf, {k_steam_controller_type_playstation}},
+{ "ctr_ps_text",    menu_controller_inf, {k_steam_controller_type_playstation}},
+{ "ctr_kbm",        menu_controller_inf, {k_steam_controller_type_keyboard}},
+{ "ctr_kbm_text",   menu_controller_inf, {k_steam_controller_type_keyboard}},
+#endif
 {
    "text_paused", menu_vis, {k_menu_page_main} 
 },
@@ -223,9 +250,7 @@ VG_STATIC int menu_get_loc( const char *loc )
 
 VG_STATIC void menu_btn_reset( int event )
 {
-   reset_player(0,NULL);
-   world_routes_clear();
-
+   localplayer_cmd_respawn( 0, NULL );
    cl_menu_go_away = 1;
    game_menu.page = 0;
 }
@@ -257,6 +282,11 @@ 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;
@@ -266,17 +296,16 @@ VG_STATIC void menu_btn_map( int event )
    tinydir_dir dir;
    tinydir_open( &dir, "maps" );
 
-   while( dir.has_next )
-   {
+   while( dir.has_next ){
       tinydir_file file;
       tinydir_readfile( &dir, &file );
       
-      if( file.is_reg )
-      {
+      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 );
+                                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) )
@@ -291,8 +320,8 @@ VG_STATIC void menu_btn_map( int event )
 
 VG_STATIC void menu_crap_ui(void)
 {
-   if( cl_menu && (game_menu.page == k_menu_page_map) )
-   {
+#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;
@@ -301,18 +330,15 @@ VG_STATIC void menu_crap_ui(void)
 
       ui_fill_rect( box, 0xa0000000 );
 
-      if( game_menu.map_count == 0 )
-      {
+      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
-      {
+      else{
          ui_rect_pad( box, 4 );
          box[3] = 16;
 
-         for( int i=0; i<game_menu.map_count; i++ )
-         {
+         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:
@@ -323,6 +349,7 @@ VG_STATIC void menu_crap_ui(void)
          }
       }
    }
+#endif
 }
 
 VG_STATIC void steam_on_game_overlay( CallbackMsg_t *msg )
@@ -330,8 +357,7 @@ 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 )
-   {
+   if( inf->m_bActive ){
       cl_menu = 1;
       game_menu.page = k_menu_page_main;
       game_menu.loc = menu_get_loc( "text_skater" );
@@ -340,13 +366,7 @@ VG_STATIC void steam_on_game_overlay( CallbackMsg_t *msg )
 
 VG_STATIC void menu_init(void)
 {
-   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 );
-
+#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" );
@@ -359,42 +379,50 @@ VG_STATIC void menu_init(void)
    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" );
-   mdl_load_metadata( &menu_model, vg_mem.rtmemory );
-   mdl_load_mesh_data( &menu_model, vg_mem.scratch );
-   mdl_invert_uv_coordinates( &menu_model );
+   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_acquire_thread_sync();
-   {
-      mdl_unpack_glmesh( &menu_model, &menu_glmesh );
-      vg_tex2d_init( (vg_tex2d *[]){ &tex_menu }, 1 );
-   }
-   vg_release_thread_sync();
+   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++ )
-   {
+
+   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->mesh = mdl_find_mesh( &menu_model, btn->name );
 
-      if( !btn->pnode )
-      {
+      if( !btn->mesh ){
          vg_info( "info: %s\n", btn->name );
-         vg_fatal_exit_loop( "Menu programming error" );
+         vg_fatal_error( "Menu programming error" );
       }
    }
 
-   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" );
-   menu_pnode_vol_max = mdl_node_from_name( &menu_model, "vol_slider_max" );
-   menu_pnode_vol_min = mdl_node_from_name( &menu_model, "vol_slider_min" );
-   menu_pnode_vol_slider = mdl_node_from_name( &menu_model, "vol_slider" );
-
-   shader_menu_register();
+   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 );
@@ -403,14 +431,13 @@ VG_STATIC void menu_init(void)
 
 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 )
-      {
+   if( vg_input_button_down( &input_menu_press ) ){
+      if( btn->fn_press ){
          audio_lock();
-         audio_play_oneshot( &audio_ui[0], 1.0f );
+         audio_oneshot( &audio_ui[0], 1.0f, 0.0f );
          audio_unlock();
 
          btn->fn_press( 1 );
@@ -418,38 +445,37 @@ VG_STATIC void menu_run_directional(void)
       }
    }
 
-   if( menu_input_cooldown <= 0.0f )
-   {
+   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 )
-      {
+      if( v2_length2( dir ) > 0.8f*0.8f ){
          const char *link = NULL;
 
-         if( fabsf(dir[0]) > fabsf(dir[1]) )
-         {
+         if( fabsf(dir[0]) > fabsf(dir[1]) ){
             if( dir[0] > 0.0f ) link = btn->lr;
             else link = btn->ll;
          }
-         else
-         {
+         else{
             if( dir[1] > 0.0f ) link = btn->ld;
             else link = btn->lu;
          }
 
-         if( link )
-         {
+         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)
@@ -473,23 +499,20 @@ VG_STATIC void menu_page_main(void)
 
 VG_STATIC void menu_page_map(void)
 {
-   if( menu_page_should_backout() )
-   {
+   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( game_menu.map_count > 0 ){
+#if 0 
       float v = input_menu_v.axis.value;
-      if( (fabsf(v) > 0.7f) && (menu_input_cooldown <= 0.0f) )
-      {
+      if( (fabsf(v) > 0.7f) && (menu_input_cooldown <= 0.0f) ){
          audio_lock();
-         audio_play_oneshot( &audio_rewind[4], 1.0f );
+         audio_oneshot( &audio_rewind[4], 1.0f, 0.0f );
          audio_unlock();
 
-         if( v > 0.0f )
-         {
+         if( v > 0.0f ){
             game_menu.selected_map --;
 
             if( game_menu.selected_map < 0 )
@@ -497,8 +520,7 @@ VG_STATIC void menu_page_map(void)
 
             menu_input_cooldown = 0.25f;
          }
-         else
-         {
+         else{
             game_menu.selected_map ++;
 
             if( game_menu.selected_map >= game_menu.map_count )
@@ -508,8 +530,8 @@ VG_STATIC void menu_page_map(void)
          }
       }
 
-      if( vg_input_button_down( &input_menu_press ) )
-      {
+      if( vg_input_button_down( &input_menu_press ) ){
+#if 0
          /* load map */
          char temp[256];
          strcpy( temp, "maps/" );
@@ -517,7 +539,9 @@ VG_STATIC void menu_page_map(void)
 
          world_change_world( 1, (const char *[]){ temp } );
          menu_close();
+#endif
       }
+#endif
    }
 
    menu_fov_target = 80.0f;
@@ -525,8 +549,7 @@ VG_STATIC void menu_page_map(void)
 
 VG_STATIC void menu_page_quit(void)
 {
-   if( menu_page_should_backout() )
-   {
+   if( menu_page_should_backout() ){
       game_menu.page = k_menu_page_main;
       game_menu.loc = menu_get_loc( "text_quit" );
    }
@@ -535,26 +558,27 @@ VG_STATIC void menu_page_quit(void)
    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() )
-   {
+   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) )
-   {
+   if( (fabsf(h) > 0.7f) && (menu_input_cooldown <= 0.0f) ){
       audio_lock();
-      audio_play_oneshot( &audio_rewind[4], 1.0f );
+      audio_oneshot( &audio_rewind[4], 1.0f, 0.0f );
       audio_unlock();
 
-      if( h < 0.0f )
-      {
+      vg_info( "%f\n", h );
+
+      if( h < 0.0f ){
          cl_playermdl_id --;
          if( cl_playermdl_id < 0 )
             cl_playermdl_id = 2;
@@ -566,34 +590,37 @@ VG_STATIC void menu_page_skater(void)
 
          menu_input_cooldown = 0.25f;
       }
-      else
-      {
+      else{
          cl_playermdl_id ++;
          if( cl_playermdl_id > 2 )
             cl_playermdl_id = 0;
          
-         int ri = menu_get_loc( "skater_left" );
+         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_node *slider, mdl_node *pmin, mdl_node *pmax )
+                            mdl_mesh *slider, v3f co_min, v3f co_max )
 {
-   if( set_value )
-   {
+#if 0
+   if( set_value ){
       float h = input_menu_h.axis.value;
       if( fabsf(h) > 0.04f )
-         *value += h * vg.frame_delta;
+         *value += h * vg.time_frame_delta;
       *value = vg_clampf( *value, 0.0f, 1.0f );
    }
 
-   v3_lerp( pmin->co, pmax->co, *value, slider->co );
+   v3_lerp( co_min, co_max, *value, slider->transform.co );
+#endif
 }
 
 VG_STATIC void menu_page_settings(void)
@@ -602,19 +629,23 @@ VG_STATIC void menu_page_settings(void)
 
    int fov_select = game_menu.loc == menu_get_loc( "fov_slider" );
    menu_slider( &cl_fov, fov_select,
-                  menu_pnode_fov_slider, menu_pnode_fov_min,
-                  menu_pnode_fov_max );
+                  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.volume_console, 
+   menu_slider( &vg_audio.external_global_volume,
                   (game_menu.loc == menu_get_loc( "vol_slider" )),
-                  menu_pnode_vol_slider, menu_pnode_vol_min,
-                  menu_pnode_vol_max );
+                  menu_mesh_vol_slider, menu_mark_vol_min->transform.co,
+                  menu_mark_vol_max->transform.co );
 
-   if( menu_page_should_backout() )
-   {
+   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;
@@ -623,28 +654,29 @@ VG_STATIC void menu_page_settings(void)
 
 VG_STATIC void menu_update(void)
 {
+#if 0
    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 );
+#endif
+   return;
+
 
+#if 0
    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 )
-      {
-         if( toggle_gp )
-         {
+   if( toggle_gp || toggle_kb ){
+      if( cl_menu ){
+         if( toggle_gp ){
             menu_close();
          }
       }
-      else
-      {
+      else{
          if( toggle_kb )
             wait_for_a_sec = 1;
 
@@ -653,8 +685,7 @@ VG_STATIC void menu_update(void)
       }
    }
 
-   if( !wait_for_a_sec && cl_menu )
-   {
+   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 )
@@ -669,87 +700,87 @@ VG_STATIC void menu_update(void)
 
    struct menu_button *btn = &menu_buttons[ game_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 );
-
+      player_instance *player = &localplayer;
+      struct player_avatar *av = player->playeravatar;
+      
       v3f center_rough;
+      if( player->subsystem == k_player_subsystem_dead ){
+         m4x3_mulv( av->sk.final_mtx[av->id_hip], (v3f){0.0f,0.9f,0.0f},
+                    center_rough );
+      }
+      else{
+         m4x3_mulv( av->sk.final_mtx[av->id_head], (v3f){0.0f,1.5f,0.0f},
+                    center_rough );
+      }
 
-      if( player.is_dead )
-      {
-         v3_copy(player.mdl.ragdoll[ player.mdl.id_hip-1 ].rb.co, center_rough);
+      v3f cam_offset;
+      float cam_rot;
+      if( player->subsystem == k_player_subsystem_walk ){
+         v3_muls( player->rb.to_world[2],  1.0f, cam_offset );
+         cam_rot = 0.0f;
       }
-      else
-      {
-         v3_add( player.camera_pos, player.visual_transform[3], center_rough );
-         v3_muls( center_rough, 0.5f, center_rough );
+      else{
+         v3_muls( player->rb.to_world[0], -1.0f, cam_offset );
+         cam_rot = -VG_PIf*0.5f;
       }
 
-      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] );
+      v3f lookdir;
+      m3x3_mulv( player->invbasis, cam_offset, lookdir );
+      lookdir[1] = 0.0f;
+      v3_normalize( lookdir );
+
+      m3x3_mulv( player->basis, lookdir, cam_offset );
+      v3_muladds( center_rough, cam_offset, 2.0f, menu_camera_pos );
+
+      menu_camera_angles[1] = 0.0f;
+      menu_camera_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_axis_angle( qmenu_mdl, (v3f){0.0f,1.0f,0.0f}, -menu_camera_angles[0] );
       q_m3x3( qmenu_mdl, menu_mdl_mtx );
-      v3_copy( center_rough, menu_mdl_mtx[3] );
+      v3_add( center_rough, (v3f){0.0f,-0.5f,0.0f}, menu_mdl_mtx[3] );
+      m3x3_mul( player->basis, menu_mdl_mtx, menu_mdl_mtx );
+
+      menu_smooth_fov = vg_lerpf( menu_smooth_fov, menu_fov_target, 
+                                  vg.time_frame_delta * 8.2f );
    }
 
    /* Extra */
    {
       v3f delta;
-      v3_sub( btn->pnode->co, (v3f){ 0.0f,1.5f,-1.5f }, delta );
+      v3_sub( btn->mesh->transform.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;
+            dt = vg.time_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 */
-   {
-      main_camera.angles[0] = 
-         vg_alerpf( main_camera.angles[0], angles[0], menu_opacity );
-      main_camera.angles[1] = 
-         vg_lerpf ( main_camera.angles[1], angles[1], menu_opacity );
-      v3_lerp( main_camera.pos, pos, menu_opacity, main_camera.pos );
-
-      camera_update_transform( &main_camera );
+      v2_muladds( menu_camera_angles, menu_extra_angles, 0.8f, 
+                  menu_camera_angles );
+      menu_camera_angles[0] = fmodf( menu_camera_angles[0], VG_TAUf );
    }
 
-   float dt = vg.frame_delta * 6.0f;
+   float dt = vg.time_frame_delta * 6.0f;
    menu_opacity = vg_lerpf( menu_opacity, cl_menu&&!cl_menu_go_away, dt );
 
-   if( menu_opacity <= 0.01f )
-   {
+   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;
+   if( cl_menu ){
+      menu_input_cooldown -= vg.time_frame_delta;
    }
+#endif
 }
 
 /* https://iquilezles.org/articles/functions/ */
@@ -759,7 +790,7 @@ float expSustainedImpulse( float x, float f, float k )
     return fminf( x*x/(f*f), 1.0f+(2.0f/f)*s*expf(-k*s));
 }
 
-VG_STATIC void menu_render( camera *cam )
+VG_STATIC void menu_render_bg(void)
 {
    glEnable(GL_BLEND);
    glDisable(GL_DEPTH_TEST);
@@ -769,31 +800,35 @@ VG_STATIC void menu_render( camera *cam )
    shader_blitcolour_use();
    shader_blitcolour_uColour( (v4f){ 0.1f, 0.1f, 0.3f, menu_opacity*0.5f } );
    render_fsquad();
+}
 
+VG_STATIC void menu_render_fg( camera *cam )
+{
    glEnable( GL_DEPTH_TEST );
    glDisable( GL_BLEND );
 
    m4x3f mtx;
    
-   shader_menu_use();
-   shader_menu_uColour( (v4f){ 1.0f,1.0f,1.0f,1.0f} );
-   shader_menu_uTexMain( 1 );
-   vg_tex2d_bind( &tex_menu, 1 );
+   shader_model_menu_use();
+   shader_model_menu_uColour( (v4f){ 1.0f,1.0f,1.0f,1.0f} );
+   shader_model_menu_uTexMain( 1 );
+
+   glActiveTexture( GL_TEXTURE1 );
+   glBindTexture( GL_TEXTURE_2D, tex_menu );
 
-   shader_menu_uPv( cam->mtx.pv );
-   shader_menu_uPvmPrev( cam->mtx_prev.pv );
+   shader_model_menu_uPv( cam->mtx.pv );
+   shader_model_menu_uPvmPrev( cam->mtx_prev.pv );
    mesh_bind( &menu_glmesh );
 
-   for( int i=0; i<vg_list_size(menu_buttons); i++ )
-   {
+   for( int i=0; i<vg_list_size(menu_buttons); i++ ){
       struct menu_button *btn = &menu_buttons[i];
       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 );
-      btn->fsize  = vg_lerpf( btn->fsize,  tsize,  vg.frame_delta * 3.0f  );
+      btn->falpha = vg_lerpf( btn->falpha, talpha, vg.time_frame_delta * 14.0f);
+      btn->fsize  = vg_lerpf( btn->fsize,  tsize,  vg.time_frame_delta * 7.0f );
 
       /* Colour */
       v4f vselected = {0.95f*1.3f,0.45f*1.3f,0.095f*1.3f, 1.0f},
@@ -801,21 +836,20 @@ VG_STATIC void menu_render( camera *cam )
           vcurrent;
 
       v4_lerp( vnormal, vselected, btn->falpha, vcurrent );
-      shader_menu_uColour( vcurrent );
+      shader_model_menu_uColour( vcurrent );
 
       /* Create matrix */
       m4x3f mtx_size;
-      mdl_node_transform( btn->pnode, mtx );
+      mdl_transform_m4x3( &btn->mesh->transform, mtx );
       m4x3_mul( menu_mdl_mtx, mtx, mtx );
       m4x3_identity( mtx_size );
-      m4x3_scale( mtx_size, expSustainedImpulse( btn->fsize, 0.5f, 8.7f) );
+      m3x3_scalef( mtx_size, expSustainedImpulse( btn->fsize, 0.5f, 8.7f) );
       m4x3_mul( mtx, mtx_size, mtx );
-      shader_menu_uMdl( mtx );
+      shader_model_menu_uMdl( mtx );
 
-      for( int j=0; j<btn->pnode->submesh_count; j++ )
-      {
+      for( int j=0; j<btn->mesh->submesh_count; j++ ){
          mdl_submesh *sm = 
-            &menu_model.submesh_buffer[ btn->pnode->submesh_start+j ];
+            mdl_arritm( &menu_model.submeshs, btn->mesh->submesh_start+j );
          mdl_draw_submesh( sm );
       }
    }