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