routes - auto disappear
[carveJwlIkooP6JGAAIwe30JlM.git] / world_routes.h
index 7f108aa88d89463ed12121e8db0de1d4116322ec..2b85f877e3bc8ebf0d5ee70f837f613fbfa1328b 100644 (file)
@@ -14,6 +14,11 @@ enum route_special_type
    k_route_special_type_collector = 2
 };
 
+static void world_routes_interact(void)
+{
+   world.routes.last_interaction = vg_time;
+}
+
 static void debug_sbpath( struct route_node *rna, struct route_node *rnb,
                           u32 colour, float xoffset )
 {
@@ -265,6 +270,7 @@ static void world_routes_ui_newseg( u32 route )
    segment->vertex_count = 4;
    segment->index_start  = pr->ui.indices_head;
    segment->index_count  = 6;
+   segment->notches      = 0;
 
    world_routes_ui_set_indices( pr, indices, 6 );
 }
@@ -302,6 +308,12 @@ static void world_routes_ui_notch( u32 route, float time )
 
    if( (time - pr->ui.last_notch) > 1.0 )
    {
+      struct route_ui_segment *segment = world_routes_ui_curseg(pr);
+      if( segment->notches == k_max_ui_splits_per_segment )
+         return;
+
+      segment->notches ++;
+
       v2f verts[8];
       
       float const k_notch_width = 1.0f;
@@ -360,7 +372,6 @@ static void world_routes_ui_notch( u32 route, float time )
 
       pr->ui.last_notch = time;
 
-      struct route_ui_segment *segment = world_routes_ui_curseg(pr);
       segment->vertex_count += 6;
       segment->index_count  += 18;
    }
@@ -414,12 +425,15 @@ static void world_routes_ui_draw( u32 route, v4f colour, float offset )
    v4_copy( colour, fade_colour );
    fade_colour[3] *= 1.0f-fade_amt;
 
+   float timer_delta = (vg_time - world.routes.last_interaction) * (1.0/60.0),
+         timer_scale = 1.0f - vg_minf( timer_delta, 1.0f );
+
    /* 
     * Draw fadeout bar
     */
 
-   float height = pr->factive*k_bar_height,
-         base = -1.0f + (offset+0.5f)*k_bar_height;
+   float height = pr->factive*k_bar_height * timer_scale,
+         base = -1.0f + (offset+0.5f)*k_bar_height * timer_scale;
 
    shader_routeui_uColour( fade_colour );
    for( u32 i=0; i<pr->ui.fade_count; i++ )
@@ -592,6 +606,8 @@ static void world_routes_verify_run( u32 route )
  */
 static void world_routes_activate_gate( u32 id )
 {
+   world_routes_interact();
+
    struct subworld_routes *r = &world.routes;
    struct route_gate *rg = &r->gates[id];
    struct route_node *pnode = &r->nodes[rg->node_id],
@@ -644,6 +660,7 @@ static void world_routes_activate_gate( u32 id )
 static void world_routes_notify_reset(void)
 {
    struct subworld_routes *r = &world.routes;
+   world_routes_interact();
 
    for( int i=0; i<r->route_count; i++ )
    {