if( press_dpad_w )
render_overlay_mesh( ov_dpad_w );
#endif
+ colorize( press_dpad_w, 1 );
+ render_overlay_mesh( ov_text_dw_quickmenu );
+ if( press_dpad_w )
+ render_overlay_mesh( ov_dpad_w );
if( subsytem == k_player_subsystem_dead )
{
mmdl[3][2] = 1.0f - 0.125f - 0.25f - 0.25f - 0.25f;
/* Q */
+#if 0
if( subsytem == k_player_subsystem_dead )
{
bool press_q = vg_getkey(SDLK_q);
draw_key( press_q, 0 );
render_overlay_mesh( ov_text_respawn );
}
+#endif
+ bool press_q = vg_getkey(SDLK_q);
+ mmdl[3][0] = -r + 0.125f;
+ shader_model_menu_uMdl( mmdl );
+ colorize( press_q, 1 );
+ draw_key( press_q, 0 );
+ render_overlay_mesh( ov_text_quickmenu );
/* W || PUSH / FRONTFLIP */
bool press_w = vg_getkey(SDLK_w);
if( button_down( k_srbind_maccept ) )
{
+ menu_close();
gui_helper_reset( k_gui_helper_mode_clear );
_world.challenge_state = k_challenge_state_running;
localplayer.immobile = 0; /* TODO: Unify this probably after eating some potats */
{
if( world_set_event( k_world_event_route_leaderboard ) )
{
+ menu_close();
gui_helper_reset( k_gui_helper_mode_clear );
vg_str text;
-#if 0
- if( (_ent_route.helper_weekly = gui_new_helper( input_button_list[k_srbind_mleft], &text )))
- vg_strcat( &text, "Weekly" );
- if( (_ent_route.helper_alltime = gui_new_helper( input_button_list[k_srbind_mright], &text )))
- vg_strcat( &text, "All time" );
-#endif
-
if( gui_new_helper( input_button_list[k_srbind_mback], &text ) )
vg_strcat( &text, "Exit" );
ent_camera_unpack( af_arritm( &world->ent_camera, mdl_entity_id_id(cam_id) ), &temp );
world_set_entity_driven_camera( &temp );
}
-
- bool select_move = 0;
-
- /* TODO: Visual buttons like the board shops */
- if( button_down( k_srbind_mup ) )
- {
- if( _ent_route.run_selection > 0 )
- {
- _ent_route.run_selection --;
- select_move = 1;
- }
- }
- if( button_down( k_srbind_mdown ) )
- {
- if( _ent_route.run_selection < 10 )
- {
- _ent_route.run_selection ++;
- select_move = 1;
- }
- }
-
- if( select_move )
- {
- sfd_encode( (v2i){0,_ent_route.run_selection }, " ", k_world_sfd_left );
- sfd_encode( (v2i){0,_ent_route.run_selection + 1}, "AA", k_world_sfd_left );
- sfd_encode( (v2i){0,_ent_route.run_selection + 2}, " ", k_world_sfd_left );
- }
-
- if( button_down( k_srbind_maccept ) )
- {
- if( _remote_replay.state != k_remote_replay_state_none )
- goto E0;
-
- struct leaderboard_cache *board = &world->leaderboard_cache[ mdl_entity_id_id( _ent_route.viewing_route_id ) ];
- vg_msg body;
- vg_msg_init( &body, board->data, board->data_len );
-
- vg_info( "Looking for the %u run\n", _ent_route.run_selection );
-
- u32 l = 0;
-
- if( vg_msg_seekframe( &body, "rows" ) )
- {
- while( vg_msg_seekframe( &body, NULL ) )
- {
- const char *username = vg_msg_getkvstr( &body, "username" );
- vg_info( "%u: %s\n", l, username );
-
- if( l == _ent_route.run_selection )
- {
- u32 centiseconds;
- vg_msg_getkvintg( &body, "time", k_vg_msg_u32, ¢iseconds, NULL );
-
- i64 lastsec;
- vg_msg_getkvintg( &body, "lastsec", k_vg_msg_i64, &lastsec, NULL );
-
- u64 steamid;
- vg_msg_getkvintg( &body, "steamid", k_vg_msg_u64, &steamid, NULL );
-
- u32 last_minute = (u32)( lastsec / 60 );
-
- // TODO: put this in a header
- u32 minutes_span = (centiseconds+(200*60)) / (100*60);
- vg_queue_clear( &_remote_replay.buffer );
- _remote_replay.min_frame_t = 0.0;
- _remote_replay.total_chunks = minutes_span;
- _remote_replay.chunks_downloaded = 0;
- _remote_replay.steamid = steamid;
- _remote_replay.state = k_remote_replay_state_init;
- _remote_replay.last_second = lastsec;
-
- for( u32 i=0; i<minutes_span; i ++ )
- {
- struct remote_replay_chunk *chunk = &_remote_replay.chunks[i];
- chunk->minute = last_minute - minutes_span + 1 + i;
- chunk->state = k_chunk_state_none;
- }
-
- // TODO: UI overlay for downlaoding
- world_clear_event( k_world_event_route_leaderboard );
- srinput.state = k_input_state_resume;
- gui_helper_reset( k_gui_helper_mode_clear );
- _replay2_open_player( k_replay_type_network, 0 );
- break;
- }
- else
- {
- l ++;
- vg_msg_skip_frame( &body );
- }
- }
- }
- }
-
-E0:
if( button_down( k_srbind_mback ) )
{
if( world_clear_event( k_world_event_route_leaderboard ) )
}
}
+void _ent_route_imgui( ui_context *ctx )
+{
+ if( _world.event != k_world_event_route_leaderboard )
+ return;
+
+ u32 index = mdl_entity_id_id( _ent_route.viewing_route_id );
+
+ ui_fill( ctx, (ui_rect){0,0,vg.window_x,vg.window_y}, 0x01ffffff );
+ ui_px w = 500;
+ ent_route_leaderboard_ui( ctx, (ui_rect){ vg.window_x/2 - w/2, 64, w, 0 }, index );
+}
+
void ent_route_leaderboard_ui( ui_context *ctx, ui_rect ref_box, u32 route_index )
{
+ ctx->font = &vgf_default_large;
if( _ent_route.viewing_route_id != route_index )
{
_ent_route.viewing_route_id = route_index;
_ent_route.cursor[1] = 0;
}
+ if( vg_input.display_input_method == k_input_method_kbm )
+ ui_capture_mouse(ctx, 1);
+
ui_rect leaderboard_box = { ref_box[0], ref_box[1] + ref_box[3] + 16, ref_box[2], 24 };
if( !network_connected() )
u32 centiseconds;
vg_msg_getkvintg( &body, "time", k_vg_msg_u32, ¢iseconds, NULL );
+ i64 lastsec;
+ vg_msg_getkvintg( &body, "lastsec", k_vg_msg_i64, &lastsec, NULL );
+
i32 seconds = centiseconds / 100,
minutes = seconds / 60;
vg_strcati32r( &str, seconds, 2, '0' );
vg_strcat( &str, "." );
vg_strcati32r( &str, centiseconds, 2, '0' );
- ui_text( ctx, brr, buf, 1, k_ui_align_middle_center, 0 );
bool view_profile = 0,
- view_replay = 0;
+ view_replay = 0,
+ hover_replay = 0;
if( vg_input.display_input_method == k_input_method_controller )
{
if( _ent_route.cursor[1] == count )
{
if( _ent_route.cursor[0] == 0 )
- {
- ui_outline( ctx, br, -1, ui_colour(ctx,k_ui_fg), 0 );
-
- //if( button_down( k_srbind_maccept ) )
view_profile = 1;
- }
else if( _ent_route.cursor[0] == 1 )
{
- ui_outline( ctx, brr, -1, ui_colour(ctx,k_ui_fg), 0 );
-
+ hover_replay = 1;
if( button_down( k_srbind_maccept ) )
view_replay = 1;
}
{
enum ui_button_state state = ui_button_base( ctx, br );
if( state == k_ui_button_hover )
- {
- ui_outline( ctx, br, -1, ui_colour(ctx,k_ui_fg), 0 );
view_profile = 1;
- }
state = ui_button_base( ctx, brr );
if( state == k_ui_button_hover )
- ui_outline( ctx, brr, -1, ui_colour(ctx,k_ui_fg), 0 );
+ hover_replay = 1;
if( state == k_ui_button_click )
view_replay = 1;
}
+ if( hover_replay )
+ {
+ ui_outline( ctx, brr, -1, ui_colour(ctx,k_ui_fg), 0 );
+ vg_strcat( &str, " \xba" );
+ }
+
+ ui_text( ctx, brr, buf, 1, k_ui_align_middle_center, 0 );
+
if( view_profile )
{
+ ui_outline( ctx, br, -1, ui_colour(ctx,k_ui_fg), 0 );
u64 steamid;
vg_msg_getkvintg( &body, "steamid", k_vg_msg_u64, &steamid, NULL );
ui_px y = bl[1];
_user_profile_ui( ctx, (ui_rect){ bl[0]-(360+8),y, 360,200 }, steamid );
}
+ if( view_replay )
+ {
+ if( _remote_replay.state == k_remote_replay_state_none )
+ {
+ skaterift.activity = k_skaterift_default;
+
+ u32 last_minute = (u32)( lastsec / 60 );
+
+ // TODO: put this in a header
+ u32 minutes_span = (centiseconds+(200*60)) / (100*60);
+ vg_queue_clear( &_remote_replay.buffer );
+ _remote_replay.min_frame_t = 0.0;
+ _remote_replay.total_chunks = minutes_span;
+ _remote_replay.chunks_downloaded = 0;
+ u64 steamid;
+ vg_msg_getkvintg( &body, "steamid", k_vg_msg_u64, &steamid, NULL );
+ _remote_replay.steamid = steamid;
+ _remote_replay.state = k_remote_replay_state_init;
+ _remote_replay.last_second = lastsec;
+
+ for( u32 i=0; i<minutes_span; i ++ )
+ {
+ struct remote_replay_chunk *chunk = &_remote_replay.chunks[i];
+ chunk->minute = last_minute - minutes_span + 1 + i;
+ chunk->state = k_chunk_state_none;
+ }
+
+ world_clear_event( k_world_event_route_leaderboard );
+ srinput.state = k_input_state_resume;
+ gui_helper_reset( k_gui_helper_mode_clear );
+ _replay2_open_player( k_replay_type_network, 0 );
+ }
+ }
+
count ++;
vg_msg_skip_frame( &body );
}
_ent_route.entries_max = count;
+ vg_ui.frosting = 0.015f;
+ ui_flush( ctx, k_ui_shader_colour, NULL );
+ vg_ui.frosting = 0.0f;
+ ctx->font = &vgf_default_small;
}
entity_call_result ent_route_call( world_instance *world, ent_call *call );
void ent_route_preupdate(void);
void ent_route_leaderboard_ui( ui_context *ctx, ui_rect ref_box, u32 route_index );
+void _ent_route_imgui( ui_context *ctx );
if( gui_new_helper( input_button_list[k_srbind_mback], &text ))
vg_strcat( &text, "Exit" );
- if( (_skateshop.helper_pick = gui_new_helper( input_button_list[k_srbind_maccept], &text))){
+ if( (_skateshop.helper_pick = gui_new_helper( input_button_list[k_srbind_maccept], &text)))
vg_strcat( &text, acceptance );
- }
- if( (_skateshop.helper_browse = gui_new_helper( input_axis_list[k_sraxis_mbrowse_h], &text ))){
+ if( (_skateshop.helper_browse = gui_new_helper( input_axis_list[k_sraxis_mbrowse_h], &text )))
vg_strcat( &text, "Browse" );
- }
}
static void skateshop_playermod( bool immobile )
{
if( button_down( k_srbind_use ) )
{
+ menu_close();
ent_skateshop *shop = _skateshop.current_shop;
if( shop->type == k_skateshop_type_boardshop )
{
k_srbind_reset,
k_srbind_dead_respawn,
k_srbind_camera,
- k_srbind_mleft,
- k_srbind_mright,
- k_srbind_mup,
- k_srbind_mdown,
- k_srbind_mback,
- k_srbind_maccept,
- k_srbind_mopen,
- k_srbind_mclose,
- k_srbind_mhub,
k_srbind_replay_play,
k_srbind_replay_freecam,
k_srbind_replay_resume,
k_srbind_miniworld_teleport,
k_srbind_miniworld_resume,
k_srbind_devbutton,
+
+ k_srbind_mopen,
+ k_srbind_mleft,
+ k_srbind_mright,
+ k_srbind_mup,
+ k_srbind_mdown,
+ k_srbind_mback,
+ k_srbind_maccept,
+ k_srbind_mquick,
+ k_srbind_mclose,
+ k_srbind_mhub,
+
k_srbind_max,
};
enum sr_axis{
k_sraxis_grab = 0,
- k_sraxis_mbrowse_h,
- k_sraxis_mbrowse_v,
k_sraxis_replay_h,
k_sraxis_skid,
+
+ k_sraxis_mbrowse_h,
+ k_sraxis_mbrowse_v,
+
k_sraxis_max
};
[k_srbind_skate] = INPUT_BASIC( SDLK_e, SDL_CONTROLLER_BUTTON_Y ),
[k_srbind_use] = INPUT_BASIC( SDLK_e, SDL_CONTROLLER_BUTTON_X ),
[k_srbind_reset] = INPUT_BASIC( SDLK_r, SDL_CONTROLLER_BUTTON_DPAD_LEFT ),
-[k_srbind_dead_respawn] =
- INPUT_BASIC( SDLK_q, SDL_CONTROLLER_BUTTON_DPAD_UP ),
[k_srbind_camera]= INPUT_BASIC( SDLK_c, SDL_CONTROLLER_BUTTON_DPAD_RIGHT ),
[k_srbind_mleft] = INPUT_BASIC( SDLK_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT ),
[k_srbind_mright]= INPUT_BASIC( SDLK_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT ),
-[k_srbind_world_left] =
- INPUT_BASIC( SDLK_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT ),
-[k_srbind_world_right] =
- INPUT_BASIC( SDLK_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT ),
+[k_srbind_world_left] = INPUT_BASIC( SDLK_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT ),
+[k_srbind_world_right]= INPUT_BASIC( SDLK_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT ),
[k_srbind_mup] = INPUT_BASIC( SDLK_UP, SDL_CONTROLLER_BUTTON_DPAD_UP ),
[k_srbind_mdown] = INPUT_BASIC( SDLK_DOWN, SDL_CONTROLLER_BUTTON_DPAD_DOWN ),
[k_srbind_mback] = INPUT_BASIC( SDLK_ESCAPE, SDL_CONTROLLER_BUTTON_B ),
[k_srbind_mopen] = INPUT_BASIC( SDLK_ESCAPE, SDL_CONTROLLER_BUTTON_START ),
+[k_srbind_mquick] = INPUT_BASIC( SDLK_q, SDL_CONTROLLER_BUTTON_DPAD_LEFT ),
[k_srbind_mclose]= (vg_input_op[]){ vg_joy_button, SDL_CONTROLLER_BUTTON_START, vg_end },
[k_srbind_mhub] = INPUT_BASIC( SDLK_h, SDL_CONTROLLER_BUTTON_Y ),
[k_srbind_maccept] = (vg_input_op[]){
[k_srjoystick_max]=NULL
};
-struct {
+struct
+{
float axis_states[ k_sraxis_max ][2];
v2f joystick_states[ k_srjoystick_max ][2];
u8 button_states[ k_srbind_max ][2];
- enum input_state {
+ enum input_state
+ {
k_input_state_enabled,
k_input_state_resume,
k_input_state_resuming,
}
static srinput;
-static int input_filter_generic(void){
- if( (srinput.state != k_input_state_enabled) || vg_console.enabled ||
- (workshop_form.page != k_workshop_form_hidden) )
+static int input_filter_generic(void)
+{
+ if( (srinput.state != k_input_state_enabled)
+ || vg_console.enabled
+ || (workshop_form.page != k_workshop_form_hidden) )
return 1;
else
return 0;
}
-static int buttons_filter_fixed(void){
+static int buttons_filter_fixed(void)
+{
if( input_filter_generic() )
return 1;
-
if( vg.engine_stage == k_engine_stage_update_fixed )
if( vg.fixed_iterations > 0 )
return 1;
}
/* Rising edge of button */
-static int button_down( enum sr_bind button ){
- if( buttons_filter_fixed() ) return 0;
-
- if( srinput.button_states[ button ][0] &&
- !srinput.button_states[ button ][1] )
- return 1;
- else
+static int button_down( enum sr_bind button )
+{
+ if( buttons_filter_fixed() )
+ return 0;
+
+ if( (skaterift.activity == k_skaterift_menu) && (button < k_srbind_mopen) && (vg_input.display_input_method != k_input_method_kbm) )
return 0;
+
+ if( srinput.button_states[ button ][0] && !srinput.button_states[ button ][1] )
+ return 1;
+
+ return 0;
}
/* Falling edge of button */
-static int button_up( enum sr_bind button ){
- if( buttons_filter_fixed() ) return 0;
-
- if( !srinput.button_states[ button ][0] &&
- srinput.button_states[ button ][1] )
- return 1;
- else
+static int button_up( enum sr_bind button )
+{
+ if( buttons_filter_fixed() )
return 0;
+
+ if( (skaterift.activity == k_skaterift_menu) && (button < k_srbind_mopen) && (vg_input.display_input_method != k_input_method_kbm) )
+ return 0;
+
+ if( !srinput.button_states[ button ][0] && srinput.button_states[ button ][1] )
+ return 1;
+
+ return 0;
}
/* State of button */
-static int button_press( enum sr_bind button ){
+static int button_press( enum sr_bind button )
+{
if( input_filter_generic() )
return 0;
- return
- srinput.button_states[ button ][0];
+
+ if( (skaterift.activity == k_skaterift_menu) && (button < k_srbind_mopen) && (vg_input.display_input_method != k_input_method_kbm))
+ return 0;
+
+ return srinput.button_states[ button ][0];
}
-static void joystick_state( enum sr_joystick joystick, v2f state ){
+static void joystick_state( enum sr_joystick joystick, v2f state )
+{
+ if( (skaterift.activity == k_skaterift_menu) && (vg_input.display_input_method != k_input_method_kbm) )
+ {
+ v2_zero( state );
+ return;
+ }
+
if( input_filter_generic() )
v2_zero( state );
else
v2_copy( srinput.joystick_states[ joystick ][0], state );
}
-static float axis_state( enum sr_axis axis ){
+static float axis_state( enum sr_axis axis )
+{
+ if( (skaterift.activity == k_skaterift_menu) && (axis < k_sraxis_mbrowse_h ) && (vg_input.display_input_method != k_input_method_kbm) )
+ return 0;
+
if( input_filter_generic() )
return 0.0f;
- else
- return srinput.axis_states[axis][0];
+
+ return srinput.axis_states[axis][0];
}
-static void skaterift_preupdate_inputs(void){
+static void skaterift_preupdate_inputs(void)
+{
if( srinput.state == k_input_state_resuming )
srinput.state = k_input_state_enabled;
if( srinput.state == k_input_state_resume )
srinput.state = k_input_state_resuming;
- for( u32 i=0; i<k_srbind_max; i++ ){
+ for( u32 i=0; i<k_srbind_max; i++ )
+ {
srinput.button_states[i][1] = srinput.button_states[i][0];
srinput.button_states[i][0] = 0;
}
- for( u32 i=0; i<k_srjoystick_max; i++ ){
+ for( u32 i=0; i<k_srjoystick_max; i++ )
+ {
v2_copy( srinput.joystick_states[i][0], srinput.joystick_states[i][1] );
v2_zero( srinput.joystick_states[i][0] );
}
- for( u32 i=0; i<k_sraxis_max; i++ ){
+ for( u32 i=0; i<k_sraxis_max; i++ )
+ {
srinput.axis_states[i][1] = srinput.axis_states[i][0];
srinput.axis_states[i][0] = 0.0f;
}
- for( int i=0; i<k_srbind_max; i++ ){
+ for( int i=0; i<k_srbind_max; i++ )
+ {
vg_input_op *prog = input_button_list[i];
- if( prog ){
- vg_exec_input_program( k_vg_input_type_button_u8, prog,
- &srinput.button_states[i][0] );
- }
+ if( prog )
+ vg_exec_input_program( k_vg_input_type_button_u8, prog, &srinput.button_states[i][0] );
}
- for( int i=0; i<k_sraxis_max; i++ ){
+ for( int i=0; i<k_sraxis_max; i++ )
+ {
vg_input_op *prog = input_axis_list[i];
- if( prog ){
- vg_exec_input_program( k_vg_input_type_axis_f32, prog,
- &srinput.axis_states[i][0] );
- }
+ if( prog )
+ vg_exec_input_program( k_vg_input_type_axis_f32, prog, &srinput.axis_states[i][0] );
}
- for( int i=0; i<k_srjoystick_max; i++ ){
+ for( int i=0; i<k_srjoystick_max; i++ )
+ {
vg_input_op *prog = input_joy_list[i];
- if( prog ){
- vg_exec_input_program( k_vg_input_type_joy_v2f, prog,
- srinput.joystick_states[i][0] );
- }
+ if( prog )
+ vg_exec_input_program( k_vg_input_type_joy_v2f, prog, srinput.joystick_states[i][0] );
}
f32 x = srinput.axis_states[k_sraxis_mbrowse_h][0],
y = srinput.axis_states[k_sraxis_mbrowse_v][0],
sensitivity = 0.35f;
- if( fabsf(x) > sensitivity ){
+ if( fabsf(x) > sensitivity )
+ {
if( x > 0.0f ) srinput.button_states[k_srbind_mright][0] = 1;
else srinput.button_states[k_srbind_mleft][0] = 1;
}
- if( fabsf(y) > sensitivity ){
+ if( fabsf(y) > sensitivity )
+ {
if( y > 0.0f ) srinput.button_states[k_srbind_mup][0] = 1;
else srinput.button_states[k_srbind_mdown][0] = 1;
}
}
}
-static void menu_close(void)
+void menu_close(void)
{
skaterift.activity = k_skaterift_default;
srinput.state = k_input_state_resume;
menu_open( k_menu_page_main );
return;
}
+
+ if( button_down( k_srbind_mquick ) )
+ {
+ menu_open( k_menu_page_quick );
+ return;
+ }
}
if( skaterift.activity != k_skaterift_menu )
goto menu_draw;
}
+ else if( menu.page == k_menu_page_quick )
+ {
+ ui_px pad = 64;
+ ui_rect panel = { 24, pad, 300, vg.window_y-(pad*2) };
+ ui_fill( ctx, panel, ui_opacity( GUI_COL_DARK, 0.35f ) );
+ ui_outline( ctx, panel, 1, GUI_COL_NORM, 0 );
+ ui_rect_pad( panel, (ui_px[]){8,8} );
+
+ ui_rect title;
+ ctx->font = &vgf_default_title;
+ ui_split( panel, k_ui_axis_h, 28*2, 0, title, panel );
+ ui_text( ctx, title, "Quick Menu", 1, k_ui_align_middle_center, 0 );
+
+ ctx->font = &vgf_default_large;
+
+ bool in_run = 0, in_challenge = 0, allow = 1;
+ if( (_world.time - _world.last_gate_hit_time) < 60.0 )
+ in_run = 1;
+ if( (_world.event == k_world_event_challenge) && (_world.challenge_state >= k_challenge_state_running) )
+ in_challenge = 1;
+
+ if( in_run || in_challenge )
+ ui_split( panel, k_ui_axis_h, 28*2, 0, title, panel );
+
+ if( in_run )
+ ui_text( ctx, title, "In Race", 1, k_ui_align_middle_center, 0 );
+ else if( in_challenge )
+ ui_text( ctx, title, "In Challenge", 1, k_ui_align_middle_center, 0 );
+
+ i32 R = 0;
+ if( in_run || in_challenge )
+ {
+ allow = 0;
+ R = menu_nav( &menu.quick_row, mv, 0 );
+ if( menu_button( ctx, panel, R == 0, 1, "Leave" ) )
+ {
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[0], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
+
+ if( in_challenge )
+ {
+ if( world_clear_event( k_world_event_challenge ) )
+ {
+ gui_helper_reset( k_gui_helper_mode_clear );
+ _world.challenge_state = k_challenge_state_none;
+ _world.active_challenge_id = 0;
+ _world.challenge_target = NULL;
+ _world.challenge_timer = 0.0f;
+ }
+ }
+ else
+ world_routes_clear( &_world.main );
+ }
+ }
+ else
+ R = menu_nav( &menu.quick_row, mv, 2 );
+
+ if( menu_button( ctx, panel, R == 0, allow && (localplayer.subsystem == k_player_subsystem_walk), "Set waypoint" ) )
+ {
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[0], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
+ player__set_waypoint();
+ }
+
+ if( menu_button( ctx, panel, R == 1, allow && localplayer.saved_waypoint, "Go to waypoint" ) )
+ {
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[2], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
+ player__spawn( &localplayer.waypoint );
+ localplayer.have_glider = localplayer.waypoint_with_glider;
+ menu_close();
+ }
+
+ if( menu_button( ctx, panel, R == 2, allow, "Spectate" ) )
+ {
+ menu_close();
+ }
+
+ if( button_down( k_srbind_mquick ) || button_down( k_srbind_mback ) )
+ {
+ vg_audio_lock();
+ vg_audio_oneshot( &audio_ui[3], 1.0f, 0.0f, 0, 0 );
+ vg_audio_unlock();
+ menu_close();
+ }
+
+ goto menu_draw;
+ }
/* TOP BAR
* -------------------------------------------------------------------*/
k_menu_page_credits,
k_menu_page_help,
k_menu_page_impromptu_guide,
+ k_menu_page_quick
};
enum menu_main_subpage
intro_row,
guide_sel,
prem_row,
- prof_row;
+ prof_row,
+ quick_row;
f32 mouse_dist; /* used for waking up mouse */
f32 repeater;
bool menu_button_rect( ui_context *ctx, ui_rect rect, bool select, bool clickable, const char *text );
//util
i32 menu_nav( i32 *p_row, int mv, i32 max );
+void menu_close(void);
vg_strcat( str, "No Connection" );
else if( state == k_ESteamNetworkingConnectionState_Connecting )
{
- vg_strcatf( str, "Connecting...\n%s", network_client.host_adress );
+ vg_strcatf( str, "Connecting... %s", network_client.host_adress );
if( network_client.retries )
{
void player__clean_refs(void)
{
- // FIXME
- //replay_clear( &player_replay.local );
gui_helper_reset( k_gui_helper_mode_clear );
_world.challenge_target = NULL;
world_routes_clear( &_world.main );
}
+void player__clear_world_dependent_variables(void)
+{
+ localplayer.saved_waypoint = 0;
+}
+
void player__reset(void)
{
v3_zero( localplayer.rb.v );
player__reset();
}
+void player__set_waypoint(void)
+{
+ localplayer.saved_waypoint = 1;
+ localplayer.waypoint_with_glider = localplayer.have_glider;
+ q_copy( localplayer.rb.q, localplayer.waypoint.transform.q );
+ v3_copy( localplayer.rb.co, localplayer.waypoint.transform.co );
+}
void player__kill(void)
{
rigidbody rb;
v3f angles;
- bool have_glider, glider_orphan, drowned;
+ bool have_glider, glider_orphan, drowned, saved_waypoint, waypoint_with_glider;
+ ent_spawn waypoint;
/*
* Camera management
void player__im_gui( ui_context *ctx );
void player__setpos( v3f pos );
void player__spawn( ent_spawn *rp );
+void player__set_waypoint(void);
void player__clean_refs(void);
+void player__clear_world_dependent_variables(void);
void player__reset(void);
void player__kill(void);
void player__begin_holdout( v3f offset );
player_dead.helper_getup->greyed = 1;
}
-
- //if( gui_new_helper(input_button_list[k_srbind_dead_respawn], &str ))
- // vg_strcat( &str, "Spawn" );
}
void player__dead_animator_exchange( bitpack_ctx *ctx, void *data )
player_walk_drop_in_vector( localplayer.rb.v );
return 1;
}
- else{
+ else
vg_error( "failed to find intersection of drop in\n" );
- }
}
return 0;
}
-static bool player__preupdate_anim( struct skeleton_anim *anim, f32 *t,
- f32 speed ){
+static bool player__preupdate_anim( struct skeleton_anim *anim, f32 *t, f32 speed )
+{
f32 length = (f32)(anim->strip->length-1) / anim->framerate;
*t += (vg.time_delta * speed) / length;
-
if( *t >= 1.0f ) return 1;
else return 0;
}
v2f steer;
joystick_state( k_srjoystick_steer, steer );
-
vg_slewf( &w->state.transition_t, 1.0f, vg.time_delta );
- if( button_down(k_srbind_sit) || (v2_length2(steer)>0.2f) ||
- button_down(k_srbind_jump) ){
+ if( button_down(k_srbind_sit) || (v2_length2(steer)>0.2f) || button_down(k_srbind_jump) )
w->state.activity = k_walk_activity_sit_up;
- }
return;
}
struct player_walk *w = &player_walk;
bool finished = player__preupdate_anim( &w->anim_jump_to_air, &w->state.transition_t, 1.0f );
if( finished )
- {
player_walk_generic_to_skate( k_skate_activity_air, player_walk.animator.board_yaw );
- }
}
-static void player_walk_pre_running_start(void){
+static void player_walk_pre_running_start(void)
+{
struct player_walk *w = &player_walk;
bool finished = player__preupdate_anim( &w->anim_intro,
&w->state.transition_t, 1.0f );
- if( finished ){
- /* TODO: get the derivative of the last keyframes to calculate new
- * velocity for player */
- player_walk_generic_to_skate( k_skate_activity_ground,
- player_walk.animator.board_yaw+1.0f );
- }
+ if( finished )
+ player_walk_generic_to_skate( k_skate_activity_ground, player_walk.animator.board_yaw+1.0f );
}
static void player_walk_pre_popoff(void){
}
}
-void player__walk_pre_update(void){
+void player__walk_pre_update(void)
+{
struct player_walk *w = &player_walk;
-
- if( localplayer.immobile ) return;
+ if( localplayer.immobile )
+ return;
else player_look( localplayer.angles, skaterift.time_rate );
-
enum walk_activity a = w->state.activity;
-
if ( a == k_walk_activity_sit ) player_walk_pre_sit();
else if( a == k_walk_activity_sit_up ) player_walk_pre_sit_up();
else if( a == k_walk_activity_ground ) player_walk_pre_ground();
return n[1] > 0.70710678118f;
}
-static void player_accelerate( v3f v, v3f movedir, f32 speed, f32 accel ){
- float currentspeed = v3_dot( v, movedir ),
- addspeed = speed - currentspeed;
-
+static void player_accelerate( v3f v, v3f movedir, f32 speed, f32 accel )
+{
+ f32 currentspeed = v3_dot( v, movedir ),
+ addspeed = speed - currentspeed;
if( addspeed <= 0 )
return;
- float accelspeed = accel * vg.time_fixed_delta * speed;
-
+ f32 accelspeed = accel * vg.time_fixed_delta * speed;
if( accelspeed > addspeed )
accelspeed = addspeed;
-
v3_muladds( v, movedir, accelspeed, v );
}
-static void player_friction( v3f v, f32 friction ){
- float speed = v3_length( v ),
- drop = 0.0f,
- control = vg_maxf( speed, k_stopspeed );
+static void player_friction( v3f v, f32 friction )
+{
+ f32 speed = v3_length( v ),
+ drop = 0.0f,
+ control = vg_maxf( speed, k_stopspeed );
if( speed < 0.04f )
return;
drop += control * friction * vg.time_fixed_delta;
-
float newspeed = vg_maxf( 0.0f, speed - drop );
newspeed /= speed;
-
v3_muls( v, newspeed, v );
}
-static void player_walk_custom_filter( world_instance *world,
- rb_ct *man, int len, f32 w ){
- for( int i=0; i<len; i++ ){
+static void player_walk_custom_filter( world_instance *world, rb_ct *man, int len, f32 w )
+{
+ for( int i=0; i<len; i++ )
+ {
rb_ct *ci = &man[i];
- if( ci->type == k_contact_type_disabled ||
- ci->type == k_contact_type_edge )
+ if( ci->type == k_contact_type_disabled || ci->type == k_contact_type_edge )
continue;
-
- float d1 = v3_dot( ci->co, ci->n );
-
- for( int j=0; j<len; j++ ){
+ f32 d1 = v3_dot( ci->co, ci->n );
+ for( int j=0; j<len; j++ )
+ {
if( j == i )
continue;
*sj = world_contact_surface( world, cj );
if( (sj->info.flags & k_material_flag_walking) &&
- !(si->info.flags & k_material_flag_walking)){
+ !(si->info.flags & k_material_flag_walking))
continue;
- }
float d2 = v3_dot( cj->co, ci->n ),
d = d2-d1;
- if( fabsf( d ) <= w ){
+ if( fabsf( d ) <= w )
cj->type = k_contact_type_disabled;
- }
}
}
}
-static void player_walk_update_generic(void){
+static void player_walk_update_generic(void)
+{
struct player_walk *w = &player_walk;
-
- if( (w->state.activity != k_walk_activity_oregular) &&
- (w->state.activity != k_walk_activity_oair) ){
+ if( (w->state.activity != k_walk_activity_oregular) && (w->state.activity != k_walk_activity_oair) )
+ {
joystick_state( k_srjoystick_steer, w->state.steer );
w->state.steer[2] = button_press(k_srbind_run)? k_runspeed: k_walkspeed;
if( v2_length2(w->state.steer)>1.0f )
v3_zero( localplayer.rb.w );
world_instance *world = &_world.main;
- if( !world_water_player_safe( world, 0.4f ) ) return;
+ if( !world_water_player_safe( world, 0.4f ) )
+ return;
enum walk_activity prev_state = w->state.activity;
w->state.activity = k_walk_activity_air;
w->surface = k_surface_prop_concrete;
- for( int i=0; i<len; i++ ){
+ for( int i=0; i<len; i++ )
+ {
rb_ct *ct = &manifold[i];
rb_debug_contact( ct );
-
- if( player_walk_normal_standable( ct->n ) ){
+ if( player_walk_normal_standable( ct->n ) )
+ {
w->state.activity = k_walk_activity_ground;
-
v3_add( surface_avg, ct->n, surface_avg );
-
struct world_surface *surf = world_contact_surface( world, ct );
if( surf->info.surface_prop > w->surface )
w->surface = surf->info.surface_prop;
v3_muls( right_dir, w->state.steer[0], movedir );
v3_muladds( movedir, forward_dir, w->state.steer[1], movedir );
- if( w->state.activity == k_walk_activity_ground ){
+ if( w->state.activity == k_walk_activity_ground )
+ {
v3_normalize( surface_avg );
v3f tx, ty;
v3_tangent_basis( surface_avg, tx, ty );
- if( v2_length2(w->state.steer) > 0.001f ){
+ if( v2_length2(w->state.steer) > 0.001f )
+ {
/* clip movement to the surface */
float d = v3_dot(surface_avg,movedir);
v3_muladds( movedir, surface_avg, -d, movedir );
nominal_speed = w->state.steer[2];
/* jump */
- if( w->state.jump_queued ){
+ if( w->state.jump_queued )
+ {
w->state.jump_queued = 0;
-
f32 t = vg.time - w->state.jump_input_time;
- if( t < PLAYER_JUMP_EPSILON ){
+ if( t < PLAYER_JUMP_EPSILON )
+ {
localplayer.rb.v[1] = 5.0f;
w->state.activity = k_walk_activity_air;
prev_state = k_walk_activity_air;
nominal_speed = k_airspeed;
}
}
- else{
+ else
player_friction( localplayer.rb.v, k_walk_friction );
- }
}
- else{
+ else
+ {
accel_speed = k_walk_air_accel;
nominal_speed = k_airspeed;
}
- if( v2_length2( w->state.steer ) > 0.001f ){
- player_accelerate( localplayer.rb.v, movedir,
- nominal_speed, accel_speed );
+ if( v2_length2( w->state.steer ) > 0.001f )
+ {
+ player_accelerate( localplayer.rb.v, movedir, nominal_speed, accel_speed );
v3_normalize( movedir );
}
_replay2.final_mtx = vg_linear_alloc( vg_mem.rtmemory, mtx_size );
}
+void _replay2_clear_local_buffer(void)
+{
+ vg_queue_clear( &_replay2.buffer );
+}
+
static vg_queue *_replay2_player_buffer(void)
{
return _replay2.type == k_replay_type_local? &_replay2.buffer: &_remote_replay.buffer;
if( bounds & NETMSG_GATE_BOUNDARY_BIT )
t = 1.0f;
- v2f angles;
- v2_lerp( _remote_replay.cam0, _remote_replay.cam1, t, angles );
+ v3f angles;
+ angles[0] = vg_alerpf( _remote_replay.cam0[0], _remote_replay.cam1[0], t );
+ angles[1] = vg_lerpf( _remote_replay.cam0[1], _remote_replay.cam1[1], t );
+ angles[2] = 0.0f;
/* position */
v3f fpv_pos, fpv_offset;
v3_add( tpv_origin, tpv_offset, tpv_pos );
v3_lerp( tpv_pos, fpv_pos, cc.camera_type_blend, _replay2.playback_cam.pos );
v2_copy( angles, _replay2.playback_cam.angles );
+
f32 fov_skate = vg_lerpf( 97.0f, 135.0f, k_fov ),
fov_walk = vg_lerpf( 90.0f, 110.0f, k_fov );
_replay2.playback_cam.fov = vg_lerpf( fov_walk, fov_skate, cc.camera_type_blend );
void _replay2_get_camera( vg_camera *cam );
void _replay2_decode(void);
void _replay2_record_local_frame(void);
+void _replay2_clear_local_buffer(void);
#include "compass.h"
#include "replay2.h"
#include "user_profile.h"
+#include "ent_route.h"
struct skaterift_globals skaterift =
{
cutscene_update( vg.time_rate * vg.time_frame_delta );
- if( skaterift.activity != k_skaterift_menu )
- {
+ if( !((skaterift.activity == k_skaterift_menu) && (menu.page != k_menu_page_quick)) )
player__pre_update();
- }
_replay2_pre_update();
remote_sfx_pre_update();
v3_copy( localplayer.rb.co, listen_co );
if( skaterift.activity & k_skaterift_menu )
{
- if( menu.bg_cam )
+ if( menu.page != k_menu_page_quick )
{
- v3_copy( menu.bg_cam->co, listen_co );
+ if( menu.bg_cam )
+ v3_copy( menu.bg_cam->co, listen_co );
+ else target = 0;
}
- else target = 0;
}
audio_ambient_sprites_update( &_world.main, listen_co );
return;
}
+ if( skaterift.activity == k_skaterift_replay )
+ return;
+
static vg_camera small_cam; /* DOES NOT NEED TO BE STATIC BUT MINGW
SAIS OTHERWISE */
player__render( &small_cam );
}
-
-
-
static void render_scene(void)
{
}
world_instance *world = &_world.main;
world_routes_imgui( ctx, world );
+ _ent_route_imgui( ctx );
//skaterift_replay_imgui( ctx );
_replay2_imgui( ctx );
workshop_form_gui( ctx );
_world.previous_world_addon = _world.main.addon_id;
_vg_tower_set_flag( skaterift.sig_world, 0 );
+ _replay2_clear_local_buffer();
_world.loader_state = k_world_loader_saving_current;
_world.event = k_world_event_none;
+ player__clear_world_dependent_variables();
vg_loader_set_user_information( "Saving current world" );
}
else
}
_world.current_run_version += 4;
+ _world.last_gate_hit_time = -9999.9;
}
static void world_routes_time_lap( world_instance *world, ent_route *route )
ui_point cursor = { 4, 4 };
for( u32 i=0; i<af_arrcount(&world->ent_route); i++ )
- {
ent_route_imgui( ctx, world, af_arritm( &world->ent_route, i ), cursor );
- }
ui_flush( ctx, k_ui_shader_colour, NULL );
vg_ui.colour[3] = 1.0f;