minor changes to be on track with vg revision
[carveJwlIkooP6JGAAIwe30JlM.git] / skaterift.c
index 1700dc7e98cb584b1ea011a47604f6ead271efb3..eec32d5b1725b38c96bf8423fb73c765f1bb4b1d 100644 (file)
@@ -2,7 +2,7 @@
  * =============================================================================
  *
  * Copyright  .        . .       -----, ,----- ,---.   .---.
- * 2021-2023  |\      /| |           /  |      |    | |    /|
+ * 2021-2024  |\      /| |           /  |      |    | |    /|
  *            | \    / | +--        /   +----- +---'  |   / |
  *            |  \  /  | |         /    |      |   \  |  /  |
  *            |   \/   | |        /     |      |    \ | /   |
@@ -13,6 +13,8 @@
 
 #define SR_NETWORKED
 #define VG_AUDIO_FORCE_COMPRESSED
+#define SDL_MAIN_HANDLED
+#define SR_ALLOW_REWIND_HUB
 
 #ifndef VG_RELEASE
  #define VG_DEVWINDOW
@@ -47,7 +49,6 @@
 #include "entity.c"
 #include "workshop.c"
 #include "addon.c"
-#include "highscores.c"
 #include "save.c"
 #include "world_map.c"
 #include "network.c"
@@ -57,6 +58,9 @@
 #include "particle.c"
 #include "player_effects.c"
 #include "freecam.c"
+#include "testing.c"
+#include "trail.h"
+#include "trail.c"
 
 static int k_tools_mode = 0;
 
@@ -164,6 +168,7 @@ static void skaterift_restore_state(void){
 
 static addon_reg *skaterift_mount_world_unloadable( const char *path, u32 ext ){
    addon_reg *reg = addon_mount_local_addon( path, k_addon_type_world, ".mdl" );
+   if( !reg ) vg_fatal_error( "world not found\n" );
    reg->flags |= (ADDON_REG_HIDDEN | ext);
    return reg;
 }
@@ -176,6 +181,7 @@ static void skaterift_load_world_content(void){
    skaterift_mount_world_unloadable( "maps/mp_mtzero", 
          ADDON_REG_MTZERO|ADDON_REG_PREMIUM );
    skaterift_mount_world_unloadable( "maps/dev_tutorial", 0 );
+   skaterift_mount_world_unloadable( "maps/dev_flatworld", 0 );
 
    world_static.load_state = k_world_loader_load;
 
@@ -193,6 +199,7 @@ static void skaterift_load_player_content(void){
    replay_clear( &skaterift.replay );
 
    particle_alloc( &particles_grind, 300 );
+   particle_alloc( &particles_env, 200 );
 
    player_load_animation_reference( "models/ch_none.mdl" );
    player_model_load( &localplayer.fallback_model, "models/ch_none.mdl" );
@@ -226,6 +233,10 @@ static void vg_load(void){
    vg_loader_step( addon_system_init, NULL );
    vg_loader_step( workshop_init, NULL );
    vg_loader_step( skateshop_init, NULL );
+   vg_loader_step( ent_tornado_init, NULL );
+   vg_loader_step( testing_init, NULL );
+   vg_loader_step( trail_init, NULL );
+   vg_loader_step( particle_init, NULL );
   
    vg_loader_step( skaterift_load_player_content, NULL );
 
@@ -321,6 +332,7 @@ static void vg_fixed_update(void){
    world_routes_fixedupdate( world_current_instance() );
    player__update();
    vehicle_update_fixed();
+   testing_update();
 }
 
 static void vg_post_update(void){
@@ -499,6 +511,13 @@ static void render_scene(void){
    //particle_system_debug( &particles_grind );
    particle_system_prerender( &particles_grind );
    particle_system_render( &particles_grind, &skaterift.cam );
+   
+   ent_tornado_pre_update();
+   particle_system_update( &particles_env, vg.time_delta );
+   particle_system_prerender( &particles_env );
+   particle_system_render( &particles_env, &skaterift.cam );
+
+   player_glide_render_effects( &skaterift.cam );
 
    /* 
     * render transition 
@@ -585,7 +604,9 @@ static void render_main_game(void){
    }
    else{
       player__animate();
-      skaterift_record_frame( &skaterift.replay, 0 );
+      skaterift_record_frame( &skaterift.replay, 
+                              localplayer.deferred_frame_record );
+      localplayer.deferred_frame_record = 0;
    }
    animate_remote_players();
    player__pre_render();
@@ -668,6 +689,35 @@ static void vg_render(void){
 static void vg_gui(void){
    if( skaterift.op == k_async_op_clientloading ) return;
 
+   if( k_tools_mode ){
+      ui_rect null;
+      ui_rect screen = { 0, 0, vg.window_x, vg.window_y };
+      ui_rect panel = { 0, 0, 1000, 700 };
+      ui_rect_center( screen, panel );
+      vg_ui.wants_mouse = 1;
+
+      ui_fill( panel, ui_colour( k_ui_bg+1 ) );
+      ui_outline( panel, 1, ui_colour( k_ui_bg+7 ), 0 );
+
+      ui_rect_pad( panel, (ui_px[2]){ 8, 8 } );
+
+      static i32 example;
+      ui_enum( panel, "example enum", vg_settings_vsync_enum, 3, &example );
+
+      static f32 val = 30.0f;
+      ui_slider( panel, "Slider", 0.0f, 100.0f, &val, NULL );
+
+      ui_dev_colourview();
+
+      static v4f colour = { 0.5f, 0.6f, 0.1f, 1.0f };
+      ui_colourpicker( panel, "hello", colour );
+
+      return;
+   }
+
+   if( k_light_editor )
+      imgui_world_light_edit( world_current_instance() );
+
    vg_ui.tex_bg = gpipeline.fb_main->attachments[0].id;
    render_fb_inverse_ratio( gpipeline.fb_main, vg_ui.bg_inverse_ratio );