animation and transition adjustments
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_route.c
1 #ifndef ENT_ROUTE_C
2 #define ENT_ROUTE_C
3
4 #include "ent_route.h"
5 #include "input.h"
6 #include "gui.h"
7
8 static void ent_route_call( world_instance *world, ent_call *call ){
9 u32 index = mdl_entity_id_id( call->id );
10 ent_route *route = mdl_arritm( &world->ent_route, index );
11
12 if( call->function == 0 ){ /* view() */
13 if( localplayer.subsystem == k_player_subsystem_walk ){
14 world_entity_focus( call->id );
15
16 gui_helper_clear();
17 vg_str text;
18
19 if( (global_ent_route.helper_weekly =
20 gui_new_helper( input_button_list[k_srbind_mleft], &text )))
21 vg_strcat( &text, "weekly" );
22
23 if( (global_ent_route.helper_alltime =
24 gui_new_helper( input_button_list[k_srbind_mright], &text )))
25 vg_strcat( &text, "all time" );
26
27 if( gui_new_helper( input_button_list[k_srbind_mback], &text ) )
28 vg_strcat( &text, "exit" );
29 }
30 }
31 else {
32 /* TODO: Comrpession */
33 vg_print_backtrace();
34 vg_error( "Unhandled function id: %u\n", call->function );
35 }
36 }
37
38 /* TODO: these should recieve the world instance */
39 static void ent_route_preupdate( ent_route *route, int active ){
40 if( !active ) return;
41
42 world_instance *world = world_current_instance();
43 u32 cam_id = 0;
44
45 if( __builtin_expect( world->meta.info.version >= 103, 1 ) )
46 cam_id = route->id_camera;
47
48 world_entity_focus_camera( world, cam_id );
49
50 if( button_down( k_srbind_mleft ) ){
51 world_sfd.view_weekly = 1;
52 world_sfd_compile_active_scores();
53 }
54
55 if( button_down( k_srbind_mright ) ){
56 world_sfd.view_weekly = 0;
57 world_sfd_compile_active_scores();
58 }
59
60 global_ent_route.helper_alltime->greyed =!world_sfd.view_weekly;
61 global_ent_route.helper_weekly->greyed = world_sfd.view_weekly;
62
63 if( button_down( k_srbind_mback ) ){
64 world_entity_unfocus();
65 gui_helper_clear();
66 return;
67 }
68 }
69
70 #endif /* ENT_ROUTE_C */