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