render fix, menu
[carveJwlIkooP6JGAAIwe30JlM.git] / ent_skateshop.c
index aeeaf702f76a11f6be6a175f3a07b853c44bab71..92e7660255ef06f813b800bb0f4e6dd79e4f8c96 100644 (file)
@@ -8,6 +8,7 @@
 #include "world.h"
 #include "player.h"
 #include "gui.h"
+#include "menu.h"
 
 /*
  * Checks string equality but does a hash check first
@@ -205,68 +206,8 @@ VG_STATIC void workshop_async_reg_update( void *data, u32 size )
    global_skateshop.registry_count = global_skateshop.t1_registry_count;
 }
 
-/*
- * Async thread which scans local files for boards, as well as scheduling 
- * synchronous calls to the workshop
- */
-VG_STATIC void workshop_scan_thread( void *_args )
+VG_STATIC void workshop_steam_scan(void)
 {
-   vg_linear_clear( vg_mem.scratch );
-
-   for( u32 i=0; i<global_skateshop.t1_registry_count; i++ ){
-      struct registry_board *reg = &global_skateshop.registry[i];
-      reg->state = k_registry_board_state_indexed_absent;
-   }
-
-   /*
-    * Local disk scan
-    */
-   vg_info( "Scanning models/boards/*.mdl\n" );
-   tinydir_dir dir;
-   tinydir_open( &dir, "models/boards" );
-
-   while( dir.has_next ){
-      tinydir_file file;
-      tinydir_readfile( &dir, &file );
-      
-      if( file.is_reg ){
-         u32 hash = vg_strdjb2( file.name );
-
-         for( u32 i=0; i<global_skateshop.t1_registry_count; i++ ){
-            struct registry_board *reg = &global_skateshop.registry[i];
-
-            if( const_str_eq( hash, file.name, reg->filename ) ){
-               reg->state = k_registry_board_state_indexed;
-               goto next_file;
-            }
-         }
-
-         if( global_skateshop.t1_registry_count == SKATESHOP_REGISTRY_MAX ){
-            vg_error( "You have too many boards installed!\n" );
-            break;
-         }
-
-         vg_info( "new listing!: %s\n", file.name );
-
-         struct registry_board *reg = 
-            &global_skateshop.registry[global_skateshop.t1_registry_count ++];
-
-         reg->cache_ptr = NULL;
-         vg_strncpy( file.name, reg->filename, 64, k_strncpy_always_add_null );
-         vg_strncpy( file.name, reg->workshop.title,
-                     64, k_strncpy_always_add_null );
-         reg->filename_hash = hash;
-         reg->workshop_id = 0;
-         reg->state = k_registry_board_state_indexed;
-         reg->workshop.author = 0;
-         strcpy( reg->workshop.author_name, "custom" );
-      }
-
-next_file: tinydir_next( &dir );
-   }
-
-   tinydir_close(&dir);
-
    /*
     * Steam workshop scan
     */
@@ -331,6 +272,71 @@ next_file: tinydir_next( &dir );
 
 next_file_workshop:;
    }
+}
+
+/*
+ * Async thread which scans local files for boards, as well as scheduling 
+ * synchronous calls to the workshop
+ */
+VG_STATIC void workshop_scan_thread( void *_args )
+{
+   vg_linear_clear( vg_mem.scratch );
+
+   for( u32 i=0; i<global_skateshop.t1_registry_count; i++ ){
+      struct registry_board *reg = &global_skateshop.registry[i];
+      reg->state = k_registry_board_state_indexed_absent;
+   }
+
+   /*
+    * Local disk scan
+    */
+   vg_info( "Scanning models/boards/*.mdl\n" );
+   tinydir_dir dir;
+   tinydir_open( &dir, "models/boards" );
+
+   while( dir.has_next ){
+      tinydir_file file;
+      tinydir_readfile( &dir, &file );
+      
+      if( file.is_reg ){
+         u32 hash = vg_strdjb2( file.name );
+
+         for( u32 i=0; i<global_skateshop.t1_registry_count; i++ ){
+            struct registry_board *reg = &global_skateshop.registry[i];
+
+            if( const_str_eq( hash, file.name, reg->filename ) ){
+               reg->state = k_registry_board_state_indexed;
+               goto next_file;
+            }
+         }
+
+         if( global_skateshop.t1_registry_count == SKATESHOP_REGISTRY_MAX ){
+            vg_error( "You have too many boards installed!\n" );
+            break;
+         }
+
+         vg_info( "new listing!: %s\n", file.name );
+
+         struct registry_board *reg = 
+            &global_skateshop.registry[global_skateshop.t1_registry_count ++];
+
+         reg->cache_ptr = NULL;
+         vg_strncpy( file.name, reg->filename, 64, k_strncpy_always_add_null );
+         vg_strncpy( file.name, reg->workshop.title,
+                     64, k_strncpy_always_add_null );
+         reg->filename_hash = hash;
+         reg->workshop_id = 0;
+         reg->state = k_registry_board_state_indexed;
+         reg->workshop.author = 0;
+         strcpy( reg->workshop.author_name, "custom" );
+      }
+
+next_file: tinydir_next( &dir );
+   }
+
+   tinydir_close(&dir);
+
+   if( steam_ready ) workshop_steam_scan();
    
    vg_async_call( workshop_async_reg_update, NULL, 0 );
    vg_async_stall();
@@ -684,6 +690,8 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
    ent_skateshop *shop = mdl_arritm( &world->ent_skateshop, index );
    vg_info( "skateshop_call\n" );
 
+   if( menu.active ) return;
+
    if( call->function == k_ent_function_trigger ){
       if( localplayer.subsystem != k_player_subsystem_walk ){
          return;
@@ -692,6 +700,7 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call )
       vg_info( "Entering skateshop\n" );
 
       localplayer.immobile = 1;
+      menu.disable_open = 1;
       global_skateshop.active = 1;
 
       v3_zero( localplayer.rb.v );
@@ -712,6 +721,7 @@ VG_STATIC void global_skateshop_exit(void)
    vg_info( "exit skateshop\n" );
    localplayer.immobile = 0;
    global_skateshop.active = 0;
+   menu.disable_open = 0;
    srinput.ignore_input_frames = 2;
 }