move compiler to its own folder, api changes. wip maps
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_route.c
index a11464093b6646c84838a9e5d110596a2d53f92e..11b680d6f08a00cb6419754ad2998fe676200017 100644 (file)
@@ -1,17 +1,33 @@
-#ifndef ENT_ROUTE_C
-#define ENT_ROUTE_C
-
 #include "ent_route.h"
 #include "input.h"
 #include "gui.h"
 
-static void ent_route_call( world_instance *world, ent_call *call ){
+struct global_ent_route global_ent_route;
+
+void ent_route_call( world_instance *world, ent_call *call )
+{
    u32 index = mdl_entity_id_id( call->id );
    ent_route *route = mdl_arritm( &world->ent_route, index );
 
    if( call->function == 0 ){ /* view() */
-      if( localplayer.subsystem == k_player_subsystem_walk ){
-         world_entity_focus( call->id );
+      if( localplayer.subsystem == k_player_subsystem_walk )
+      {
+         world_entity_set_focus( call->id );
+         world_entity_focus_modal();
+
+         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 {
@@ -22,7 +38,8 @@ static void ent_route_call( world_instance *world, ent_call *call ){
 }
 
 /* TODO: these should recieve the world instance */
-static void ent_route_preupdate( ent_route *route, int active ){
+void ent_route_preupdate( ent_route *route, int active )
+{
    if( !active ) return;
 
    world_instance *world = world_current_instance();
@@ -33,15 +50,24 @@ 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" );
+   if( button_down( k_srbind_mleft ) ){
+      world_sfd.view_weekly = 1;
+      world_sfd_compile_active_scores();
+   }
 
-   gui_helper_action( button_display_string( k_srbind_mback ), "exit" );
+   if( button_down( k_srbind_mright ) ){
+      world_sfd.view_weekly = 0;
+      world_sfd_compile_active_scores();
+   }
 
-   if( button_down( k_srbind_mback ) ){
-      world_entity_unfocus();
+   global_ent_route.helper_alltime->greyed =!world_sfd.view_weekly;
+   global_ent_route.helper_weekly->greyed =  world_sfd.view_weekly;
+
+   if( button_down( k_srbind_mback ) )
+   {
+      world_entity_exit_modal();
+      world_entity_clear_focus();
+      gui_helper_clear();
       return;
    }
 }
-
-#endif /* ENT_ROUTE_C */