X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=menu.h;h=ca7cec188289979a340f960bffe58bab16525cb6;hb=53b534974303043efaf1d887711fcd349f6a2885;hp=c2a963e0071c2ae954ce028d302ba8c66100ab3a;hpb=2c91a71533b4ce86b9e7fd708420ae05c74d8f52;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/menu.h b/menu.h index c2a963e..ca7cec1 100644 --- a/menu.h +++ b/menu.h @@ -9,8 +9,9 @@ #include "audio.h" #include "input.h" #include "workshop.h" -#include "respawn.h" +#include "world_map.h" #include "gui.h" +#include "ent_miniworld.h" #define MENU_STACK_SIZE 8 @@ -48,7 +49,7 @@ struct { camera view; mdl_context model; - GLuint texture; + GLuint *textures; glmesh mesh; mdl_array_ptr items, markers, cameras; @@ -140,23 +141,27 @@ static void menu_init(void){ vg_linear_clear( vg_mem.scratch ); - mdl_load_array( &menu.model, &menu.items, "ent_menuitem", alloc ); - mdl_load_array( &menu.model, &menu.markers, "ent_marker", alloc ); - mdl_load_array( &menu.model, &menu.cameras, "ent_camera", alloc ); + MDL_LOAD_ARRAY( &menu.model, &menu.items, ent_menuitem, alloc ); + MDL_LOAD_ARRAY( &menu.model, &menu.markers, ent_marker, alloc ); + MDL_LOAD_ARRAY( &menu.model, &menu.cameras, ent_camera, alloc ); - vg_linear_clear( vg_mem.scratch ); + u32 count = mdl_arrcount( &menu.model.textures ); + menu.textures = vg_linear_alloc(alloc,vg_align8(sizeof(GLuint)*(count+1))); + menu.textures[0] = vg.tex_missing; - if( !mdl_arrcount( &menu.model.textures ) ) - vg_fatal_error( "No texture in menu file" ); + mdl_async_load_glmesh( &menu.model, &menu.mesh, NULL ); - mdl_texture *tex0 = mdl_arritm( &menu.model.textures, 0 ); - void *data = vg_linear_alloc( vg_mem.scratch, tex0->file.pack_size ); - mdl_fread_pack_file( &menu.model, &tex0->file, data ); + for( u32 i=0; ifile.pack_size, - VG_TEX2D_LINEAR|VG_TEX2D_CLAMP, - &menu.texture ); + mdl_texture *tex = mdl_arritm( &menu.model.textures, i ); + void *data = vg_linear_alloc( vg_mem.scratch, tex->file.pack_size ); + mdl_fread_pack_file( &menu.model, &tex->file, data ); + vg_tex2d_load_qoi_async( data, tex->file.pack_size, + VG_TEX2D_LINEAR|VG_TEX2D_CLAMP, + &menu.textures[i+1] ); + } mdl_close( &menu.model ); shader_model_menu_register(); @@ -185,6 +190,7 @@ static void menu_back_page(void){ */ static void menu_open_page( const char *name, enum ent_menuitem_stack_behaviour stackmode ){ + srinput.state = k_input_state_resume; if( stackmode == k_ent_menuitem_stack_append ){ if( menu.page_depth >= MENU_STACK_SIZE ) vg_fatal_error( "Stack overflow\n" ); @@ -244,18 +250,30 @@ static void menu_trigger_item( ent_menuitem *item ){ if( MDL_CONST_PSTREQ( &menu.model, q, "quit" ) ){ vg.window_should_close = 1; } - - else if( MDL_CONST_PSTREQ( &menu.model, q, "reset" ) ){ + else if( MDL_CONST_PSTREQ( &menu.model, q, "map" ) ){ menu_close(); - respawn_begin_chooser(); + world_map_enter(); + } + else if( MDL_CONST_PSTREQ( &menu.model, q, "hub" ) ){ + if( world_static.active_instance == k_world_purpose_client ){ + menu_close(); + ent_miniworld_goback(); + } } - else if( MDL_CONST_PSTREQ( &menu.model, q, "credits" ) ){ menu.credits_open = 1; } else if( MDL_CONST_PSTREQ( &menu.model, q, "workshop" ) ){ workshop_submit_command(0,NULL); } + else if( MDL_CONST_PSTREQ( &menu.model, q, "prem_store" ) ){ + if( steam_ready ) + SteamAPI_ISteamFriends_ActivateGameOverlayToStore( + SteamAPI_SteamFriends(), 2103940, k_EOverlayToStoreFlag_None); + } + else if( MDL_CONST_PSTREQ( &menu.model, q, "prem_nevermind" ) ){ + menu_close(); + } } else if( item->type == k_ent_menuitem_type_page_button ){ menu_open_page( mdl_pstr( &menu.model, item->button.pstr ), @@ -601,11 +619,6 @@ static void menu_render(void){ ui_split( panel, k_ui_axis_h, 28, 0, title, panel ); ui_text( title, "Mt.Zero Software", 1, k_ui_align_middle_center, 0 ); - ui_split( panel, k_ui_axis_h, 8, 0, title, panel ); - ui_split( panel, k_ui_axis_h, 28, 0, title, panel ); - ui_text( title, "A game by Harry Godden", 1, - k_ui_align_middle_center, 0 ); - ui_split( panel, k_ui_axis_h, 8, 0, title, panel ); ui_split( panel, k_ui_axis_h, 28*2, 0, title, panel ); ui_text( title, "Free Software", 2, k_ui_align_middle_center, 0 ); @@ -635,7 +648,7 @@ static void menu_render(void){ v3f v0; mdl_transform_vector( &menu.cam->transform, (v3f){0.0f,-1.0f,0.0f}, v0 ); - player_vector_angles( target.angles, v0, 1.0f, 0.0f ); + v3_angles( v0, target.angles ); camera_lerp( &menu.view, &target, rate, &menu.view ); @@ -651,8 +664,6 @@ static void menu_render(void){ shader_model_menu_use(); shader_model_menu_uTexMain( 1 ); - glActiveTexture( GL_TEXTURE1 ); - glBindTexture( GL_TEXTURE_2D, menu.texture ); shader_model_menu_uPv( menu.view.mtx.pv ); shader_model_menu_uPvmPrev( menu.view.mtx_prev.pv ); @@ -666,6 +677,8 @@ static void menu_render(void){ ent_menuitem *text_list[ 8 ]; u32 text_count = 0; + u32 current_tex = 0xffffffff; + for( u32 i=0; isubmesh_count; j++ ){ u32 index = item->submesh_start + j; - mdl_draw_submesh( mdl_arritm( &menu.model.submeshs, index )); + mdl_submesh *sm = mdl_arritm( &menu.model.submeshs, index ); + + mdl_material *mat = mdl_arritm( &menu.model.materials, + sm->material_id-1 ); + + if( mat->tex_diffuse != current_tex ){ + glActiveTexture( GL_TEXTURE1 ); + glBindTexture( GL_TEXTURE_2D, menu.textures[ mat->tex_diffuse ] ); + current_tex = mat->tex_diffuse; + } + + mdl_draw_submesh( sm ); } }