better nametag
[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 }
17 else {
18 /* TODO: Comrpession */
19 vg_print_backtrace();
20 vg_error( "Unhandled function id: %u\n", call->function );
21 }
22 }
23
24 /* TODO: these should recieve the world instance */
25 static void ent_route_preupdate( ent_route *route, int active ){
26 if( !active ) return;
27
28 world_instance *world = world_current_instance();
29 u32 cam_id = 0;
30
31 if( __builtin_expect( world->meta.info.version >= 103, 1 ) )
32 cam_id = route->id_camera;
33
34 world_entity_focus_camera( world, cam_id );
35
36 gui_helper_action( button_display_string( k_srbind_mleft ), "weekly" );
37 gui_helper_action( button_display_string( k_srbind_mright ), "all time" );
38 gui_helper_action( button_display_string( k_srbind_mback ), "exit" );
39
40 if( button_down( k_srbind_mleft ) ){
41 world_sfd.view_weekly = 1;
42 world_sfd_compile_active_scores();
43 }
44
45 if( button_down( k_srbind_mright ) ){
46 world_sfd.view_weekly = 0;
47 world_sfd_compile_active_scores();
48 }
49
50 if( button_down( k_srbind_mback ) ){
51 world_entity_unfocus();
52 return;
53 }
54 }
55
56 #endif /* ENT_ROUTE_C */