8 #include "ent_miniworld.h"
12 #include "shaders/model_menu.h"
14 struct global_menu menu
= { .skip_starter
= 0 };
17 * Attaches memory locations to the various items in the menu
21 /* link data locations */
22 for( u32 i
=0; i
<mdl_arrcount(&menu
.items
); i
++ ){
23 ent_menuitem
*item
= mdl_arritm( &menu
.items
, i
);
25 if( item
->type
== k_ent_menuitem_type_toggle
||
26 item
->type
== k_ent_menuitem_type_slider
){
30 if( item
->type
== k_ent_menuitem_type_slider
)
31 name
= mdl_pstr( &menu
.model
, item
->slider
.pstr_data
);
33 name
= mdl_pstr( &menu
.model
, item
->checkmark
.pstr_data
);
34 vg_var
*var
= vg_console_match_var( name
);
37 if( ( item
->type
== k_ent_menuitem_type_slider
&&
38 var
->data_type
!= k_var_dtype_f32
40 ( item
->type
== k_ent_menuitem_type_toggle
&&!
41 ( var
->data_type
== k_var_dtype_i32
||
42 var
->data_type
== k_var_dtype_u32
46 vg_error( "Cannot hook to data %s(%p), because it is type %d.\n",
47 name
, var
, var
->data_type
);
51 item
->pvoid
= var
->data
;
55 vg_error( "No data named %s\n", name
);
64 /* link controllers */
68 menu
.ctr_steam
= NULL
;
71 for( u32 i
=0; i
<mdl_arrcount(&menu
.items
); i
++ ){
72 ent_menuitem
*item
= mdl_arritm( &menu
.items
, i
);
74 if( MDL_CONST_PSTREQ( &menu
.model
, item
->visual
.pstr_name
, "deck" ) )
76 if( MDL_CONST_PSTREQ( &menu
.model
, item
->visual
.pstr_name
, "kbm" ) )
78 if( MDL_CONST_PSTREQ( &menu
.model
, item
->visual
.pstr_name
, "ps" ) )
80 if( MDL_CONST_PSTREQ( &menu
.model
, item
->visual
.pstr_name
, "steam" ) )
81 menu
.ctr_steam
= item
;
82 if( MDL_CONST_PSTREQ( &menu
.model
, item
->visual
.pstr_name
, "xbox" ) )
89 skaterift
.activity
= k_skaterift_default
;
91 menu
.page
= 0xffffffff;
92 srinput
.state
= k_input_state_resume
;
97 void *alloc
= vg_mem
.rtmemory
;
99 mdl_open( &menu
.model
, "models/rs_menu.mdl", alloc
);
100 mdl_load_metadata_block( &menu
.model
, alloc
);
102 vg_linear_clear( vg_mem
.scratch
);
104 MDL_LOAD_ARRAY( &menu
.model
, &menu
.items
, ent_menuitem
, alloc
);
105 MDL_LOAD_ARRAY( &menu
.model
, &menu
.markers
, ent_marker
, alloc
);
106 MDL_LOAD_ARRAY( &menu
.model
, &menu
.cameras
, ent_camera
, alloc
);
108 u32 count
= mdl_arrcount( &menu
.model
.textures
);
109 menu
.textures
= vg_linear_alloc(alloc
,vg_align8(sizeof(GLuint
)*(count
+1)));
110 menu
.textures
[0] = vg
.tex_missing
;
112 mdl_async_load_glmesh( &menu
.model
, &menu
.mesh
, NULL
);
114 for( u32 i
=0; i
<count
; i
++ ){
115 vg_linear_clear( vg_mem
.scratch
);
116 menu
.textures
[i
+1] = vg
.tex_missing
;
118 mdl_texture
*tex
= mdl_arritm( &menu
.model
.textures
, i
);
119 void *data
= vg_linear_alloc( vg_mem
.scratch
, tex
->file
.pack_size
);
120 mdl_fread_pack_file( &menu
.model
, &tex
->file
, data
);
121 vg_tex2d_load_qoi_async( data
, tex
->file
.pack_size
,
122 VG_TEX2D_LINEAR
|VG_TEX2D_CLAMP
,
123 &menu
.textures
[i
+1] );
126 mdl_close( &menu
.model
);
128 vg_console_reg_var( "skip_starter_menu", &menu
.skip_starter
,
129 k_var_dtype_i32
, VG_VAR_PERSISTENT
);
132 void menu_at_begin(void)
134 if( menu
.skip_starter
) return;
136 skaterift
.activity
= k_skaterift_menu
;
137 menu
.page
= 0xffffffff;
138 menu_open_page( "Starter", k_ent_menuitem_stack_append
);
142 * Drop back a page until we're at the bottom which then we jus quit
144 static void menu_back_page(void){
146 if( menu
.page_depth
== 0 ){
150 menu
.page
= menu
.page_stack
[ menu
.page_depth
].page
;
151 menu
.cam
= menu
.page_stack
[ menu
.page_depth
].cam
;
153 if( menu
.input_mode
== k_menu_input_mode_keys
)
154 menu
.loc
= menu
.page_stack
[ menu
.page_depth
].loc
;
155 else menu
.loc
= NULL
;
160 * Open page to the string identifier
162 void menu_open_page( const char *name
,
163 enum ent_menuitem_stack_behaviour stackmode
)
165 srinput
.state
= k_input_state_resume
;
166 if( stackmode
== k_ent_menuitem_stack_append
){
167 if( menu
.page_depth
>= MENU_STACK_SIZE
)
168 vg_fatal_error( "Stack overflow\n" );
171 if( menu
.page_depth
== 0 )
172 vg_fatal_error( "Stack underflow\n" );
175 u32 hash
= vg_strdjb2( name
);
176 for( u32 i
=0; i
<mdl_arrcount(&menu
.items
); i
++ ){
177 ent_menuitem
*item
= mdl_arritm( &menu
.items
, i
);
179 if( item
->type
== k_ent_menuitem_type_page
){
180 if( mdl_pstreq( &menu
.model
, item
->page
.pstr_name
, name
, hash
) ){
181 u32 new_page
= __builtin_ctz( item
->groups
);
183 if( new_page
== menu
.page
){
184 if( stackmode
!= k_ent_menuitem_stack_replace
)
188 menu
.page_stack
[ menu
.page_depth
].page
= menu
.page
;
189 menu
.page_stack
[ menu
.page_depth
].cam
= menu
.cam
;
190 menu
.page_stack
[ menu
.page_depth
].loc
= menu
.loc
;
192 if( stackmode
== k_ent_menuitem_stack_append
)
195 menu
.page
= __builtin_ctz( item
->groups
);
197 if( menu
.input_mode
== k_menu_input_mode_keys
){
198 if( item
->page
.id_entrypoint
){
199 u32 id
= mdl_entity_id_id( item
->page
.id_entrypoint
);
200 menu
.loc
= mdl_arritm( &menu
.items
, id
);
204 if( item
->page
.id_viewpoint
){
205 u32 id
= mdl_entity_id_id( item
->page
.id_viewpoint
);
206 menu
.cam
= mdl_arritm( &menu
.cameras
, id
);
216 * activate a pressable type
218 static void menu_trigger_item( ent_menuitem
*item
)
221 audio_oneshot( &audio_ui
[0], 1.0f
, 0.0f
);
224 if ( item
->type
== k_ent_menuitem_type_event_button
)
226 u32 q
= item
->button
.pstr
;
228 if( MDL_CONST_PSTREQ( &menu
.model
, q
, "quit" ) )
230 vg
.window_should_close
= 1;
232 else if( MDL_CONST_PSTREQ( &menu
.model
, q
, "map" ) ){
236 else if( MDL_CONST_PSTREQ( &menu
.model
, q
, "hub" ) ){
237 if( world_static
.active_instance
== k_world_purpose_client
){
239 ent_miniworld_goback();
242 else if( MDL_CONST_PSTREQ( &menu
.model
, q
, "credits" ) ){
243 menu
.credits_open
= 1;
245 else if( MDL_CONST_PSTREQ( &menu
.model
, q
, "workshop" ) ){
246 workshop_submit_command(0,NULL
);
248 else if( MDL_CONST_PSTREQ( &menu
.model
, q
, "engine" ) ){
251 else if( MDL_CONST_PSTREQ( &menu
.model
, q
, "prem_store" ) ){
253 SteamAPI_ISteamFriends_ActivateGameOverlayToStore(
254 SteamAPI_SteamFriends(), 2103940, k_EOverlayToStoreFlag_None
);
256 else if( MDL_CONST_PSTREQ( &menu
.model
, q
, "prem_nevermind" ) ){
259 else if( MDL_CONST_PSTREQ( &menu
.model
, q
, "starter_enter" ) )
261 if( network_client
.auto_connect
)
262 network_client
.user_intent
= k_server_intent_online
;
267 else if( item
->type
== k_ent_menuitem_type_page_button
)
269 menu_open_page( mdl_pstr( &menu
.model
, item
->button
.pstr
),
270 item
->button
.stack_behaviour
);
272 else if( item
->type
== k_ent_menuitem_type_toggle
)
275 *item
->pi32
= *item
->pi32
^ 0x1;
280 static f32
menu_slider_snap( f32 value
, f32 old
, f32 notch
){
281 f32
const k_epsilon
= 0.0125f
;
283 if( fabsf(notch
-value
) < k_epsilon
){
284 if( fabsf(notch
-old
) > k_epsilon
){
286 audio_oneshot( &audio_ui
[0], 1.0f
, 0.0f
);
296 static void menu_setitem_type( ent_menuitem
*item
,
297 enum ent_menuitem_type type
){
303 * Run from vg_gui every frame
305 void menu_update(void)
307 if( workshop_form
.page
!= k_workshop_form_hidden
){
311 int escape
= button_down( k_srbind_mback
);
312 if( menu
.credits_open
|| vg
.settings_open
){
314 menu
.credits_open
= 0;
316 if( vg
.settings_open
)
322 if( button_down( k_srbind_mopen
) ){
323 if( skaterift
.activity
== k_skaterift_default
){
324 skaterift
.activity
= k_skaterift_menu
;
325 menu
.page
= 0xffffffff;
326 menu_open_page( "Main Menu", k_ent_menuitem_stack_append
);
331 if( skaterift
.activity
!= k_skaterift_menu
) return;
332 enum menu_input_mode prev_mode
= menu
.input_mode
;
334 /* get buttons inputs
335 * -------------------------------------------------------------------*/
336 int ml
= button_down( k_srbind_mleft
),
337 mr
= button_down( k_srbind_mright
),
338 mu
= button_down( k_srbind_mup
),
339 md
= button_down( k_srbind_mdown
),
342 enter
= button_down( k_srbind_maccept
);
345 menu
.input_mode
= k_menu_input_mode_keys
;
349 * --------------------------------------------------------------------*/
350 menu
.mouse_dist
+= v2_length( vg
.mouse_delta
); /* TODO: Move to UI */
351 menu
.mouse_track
+= vg
.time_frame_delta
;
352 if( menu
.mouse_track
> 0.1f
){
353 menu
.mouse_track
= fmodf( menu
.mouse_track
, 0.1f
);
354 if( menu
.mouse_dist
> 10.0f
){
355 menu
.input_mode
= k_menu_input_mode_mouse
;
356 menu
.mouse_dist
= 0.0f
;
360 if( ui_clicking(UI_MOUSE_LEFT
) || ui_clicking(UI_MOUSE_RIGHT
) ){
361 menu
.input_mode
= k_menu_input_mode_mouse
;
364 if( menu
.input_mode
== k_menu_input_mode_mouse
){
367 * ------------------------------------------------------------*/
368 vg_ui
.wants_mouse
= 1;
371 * this raycasting is super cumbersome because all the functions were
372 * designed for other purposes. we dont care though.
375 m4x4_inv( menu
.view
.mtx
.p
, inverse
);
377 coords
[0] = vg_ui
.mouse
[0];
378 coords
[1] = vg
.window_y
- vg_ui
.mouse
[1];
379 v2_div( coords
, (v2f
){ vg
.window_x
, vg
.window_y
}, coords
);
380 v2_muls( coords
, 2.0f
, coords
);
381 v2_add( coords
, (v2f
){-1.0f
,-1.0f
}, coords
);
384 m4x4_mulv( inverse
, coords
, coords
);
386 m3x3_mulv( menu
.view
.transform
, coords
, ray
);
389 if( menu
.loc
&& (menu
.loc
->type
== k_ent_menuitem_type_slider
) &&
390 ui_clicking(UI_MOUSE_LEFT
) && menu
.loc
->pf32
){
392 u32 il
= mdl_entity_id_id( menu
.loc
->slider
.id_min
),
393 ir
= mdl_entity_id_id( menu
.loc
->slider
.id_max
);
394 ent_marker
*ml
= mdl_arritm( &menu
.markers
, il
),
395 *mr
= mdl_arritm( &menu
.markers
, ir
);
398 v3_muladds( menu
.view
.pos
, ray
, 100.0f
, q2
);
403 v3_sub( mr
->transform
.co
, ml
->transform
.co
, v0
);
404 v3_muladds( ml
->transform
.co
, v0
, -1.0f
, p1
);
405 v3_muladds( mr
->transform
.co
, v0
, 1.0f
, q1
);
406 closest_segment_segment( p1
, q1
, menu
.view
.pos
, q2
, &s
,&t
, c1
,c2
);
411 if( ui_click_down(UI_MOUSE_LEFT
) ){
412 menu
.slider_offset
= *menu
.loc
->pf32
- s
;
415 f32 newvalue
= vg_clampf( s
+menu
.slider_offset
, 0.0f
, 1.0f
);
417 newvalue
= menu_slider_snap( newvalue
, *menu
.loc
->pf32
, 0.00f
);
418 newvalue
= menu_slider_snap( newvalue
, *menu
.loc
->pf32
, 1.00f
);
419 newvalue
= menu_slider_snap( newvalue
, *menu
.loc
->pf32
, 0.25f
);
420 newvalue
= menu_slider_snap( newvalue
, *menu
.loc
->pf32
, 0.50f
);
421 newvalue
= menu_slider_snap( newvalue
, *menu
.loc
->pf32
, 0.75f
);
423 *menu
.loc
->pf32
= newvalue
;
427 ent_menuitem
*hit_item
= NULL
;
429 for( u32 i
=0; i
<mdl_arrcount(&menu
.items
); i
++ ){
430 ent_menuitem
*item
= mdl_arritm( &menu
.items
, i
);
432 if( item
->type
== k_ent_menuitem_type_page
) continue;
433 if( (item
->type
== k_ent_menuitem_type_visual
) ||
434 (item
->type
== k_ent_menuitem_type_visual_nocol
) ) continue;
435 if( item
->type
== k_ent_menuitem_type_binding
) continue;
436 if( !(item
->groups
& (0x1<<menu
.page
)) ) continue;
438 ent_menuitem
*ray_item
= item
;
440 if( item
->type
== k_ent_menuitem_type_slider
){
441 u32 subtarget
= mdl_entity_id_id( item
->slider
.id_handle
);
442 ray_item
= mdl_arritm( &menu
.items
, subtarget
);
449 mdl_transform_m4x3( &ray_item
->transform
, inverse_mtx
);
450 m4x3_invert_full( inverse_mtx
, inverse_mtx
);
452 m4x3_mulv( inverse_mtx
, menu
.view
.transform
[3], local_co
);
453 m3x3_mulv( inverse_mtx
, ray
, local_ray
);
454 v3_normalize( local_ray
);
456 local_ray
[0] = 1.0f
/local_ray
[0];
457 local_ray
[1] = 1.0f
/local_ray
[1];
458 local_ray
[2] = 1.0f
/local_ray
[2];
460 for( u32 j
=0; j
<ray_item
->submesh_count
; j
++ ){
461 mdl_submesh
*sm
= mdl_arritm( &menu
.model
.submeshs
,
462 ray_item
->submesh_start
+ j
);
463 if( ray_aabb1( sm
->bbx
, local_co
, local_ray
, 1000.0f
) ){
470 if( hit_item
!= menu
.loc
){
478 if( ui_click_down( UI_MOUSE_LEFT
) )
480 menu_trigger_item( menu
.loc
);
484 else if( menu
.input_mode
== k_menu_input_mode_keys
){
486 * handle button input
487 * ------------------------------------------------------------*/
488 if( (prev_mode
!= k_menu_input_mode_keys
) && !menu
.loc
){
489 for( u32 i
=0; i
<mdl_arrcount(&menu
.items
); i
++ ){
490 ent_menuitem
*item
= mdl_arritm( &menu
.items
, i
);
492 if( (item
->type
!= k_ent_menuitem_type_page
) &&
493 (item
->type
!= k_ent_menuitem_type_visual
) &&
494 (item
->type
!= k_ent_menuitem_type_visual_nocol
) &&
495 (item
->groups
& (0x1<<menu
.page
)) ){
501 if( !menu
.loc
) vg_fatal_error( "No location\n" );
503 if( menu
.loc
->type
== k_ent_menuitem_type_slider
&& menu
.loc
->pf32
){
506 if( vg_input
.display_input_method
== k_input_method_controller
){
507 move
+= button_press( k_srbind_mright
);
508 move
-= button_press( k_srbind_mleft
);
511 move
+= axis_state( k_sraxis_mbrowse_h
);
514 move
*= vg
.time_frame_delta
;
515 *menu
.loc
->pf32
= vg_clampf( *menu
.loc
->pf32
+ move
, 0.0f
, 1.0f
);
524 audio_oneshot( &audio_ui
[3], 1.0f
, 0.0f
);
529 menu_trigger_item( menu
.loc
);
535 ent_menuitem
*nextpos
= NULL
;
539 mdl_transform_vector( &menu
.cam
->transform
, opt
, opt
);
541 for( u32 i
=0; i
<4; i
++ ){
542 u32 id
= menu
.loc
->id_links
[i
];
544 u32 index
= mdl_entity_id_id( id
);
546 ent_menuitem
*other
= mdl_arritm( &menu
.items
, index
);
548 v3_sub( menu
.loc
->transform
.co
, other
->transform
.co
, delta
);
549 v3_normalize( delta
);
551 f32 score
= v3_dot( delta
, opt
);
562 audio_oneshot( &audio_ui
[3], 1.0f
, 0.0f
);
568 menu_setitem_type( menu
.ctr_deck
, k_ent_menuitem_type_disabled
);
569 menu_setitem_type( menu
.ctr_ps
, k_ent_menuitem_type_disabled
);
570 menu_setitem_type( menu
.ctr_kbm
, k_ent_menuitem_type_disabled
);
571 menu_setitem_type( menu
.ctr_xbox
, k_ent_menuitem_type_disabled
);
572 menu_setitem_type( menu
.ctr_steam
, k_ent_menuitem_type_disabled
);
574 if( vg_input
.display_input_method
== k_input_method_kbm
)
575 menu_setitem_type( menu
.ctr_kbm
, k_ent_menuitem_type_visual_nocol
);
577 if( vg_input
.display_input_type
== SDL_CONTROLLER_TYPE_PS3
||
578 vg_input
.display_input_type
== SDL_CONTROLLER_TYPE_PS4
||
579 vg_input
.display_input_type
== SDL_CONTROLLER_TYPE_PS5
){
580 menu_setitem_type( menu
.ctr_ps
, k_ent_menuitem_type_visual_nocol
);
583 menu_setitem_type( menu
.ctr_xbox
, k_ent_menuitem_type_visual_nocol
);
585 /* FIXME: Steam/Deck controller detection? */
589 static void menu_binding_string( char buf
[128], u32 pstr
);
592 * Run from vg_gui when active
594 void menu_render(void)
597 glDisable(GL_DEPTH_TEST
);
598 glBlendFunc( GL_SRC_ALPHA
, GL_ONE_MINUS_SRC_ALPHA
);
599 glBlendEquation(GL_FUNC_ADD
);
601 shader_blitcolour_use();
603 ui_hex_to_norm( ui_colour( k_ui_bg
+3 ), colour
);
606 shader_blitcolour_uColour( colour
);
609 if( (workshop_form
.page
!= k_workshop_form_hidden
) ||
610 (vg_ui
.focused_control_type
!= k_ui_control_none
) ){
614 if( vg
.settings_open
)
617 if( menu
.credits_open
){
618 ui_rect panel
= { 0,0, 460, 400 },
619 screen
= { 0,0, vg
.window_x
,vg
.window_y
};
620 ui_rect_center( screen
, panel
);
621 ui_fill( panel
, ui_colour(k_ui_bg
) );
622 ui_outline( panel
, 1, ui_colour(k_ui_fg
), 0 );
623 ui_rect_pad( panel
, (ui_px
[]){8,8} );
626 ui_split( panel
, k_ui_axis_h
, 28*2, 0, title
, panel
);
627 ui_text( title
, "Skate Rift - Credits", 2, k_ui_align_middle_center
, 0 );
628 ui_split( panel
, k_ui_axis_h
, 28, 0, title
, panel
);
629 ui_text( title
, "Mt.Zero Software", 1, k_ui_align_middle_center
, 0 );
631 ui_split( panel
, k_ui_axis_h
, 8, 0, title
, panel
);
632 ui_split( panel
, k_ui_axis_h
, 28*2, 0, title
, panel
);
633 ui_text( title
, "Free Software", 2, k_ui_align_middle_center
, 0 );
635 ui_split( panel
, k_ui_axis_h
, 8, 0, title
, panel
);
637 "Sam Lantinga - SDL2 - libsdl.org\n"
638 "Hunter WB - Anyascii\n"
639 "David Herberth - GLAD\n"
640 "Dominic Szablewski - QOI - qoiformat.org\n"
641 "Sean Barrett - stb_image,stb_vorbis,stb_include\n"
642 "Khronos Group - OpenGL\n"
643 , 1, k_ui_align_left
, 0 );
647 glEnable( GL_DEPTH_TEST
);
648 glDisable( GL_BLEND
);
650 f32 rate
= vg
.time_frame_delta
* 12.0f
;
655 target
.fov
= menu
.cam
->fov
;
656 v3_copy( menu
.cam
->transform
.co
, target
.pos
);
659 mdl_transform_vector( &menu
.cam
->transform
, (v3f
){0.0f
,-1.0f
,0.0f
}, v0
);
660 v3_angles( v0
, target
.angles
);
662 vg_camera_lerp( &menu
.view
, &target
, rate
, &menu
.view
);
664 menu
.view
.farz
= 150.0f
;
665 menu
.view
.nearz
= 0.01f
;
667 vg_camera_update_transform( &menu
.view
);
668 vg_camera_update_view( &menu
.view
);
669 vg_camera_update_projection( &menu
.view
);
670 vg_camera_finalize( &menu
.view
);
674 shader_model_menu_use();
675 shader_model_menu_uTexMain( 1 );
676 shader_model_menu_uPv( menu
.view
.mtx
.pv
);
677 shader_model_menu_uPvmPrev( menu
.view
.mtx_prev
.pv
);
679 mesh_bind( &menu
.mesh
);
683 ui_hex_to_norm( ui_colour( k_ui_fg
), white
);
684 ui_hex_to_norm( ui_colour( k_ui_orange
+k_ui_brighter
), blue
);
686 ent_menuitem
*text_list
[ 8 ];
689 u32 current_mat
= 0xffffffff;
691 for( u32 i
=0; i
<mdl_arrcount(&menu
.items
); i
++ ){
692 ent_menuitem
*item
= mdl_arritm( &menu
.items
, i
);
694 if( item
->type
== k_ent_menuitem_type_disabled
) continue;
695 if( item
->type
== k_ent_menuitem_type_page
) continue;
696 if( !(item
->groups
& (0x1 << menu
.page
)) ) continue;
698 if( item
->type
== k_ent_menuitem_type_binding
){
699 if( text_count
< vg_list_size(text_list
) )
700 text_list
[ text_count
++ ] = item
;
702 vg_fatal_error( "Text list overflow" );
710 if( menu
.loc
->type
== k_ent_menuitem_type_slider
){
711 u32 subid
= menu
.loc
->slider
.id_handle
;
712 if( item
== mdl_arritm( &menu
.items
, mdl_entity_id_id(subid
) ))
716 if( item
== menu
.loc
)
721 if( item
->type
== k_ent_menuitem_type_visual_nocol
){
722 shader_model_menu_uColour( (v4f
){1.0f
,1.0f
,1.0f
,1.0f
} );
726 item
->factive
= vg_lerpf( item
->factive
, selected
, rate
);
727 v4_lerp( white
, blue
, item
->factive
, colour
);
728 shader_model_menu_uColour( colour
);
731 f32 scale
= 1.0f
+item
->factive
*0.1f
;
734 mdl_transform transform
= item
->transform
;
735 v3_muls( transform
.s
, scale
, transform
.s
);
736 mdl_transform_m4x3( &transform
, mmdl
);
738 if( item
->type
== k_ent_menuitem_type_toggle
&& item
->pi32
){
739 u32 subid
= mdl_entity_id_id( item
->checkmark
.id_check
);
740 ent_menuitem
*subitem
= mdl_arritm( &menu
.items
, subid
);
742 v3_muladds( item
->transform
.co
, item
->checkmark
.offset
, scale
,
743 subitem
->transform
.co
);
745 subitem
->fvisible
= vg_lerpf( subitem
->fvisible
, *item
->pi32
, rate
);
746 v3_fill( subitem
->transform
.s
, subitem
->fvisible
);
748 else if( item
->type
== k_ent_menuitem_type_slider
&& item
->pf32
){
749 u32 il
= mdl_entity_id_id( item
->slider
.id_min
),
750 ir
= mdl_entity_id_id( item
->slider
.id_max
),
751 ih
= mdl_entity_id_id( item
->slider
.id_handle
);
752 ent_marker
*ml
= mdl_arritm( &menu
.markers
, il
),
753 *mr
= mdl_arritm( &menu
.markers
, ir
);
754 ent_menuitem
*handle
= mdl_arritm( &menu
.items
, ih
);
756 v3_lerp( ml
->transform
.co
, mr
->transform
.co
, *item
->pf32
,
757 handle
->transform
.co
);
760 shader_model_menu_uMdl( mmdl
);
762 for( u32 j
=0; j
<item
->submesh_count
; j
++ )
764 u32 index
= item
->submesh_start
+ j
;
765 mdl_submesh
*sm
= mdl_arritm( &menu
.model
.submeshs
, index
);
767 if( sm
->material_id
!= current_mat
)
769 mdl_material
*mat
= mdl_arritm( &menu
.model
.materials
,
771 glActiveTexture( GL_TEXTURE1
);
773 if( mat
->shader
== k_shader_standard
)
775 struct shader_props_standard
*props
= mat
->props
.compiled
;
777 /* FIXME: why does menu have its own texture array?? */
778 glBindTexture( GL_TEXTURE_2D
,
779 menu
.textures
[ props
->tex_diffuse
] );
783 glBindTexture( GL_TEXTURE_2D
, vg
.tex_missing
);
786 current_mat
= sm
->material_id
;
789 mdl_draw_submesh( sm
);
793 if( !text_count
) return;
798 m4x3_identity( local
);
800 font3d_bind( &gui
.font
, k_font_shader_default
, 0, NULL
, &menu
.view
);
801 for( u32 i
=0; i
<text_count
; i
++ ){
802 ent_menuitem
*item
= text_list
[ i
];
804 mdl_transform_m4x3( &item
->transform
, transform
);
806 u32 variant
= item
->binding
.font_variant
;
807 menu_binding_string( buf
, item
->binding
.pstr_bind
);
808 f32 offset
= font3d_string_width( variant
, buf
);
810 local
[3][0] = -0.5f
* offset
;
811 m4x3_mul( transform
, local
, transform
);
813 font3d_simple_draw( variant
, buf
, &menu
.view
, transform
);
817 static void menu_binding_string( char buf
[128], u32 pstr
){
819 vg_strnull( &str
, buf
, 128 );
821 if( MDL_CONST_PSTREQ( &menu
.model
, pstr
, "bind_jump" ) ){
822 vg_input_string( &str
, input_button_list
[k_srbind_jump
], 1 );
824 else if( MDL_CONST_PSTREQ( &menu
.model
, pstr
, "bind_trick0" ) ){
825 vg_strcat( &str
, "SHUVIT " );
826 vg_input_string( &str
, input_button_list
[k_srbind_trick0
], 1 );
828 else if( MDL_CONST_PSTREQ( &menu
.model
, pstr
, "bind_trick1" ) ){
829 vg_strcat( &str
, "KICKFLIP " );
830 vg_input_string( &str
, input_button_list
[k_srbind_trick1
], 1 );
832 else if( MDL_CONST_PSTREQ( &menu
.model
, pstr
, "bind_trick2" ) ){
833 vg_strcat( &str
, "TREFLIP " );
834 vg_input_string( &str
, input_button_list
[k_srbind_trick2
], 1 );
836 else if( MDL_CONST_PSTREQ( &menu
.model
, pstr
, "bind_grab" ) ){
837 vg_input_string( &str
, input_axis_list
[k_sraxis_grab
], 1 );
839 else if( MDL_CONST_PSTREQ( &menu
.model
, pstr
, "bind_grab_mod" ) ){
840 vg_input_string( &str
, input_joy_list
[k_srjoystick_grab
], 1 );
843 vg_strcat( &str
, "error" );