From 330eda0436ed73d6c68214fef8922904abe19422 Mon Sep 17 00:00:00 2001 From: hgn Date: Tue, 21 Nov 2023 14:27:47 +0000 Subject: [PATCH] more gui changes --- ent_miniworld.c | 22 ++++++++-------------- gui.h | 6 ++++-- input.h | 6 +++++- menu.h | 1 + player.c | 5 ++++- player_dead.c | 30 ++++++++++++++++++++++++++++++ 6 files changed, 52 insertions(+), 18 deletions(-) diff --git a/ent_miniworld.c b/ent_miniworld.c index 5e9a23c..0ceefda 100644 --- a/ent_miniworld.c +++ b/ent_miniworld.c @@ -8,11 +8,12 @@ static void miniworld_helper_default(void){ gui_helper_clear(); vg_str text; - if( gui_new_helper( input_button_list[k_srbind_miniworld_resume], &text )) - vg_strcat( &text, "Enter World" ); if( gui_new_helper( input_button_list[k_srbind_miniworld_teleport],&text)) vg_strcat( &text, "Teleport" ); + + if( gui_new_helper( input_button_list[k_srbind_miniworld_resume], &text )) + vg_strcat( &text, "Enter World" ); } static void miniworld_helper_tele(void){ @@ -37,10 +38,14 @@ static void ent_miniworld_call( world_instance *world, ent_call *call ){ mdl_transform_m4x3( &miniworld->transform, global_miniworld.mmdl ); global_miniworld.active = miniworld; + global_miniworld.mode = 0; + global_miniworld.dest_spawn = NULL; miniworld_helper_default(); } else if( call->function == 1 ){ global_miniworld.active = NULL; + global_miniworld.mode = 0; + global_miniworld.dest_spawn = NULL; gui_helper_clear(); if( miniworld->proxy ){ @@ -129,18 +134,6 @@ static void ent_miniworld_render( world_instance *host_world, camera *cam ){ miniworld_icon( cam, icon, challenge->transform.co, 1.0f ); } -#if 0 - for( u32 i=0; ient_skateshop); i++ ){ - ent_skateshop *shop = mdl_arritm( &dest_world->ent_skateshop, i ); - if( shop->type == k_skateshop_type_boardshop ){ - miniworld_icon( cam, k_gui_icon_board, shop->transform.co, 1.0f ); - } - else if( shop->type == k_skateshop_type_worldshop ){ - miniworld_icon( cam, k_gui_icon_world, shop->transform.co, 1.0f ); - } - } -#endif - for( u32 i=0; ient_route); i++ ){ ent_route *route = mdl_arritm( &dest_world->ent_route, i ); @@ -166,6 +159,7 @@ static void ent_miniworld_preupdate(void){ if( global_miniworld.mode ){ global_miniworld.mode = 0; + global_miniworld.dest_spawn = 0; menu.disable_open = 0; srinput.state = k_input_state_resume; gui_helper_clear(); diff --git a/gui.h b/gui.h index a84835d..5b662b2 100644 --- a/gui.h +++ b/gui.h @@ -189,7 +189,6 @@ static void gui_draw(void){ v3_zero( mmdl[3] ); float pad = dy*0x1p-4f*0.125f; - mmdl[3][0] = pad*2.0f; mmdl[3][1] = pad; for( u32 i=0; ibinding, 1 ); + f32 bs = (f32)vg.window_x / (f32)(gui.helper_count+1), + x = ((f32)i + 1.0f) * bs; + mmdl[3][0] = x - font3d_string_width( 2, buf )*0.5f*scale; + font3d_setcolour( (v4f){1.0f,1.0f,1.0f, helper->greyed? 0.5f: 1.0f} ); font3d_simple_draw( 2, buf, &ortho, mmdl ); @@ -208,7 +211,6 @@ static void gui_draw(void){ font3d_draw( helper->text ); float w = gui_font3d.offset[0]+1.0f; - mmdl[3][0] += w*scale; } } diff --git a/input.h b/input.h index c66b7fb..b742119 100644 --- a/input.h +++ b/input.h @@ -18,6 +18,7 @@ enum sr_bind{ k_srbind_sit, k_srbind_use, k_srbind_reset, + k_srbind_dead_respawn, k_srbind_camera, k_srbind_mleft, k_srbind_mright, @@ -77,6 +78,8 @@ static vg_input_op *input_button_list[] = { }, [k_srbind_use] = INPUT_BASIC( SDLK_e, SDL_CONTROLLER_BUTTON_Y ), [k_srbind_reset] = INPUT_BASIC( SDLK_r, SDL_CONTROLLER_BUTTON_LEFTSHOULDER ), +[k_srbind_dead_respawn] = + INPUT_BASIC( SDLK_q, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ), [k_srbind_camera]= INPUT_BASIC( SDLK_c, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER ), [k_srbind_mleft] = INPUT_BASIC( SDLK_LEFT, SDL_CONTROLLER_BUTTON_DPAD_LEFT ), [k_srbind_mright]= INPUT_BASIC( SDLK_RIGHT, SDL_CONTROLLER_BUTTON_DPAD_RIGHT ), @@ -108,7 +111,8 @@ static vg_input_op *input_button_list[] = { vg_gui_visible, 1, vg_joy_button, SDL_CONTROLLER_BUTTON_X, vg_end }, -[k_srbind_miniworld_teleport]= INPUT_BASIC( SDLK_r, SDL_CONTROLLER_BUTTON_X ), +[k_srbind_miniworld_teleport]= INPUT_BASIC( SDLK_q, + SDL_CONTROLLER_BUTTON_LEFTSHOULDER ), [k_srbind_max]=NULL }; diff --git a/menu.h b/menu.h index 8691f08..3bbaf7c 100644 --- a/menu.h +++ b/menu.h @@ -247,6 +247,7 @@ static void menu_trigger_item( ent_menuitem *item ){ } else if( MDL_CONST_PSTREQ( &menu.model, q, "reset" ) ){ + srinput.state = k_input_state_resume; menu_close(); ent_miniworld_goback(); } diff --git a/player.c b/player.c index 860e048..b6d6a85 100644 --- a/player.c +++ b/player.c @@ -12,6 +12,7 @@ #include "network_common.h" #include "world_routes.h" #include "ent_miniworld.h" +#include "gui.h" static int localplayer_cmd_respawn( int argc, const char *argv[] ){ ent_spawn *rp = NULL, *r; @@ -89,7 +90,8 @@ static void player__bind(void){ */ static void player__pre_update(void){ - if( button_down( k_srbind_camera ) && !localplayer.immobile ){ + if( button_down( k_srbind_camera ) && !localplayer.immobile && + (localplayer.subsystem != k_player_subsystem_dead) ){ if( localplayer.cam_control.camera_mode == k_cam_firstperson ) localplayer.cam_control.camera_mode = k_cam_thirdperson; else @@ -220,6 +222,7 @@ static void player__setpos( v3f pos ){ static void player__reset(void){ replay_clear( &skaterift.replay ); + gui_helper_clear(); v3_zero( localplayer.rb.v ); v3_zero( localplayer.rb.w ); diff --git a/player_dead.c b/player_dead.c index 8f7170e..1f6087b 100644 --- a/player_dead.c +++ b/player_dead.c @@ -2,6 +2,7 @@ #define PLAYER_DEAD_C #include "player.h" +#include "gui.h" static void player__dead_update(void){ player_ragdoll_iter( &localplayer.ragdoll ); @@ -23,6 +24,21 @@ static void player__dead_post_update(void){ v3_copy( d->co_lpf, localplayer.rb.co ); v3_zero( localplayer.rb.v ); v3_zero( localplayer.rb.w ); + + if( (skaterift.activity == k_skaterift_default) && + button_down(k_srbind_dead_respawn) ){ + ent_spawn *spawn = world_find_closest_spawn( + world_current_instance(), localplayer.rb.co ); + + if( spawn ){ + v3_copy( spawn->transform.co, localplayer.rb.co ); + player__reset(); + srinput.state = k_input_state_resume; + } + else { + vg_error( "No spawns!\n" ); + } + } } static void player__dead_animate(void){ @@ -131,6 +147,20 @@ static void player__dead_transition(void){ v3_copy( part->obj.rb.co, player_dead.co_lpf ); v3_copy( part->obj.rb.v, player_dead.v_lpf ); v3_copy( part->obj.rb.w, player_dead.w_lpf ); + + gui_helper_clear(); + vg_str str; + + struct gui_helper *h; + if( (h = gui_new_helper(input_button_list[k_srbind_reset], &str) )){ + vg_strcat( &str, "rewind" ); + + if( world_static.active_instance == k_world_purpose_hub ) + h->greyed = 1; + } + + if( gui_new_helper(input_button_list[k_srbind_dead_respawn], &str )) + vg_strcat( &str, "spawn" ); } static void player__dead_animator_exchange( bitpack_ctx *ctx, void *data ){ -- 2.25.1