#include "audio.h"
#include "input.h"
#include "workshop.h"
-#include "respawn.h"
+#include "world_map.h"
#include "gui.h"
#include "ent_miniworld.h"
camera view;
mdl_context model;
- GLuint texture;
+ GLuint *textures;
glmesh mesh;
mdl_array_ptr items, markers, cameras;
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; i<count; i ++ ){
+ vg_linear_clear( vg_mem.scratch );
+ menu.textures[i+1] = vg.tex_missing;
- mdl_async_load_glmesh( &menu.model, &menu.mesh );
- vg_tex2d_load_qoi_async( data, tex0->file.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();
*/
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" );
if( MDL_CONST_PSTREQ( &menu.model, q, "quit" ) ){
vg.window_should_close = 1;
}
-
- else if( MDL_CONST_PSTREQ( &menu.model, q, "reset" ) ){
-
- /* FIXME: Should only be availible in CLIENT WORLD */
-
+ else if( MDL_CONST_PSTREQ( &menu.model, q, "map" ) ){
menu_close();
- respawn_begin_chooser();
-
- /* FIXME: Need a back to hub button */
-#if 0
- srinput.state = k_input_state_resume;
- menu_close();
- ent_miniworld_goback();
-#endif
+ 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 ),
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 );
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 );
ent_menuitem *text_list[ 8 ];
u32 text_count = 0;
+ u32 current_tex = 0xffffffff;
+
for( u32 i=0; i<mdl_arrcount(&menu.items); i++ ){
ent_menuitem *item = mdl_arritm( &menu.items, i );
for( u32 j=0; j<item->submesh_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 );
}
}