X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=menu.h;h=4f9e671304c89ce0ea04df8e4508f7058a4578f5;hb=c34dde859968ced3dc7e8dd7be29f676689813d3;hp=7a008468802d1775848fdf358c48ec8002db9a41;hpb=d6171f1c56789b2ca79efa3313fbbf74a13bda7a;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/menu.h b/menu.h index 7a00846..4f9e671 100644 --- a/menu.h +++ b/menu.h @@ -9,7 +9,6 @@ #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; @@ -30,7 +29,7 @@ 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; VG_STATIC struct input_binding input_menu_h, input_menu_v, @@ -110,7 +109,7 @@ VG_STATIC int menu_vis( struct menu_btn_userdata ud ) 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; } @@ -118,7 +117,7 @@ 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; } @@ -218,16 +217,16 @@ VG_STATIC menu_buttons[] = { "res_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}}, +{ "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}}, { "text_paused", menu_vis, {k_menu_page_main} }, @@ -243,10 +242,9 @@ VG_STATIC int menu_get_loc( const char *loc ) return 0; } -VG_STATIC int __respawn( int argc, const char *argv[] ); VG_STATIC void menu_btn_reset( int event ) { - __respawn(0,NULL); + localplayer_cmd_respawn( 0, NULL ); cl_menu_go_away = 1; game_menu.page = 0; } @@ -300,7 +298,8 @@ VG_STATIC void menu_btn_map( int event ) 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) ) @@ -383,17 +382,15 @@ VG_STATIC void menu_init(void) mdl_open( &menu_model, "models/rs_menu.mdl", vg_mem.rtmemory ); mdl_load_metadata_block( &menu_model, vg_mem.rtmemory ); - mdl_load_mesh_block( &menu_model, vg_mem.scratch ); 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; imesh ){ vg_info( "info: %s\n", btn->name ); - vg_fatal_exit_loop( "Menu programming error" ); + vg_fatal_error( "Menu programming error" ); } } @@ -605,7 +602,7 @@ VG_STATIC void menu_slider( float *value, int set_value, 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 ); } @@ -641,8 +638,6 @@ VG_STATIC void menu_page_settings(void) } } -player_instance *tmp_localplayer(void); - VG_STATIC void menu_update(void) { vg_input_update( 1, &input_menu_h ); @@ -651,6 +646,7 @@ VG_STATIC void menu_update(void) vg_input_update( 1, &input_menu_press ); vg_input_update( 1, &input_menu_toggle ); vg_input_update( 1, &input_menu_toggle_kbm ); + return; int toggle_gp = vg_input_button_down( &input_menu_toggle ), toggle_kb = vg_input_button_down( &input_menu_toggle_kbm ), @@ -688,7 +684,7 @@ VG_STATIC void menu_update(void) /* Base */ { - player_instance *player = tmp_localplayer(); + player_instance *player = &localplayer; struct player_avatar *av = player->playeravatar; v3f center_rough; @@ -732,7 +728,7 @@ VG_STATIC void menu_update(void) m3x3_mul( player->basis, menu_mdl_mtx, menu_mdl_mtx ); menu_smooth_fov = vg_lerpf( menu_smooth_fov, menu_fov_target, - vg.frame_delta * 8.2f ); + vg.time_frame_delta * 8.2f ); } /* Extra */ @@ -743,7 +739,7 @@ VG_STATIC void menu_update(void) 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 ); @@ -753,7 +749,7 @@ VG_STATIC void menu_update(void) 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 ){ @@ -764,7 +760,7 @@ VG_STATIC void menu_update(void) vg.time_rate = 1.0-(double)menu_opacity; if( cl_menu ){ - menu_input_cooldown -= vg.frame_delta; + menu_input_cooldown -= vg.time_frame_delta; } } @@ -797,7 +793,9 @@ VG_STATIC void menu_render_fg( camera *cam ) shader_model_menu_use(); shader_model_menu_uColour( (v4f){ 1.0f,1.0f,1.0f,1.0f} ); shader_model_menu_uTexMain( 1 ); - vg_tex2d_bind( &tex_menu, 1 ); + + glActiveTexture( GL_TEXTURE1 ); + glBindTexture( GL_TEXTURE_2D, tex_menu ); shader_model_menu_uPv( cam->mtx.pv ); shader_model_menu_uPvmPrev( cam->mtx_prev.pv ); @@ -810,8 +808,8 @@ VG_STATIC void menu_render_fg( camera *cam ) 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 * 7.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},