8d79e9ebdabad3cbf85c0f20b8c47a3b33889933
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift.c
1 /*
2 * =============================================================================
3 *
4 * Copyright . . . -----, ,----- ,---. .---.
5 * 2021-2024 |\ /| | / | | | | /|
6 * | \ / | +-- / +----- +---' | / |
7 * | \ / | | / | | \ | / |
8 * | \/ | | / | | \ | / |
9 * ' ' '--' [] '----- '----- ' ' '---' SOFTWARE
10 *
11 * =============================================================================
12 */
13
14 #define SR_ALLOW_REWIND_HUB
15
16 /*
17 * system headers
18 * --------------------- */
19
20 #include "skaterift.h"
21 #include "steam.h"
22 #include "render.h"
23 #include "vg/vg_opt.h"
24 #include "vg/vg_loader.h"
25
26 #include "world.h"
27
28 #include "font.h"
29 #include "player.h"
30
31 #include "network.h"
32 #include "menu.h"
33 #include "vehicle.h"
34 #include "save.h"
35 #include "player_remote.h"
36 #include "particle.h"
37 #include "trail.h"
38 #include "freecam.h"
39 #include "ent_tornado.h"
40 #include "ent_miniworld.h"
41 #include "ent_skateshop.h"
42 #include "world_map.h"
43 #include "gui.h"
44 #include "workshop.h"
45 #include "audio.h"
46 #include "player_render.h"
47
48 struct skaterift_globals skaterift =
49 {
50 .op = k_async_op_clientloading, .time_rate = 1.0f, .demo_mode = 1,
51 .hub_world = "maps/dev_hub",
52 };
53
54 static int k_tools_mode = 0;
55
56 int main( int argc, char *argv[] ){
57 vg_mem.use_libc_malloc = 0;
58 vg_set_mem_quota( 160*1024*1024 );
59 vg_enter( argc, argv, "Voyager Game Engine" );
60 return 0;
61 }
62
63 void vg_launch_opt(void)
64 {
65 const char *arg;
66 if( vg_long_opt( "noauth" ) ){
67 network_client.auth_mode = eServerModeNoAuthentication;
68 }
69
70 if( (arg = vg_long_opt_arg( "server" )) ){
71 vg_strncpy( arg, network_client.server_adress, 64,
72 k_strncpy_overflow_fatal );
73 }
74
75 if( vg_long_opt( "tools" ) ){
76 k_tools_mode = 1;
77 }
78
79 if( vg_long_opt( "demo" ) ){
80 skaterift.demo_mode = 1;
81 }
82
83 if( (arg = vg_long_opt_arg( "world" )) ){
84 skaterift.hub_world = arg;
85 }
86 }
87
88 void vg_preload(void)
89 {
90 vg_info(" Copyright . . . -----, ,----- ,---. .---. \n" );
91 vg_info(" 2021-2023 |\\ /| | / | | | | /| \n" );
92 vg_info(" | \\ / | +-- / +----- +---' | / | \n" );
93 vg_info(" | \\ / | | / | | \\ | / | \n" );
94 vg_info(" | \\/ | | / | | \\ | / | \n" );
95 vg_info(" ' ' '--' [] '----- '----- ' ' '---' "
96 "SOFTWARE\n" );
97
98 /* please forgive me! */
99 u32 sz; char *drm;
100 if( (drm = vg_file_read_text( vg_mem.scratch, "DRM", &sz )) )
101 if( !strcmp(drm, "blibby!") )
102 skaterift.demo_mode = 0;
103
104 vg_loader_step( remote_players_init, NULL );
105
106 if( k_tools_mode )
107 return;
108
109 steam_init();
110 vg_loader_step( NULL, steam_end );
111 vg_loader_step( network_init, network_end );
112 }
113
114 static void async_skaterift_player_start( void *payload, u32 size ){
115 world_switch_instance(0);
116 }
117
118 static void async_call_ready( void *payload, u32 size ){
119 skaterift.op = k_async_op_none;
120 }
121
122 static void skaterift_restore_state(void)
123 {
124 savedata_file sav;
125 skaterift_read_main_savedata( &sav );
126
127 vg_msg kvsav;
128 vg_msg_init( &kvsav, sav.buf, sizeof(sav.buf) );
129
130 u32 ach;
131 vg_msg_getkvintg( &kvsav, "ach", k_vg_msg_u32, &ach );
132 skaterift.achievements |= ach;
133
134 u32 board_reg_id = 0,
135 player_reg_id = 0;
136
137 vg_msg_cursor orig = kvsav.cur;
138 if( vg_msg_seekframe( &kvsav, "player" ) ){
139 addon_alias q;
140
141 /* board */
142 skaterift_read_addon_alias( &kvsav, "board", k_addon_type_board, &q );
143 u32 reg_id = addon_match( &q );
144 if( reg_id != 0xffffffff )
145 board_reg_id = reg_id;
146
147 /* playermodel */
148 skaterift_read_addon_alias( &kvsav, "playermodel",
149 k_addon_type_player, &q );
150 reg_id = addon_match( &q );
151 if( reg_id != 0xffffffff )
152 player_reg_id = reg_id;
153 }
154
155 localplayer.board_view_slot =
156 addon_cache_create_viewer( k_addon_type_board, board_reg_id );
157 localplayer.playermodel_view_slot =
158 addon_cache_create_viewer( k_addon_type_player, player_reg_id );
159
160 kvsav.cur = orig;
161 }
162
163 static addon_reg *skaterift_mount_world_unloadable( const char *path, u32 ext ){
164 addon_reg *reg = addon_mount_local_addon( path, k_addon_type_world, ".mdl" );
165 if( !reg ) vg_fatal_error( "world not found\n" );
166 reg->flags |= (ADDON_REG_HIDDEN | ext);
167 return reg;
168 }
169
170 static void skaterift_load_world_content(void){
171 /* hub world */
172 addon_reg *hub = skaterift_mount_world_unloadable( skaterift.hub_world, 0 );
173 skaterift_mount_world_unloadable( "maps/mp_spawn",
174 ADDON_REG_CITY|ADDON_REG_PREMIUM );
175 skaterift_mount_world_unloadable( "maps/mp_mtzero",
176 ADDON_REG_MTZERO|ADDON_REG_PREMIUM );
177 skaterift_mount_world_unloadable( "maps/dev_tutorial", 0 );
178 skaterift_mount_world_unloadable( "maps/dev_flatworld", 0 );
179
180 world_static.load_state = k_world_loader_load;
181
182 struct world_load_args args = {
183 .purpose = k_world_purpose_hub,
184 .reg = hub
185 };
186 skaterift_world_load_thread( &args );
187 }
188
189 static void skaterift_load_player_content(void){
190 u32 bytes = 1024*1024*10;
191 player_replay.local.data = vg_linear_alloc( vg_mem.rtmemory, bytes );
192 player_replay.local.size = bytes;
193 replay_clear( &player_replay.local );
194
195 particle_alloc( &particles_grind, 300 );
196 particle_alloc( &particles_env, 200 );
197
198 player_load_animation_reference( "models/ch_none.mdl" );
199 player_model_load( &localplayer.fallback_model, "models/ch_none.mdl" );
200 player__bind();
201 player_board_load( &localplayer.fallback_board, "models/board_none.mdl" );
202 }
203
204 void vg_load(void)
205 {
206 if( k_tools_mode ){
207 vg_async_call( async_call_ready, NULL, 0 );
208 return;
209 }
210
211 vg_audio.always_keep_compressed = 1;
212
213 vg_console_reg_cmd( "load_world", skaterift_load_world_command, NULL );
214 vg_console_reg_cmd( "fc", freecam_cmd, NULL );
215 vg_console_reg_var( "immobile", &localplayer.immobile, k_var_dtype_i32, 0 );
216
217 vg_loader_step( render_init, NULL );
218 vg_loader_step( menu_init, NULL );
219 vg_loader_step( world_init, NULL );
220 vg_loader_step( vehicle_init, NULL );
221 vg_loader_step( gui_init, NULL );
222
223 vg_loader_step( player_init, NULL );
224 vg_loader_step( player_ragdoll_init, NULL );
225
226 /* content stuff */
227 vg_loader_step( addon_system_init, NULL );
228 vg_loader_step( workshop_init, NULL );
229 vg_loader_step( skateshop_init, NULL );
230 vg_loader_step( ent_tornado_init, NULL );
231 vg_loader_step( skaterift_load_player_content, NULL );
232
233 /* --------------------- */
234
235 vg_bake_shaders();
236 vg_loader_step( audio_init, audio_free );
237
238 /* 'systems' are completely loaded now */
239
240 /* Completing addon registrations
241 * -------------------------------------
242 */
243
244 /* load home/permanent world manually */
245 vg_loader_step( skaterift_load_world_content, NULL );
246 vg_async_call( async_skaterift_player_start, NULL, 0 );
247 vg_async_stall();
248
249 vg_console_load_autos();
250 menu_link();
251
252 addon_mount_content_folder( k_addon_type_player,
253 "playermodels", ".mdl" );
254 addon_mount_content_folder( k_addon_type_board, "boards", ".mdl" );
255 addon_mount_content_folder( k_addon_type_world, "maps", ".mdl" );
256 addon_mount_workshop_items();
257 vg_async_call( async_addon_reg_update, NULL, 0 );
258 vg_async_stall();
259
260 /* and now */
261 skaterift_restore_state();
262 update_ach_models();
263
264 vg_loader_step( NULL, skaterift_autosave_synchronous );
265
266 //board_processview_thread(NULL);
267 vg_async_call( async_call_ready, NULL, 0 );
268 }
269
270 static void draw_origin_axis(void){
271 vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 1.0f, 0.0f, 0.0f }, 0xffff0000 );
272 vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 1.0f, 0.0f }, 0xff00ff00 );
273 vg_line( (v3f){ 0.0f, 0.0f, 0.0f }, (v3f){ 0.0f, 0.0f, 1.0f }, 0xff0000ff );
274 }
275 void skaterift_change_client_world_preupdate(void);
276
277 /*
278 * UPDATE LOOP
279 * ---------------------------------------------------------------------------*/
280
281 void vg_pre_update(void)
282 {
283 skaterift_preupdate_inputs();
284
285 if( k_tools_mode ) return;
286
287 steam_update();
288 if( skaterift.op == k_async_op_clientloading ) return;
289 if( world_static.load_state == k_world_loader_preload )
290 skaterift_change_client_world_preupdate();
291
292 draw_origin_axis();
293 skateshop_autostart_loading();
294 network_update();
295
296 /* time rate */
297 f32 target = 1;
298 if( skaterift.activity & (k_skaterift_replay|k_skaterift_menu|
299 k_skaterift_world_map) ){
300 target = 0;
301 }
302
303 vg_slewf( &skaterift.time_rate, target, vg.time_frame_delta * (1.0f/0.3f) );
304 vg.time_rate = vg_smoothstepf( skaterift.time_rate );
305
306 /* TODO: how can we compress this? */
307 ent_miniworld_preupdate();
308 player__pre_update();
309 world_entity_focus_preupdate();
310 skaterift_replay_pre_update();
311 remote_sfx_pre_update();
312 skateshop_world_preupdate( world_current_instance() );
313
314 world_update( world_current_instance(), localplayer.rb.co );
315 audio_ambient_sprites_update( world_current_instance(), localplayer.rb.co );
316 world_map_pre_update();
317 }
318
319 void vg_fixed_update(void)
320 {
321 if( k_tools_mode ) return;
322 if( skaterift.op == k_async_op_clientloading ) return;
323
324 world_routes_fixedupdate( world_current_instance() );
325 player__update();
326 vehicle_update_fixed();
327 }
328
329 void vg_post_update(void)
330 {
331 if( k_tools_mode ) return;
332 if( skaterift.op == k_async_op_clientloading ) return;
333
334 player__post_update();
335
336 float dist;
337 int sample_index;
338 world_audio_sample_distances( localplayer.rb.co, &sample_index, &dist );
339
340 audio_lock();
341 vg_dsp.echo_distances[sample_index] = dist;
342
343 v3f ears = { 1.0f,0.0f,0.0f };
344 m3x3_mulv( skaterift.cam.transform, ears, ears );
345 v3_copy( ears, vg_audio.external_listener_ears );
346 v3_copy( skaterift.cam.transform[3], vg_audio.external_listener_pos );
347
348 if( localplayer.gate_waiting ){
349 m4x3_mulv( localplayer.gate_waiting->transport,
350 vg_audio.external_listener_pos,
351 vg_audio.external_listener_pos );
352 }
353
354 v3_copy( localplayer.rb.v, vg_audio.external_lister_velocity );
355 audio_unlock();
356
357 vehicle_update_post();
358 skaterift_autosave_update();
359 }
360
361 /*
362 * RENDERING
363 * ---------------------------------------------------------------------------*/
364
365 void vg_framebuffer_resize( int w, int h ){
366 render_fb_resize();
367 }
368
369 static void present_view_with_post_processing(void){
370 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
371 glViewport( 0,0, vg.window_x, vg.window_y );
372
373 glEnable(GL_BLEND);
374 glDisable(GL_DEPTH_TEST);
375 glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
376 glBlendEquation(GL_FUNC_ADD);
377
378 v2f inverse;
379 render_fb_inverse_ratio( gpipeline.fb_main, inverse );
380
381 if( k_blur_effect ){
382 shader_blitblur_use();
383 shader_blitblur_uTexMain( 0 );
384 shader_blitblur_uTexMotion( 1 );
385 shader_blitblur_uBlurStrength( k_blur_strength /
386 (vg.time_frame_delta*60.0) );
387 shader_blitblur_uInverseRatio( inverse );
388
389 inverse[0] -= 0.0001f;
390 inverse[1] -= 0.0001f;
391 shader_blitblur_uClampUv( inverse );
392
393 static f64 effect_time = 133.0;
394 effect_time += vg.time_frame_delta;
395 shader_blitblur_uTime( effect_time );
396
397 f32 glitch_strength = 0.0f;
398 if( skaterift.activity == k_skaterift_replay ){
399 glitch_strength = 0.005f;
400 if( player_replay.replay_control == k_replay_control_play )
401 glitch_strength = 0.005f;
402 else
403 glitch_strength += 0.005f*player_replay.track_velocity;
404 }
405 shader_blitblur_uGlitchStrength( glitch_strength );
406
407 v2f override;
408 if( skaterift.activity == k_skaterift_menu )
409 v2_muls( (v2f){ 0.04f, 0.001f }, 1.0f-skaterift.time_rate, override );
410 else
411 v2_zero( override );
412 shader_blitblur_uOverrideDir( override );
413
414 render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
415 render_fb_bind_texture( gpipeline.fb_main, 1, 1 );
416 }
417 else{
418 shader_blit_use();
419 shader_blit_uTexMain( 0 );
420 shader_blit_uInverseRatio( inverse );
421 render_fb_bind_texture( gpipeline.fb_main, 0, 0 );
422 }
423
424 render_fsquad();
425 }
426
427 static void render_player_transparent(void){
428 static vg_camera small_cam; /* DOES NOT NEED TO BE STATIC BUT MINGW
429 SAIS OTHERWISE */
430
431 m4x3_copy( skaterift.cam.transform, small_cam.transform );
432
433 small_cam.fov = skaterift.cam.fov;
434 small_cam.nearz = 0.05f;
435 small_cam.farz = 60.0f;
436
437 vg_camera_update_view( &small_cam );
438 vg_camera_update_projection( &small_cam );
439 vg_camera_finalize( &small_cam );
440
441 /* Draw player to window buffer and blend background ontop */
442 player__render( &small_cam );
443 }
444
445 static world_instance *get_view_world(void){
446 world_instance *view_world = world_current_instance();
447 if( localplayer.gate_waiting &&
448 (localplayer.gate_waiting->flags & k_ent_gate_nonlocal) ){
449 view_world = &world_static.instances[world_static.active_instance ^ 0x1];
450 }
451
452 return view_world;
453 }
454
455 static void render_scene(void){
456 /* Draw world */
457 glEnable( GL_DEPTH_TEST );
458
459 for( u32 i=0; i<vg_list_size(world_static.instances); i++ ){
460 if( world_static.instances[i].status == k_world_status_loaded ){
461 world_prerender( &world_static.instances[i] );
462 }
463 }
464
465 if( skaterift.activity == k_skaterift_world_map ){
466 world_instance *world = world_current_instance();
467 glDrawBuffers( 1, (GLenum[]){ GL_COLOR_ATTACHMENT0 } );
468
469 v3f bg;
470 v3_muls( world->ub_lighting.g_daysky_colour,
471 world->ub_lighting.g_day_phase -
472 world->ub_lighting.g_sunset_phase*0.1f, bg );
473
474 v3_muladds( bg, world->ub_lighting.g_sunset_colour,
475 (1.0f-0.5f)*world->ub_lighting.g_sunset_phase, bg );
476
477 v3_muladds( bg, world->ub_lighting.g_nightsky_colour,
478 (1.0f-world->ub_lighting.g_day_phase), bg );
479
480 glClearColor( bg[0], bg[1], bg[2], 0.0f );
481 glClear( GL_COLOR_BUFFER_BIT );
482 glDrawBuffers( 2, (GLenum[]){ GL_COLOR_ATTACHMENT0,
483 GL_COLOR_ATTACHMENT1 } );
484
485 m4x3f identity;
486 m4x3_identity( identity );
487 render_world_override( world, world, identity, &skaterift.cam,
488 world_map.spawn,
489 (v4f){world->tar_min, world->tar_max, 1.0f, 0.0f});
490 render_world_routes( world, world, identity, &skaterift.cam, 0, 1 );
491 return;
492 }
493
494 world_instance *view_world = get_view_world();
495 render_world( view_world, &skaterift.cam, 0, 0, 1, 1 );
496
497 particle_system_update( &particles_grind, vg.time_delta );
498 //particle_system_debug( &particles_grind );
499 particle_system_prerender( &particles_grind );
500 particle_system_render( &particles_grind, &skaterift.cam );
501
502 ent_tornado_pre_update();
503 particle_system_update( &particles_env, vg.time_delta );
504 particle_system_prerender( &particles_env );
505 particle_system_render( &particles_env, &skaterift.cam );
506
507 player_glide_render_effects( &skaterift.cam );
508
509 /*
510 * render transition
511 */
512 if( global_miniworld.transition == 0 )
513 return;
514
515 world_instance *holdout_world = NULL;
516 f32 t = 0.0f;
517
518 if( global_miniworld.transition == 1 ){
519 holdout_world = &world_static.instances[ k_world_purpose_hub ];
520 t = global_miniworld.t;
521 }
522 else{
523 holdout_world = &world_static.instances[ k_world_purpose_client ];
524 t = 1.0f-global_miniworld.t;
525 }
526
527 if( holdout_world->status != k_world_status_loaded )
528 return;
529
530 t = vg_smoothstepf( t );
531
532 glEnable( GL_STENCIL_TEST );
533 glDisable( GL_DEPTH_TEST );
534 glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
535 glStencilFunc( GL_ALWAYS, 1, 0xFF );
536 glStencilMask( 0xFF );
537
538 shader_blit_transition_use();
539 shader_blit_transition_uInverseRatio( (v2f){1.0f,1.0f} );
540 shader_blit_transition_uT( -(sqrtf(2)+0.5f) * t );
541
542 render_fsquad();
543 render_world( holdout_world, &global_miniworld.cam, 1, 0, 1, 1 );
544 }
545
546 static void skaterift_composite_maincamera(void){
547 vg_camera_lerp( &localplayer.cam, &world_static.focus_cam,
548 vg_smoothstepf(world_static.focus_strength), &skaterift.cam );
549
550 if( player_replay.freecam ){
551 freecam_preupdate();
552 v3_copy( player_replay.replay_freecam.pos, skaterift.cam.pos );
553 v3_copy( player_replay.replay_freecam.angles, skaterift.cam.angles );
554 skaterift.cam.fov = player_replay.replay_freecam.fov;
555 }
556 else {
557 if( skaterift.activity == k_skaterift_replay ){
558 replay_get_camera( &player_replay.local, &skaterift.cam );
559 }
560 }
561
562 skaterift.cam.nearz = 0.1f;
563 skaterift.cam.farz = 2100.0f;
564
565 if( skaterift.activity == k_skaterift_world_map ){
566 vg_camera_copy( &world_map.cam, &skaterift.cam );
567 skaterift.cam.nearz = 4.0f;
568 skaterift.cam.farz = 3100.0f;
569 }
570
571 if( global_miniworld.transition ){
572 f32 dt = vg.time_frame_delta / 2.0f,
573 s = vg_signf( global_miniworld.transition );
574 global_miniworld.t += s * dt;
575
576 if( (global_miniworld.t > 1.0f) || (global_miniworld.t < 0.0f) ){
577 global_miniworld.t = vg_clampf( global_miniworld.t, 0.0f, 1.0f );
578 global_miniworld.transition = 0;
579 }
580 }
581
582 vg_camera_update_transform( &skaterift.cam );
583 vg_camera_update_view( &skaterift.cam );
584 vg_camera_update_projection( &skaterift.cam );
585 vg_camera_finalize( &skaterift.cam );
586 }
587
588 static void render_main_game(void){
589 if( skaterift.activity == k_skaterift_replay ){
590 player__animate_from_replay( &player_replay.local );
591 }
592 else{
593 player__animate();
594 skaterift_record_frame( &player_replay.local,
595 localplayer.deferred_frame_record );
596 localplayer.deferred_frame_record = 0;
597 }
598 animate_remote_players();
599 player__pre_render();
600
601 skaterift_composite_maincamera();
602
603 /* --------------------------------------------------------------------- */
604 if( skaterift.activity != k_skaterift_world_map ){
605 world_instance *world = world_current_instance();
606 render_world_cubemaps( world );
607
608 ent_gate *nlg = world->rendering_gate;
609 if( nlg && nlg->flags & k_ent_gate_nonlocal )
610 render_world_cubemaps( &world_static.instances[nlg->target] );
611 }
612
613 /* variable res target */
614 render_fb_bind( gpipeline.fb_main, 1 );
615 glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
616 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT );
617
618 render_scene();
619 glEnable( GL_DEPTH_TEST );
620
621 /* full res target */
622 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
623 glViewport( 0,0, vg.window_x, vg.window_y );
624
625 render_player_transparent(); /* needs to read the depth buffer before we fuck
626 it up with the oblique rendering inside the
627 portals */
628
629 /* continue with variable rate */
630 if( !global_miniworld.transition &&
631 (skaterift.activity != k_skaterift_world_map) ){
632 render_fb_bind( gpipeline.fb_main, 1 );
633 render_world_gates( get_view_world(), &skaterift.cam );
634 }
635
636 /* composite */
637 present_view_with_post_processing();
638 skaterift_replay_post_render();
639 }
640
641 void vg_render(void)
642 {
643 if( k_tools_mode ){
644 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
645 glViewport( 0,0, vg.window_x, vg.window_y );
646 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
647 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
648 return;
649 }
650
651 if( skaterift.op == k_async_op_clientloading ){
652 vg_loader_render();
653 return;
654 }
655
656 glBindFramebuffer( GL_FRAMEBUFFER, 0 );
657
658 glViewport( 0,0, vg.window_x, vg.window_y );
659 glDisable( GL_DEPTH_TEST );
660 glDisable( GL_BLEND );
661
662 glClearColor( 1.0f, 0.0f, 0.0f, 0.0f );
663 glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
664
665 render_main_game();
666 m4x4_copy( skaterift.cam.mtx.pv, vg.pv );
667
668 /* Other shite */
669 glDisable(GL_BLEND);
670 glDisable(GL_DEPTH_TEST);
671 vg_lines_drawall();
672 glViewport( 0,0, vg.window_x, vg.window_y );
673 gui_draw();
674 }
675
676 void vg_gui(void)
677 {
678 if( skaterift.op == k_async_op_clientloading ) return;
679
680 if( k_tools_mode ){
681 ui_rect null;
682 ui_rect screen = { 0, 0, vg.window_x, vg.window_y };
683 ui_rect panel = { 0, 0, 1000, 700 };
684 ui_rect_center( screen, panel );
685 vg_ui.wants_mouse = 1;
686
687 ui_fill( panel, ui_colour( k_ui_bg+1 ) );
688 ui_outline( panel, 1, ui_colour( k_ui_bg+7 ), 0 );
689
690 ui_rect_pad( panel, (ui_px[2]){ 8, 8 } );
691
692 return;
693 }
694
695 if( k_light_editor )
696 imgui_world_light_edit( world_current_instance() );
697
698 vg_ui.tex_bg = gpipeline.fb_main->attachments[0].id;
699 render_fb_inverse_ratio( gpipeline.fb_main, vg_ui.bg_inverse_ratio );
700
701 menu_update();
702 if( skaterift.activity == k_skaterift_menu ){
703 glClear( GL_DEPTH_BUFFER_BIT );
704 menu_render();
705 }
706
707 player__im_gui();
708 world_instance *world = world_current_instance();
709
710 world_routes_imgui( world );
711 skaterift_replay_imgui();
712 workshop_form_gui();
713 render_view_framebuffer_ui();
714 remote_player_network_imgui( vg.pv );
715
716 if( skaterift.activity == k_skaterift_world_map ){
717 remote_players_imgui_world( world_current_instance(), vg.pv, 2000.0f, 0 );
718 remote_players_imgui_lobby();
719 }
720 else {
721 remote_players_chat_imgui(); /* TODO: conditional */
722 remote_players_imgui_world( world_current_instance(), vg.pv, 100.0f, 1 );
723 }
724 }
725
726 #include "addon.c"
727 #include "addon_types.c"
728 #include "audio.c"
729 #include "ent_challenge.c"
730 #include "ent_glider.c"
731 #include "entity.c"
732 #include "ent_miniworld.c"
733 #include "ent_objective.c"
734 #include "ent_region.c"
735 #include "ent_relay.c"
736 #include "ent_route.c"
737 #include "ent_skateshop.c"
738 #include "ent_tornado.c"
739 #include "ent_traffic.c"
740 #include "freecam.c"
741 #include "menu.c"
742 #include "network.c"
743 #include "particle.c"
744 #include "player_basic_info.c"
745 #include "player.c"
746 #include "player_common.c"
747 #include "player_dead.c"
748 #include "player_drive.c"
749 #include "player_effects.c"
750 #include "player_glide.c"
751 #include "player_ragdoll.c"
752 #include "player_remote.c"
753 #include "player_render.c"
754 #include "player_replay.c"
755 #include "player_skate.c"
756 #include "player_walk.c"
757 #include "render.c"
758 #include "save.c"
759 #include "scene.c"
760 #include "steam.c"
761 #include "trail.c"
762 #include "vehicle.c"
763 #include "workshop.c"
764 #include "world_audio.c"
765 #include "world.c"
766 #include "world_entity.c"
767 #include "world_gate.c"
768 #include "world_gen.c"
769 #include "world_load.c"
770 #include "world_map.c"
771 #include "world_physics.c"
772 #include "world_render.c"
773 #include "world_routes.c"
774 #include "world_routes_ui.c"
775 #include "world_sfd.c"
776 #include "world_volumes.c"
777 #include "world_water.c"