From 7ccbfdd0b7717b5a906a4d4309324782d1fe73e8 Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 17 Nov 2023 03:56:41 +0000 Subject: [PATCH] update helpers --- ent_challenge.c | 12 ++++-- ent_route.c | 19 +++++++-- ent_route.h | 5 +++ ent_skateshop.c | 58 +++++++++++++------------- ent_skateshop.h | 8 +--- gui.h | 107 ++++++++++++++++++++++++++---------------------- input.h | 54 +++++++++++++----------- menu.h | 26 +++++------- player_replay.c | 70 +++++++++++++++++++++---------- respawn.c | 21 +++++++--- skaterift.c | 15 +------ skaterift.h | 1 + 12 files changed, 225 insertions(+), 171 deletions(-) diff --git a/ent_challenge.c b/ent_challenge.c index 10196bf..b8f2f5e 100644 --- a/ent_challenge.c +++ b/ent_challenge.c @@ -27,6 +27,13 @@ static void ent_challenge_call( world_instance *world, ent_call *call ){ (world_static.challenge_target == NULL) ){ world_static.challenge_target = NULL; world_entity_focus( call->id ); + + gui_helper_clear(); + vg_str text; + if( gui_new_helper( input_button_list[k_srbind_maccept], &text )) + vg_strcat( &text, "start" ); + if( gui_new_helper( input_button_list[k_srbind_mback], &text )) + vg_strcat( &text, "exit" ); } } else { @@ -68,9 +75,6 @@ static void ent_challenge_preupdate( ent_challenge *challenge, int active ){ world_entity_focus_camera( world, challenge->camera ); - gui_helper_action( button_display_string( k_srbind_maccept ), "start" ); - gui_helper_action( button_display_string( k_srbind_mback ), "exit" ); - if( mdl_entity_id_type( challenge->first ) == k_ent_objective ){ if( button_down( k_srbind_maccept ) ){ u32 index = mdl_entity_id_id( challenge->first ); @@ -78,6 +82,7 @@ static void ent_challenge_preupdate( ent_challenge *challenge, int active ){ index ); world_static.challenge_timer = 0.0f; world_entity_unfocus(); + gui_helper_clear(); u32 next = challenge->first; while( mdl_entity_id_type(next) == k_ent_objective ){ @@ -95,6 +100,7 @@ static void ent_challenge_preupdate( ent_challenge *challenge, int active ){ if( button_down( k_srbind_mback ) ){ world_static.challenge_target = NULL; world_entity_unfocus(); + gui_helper_clear(); audio_oneshot( &audio_challenge[4], 1.0f, 0.0f ); return; } diff --git a/ent_route.c b/ent_route.c index 1f0bbed..1ef9f1d 100644 --- a/ent_route.c +++ b/ent_route.c @@ -12,6 +12,20 @@ static void ent_route_call( world_instance *world, ent_call *call ){ if( call->function == 0 ){ /* view() */ if( localplayer.subsystem == k_player_subsystem_walk ){ world_entity_focus( call->id ); + + gui_helper_clear(); + vg_str text; + + if( (global_ent_route.helper_weekly = + gui_new_helper( input_button_list[k_srbind_mleft], &text ))) + vg_strcat( &text, "weekly" ); + + if( (global_ent_route.helper_alltime = + gui_new_helper( input_button_list[k_srbind_mright], &text ))) + vg_strcat( &text, "all time" ); + + if( gui_new_helper( input_button_list[k_srbind_mback], &text ) ) + vg_strcat( &text, "exit" ); } } else { @@ -33,10 +47,6 @@ static void ent_route_preupdate( ent_route *route, int active ){ world_entity_focus_camera( world, cam_id ); - gui_helper_action( button_display_string( k_srbind_mleft ), "weekly" ); - gui_helper_action( button_display_string( k_srbind_mright ), "all time" ); - gui_helper_action( button_display_string( k_srbind_mback ), "exit" ); - if( button_down( k_srbind_mleft ) ){ world_sfd.view_weekly = 1; world_sfd_compile_active_scores(); @@ -49,6 +59,7 @@ static void ent_route_preupdate( ent_route *route, int active ){ if( button_down( k_srbind_mback ) ){ world_entity_unfocus(); + gui_helper_clear(); return; } } diff --git a/ent_route.h b/ent_route.h index 786d850..65c074f 100644 --- a/ent_route.h +++ b/ent_route.h @@ -3,6 +3,11 @@ #include "entity.h" +static struct { + struct gui_helper *helper_weekly, *helper_alltime; +} +global_ent_route; + static void ent_route_call( world_instance *world, ent_call *call ); static void ent_route_preupdate( ent_route *route, int active ); diff --git a/ent_skateshop.c b/ent_skateshop.c index bfec73f..8a03ff1 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -220,13 +220,8 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){ if( shop->type == k_skateshop_type_boardshop ){ if( !vg_loader_availible() ) return; - gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" ); - gui_helper_action( button_display_string( k_srbind_mback ), "exit" ); - u16 cache_id = skateshop_selected_cache_id(); - if( cache_id ){ - gui_helper_action( button_display_string( k_srbind_maccept ), "pick" ); - } + global_skateshop.helper_pick->greyed = !cache_id; /* * Controls @@ -264,6 +259,7 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){ network_send_item( k_netmsg_playeritem_board ); world_entity_unfocus(); + gui_helper_clear(); skaterift_autosave(1); return; } @@ -271,10 +267,6 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){ else if( shop->type == k_skateshop_type_charshop ){ if( !vg_loader_availible() ) return; - gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" ); - gui_helper_action( button_display_string( k_srbind_mback ), "exit" ); - gui_helper_action( button_display_string( k_srbind_maccept ), "pick" ); - int changed = 0; if( button_down( k_srbind_mleft ) ){ @@ -309,22 +301,21 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){ if( button_down( k_srbind_maccept ) ){ network_send_item( k_netmsg_playeritem_player ); world_entity_unfocus(); + gui_helper_clear(); } } else if( shop->type == k_skateshop_type_worldshop ){ int browseable = 0, loadable = 0; - if( addon_count(k_addon_type_world) && vg_loader_availible() ){ - gui_helper_action( axis_display_string(k_sraxis_mbrowse_h), "browse" ); + if( addon_count(k_addon_type_world) && vg_loader_availible() ) browseable = 1; - } - if( vg_loader_availible() && global_skateshop.selected_world_id > 0 ){ - gui_helper_action( button_display_string(k_srbind_maccept), - "open rift" ); + if( vg_loader_availible() && global_skateshop.selected_world_id > 0 ) loadable = 1; - } + + global_skateshop.helper_browse->greyed = !browseable; + global_skateshop.helper_pick->greyed = !loadable; int change = 0; @@ -393,6 +384,7 @@ static void ent_skateshop_preupdate( ent_skateshop *shop, int active ){ network_send_item( k_netmsg_playeritem_player ); world_entity_unfocus(); + gui_helper_clear(); return; } } @@ -668,6 +660,23 @@ static void skateshop_render( ent_skateshop *shop ){ vg_fatal_error( "Unknown store (%u)\n", shop->type ); } +static void ent_skateshop_helpers_pickable( const char *acceptance ){ + vg_str text; + + if( gui_new_helper( input_button_list[k_srbind_mback], &text )) + vg_strcat( &text, "exit" ); + + if( (global_skateshop.helper_pick = gui_new_helper( + input_button_list[k_srbind_maccept], &text))){ + vg_strcat( &text, acceptance ); + } + + if( (global_skateshop.helper_browse = gui_new_helper( + input_axis_list[k_sraxis_mbrowse_h], &text ))){ + vg_strcat( &text, "browse" ); + } +} + /* * Entity logic: entrance event */ @@ -685,25 +694,18 @@ static void ent_skateshop_call( world_instance *world, ent_call *call ){ vg_info( "Entering skateshop\n" ); world_entity_focus( call->id ); -#if 0 - localplayer.immobile = 1; - menu.disable_open = 1; - skaterift.activity = k_skaterift_skateshop; - - v3_zero( localplayer.rb.v ); - v3_zero( localplayer.rb.w ); - localplayer._walk.move_speed = 0.0f; - global_skateshop.ptr_ent = shop; -#endif + gui_helper_clear(); if( shop->type == k_skateshop_type_boardshop ){ skateshop_update_viewpage(); skateshop_op_board_scan(); + ent_skateshop_helpers_pickable( "pick" ); } else if( shop->type == k_skateshop_type_charshop ){ - + ent_skateshop_helpers_pickable( "pick" ); } else if( shop->type == k_skateshop_type_worldshop ){ + ent_skateshop_helpers_pickable( "open rift" ); pointcloud_animate( k_pointcloud_anim_opening ); skateshop_op_world_scan(); } diff --git a/ent_skateshop.h b/ent_skateshop.h index 3866021..81be2e8 100644 --- a/ent_skateshop.h +++ b/ent_skateshop.h @@ -13,12 +13,6 @@ struct{ v3f look_target; -#if 0 - ent_skateshop *ptr_ent; /* TODO */ - float factive; /* TODO */ - camera cam; -#endif - struct shop_view_slot{ u16 cache_id; float view_blend; @@ -38,6 +32,8 @@ struct{ u32 world_reg; } render; + + struct gui_helper *helper_pick, *helper_browse; } static global_skateshop={.render={.reg_id=0xffffffff,.world_reg=0xffffffff}}; diff --git a/gui.h b/gui.h index 7c2dbb6..30664d8 100644 --- a/gui.h +++ b/gui.h @@ -17,13 +17,19 @@ enum gui_icon { k_gui_icon_count, }; +#define GUI_HELPER_TEXT_LENGTH 32 + struct{ struct gui_helper{ - const char *bindstr, *text; + vg_input_op *binding; + char text[GUI_HELPER_TEXT_LENGTH]; + int greyed; } helpers[4]; u32 helper_count; + int active_positional_helper; + struct icon_call { enum gui_icon icon; v4f location; @@ -42,15 +48,6 @@ struct{ font3d font; v3f trick_co; - enum guitrick_type{ - k_guitrick_type_none, - k_guitrick_type_ollie, - k_guitrick_type_trick, - k_guitrick_type_backflip, - k_guitrick_type_pump, - k_guitrick_type_isc - } - trick_type; mdl_context model_icons; GLuint icons_texture; @@ -60,41 +57,28 @@ struct{ } static gui = {.cur_icon_colour = {1.0f,1.0f,1.0f,1.0f},.colour_changed=1}; -static -void gui_helper_action( const char *bindstr, const char *text ){ +static void gui_helper_clear(void){ + gui.helper_count = 0; + gui.active_positional_helper = 0; +} + +static struct gui_helper *gui_new_helper( vg_input_op *bind, vg_str *out_text ){ if( gui.helper_count >= vg_list_size(gui.helpers) ){ vg_error( "Too many helpers\n" ); - return; + return NULL; } struct gui_helper *helper = &gui.helpers[ gui.helper_count ++ ]; - helper->bindstr = bindstr; - helper->text = text; + helper->greyed = 0; + helper->binding = bind; + vg_strnull( out_text, helper->text, sizeof(helper->text) ); + return helper; } static void gui_draw(void){ - if( v3_dist2(localplayer.rb.co,gui.trick_co) > 2.0f ){ - gui.trick_type = k_guitrick_type_none; - } - - if( gui.trick_type == k_guitrick_type_pump ){ - gui_helper_action(axis_display_string(k_sraxis_grab),"Crouch"); - } - else if( gui.trick_type == k_guitrick_type_backflip ){ - gui_helper_action(joystick_display_string(k_srjoystick_steer,1),"Flip"); - } - else if( gui.trick_type == k_guitrick_type_ollie ){ - gui_helper_action(button_display_string(k_srbind_jump),"Ollie"); - } - else if( gui.trick_type == k_guitrick_type_trick ){ - gui_helper_action(button_display_string(k_srbind_trick0),"Shuvit"); - gui_helper_action(button_display_string(k_srbind_trick1),"Kickflip"); - gui_helper_action(button_display_string(k_srbind_trick2),"Tre-Flip"); - } - else if( gui.trick_type == k_guitrick_type_isc ){ - gui_helper_action(button_display_string(k_srbind_camera),"Camera"); - gui_helper_action(button_display_string(k_srbind_use), "Skate/Walk"); - } + if( gui.active_positional_helper && + (v3_dist2(localplayer.rb.co,gui.trick_co) > 2.0f) ) + gui_helper_clear(); camera ortho; @@ -210,8 +194,13 @@ static void gui_draw(void){ for( u32 i=0; ibindstr, &ortho, mmdl ); + char buf[32]; + vg_str str; + vg_strnull( &str, buf, sizeof(buf) ); + vg_input_string( &str, helper->binding, 1 ); + + font3d_setcolour( (v4f){1.0f,1.0f,1.0f, helper->greyed? 0.5f: 1.0f} ); + font3d_simple_draw( 2, buf, &ortho, mmdl ); const char *make_smaller = "\x02\xaf\x03 "; font3d_draw( make_smaller ); @@ -220,8 +209,6 @@ static void gui_draw(void){ float w = gui_font3d.offset[0]+1.0f; mmdl[3][0] += w*scale; } - - gui.helper_count = 0; } static int gui_location_print_ccmd( int argc, const char *argv[] ){ @@ -242,15 +229,39 @@ static int gui_location_print_ccmd( int argc, const char *argv[] ){ static int gui_showtrick_ccmd( int argc, const char *argv[] ){ if( argc == 1 ){ - enum guitrick_type type = k_guitrick_type_none; - if( !strcmp( argv[0], "pump" ) ) type = k_guitrick_type_pump; - else if( !strcmp( argv[0], "flip" ) ) type = k_guitrick_type_backflip; - else if( !strcmp( argv[0], "ollie" ) ) type = k_guitrick_type_ollie; - else if( !strcmp( argv[0], "trick" ) ) type = k_guitrick_type_trick; - else if( !strcmp( argv[0], "misc" ) ) type = k_guitrick_type_isc; + gui_helper_clear(); + vg_str text; + + if( !strcmp( argv[0], "pump" ) ){ + if( gui_new_helper( input_axis_list[k_sraxis_grab], &text ) ) + vg_strcat( &text, "Pump" ); + } + else if( !strcmp( argv[0], "flip" ) ){ + if( gui_new_helper( input_joy_list[k_srjoystick_steer], &text ) ) + vg_strcat( &text, "Flip" ); + } + else if( !strcmp( argv[0], "ollie" ) ){ + if( gui_new_helper( input_button_list[k_srbind_jump], &text ) ) + vg_strcat( &text, "Ollie" ); + } + else if( !strcmp( argv[0], "trick" ) ){ + if( gui_new_helper( input_button_list[k_srbind_trick0], &text ) ) + vg_strcat( &text, "Shuvit" ); + if( gui_new_helper( input_button_list[k_srbind_trick1], &text ) ) + vg_strcat( &text, "Kickflip" ); + if( gui_new_helper( input_button_list[k_srbind_trick2], &text ) ) + vg_strcat( &text, "Tre-Flip" ); + } + else if( !strcmp( argv[0], "misc" ) ){ + if( gui_new_helper( input_button_list[k_srbind_camera], &text ) ) + vg_strcat( &text, "Camera" ); + if( gui_new_helper( input_button_list[k_srbind_use], &text ) ) + vg_strcat( &text, "Skate/Walk" ); + } else return 1; - gui.trick_type = type; + v3_copy( localplayer.rb.co, gui.trick_co ); + gui.active_positional_helper = 1; return 0; } return 1; diff --git a/input.h b/input.h index cdb93a3..1595325 100644 --- a/input.h +++ b/input.h @@ -49,8 +49,6 @@ enum sr_axis{ k_sraxis_mbrowse_h, k_sraxis_mbrowse_v, k_sraxis_replay_h, - k_sraxis_mworld_h, - k_sraxis_max }; @@ -70,7 +68,7 @@ static vg_input_op *input_button_list[] = { vg_joy_button, SDL_CONTROLLER_BUTTON_B, vg_end }, [k_srbind_trick2] = (vg_input_op[]){ - vg_mode_mul, vg_mouse, SDL_BUTTON_LEFT, vg_mouse, SDL_BUTTON_RIGHT, + vg_mouse, SDL_BUTTON_LEFT, vg_mode_mul, vg_mouse, SDL_BUTTON_RIGHT, vg_mode_absmax, vg_joy_button, SDL_CONTROLLER_BUTTON_X, vg_end }, [k_srbind_use] = INPUT_BASIC( SDLK_e, SDL_CONTROLLER_BUTTON_Y ), @@ -88,7 +86,9 @@ static vg_input_op *input_button_list[] = { [k_srbind_mback] = INPUT_BASIC( SDLK_ESCAPE, SDL_CONTROLLER_BUTTON_B ), [k_srbind_mopen] = INPUT_BASIC( SDLK_ESCAPE, SDL_CONTROLLER_BUTTON_START ), [k_srbind_maccept] = (vg_input_op[]){ - vg_keyboard, SDLK_e, vg_keyboard, SDLK_RETURN, vg_keyboard, SDLK_RETURN2, + vg_keyboard, SDLK_e, vg_gui_visible, 0, + vg_keyboard, SDLK_RETURN, vg_keyboard, SDLK_RETURN2, + vg_gui_visible, 1, vg_joy_button, SDL_CONTROLLER_BUTTON_A, vg_end }, [k_srbind_replay_play] = INPUT_BASIC( SDLK_g, SDL_CONTROLLER_BUTTON_X ), @@ -106,8 +106,8 @@ static vg_input_op *input_axis_list[] = { vg_joy_axis, SDL_CONTROLLER_AXIS_TRIGGERRIGHT, vg_end }, [k_sraxis_mbrowse_h] = (vg_input_op[]){ - vg_mode_add, vg_keyboard, SDLK_RIGHT, vg_mode_sub, vg_keyboard, SDLK_LEFT, + vg_mode_add, vg_keyboard, SDLK_RIGHT, vg_mode_absmax, vg_joy_axis, SDL_CONTROLLER_AXIS_LEFTX, vg_end }, @@ -131,21 +131,16 @@ static vg_input_op *input_joy_list[] = { [k_srjoystick_steer] = (vg_input_op[]){ vg_index, 0, vg_mode_add, vg_keyboard, SDLK_d, vg_mode_sub, vg_keyboard, SDLK_a, - vg_mode_absmax, vg_joy_axis, SDL_CONTROLLER_AXIS_LEFTX, vg_index, 1, vg_mode_add, vg_keyboard, SDLK_s, vg_mode_sub, vg_keyboard, SDLK_w, - vg_mode_absmax, vg_joy_axis, SDL_CONTROLLER_AXIS_LEFTY, + vg_mode_absmax, vg_joy_ls, vg_end }, [k_srjoystick_grab] = (vg_input_op[]){ - vg_index, 0, vg_mode_absmax, vg_joy_axis, SDL_CONTROLLER_AXIS_RIGHTX, - vg_index, 1, vg_mode_absmax, vg_joy_axis, SDL_CONTROLLER_AXIS_RIGHTY, - vg_end + vg_joy_rs, vg_end }, [k_srjoystick_look] = (vg_input_op[]){ - vg_index, 0, vg_mode_absmax, vg_joy_axis, SDL_CONTROLLER_AXIS_RIGHTX, - vg_index, 1, vg_mode_absmax, vg_joy_axis, SDL_CONTROLLER_AXIS_RIGHTY, - vg_end + vg_joy_rs, vg_end }, [k_srjoystick_max]=NULL }; @@ -158,12 +153,14 @@ struct { enum input_state { k_input_state_enabled, k_input_state_resume, + k_input_state_resuming, k_input_state_pause } state; } static srinput; +#if 0 static const char *controller_glyphs[ SDL_CONTROLLER_BUTTON_MAX ][2] = { /* xbox/generic playstation */ [ SDL_CONTROLLER_BUTTON_A ] = { "\x1e\x85","\x1e\x82" }, @@ -274,7 +271,6 @@ static const char *axis_display_string( enum sr_axis axis ) [k_sraxis_mbrowse_h] = "\x88", [k_sraxis_mbrowse_v] = "\x89", [k_sraxis_replay_h] = "\x8f\x90", - [k_sraxis_mworld_h] = "\x93\x95" }; const char *keyboard_table[ k_sraxis_max ] = { @@ -282,7 +278,6 @@ static const char *axis_display_string( enum sr_axis axis ) [k_sraxis_mbrowse_h] = KEYBOARD_GLYPH("\x93")KEYBOARD_GLYPH("\x95"), [k_sraxis_mbrowse_v] = KEYBOARD_GLYPH("\x96")KEYBOARD_GLYPH("\x94"), [k_sraxis_replay_h] = KEYBOARD_GLYPH("Q")KEYBOARD_GLYPH("E"), - [k_sraxis_mworld_h] = KEYBOARD_GLYPH("\x93")KEYBOARD_GLYPH("\x95"), }; if( vg_input.display_input_method == k_input_method_controller ) @@ -314,6 +309,7 @@ static const char *joystick_display_string( enum sr_joystick joystick, return controller_table[ joystick ][axis]; else return keyboard_table[ joystick ][axis]; } +#endif static int input_filter_generic(void){ if( srinput.state != k_input_state_enabled || @@ -378,15 +374,13 @@ static float axis_state( enum sr_axis axis ){ return srinput.axis_states[axis][0]; } -static void setbtn( enum sr_bind button, u8 value ) -{ - srinput.button_states[button][0] |= value; -} - static void skaterift_preupdate_inputs(void){ - if( srinput.state == k_input_state_resume ) + 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 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( y > 0.0f ) srinput.button_states[k_srbind_mup][0] = 1; + else srinput.button_states[k_srbind_mdown][0] = 1; + } } #endif /* INPUT_H */ diff --git a/menu.h b/menu.h index 5143c51..5218485 100644 --- a/menu.h +++ b/menu.h @@ -781,38 +781,32 @@ static void menu_render(void){ } static void menu_binding_string( char buf[128], u32 pstr ){ - vg_strncpy( "error", buf, 128, k_strncpy_allow_cutoff ); + vg_str str; + vg_strnull( &str, buf, 128 ); if( MDL_CONST_PSTREQ( &menu.model, pstr, "bind_jump" ) ){ - vg_strncpy( button_display_string(k_srbind_jump), buf, 128, - k_strncpy_allow_cutoff ); + vg_input_string( &str, input_button_list[k_srbind_jump], 1 ); } else if( MDL_CONST_PSTREQ( &menu.model, pstr, "bind_trick0" ) ){ - vg_str str; - vg_strnull( &str, buf, 128 ); vg_strcat( &str, "SHUVIT " ); - vg_strcat( &str, button_display_string(k_srbind_trick0) ); + vg_input_string( &str, input_button_list[k_srbind_trick0], 1 ); } else if( MDL_CONST_PSTREQ( &menu.model, pstr, "bind_trick1" ) ){ - vg_str str; - vg_strnull( &str, buf, 128 ); vg_strcat( &str, "KICKFLIP " ); - vg_strcat( &str, button_display_string(k_srbind_trick1) ); + vg_input_string( &str, input_button_list[k_srbind_trick1], 1 ); } else if( MDL_CONST_PSTREQ( &menu.model, pstr, "bind_trick2" ) ){ - vg_str str; - vg_strnull( &str, buf, 128 ); vg_strcat( &str, "TREFLIP " ); - vg_strcat( &str, button_display_string(k_srbind_trick2) ); + vg_input_string( &str, input_button_list[k_srbind_trick2], 1 ); } else if( MDL_CONST_PSTREQ( &menu.model, pstr, "bind_grab" ) ){ - vg_strncpy( axis_display_string(k_sraxis_grab), buf, 128, - k_strncpy_allow_cutoff ); + vg_input_string( &str, input_axis_list[k_sraxis_grab], 1 ); } else if( MDL_CONST_PSTREQ( &menu.model, pstr, "bind_grab_mod" ) ){ - vg_strncpy( joystick_display_string(k_srjoystick_grab, 2), buf, 128, - k_strncpy_allow_cutoff ); + vg_input_string( &str, input_joy_list[k_srjoystick_grab], 1 ); } + else + vg_strcat( &str, "error" ); } #endif /* MENU_H */ diff --git a/player_replay.c b/player_replay.c index b9172c7..0e71408 100644 --- a/player_replay.c +++ b/player_replay.c @@ -381,8 +381,12 @@ static void skaterift_replay_resume(void){ skaterift.resume_begin = skaterift.replay.cursor; skaterift.resume_transition = 0.0f; } + + gui_helper_clear(); } +static void skaterift_replay_update_helpers(void); + static void skaterift_replay_pre_update(void){ if( skaterift.activity != k_skaterift_replay ) return; @@ -413,6 +417,8 @@ static void skaterift_replay_pre_update(void){ if( skaterift.freecam ) replay_get_camera( &skaterift.replay, &skaterift.replay_freecam ); + + skaterift_replay_update_helpers(); } f32 target_speed = axis_state( k_sraxis_replay_h ) * 5.0; @@ -441,14 +447,10 @@ static void skaterift_replay_pre_update(void){ else skaterift.activity = k_skaterift_default; srinput.state = k_input_state_resume; + gui_helper_clear(); } - gui_helper_action( button_display_string(k_srbind_replay_play), "play" ); - gui_helper_action( axis_display_string(k_sraxis_replay_h), "scrub" ); if( skaterift.freecam ){ - gui_helper_action( button_display_string(k_srbind_replay_freecam), - "exit freecam" ); - camera *cam = &skaterift.replay_freecam; v3f angles; v3_copy( cam->angles, angles ); @@ -489,11 +491,6 @@ static void skaterift_replay_pre_update(void){ skaterift.freecam_v, vg.time_frame_delta, cam->pos ); } else { - gui_helper_action( button_display_string(k_srbind_replay_resume), - "resume" ); - gui_helper_action( button_display_string(k_srbind_replay_freecam), - "enter freecam" ); - if( button_down( k_srbind_replay_resume ) ){ skaterift_replay_resume(); } @@ -501,6 +498,48 @@ static void skaterift_replay_pre_update(void){ } } +static void skaterift_replay_update_helpers(void){ + skaterift.helper_resume->greyed = skaterift.freecam; + + vg_str freecam_text; + vg_strnull( &freecam_text, skaterift.helper_freecam->text, + GUI_HELPER_TEXT_LENGTH ); + vg_strcat( &freecam_text, skaterift.freecam? "exit freecam": "freecam" ); +} + +static void skaterift_replay_post_render(void){ + /* capture the current resume frame at the very last point */ + if( button_down( k_srbind_reset ) ){ + if( skaterift.activity == k_skaterift_default ){ + skaterift.activity = k_skaterift_replay; + skaterift_record_frame( &skaterift.replay, 1 ); + if( skaterift.replay.head ){ + skaterift.replay.cursor = skaterift.replay.head->time; + skaterift.replay.cursor_frame = skaterift.replay.head; + } + skaterift.replay_control = k_replay_control_scrub; + + gui_helper_clear(); + vg_str text; + + if( gui_new_helper( input_axis_list[k_sraxis_replay_h], &text ) ) + vg_strcat( &text, "scrub" ); + + if( (skaterift.helper_resume = gui_new_helper( + input_button_list[k_srbind_replay_resume], &text )) ) + vg_strcat( &text, "resume" ); + + if( gui_new_helper( input_button_list[k_srbind_replay_play], &text )) + vg_strcat( &text, "playback" ); + + skaterift.helper_freecam = gui_new_helper( + input_button_list[k_srbind_replay_freecam], &text ); + + skaterift_replay_update_helpers(); + } + } +} + static void skaterift_get_replay_camera( camera *cam ){ if( skaterift.freecam ){ cam->nearz = 0.1f; @@ -609,17 +648,6 @@ static void skaterift_replay_imgui(void){ snprintf( buffer, 128, "-%.2fs\n", len ); ui_text( bar, buffer, 1, k_ui_align_middle_left, 0 ); ui_text( bar, "0s", 1, k_ui_align_middle_right, 0 ); - -#if 0 - char buf[256]; - snprintf( buf, 256, "scrub: %s\nresume: %s\nplay: %s\n", - axis_display_string( k_sraxis_replay_h ), - button_display_string( k_srbind_replay_resume ), - button_display_string( k_srbind_replay_play ) ); - - ui_rect info = { 0, vg.window_y-bar[3]-128, 256, 128 }; - ui_text( info, buf, 2,0,0 ); -#endif } #endif /* PLAYER_REPLAY_C */ diff --git a/respawn.c b/respawn.c index e90f9be..b7594db 100644 --- a/respawn.c +++ b/respawn.c @@ -87,12 +87,6 @@ static void respawn_map_draw_icon( camera *cam, static void respawn_chooser_pre_update(void){ if( skaterift.activity != k_skaterift_respawning ) return; - gui_helper_action( joystick_display_string(k_srjoystick_steer,2), "move" ); - if( world_static.instances[0].status == k_world_status_loaded ) - gui_helper_action( axis_display_string(k_sraxis_mworld_h), "world" ); - gui_helper_action( button_display_string(k_srbind_maccept), "spawn" ); - gui_helper_action( button_display_string(k_srbind_home), "home" ); - if( button_down( k_srbind_mback ) ){ srinput.state = k_input_state_resume; skaterift.activity = k_skaterift_menu; @@ -243,6 +237,21 @@ static void respawn_begin_chooser(void){ respawn_world_to_plane_pos( localplayer.rb.co, respawn_chooser.plane_pos ); respawn_chooser.boom_dist = 400.0f; respawn_chooser.home_select = 0; + + gui_helper_clear(); + + vg_str text; + if( gui_new_helper( input_joy_list[k_srjoystick_steer], &text ) ) + vg_strcat( &text, "move" ); + + if( gui_new_helper( input_button_list[k_srbind_mleft], &text ) ) + vg_strcat( &text, "world" ); + + if( gui_new_helper( input_button_list[k_srbind_maccept], &text ) ) + vg_strcat( &text, "spawn" ); + + if( gui_new_helper( input_button_list[k_srbind_home], &text ) ) + vg_strcat( &text, "home" ); } static void respawn_chooser_shader_uniforms(void){ diff --git a/skaterift.c b/skaterift.c index 113f65a..49fdc88 100644 --- a/skaterift.c +++ b/skaterift.c @@ -601,20 +601,7 @@ static void render_main_game(void){ /* composite */ present_view_with_post_processing(); - /* --------------------------------------------------------------------- */ - - /* capture the current resume frame at the very last point */ - if( button_down( k_srbind_reset ) ){ - if( skaterift.activity == k_skaterift_default ){ - skaterift.activity = k_skaterift_replay; - skaterift_record_frame( &skaterift.replay, 1 ); - if( skaterift.replay.head ){ - skaterift.replay.cursor = skaterift.replay.head->time; - skaterift.replay.cursor_frame = skaterift.replay.head; - } - skaterift.replay_control = k_replay_control_scrub; - } - } + skaterift_replay_post_render(); } static void vg_render(void){ diff --git a/skaterift.h b/skaterift.h index 7624fd4..6664637 100644 --- a/skaterift.h +++ b/skaterift.h @@ -40,6 +40,7 @@ struct{ } replay_control; f32 track_velocity; + struct gui_helper *helper_resume, *helper_freecam; camera replay_freecam; int freecam; -- 2.25.1