update helpers
authorhgn <hgodden00@gmail.com>
Fri, 17 Nov 2023 03:56:41 +0000 (03:56 +0000)
committerhgn <hgodden00@gmail.com>
Fri, 17 Nov 2023 03:56:41 +0000 (03:56 +0000)
12 files changed:
ent_challenge.c
ent_route.c
ent_route.h
ent_skateshop.c
ent_skateshop.h
gui.h
input.h
menu.h
player_replay.c
respawn.c
skaterift.c
skaterift.h

index 10196bf635fce0ed5297ae84ef513391412ef900..b8f2f5e27ef6a083c822557455df179a44115222 100644 (file)
@@ -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;
    }
index 1f0bbeddf401c3ed6763dbf0608e4ecc4d35194e..1ef9f1dcf208d93a0cb9878058ac4eb5cf28a873 100644 (file)
@@ -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;
    }
 }
index 786d85087595596e4b4ec793a4098fc734a871f3..65c074f2ca545ab1a9726faf95b3f71421627a9e 100644 (file)
@@ -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 );
 
index bfec73f9edaf24fe6082b90af3182f7fb2875478..8a03ff1e6ab46b7772ff1905ecedbdaf9675b419 100644 (file)
@@ -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();
       }
index 386602170fd091a26dace1038273afda66f960aa..81be2e81b9f313bff755852fbdb2861e9548943e 100644 (file)
 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 7c2dbb6e5f34e5ee0c795338a18650744881c9a8..30664d8a00bb7b8905e92dc0fd10a04bf0af33cf 100644 (file)
--- 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; i<gui.helper_count; i++ ){
       struct gui_helper *helper = &gui.helpers[i];
 
-      font3d_setcolour( (v4f){1.0f,1.0f,1.0f,1.0f} );
-      font3d_simple_draw( 2, helper->bindstr, &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 cdb93a3ce7162f1fd7900157a53e6a51d317952f..1595325a4a460e35931e4eb64772af7037f67409 100644 (file)
--- 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<k_srbind_max; i++ ){
       srinput.button_states[i][1] = srinput.button_states[i][0];
       srinput.button_states[i][0] = 0;
@@ -402,10 +396,6 @@ static void skaterift_preupdate_inputs(void){
       srinput.axis_states[i][0] = 0.0f;
    }
 
-   u32 mouse = SDL_GetMouseState(NULL,NULL),
-       mouse1= (mouse & SDL_BUTTON(SDL_BUTTON_LEFT))? 1: 0,
-       mouse2= (mouse & SDL_BUTTON(SDL_BUTTON_RIGHT))? 1: 0;
-
    for( int i=0; i<k_srbind_max; i++ ){
       vg_input_op *prog = input_button_list[i];
       if( prog ){
@@ -429,6 +419,20 @@ static void skaterift_preupdate_inputs(void){
                                 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( 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 5143c511cf122ff6d862093ce3748283365a814c..5218485c8574ca036b4906b6685369d37fd0ddc4 100644 (file)
--- 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 */
index b9172c73b0c3c04664d6bdd63b31741859f67ee2..0e71408bd1fb60996bc05cb372b646357e69dc9a 100644 (file)
@@ -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 */
index e90f9be3ebf389fb088370ad67905beb2a39e9dd..b7594db52b38ffe80eb6a7e757ebec074df7826f 100644 (file)
--- 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){
index 113f65ac8e806d77de2bb02002c50ce489dcde21..49fdc88ca85918f2dcaa422f979366df353285cc 100644 (file)
@@ -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){
index 7624fd4846170d765fb2b75346e84abb334f15ef..666463774e5e51c9fe3ff9c3bb62b9ab4b751323 100644 (file)
@@ -40,6 +40,7 @@ struct{
    }
    replay_control;
    f32 track_velocity;
+   struct gui_helper *helper_resume, *helper_freecam;
 
    camera replay_freecam;
    int freecam;