npcs and tutorial stuff
[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 {
15 world_entity_set_focus( call->id );
16 world_entity_focus_modal();
17
18 gui_helper_clear();
19 vg_str text;
20
21 if( (global_ent_route.helper_weekly =
22 gui_new_helper( input_button_list[k_srbind_mleft], &text )))
23 vg_strcat( &text, "weekly" );
24
25 if( (global_ent_route.helper_alltime =
26 gui_new_helper( input_button_list[k_srbind_mright], &text )))
27 vg_strcat( &text, "all time" );
28
29 if( gui_new_helper( input_button_list[k_srbind_mback], &text ) )
30 vg_strcat( &text, "exit" );
31 }
32 }
33 else {
34 /* TODO: Comrpession */
35 vg_print_backtrace();
36 vg_error( "Unhandled function id: %u\n", call->function );
37 }
38 }
39
40 /* TODO: these should recieve the world instance */
41 void ent_route_preupdate( ent_route *route, int active )
42 {
43 if( !active ) return;
44
45 world_instance *world = world_current_instance();
46 u32 cam_id = 0;
47
48 if( __builtin_expect( world->meta.info.version >= 103, 1 ) )
49 cam_id = route->id_camera;
50
51 world_entity_focus_camera( world, cam_id );
52
53 if( button_down( k_srbind_mleft ) ){
54 world_sfd.view_weekly = 1;
55 world_sfd_compile_active_scores();
56 }
57
58 if( button_down( k_srbind_mright ) ){
59 world_sfd.view_weekly = 0;
60 world_sfd_compile_active_scores();
61 }
62
63 global_ent_route.helper_alltime->greyed =!world_sfd.view_weekly;
64 global_ent_route.helper_weekly->greyed = world_sfd.view_weekly;
65
66 if( button_down( k_srbind_mback ) )
67 {
68 world_entity_exit_modal();
69 world_entity_clear_focus();
70 gui_helper_clear();
71 return;
72 }
73 }