X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=world_routes_ui.c;h=0afbeae9abd8154a1b405afe17f32dce9bc01519;hb=22aab5cc99ed5b927c57f0fd8fa65b33575101a6;hp=319870a9f85658971ceaf5456de942ac0ac9aafb;hpb=02c9203df66d93f21c0e64f51193bcbeaabfc9bd;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/world_routes_ui.c b/world_routes_ui.c index 319870a..0afbeae 100644 --- a/world_routes_ui.c +++ b/world_routes_ui.c @@ -1,6 +1,7 @@ #include "skaterift.h" #include "world_routes_ui.h" #include "world_routes.h" +#include "player.h" static u32 v4_rgba( v4f colour ){ u32 r = vg_minf(1.0f,colour[0])*255.0f, @@ -11,7 +12,8 @@ static u32 v4_rgba( v4f colour ){ return r | (g<<8) | (b<<16) | (a<<24); } -static void ent_route_imgui( world_instance *world, ent_route *route, +static void ent_route_imgui( ui_context *ctx, + world_instance *world, ent_route *route, ui_point inout_cursor ){ if( route->flags & k_ent_route_flag_out_of_zone ) return; @@ -62,18 +64,43 @@ static void ent_route_imgui( world_instance *world, ent_route *route, u32 colour = v4_rgba( route->colour ) | 0xff000000; ui_px x = 0, - h = route->factive * 16.0f; + h = route->factive * 16.0f, + base = inout_cursor[0];//(f32)vg.window_x*0.5f - route->ui_stopper; - for( u32 i=0; iui_residual > 0.0f ) + { + ui_px w = route->ui_residual_block_w, + total = w + 4; + + f32 t = vg_smoothstepf(1.0f-route->ui_residual); + + x -= (f32)total * t; + + ui_rect rect = { base+x, inout_cursor[1], w, h }; + + v4f fadecolour; + v4_copy( route->colour, fadecolour ); + fadecolour[3] *= route->ui_residual; + + ui_fill( ctx, rect, v4_rgba(fadecolour) ); + + x += total; + } + + int got_first = 0; + + for( u32 i=0; ilength * 6.0f); - ui_rect rect = { x, inout_cursor[1], w, h }; - ui_fill( rect, colour ); + ui_rect rect = { base+x, inout_cursor[1], w, h }; + ui_fill( ctx, rect, colour ); if( block->clean ) - ui_outline( rect, 1, 0xff00ffff, 0 ); + ui_outline( ctx, rect, 1, 0xff00ffff, 0 ); - if( block->best != 0.0f ){ + if( block->best != 0.0f ) + { char buf[32]; vg_str str; vg_strnull( &str, buf, 32 ); @@ -83,7 +110,8 @@ static void ent_route_imgui( world_instance *world, ent_route *route, s = floorf( as ), ds = floorf( vg_fractf( as ) * 10.0f ); - if( (block->best != 0.0f) && (fabsf(diff) > 0.02f) ){ + if( (block->best != 0.0f) && (fabsf(diff) > 0.001f) ) + { if( diff > 0.0f ) vg_strcatch( &str, '+' ); else @@ -93,28 +121,48 @@ static void ent_route_imgui( world_instance *world, ent_route *route, vg_strcatch( &str, '.' ); vg_strcati32( &str, ds ); - ui_text( rect, buf, 1, k_ui_align_middle_center, 0 ); + ui_text( ctx, rect, buf, 1, k_ui_align_middle_center, 0 ); } } x += w + 4; + + if( !got_first ){ + route->ui_first_block_width = w; + got_first = 1; + } } - for( u32 i=0; icheckpoints_count-valid_sections; i++ ){ + for( u32 i=0; icheckpoints_count-valid_sections; i++ ) + { struct time_block *block = &blocks[ i ]; ui_px w = 20; - ui_rect rect = { x, inout_cursor[1], w, h }; - ui_outline( rect, -1, colour, 0 ); + ui_rect rect = { base+x, inout_cursor[1], w, h }; + ui_outline( ctx, rect, -1, colour, 0 ); x += w + 4; + + if( !got_first ) + { + route->ui_first_block_width = w; + got_first = 1; + } } inout_cursor[1] += h + 4; + + vg_slewf( &route->ui_residual, 0.0f, vg.time_frame_delta ); + route->ui_stopper = vg_lerpf( route->ui_stopper, (f32)x*0.5f, + vg.time_frame_delta ); } -static void world_routes_imgui( world_instance *world ){ - ui_point cursor = { 0, 0 }; - for( u32 i=0; ient_route); i++ ){ - ent_route_imgui( world, mdl_arritm( &world->ent_route, i ), cursor ); +void world_routes_imgui( ui_context *ctx, world_instance *world ) +{ + if( skaterift.activity == k_skaterift_menu ) return; + + ui_point cursor = { 4, 4 }; + for( u32 i=0; ient_route); i++ ) + { + ent_route_imgui( ctx, world, mdl_arritm( &world->ent_route, i ), cursor ); } }