revision 2
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_route.c
1 #include "ent_route.h"
2 #include "input.h"
3 #include "gui.h"
4
5 struct global_ent_route global_ent_route;
6
7 void ent_route_call( world_instance *world, ent_call *call )
8 {
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 void ent_route_preupdate( ent_route *route, int active )
40 {
41 if( !active ) return;
42
43 world_instance *world = world_current_instance();
44 u32 cam_id = 0;
45
46 if( __builtin_expect( world->meta.info.version >= 103, 1 ) )
47 cam_id = route->id_camera;
48
49 world_entity_focus_camera( world, cam_id );
50
51 if( button_down( k_srbind_mleft ) ){
52 world_sfd.view_weekly = 1;
53 world_sfd_compile_active_scores();
54 }
55
56 if( button_down( k_srbind_mright ) ){
57 world_sfd.view_weekly = 0;
58 world_sfd_compile_active_scores();
59 }
60
61 global_ent_route.helper_alltime->greyed =!world_sfd.view_weekly;
62 global_ent_route.helper_weekly->greyed = world_sfd.view_weekly;
63
64 if( button_down( k_srbind_mback ) ){
65 world_entity_unfocus();
66 gui_helper_clear();
67 return;
68 }
69 }