fadeout the route ui over time
authorhgn <hgodden00@gmail.com>
Mon, 24 Mar 2025 03:56:47 +0000 (03:56 +0000)
committerhgn <hgodden00@gmail.com>
Mon, 24 Mar 2025 03:56:47 +0000 (03:56 +0000)
src/world.h
src/world_routes.c
src/world_routes_ui.c

index 9fffb713f0334ce639948b16226939a2ccf9aa72..bd46891367634a5fda5f7714970a5c24cd873ff5 100644 (file)
@@ -227,7 +227,9 @@ struct world_static
    void *heap, *preview_heap;
 
    u32 current_run_version;
-   double time, rewind_from, rewind_to;
+   f64 last_gate_hit_time;
+
+   double time;
 
    u32 active_trigger_volumes[8];
    u32 active_trigger_volume_count;
index 53d911bd97952c9a40fecc008dd64e41dc95b11c..c6735bb49156d1dbea9ae7bd8a2820d5f08022cd 100644 (file)
@@ -200,6 +200,7 @@ void world_routes_activate_entry_gate( world_instance *world, ent_gate *rg )
    else
       recording_gate->flags |= k_ent_gate_clean_pass;
 
+   _world.last_gate_hit_time = _world.time;
    _world.current_run_version ++;
 }
 
index e607b9077d55059ae9682111aa48d9330121a38d..25ac799330c030dea500631f9a0f020824a39556 100644 (file)
@@ -70,7 +70,7 @@ static void ent_route_imgui( ui_context *ctx, world_instance *world, ent_route *
 
    ui_px x = 0,
          h = route->factive * 16.0f,
-         base = inout_cursor[0];//(f32)vg.window_x*0.5f - route->ui_stopper;
+         base = inout_cursor[0];
 
    if( route->ui_residual > 0.0f )
    {
@@ -82,12 +82,7 @@ static void ent_route_imgui( ui_context *ctx, world_instance *world, ent_route *
       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) );
+      ui_fill( ctx, rect, ui_opacity( colour, route->ui_residual ) );
 
       x += total;
    }
@@ -104,7 +99,7 @@ static void ent_route_imgui( ui_context *ctx, world_instance *world, ent_route *
       if( block->clean )
          ui_outline( ctx, rect, 1, 0xff00ffff, 0 );
 
-      if( block->best != 0.0f )
+      if( (block->best != 0.0f) )
       {
          char buf[32];
          vg_str str;
@@ -165,9 +160,18 @@ void world_routes_imgui( ui_context *ctx, world_instance *world )
    if( skaterift.activity == k_skaterift_menu ) return;
    if( _world.event != k_world_event_none ) return;
 
+   ui_flush( ctx, k_ui_shader_colour, NULL );
+
+   f32 t = (_world.time - _world.last_gate_hit_time) / 30.0f;
+   f32 alpha = vg_clampf( 2.0f-t, 0.0f, 1.0f );
+   vg_ui.colour[3] = alpha;
+
    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;
 }