projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
some refactors before the storm
[carveJwlIkooP6JGAAIwe30JlM.git]
/
menu.h
diff --git
a/menu.h
b/menu.h
index 737c849e4b892c53e532694ba422259d26010684..ca7cec188289979a340f960bffe58bab16525cb6 100644
(file)
--- a/
menu.h
+++ b/
menu.h
@@
-9,7
+9,7
@@
#include "audio.h"
#include "input.h"
#include "workshop.h"
#include "audio.h"
#include "input.h"
#include "workshop.h"
-#include "
respawn
.h"
+#include "
world_map
.h"
#include "gui.h"
#include "ent_miniworld.h"
#include "gui.h"
#include "ent_miniworld.h"
@@
-49,7
+49,7
@@
struct {
camera view;
mdl_context model;
camera view;
mdl_context model;
- GLuint
texture
;
+ GLuint
*textures
;
glmesh mesh;
mdl_array_ptr items, markers, cameras;
glmesh mesh;
mdl_array_ptr items, markers, cameras;
@@
-145,19
+145,23
@@
static void menu_init(void){
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.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, NULL );
- 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();
mdl_close( &menu.model );
shader_model_menu_register();
@@
-186,6
+190,7
@@
static void menu_back_page(void){
*/
static void menu_open_page( const char *name,
enum ent_menuitem_stack_behaviour stackmode ){
*/
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( stackmode == k_ent_menuitem_stack_append ){
if( menu.page_depth >= MENU_STACK_SIZE )
vg_fatal_error( "Stack overflow\n" );
@@
-245,15
+250,12
@@
static void menu_trigger_item( ent_menuitem *item ){
if( MDL_CONST_PSTREQ( &menu.model, q, "quit" ) ){
vg.window_should_close = 1;
}
if( MDL_CONST_PSTREQ( &menu.model, q, "quit" ) ){
vg.window_should_close = 1;
}
-
else if( MDL_CONST_PSTREQ( &menu.model, q, "map" ) ){
else if( MDL_CONST_PSTREQ( &menu.model, q, "map" ) ){
-
menu_close();
menu_close();
-
respawn_begin_choos
er();
+
world_map_ent
er();
}
else if( MDL_CONST_PSTREQ( &menu.model, q, "hub" ) ){
if( world_static.active_instance == k_world_purpose_client ){
}
else if( MDL_CONST_PSTREQ( &menu.model, q, "hub" ) ){
if( world_static.active_instance == k_world_purpose_client ){
- srinput.state = k_input_state_resume;
menu_close();
ent_miniworld_goback();
}
menu_close();
ent_miniworld_goback();
}
@@
-264,6
+266,14
@@
static void menu_trigger_item( ent_menuitem *item ){
else if( MDL_CONST_PSTREQ( &menu.model, q, "workshop" ) ){
workshop_submit_command(0,NULL);
}
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 ),
}
else if( item->type == k_ent_menuitem_type_page_button ){
menu_open_page( mdl_pstr( &menu.model, item->button.pstr ),
@@
-609,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, 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 );
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 );
@@
-659,8
+664,6
@@
static void menu_render(void){
shader_model_menu_use();
shader_model_menu_uTexMain( 1 );
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 );
shader_model_menu_uPv( menu.view.mtx.pv );
shader_model_menu_uPvmPrev( menu.view.mtx_prev.pv );
@@
-674,6
+677,8
@@
static void menu_render(void){
ent_menuitem *text_list[ 8 ];
u32 text_count = 0;
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 i=0; i<mdl_arrcount(&menu.items); i++ ){
ent_menuitem *item = mdl_arritm( &menu.items, i );
@@
-747,7
+752,18
@@
static void menu_render(void){
for( u32 j=0; j<item->submesh_count; j++ ){
u32 index = item->submesh_start + j;
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 );
}
}
}
}