-#ifndef MENU_H
-#define MENU_H
+#pragma once
-#include "common.h"
-#include "model.h"
-#include "world_render.h"
-#include "player.h"
+#define MENU_STACK_SIZE 8
-#include "shaders/menu.h"
+#include "vg/vg_engine.h"
+#include "entity.h"
-static mdl_header *menu_model;
-static glmesh menu_glmesh;
-static v3f menu_cam_pos,
- menu_target_cam_pos;
-static v4f menu_cam_q = { 0.0f, 0.0f, 0.0f, 1.0f },
- menu_target_cam_q;
-static m4x3f menu_cam, menu_cam_inv;
-static float menu_opacity = 0.0f;
-
-static void menu_init(void)
+enum menu_page
{
- menu_model = mdl_load( "models/rs_menu.mdl" );
-
- if( !menu_model )
- vg_fatal_exit_loop( "No menu model" );
-
- vg_acquire_thread_sync();
- mdl_unpack_glmesh( menu_model, &menu_glmesh );
- vg_release_thread_sync();
-
- shader_menu_register();
-}
-
-static void menu_update( int enabled )
+ k_menu_page_any,
+ k_menu_page_starter,
+ k_menu_page_premium,
+ k_menu_page_main,
+ k_menu_page_credits
+};
+
+enum menu_main_subpage
{
- static int enabled_last = 0;
-
- if( enabled && !enabled_last )
- {
- v3_copy( player.camera[3], menu_cam_pos );
- m3x3_q( player.camera, menu_cam_q );
-
- if( player.phys.on_board )
- {
- v4f r90;
- q_axis_angle( r90, player.phys.rb.up, VG_PIf*-0.5f );
- q_mul( r90, player.phys.rb.q, menu_target_cam_q );
- m4x3_mulv( player.phys.rb.to_world, (v3f){-1.0f,1.6f,0.0f},
- menu_target_cam_pos );
- }
- else
- {
- v4f r180;
- q_axis_angle( r180, player.phys.rb.up, VG_PIf );
- q_mul( r180, player.phys.rb.q, menu_target_cam_q );
- m4x3_mulv( player.phys.rb.to_world, (v3f){0.0f,1.6f,-1.0f},
- menu_target_cam_pos );
- }
-
- q_normalize( menu_target_cam_q );
- q_normalize( menu_cam_q );
- menu_opacity = 0.0f;
- }
-
- if( enabled_last && !enabled )
- {
- m3x3_q( player.camera, menu_target_cam_q );
- v3_copy( player.camera[3], menu_target_cam_pos );
- }
-
- float dt = vg.time_delta * 6.0f;
-
- q_nlerp( menu_cam_q, menu_target_cam_q, dt, menu_cam_q );
- v3_lerp( menu_cam_pos, menu_target_cam_pos, dt, menu_cam_pos );
+ k_menu_main_main = 0,
+ k_menu_main_map = 1,
+ k_menu_main_settings = 2,
+ k_menu_main_guide = 3
+};
- q_m3x3( menu_cam_q, menu_cam );
- v3_copy( menu_cam_pos, menu_cam[3] );
- m4x3_invert_affine( menu_cam, menu_cam_inv );
- menu_opacity = vg_lerpf( menu_opacity, enabled, dt );
-
- enabled_last = enabled;
+struct global_menu
+{
+ int disable_open;
+ i32 skip_starter;
+ enum menu_page page;
+ i32 main_index,
+ main_row,
+ settings_row,
+ guides_row;
+ f32 mouse_dist; /* used for waking up mouse */
+
+ f32 repeater;
}
+extern menu;
-static void menu_render( m4x4f projection )
-{
- glEnable(GL_BLEND);
- glDisable(GL_DEPTH_TEST);
- glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
- glBlendEquation(GL_FUNC_ADD);
+void menu_init(void);
+void menu_at_begin(void);
+void menu_gui(void);
+void menu_open( enum menu_page page );
+bool menu_viewing_map(void);
- shader_fscolour_use();
- shader_fscolour_uColour( (v4f){ 0.1f, 0.1f, 0.3f, menu_opacity*0.5f } );
- render_fsquad();
+#if 0
+#define MENU_STACK_SIZE 8
- glEnable( GL_DEPTH_TEST );
- glDisable( GL_BLEND );
+#include "vg/vg_engine.h"
+#include "entity.h"
- m4x3f mtx;
+struct global_menu
+{
+ int credits_open;
+ int disable_open;
+ i32 skip_starter;
+
+ u32 page, /* current page index */
+ page_depth,
+ controls_page_id;
+
+ ent_menuitem *ctr_kbm,
+ *ctr_deck,
+ *ctr_ps,
+ *ctr_steam,
+ *ctr_xbox;
+ f32 slider_offset;
+
+ struct page_stack_frame {
+ u32 page;
+ ent_menuitem *loc;
+ ent_camera *cam;
+ }
+ page_stack[ MENU_STACK_SIZE ];
- shader_menu_use();
- shader_menu_uColour( (v4f){ 1.0f,1.0f,1.0f,1.0f} );
- shader_menu_uTexMain( 1 );
- vg_tex2d_bind( &tex_graffiti, 1 );
-
- shader_menu_uPv( projection );
- mesh_bind( &menu_glmesh );
-
- m4x3_identity( mtx );
- shader_menu_uMdl( mtx );
- mesh_draw( &menu_glmesh );
+ ent_menuitem *loc;
+ ent_camera *cam;
+ vg_camera view;
- for( int i=0; i<menu_model->node_count; i++ )
- {
- mdl_node *pnode = mdl_node_from_id( menu_model, i );
-
- for( int j=0; j<pnode->submesh_count; j++ )
- {
- mdl_submesh *sm =
- mdl_submesh_from_id( menu_model, pnode->submesh_start+j );
+ mdl_context model;
+ GLuint *textures;
+ glmesh mesh;
- mdl_node_transform( pnode, mtx );
- m4x3_mul( player.phys.rb.to_world, mtx, mtx );
- shader_menu_uMdl( mtx );
-
- mdl_draw_submesh( sm );
- }
- }
-}
-
-static void menu_free(void *_)
-{
- mesh_free( &menu_glmesh );
+ mdl_array_ptr items, markers, cameras;
}
-
-#endif /* MENU_H */
+extern menu;
+void menu_close(void);
+void menu_open_page( const char *name,
+ enum ent_menuitem_stack_behaviour stackmode );
+void menu_link(void);
+void menu_render(void);
+#endif