a mess but stable
[carveJwlIkooP6JGAAIwe30JlM.git] / world_routes_ui.c
index 4d39e9cce004542603187eaf9438adfe465bcee7..0afbeae9abd8154a1b405afe17f32dce9bc01519 100644 (file)
@@ -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;
@@ -65,7 +67,8 @@ static void ent_route_imgui( world_instance *world, ent_route *route,
          h = route->factive * 16.0f,
          base = inout_cursor[0];//(f32)vg.window_x*0.5f - route->ui_stopper;
 
-   if( route->ui_residual > 0.0f ){
+   if( route->ui_residual > 0.0f )
+   {
       ui_px w = route->ui_residual_block_w,
             total = w + 4;
 
@@ -79,23 +82,25 @@ static void ent_route_imgui( world_instance *world, ent_route *route,
       v4_copy( route->colour, fadecolour );
       fadecolour[3] *= route->ui_residual;
 
-      ui_fill( rect, v4_rgba(fadecolour) );
+      ui_fill( ctx, rect, v4_rgba(fadecolour) );
 
       x += total;
    }
 
    int got_first = 0;
 
-   for( u32 i=0; i<valid_sections; i ++ ){
+   for( u32 i=0; i<valid_sections; i ++ )
+   {
       struct time_block *block = &blocks[ i ];
       ui_px w = 20 + (block->length * 6.0f);
       ui_rect rect = { base+x, inout_cursor[1], w, h };
-      ui_fill( rect, colour );
+      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 );
@@ -105,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.001f) ){
+         if( (block->best != 0.0f) && (fabsf(diff) > 0.001f) )
+         {
             if( diff > 0.0f )
                vg_strcatch( &str, '+' );
             else
@@ -115,7 +121,7 @@ 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 );
          }
       }
 
@@ -127,15 +133,17 @@ static void ent_route_imgui( world_instance *world, ent_route *route,
       }
    }
 
-   for( u32 i=0; i<route->checkpoints_count-valid_sections; i++ ){
+   for( u32 i=0; i<route->checkpoints_count-valid_sections; i++ )
+   {
       struct time_block *block = &blocks[ i ];
 
       ui_px w = 20;
       ui_rect rect = { base+x, inout_cursor[1], w, h };
-      ui_outline( rect, -1, colour, 0 );
+      ui_outline( ctx, rect, -1, colour, 0 );
       x += w + 4;
 
-      if( !got_first ){
+      if( !got_first )
+      {
          route->ui_first_block_width = w;
          got_first = 1;
       }
@@ -148,9 +156,13 @@ static void ent_route_imgui( world_instance *world, ent_route *route,
                                  vg.time_frame_delta );
 }
 
-static void world_routes_imgui( world_instance *world ){
+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; i<mdl_arrcount(&world->ent_route); i++ ){
-      ent_route_imgui( world, mdl_arritm( &world->ent_route, i ), cursor );
+   for( u32 i=0; i<mdl_arrcount(&world->ent_route); i++ )
+   {
+      ent_route_imgui( ctx, world, mdl_arritm( &world->ent_route, i ), cursor );
    }
 }