a more comprehensive workshop system
authorhgn <hgodden00@gmail.com>
Wed, 24 May 2023 15:50:23 +0000 (16:50 +0100)
committerhgn <hgodden00@gmail.com>
Wed, 24 May 2023 15:50:23 +0000 (16:50 +0100)
boards_src/test/addon.inf [new file with mode: 0644]
boards_src/test/preview.jpg [new file with mode: 0644]
boards_src/test/skaterift_fish.mdl [new file with mode: 0644]
build.c
ent_skateshop.c
ent_skateshop.h
maps_src/mp_mtzero/main.mdl.meta [deleted file]
maps_src/mp_spawn/addon.inf [new file with mode: 0644]
workshop.c
workshop.h
workshop_types.h [new file with mode: 0644]

diff --git a/boards_src/test/addon.inf b/boards_src/test/addon.inf
new file mode 100644 (file)
index 0000000..0b5ceb2
Binary files /dev/null and b/boards_src/test/addon.inf differ
diff --git a/boards_src/test/preview.jpg b/boards_src/test/preview.jpg
new file mode 100644 (file)
index 0000000..27c2667
Binary files /dev/null and b/boards_src/test/preview.jpg differ
diff --git a/boards_src/test/skaterift_fish.mdl b/boards_src/test/skaterift_fish.mdl
new file mode 100644 (file)
index 0000000..f29acf1
Binary files /dev/null and b/boards_src/test/skaterift_fish.mdl differ
diff --git a/build.c b/build.c
index d5b09c2cfd6c71ffec7822ee67382c467ef4ea0f..6d3b521a8a6a92f6003b51dfc0c5b2d226a878c0 100644 (file)
--- a/build.c
+++ b/build.c
@@ -4,6 +4,8 @@
 #include "vg/vg_opt.h"
 #include "vg/vg_build.h"
 #include "vg/vg_build_utils_shader.h"
+#include "vg/vg_msg.h"
+#include "workshop_types.h"
 
 /* 
  * c build.c --release --clang 
@@ -32,8 +34,7 @@ void build_shaders(void);
 void build_game( enum compiler compiler )
 {
    static int shaders_built = 0;
-   if( !shaders_built )
-   {
+   if( !shaders_built ){
       shaders_built = 1;
       build_shaders();
    }
@@ -48,10 +49,46 @@ void build_game( enum compiler compiler )
 
    vg_build_symbolic_link( "textures_src", "textures" );
    vg_build_symbolic_link( "models_src", "models" );
+   vg_build_symbolic_link( "boards_src", "boards" );
    vg_build_symbolic_link( "maps_src", "maps" );
    vg_build_symbolic_link( "sound_src", "sound" );
    vg_build_syscall( "mkdir -p %s/cfg", vg_compiler.build_dir );
 
+   u8 descriptor_buf[ 512 ];
+   vg_msg descriptor;
+   vg_msg_init( &descriptor, descriptor_buf, 512 );
+   vg_msg_frame( &descriptor, "workshop" );
+      vg_msg_wkvstr( &descriptor, "title", "Understate DIY Park" );
+      vg_msg_wkvstr( &descriptor, "author", "Skaterift" );
+      vg_msg_wkvuint(&descriptor, "type", u32 value=k_workshop_file_type_world);
+   vg_msg_end_frame( &descriptor );
+   vg_msg_wkvstr( &descriptor, "location", "USA" );
+   vg_msg_wkvstr( &descriptor, "content", "main.mdl" );
+
+   if( descriptor.error == k_vg_msg_error_OK ){
+      FILE *fp = fopen( "maps_src/mp_spawn/addon.inf", "wb" );
+      fwrite( descriptor_buf, descriptor.cur, 1, fp );
+      fclose( fp );
+
+      vg_msg recvtest;
+      vg_msg_init( &recvtest, descriptor_buf, descriptor.cur );
+
+      vg_msg_cmd cmd;
+      while( vg_msg_next( &recvtest, &cmd ) ){
+         if( cmd.code == k_vg_msg_code_frame ){
+            vg_info( "FRAME: [%u]%s\n", cmd.key_djb2, cmd.key );
+         }
+         else if( cmd.code == k_vg_msg_code_endframe ){
+            vg_info( "ENDFRAME\n" );
+         }
+         else if( cmd.code == k_vg_msg_code_kvstring ){
+            vg_info( "KVSTR: [%u]%s: [%u]%s\n", cmd.key_djb2, cmd.key,
+                                                cmd.value_djb2, 
+                                                (const char *)cmd.value._buf );
+         }
+      }
+   }
+
    vg_build();
    compiled_something = 1;
 }
index a667599bc31afaa5a07b95005d615db1f93f0a02..ce0ca5d2b55236f98164197d906a469df462b681 100644 (file)
@@ -4,6 +4,7 @@
 #define VG_GAME
 #include "vg/vg.h"
 #include "vg/vg_steam_ugc.h"
+#include "vg/vg_msg.h"
 #include "ent_skateshop.h"
 #include "world.h"
 #include "player.h"
@@ -11,6 +12,7 @@
 #include "menu.h"
 #include "pointcloud.h"
 #include "highscores.h"
+#include "steam.h"
 
 /*
  * Checks string equality but does a hash check first
@@ -61,7 +63,7 @@ VG_STATIC struct cache_board *skateshop_cache_fetch( u32 registry_index )
          struct registry_board *other = 
             &global_skateshop.registry[ min_board->registry_id ];
 
-         vg_info( "Deallocating board: '%s'\n", min_board, other->filename );
+         vg_info( "Deallocating board: '%s'\n", min_board, other->foldername );
 
          player_board_unload( &min_board->board );
          other->cache_ptr = NULL;
@@ -69,7 +71,7 @@ VG_STATIC struct cache_board *skateshop_cache_fetch( u32 registry_index )
 
       if( reg ){
          vg_info( "Allocating board (reg:%u) '%s'\n", 
-                  registry_index, reg->filename );
+                  registry_index, reg->foldername );
       }
       else{
          vg_info( "Pre-allocating board (reg:%u) 'null'\n", registry_index );
@@ -123,7 +125,7 @@ VG_STATIC void skateshop_async_board_loaded( void *payload, u32 size )
    reg->cache_ptr = cache_ptr;
    SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
 
-   vg_success( "Async board loaded (%s)\n", reg->filename );
+   vg_success( "Async board loaded (%s)\n", reg->foldername );
 }
 
 /*
@@ -132,7 +134,9 @@ VG_STATIC void skateshop_async_board_loaded( void *payload, u32 size )
  */
 VG_STATIC void workshop_visibile_load_loop_thread( void *_args )
 {
-   char path[1024];
+   char path_buf[4096];
+   vg_str folder;
+
    for( u32 i=0; i<SKATESHOP_BOARD_CACHE_MAX; i++ ){
       struct cache_board *cache_ptr = &global_skateshop.cache[i];
 
@@ -156,31 +160,82 @@ VG_STATIC void workshop_visibile_load_loop_thread( void *_args )
                vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
 
             struct async_workshop_filepath_info *info = call->payload;
-            info->buf = path;
+            info->buf = path_buf;
             info->id = reg->workshop_id;
-            info->len = vg_list_size(path) - strlen("/board.mdl")-1;
+            info->len = vg_list_size(path_buf);
             vg_async_dispatch( call, async_workshop_get_filepath );
             vg_async_stall(); /* too bad! */
 
-            if( path[0] == '\0' ){
-               SDL_AtomicLock( &global_skateshop.sl_cache_access );
-               cache_ptr->state = k_cache_board_state_none;
-               SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
-
+            if( path_buf[0] == '\0' ){
                vg_error( "Failed SteamAPI_GetItemInstallInfo(" PRINTF_U64 ")\n",
                            reg->workshop_id );
-               continue;
-            }
-            else{
-               strcat( path, "/board.mdl" );
+
+               goto file_is_broken;
             }
+
+            folder.buffer = path_buf;
+            folder.i = strlen(path_buf);
+            folder.len = 4096;
          }
          else{
-            snprintf( path, 256, "models/boards/%s", reg->filename );
+            vg_strnull( &folder, path_buf, 4096 );
+            vg_strcat( &folder, "boards/" );
+            vg_strcat( &folder, reg->foldername );
+         }
+
+         vg_str meta_path = folder;
+         vg_strcat( &meta_path, "/addon.inf" );
+
+         if( !vg_strgood( &meta_path ) ) {
+            vg_error( "Metadata path too long\n" );
+            goto file_is_broken;
+         }
+
+         u8 meta[512];
+         FILE *fp = fopen( meta_path.buffer, "rb" );
+
+         if( !fp ) goto file_is_broken;
+
+         u32 l = fread( meta, 1, 512, fp );
+         if( l != 512 ){
+            if( !feof(fp) ){
+               fclose(fp);
+               vg_error( "unknown error codition" );
+               goto file_is_broken;
+            }
+         }
+         fclose(fp);
+
+         /* load content files
+          * --------------------------------- */
+
+         vg_str content_path = folder;
+
+         vg_msg msg;
+         vg_msg_init( &msg, meta, l );
+         vg_msg_cmd cmd;
+         while( vg_msg_next( &msg, &cmd ) ){
+            if( (msg.depth == 0) && (cmd.code == k_vg_msg_code_kvstring) ){
+               if( VG_STRDJB2_EQ( "content", cmd.key, cmd.key_djb2 ) ){
+                  vg_strcat( &content_path, "/" );
+                  vg_strcat( &content_path, cmd.value._buf );
+                  break;
+               }
+            }
+         }
+         if( !vg_strgood( &content_path ) ) {
+            vg_error( "Metadata path too long\n" );
+            goto file_is_broken;
          }
 
-         player_board_load( &cache_ptr->board, path );
+         player_board_load( &cache_ptr->board, content_path.buffer );
          vg_async_call( skateshop_async_board_loaded, cache_ptr, 0 );
+         continue;
+
+file_is_broken:;
+         SDL_AtomicLock( &global_skateshop.sl_cache_access );
+         cache_ptr->state = k_cache_board_state_none;
+         SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
       }
       else
          SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
@@ -220,8 +275,9 @@ VG_STATIC void workshop_steam_scan(void)
    vg_async_stall();
 
    for( u32 j=0; j<workshop_count; j++ ){
+      /* check for existance in both our caches
+       * ----------------------------------------------------------*/
       PublishedFileId_t id = workshop_ids[j];
-
       for( u32 i=0; i<global_skateshop.t1_registry_count; i++ ){
          struct registry_board *reg = &global_skateshop.registry[i];
 
@@ -230,41 +286,114 @@ VG_STATIC void workshop_steam_scan(void)
             goto next_file_workshop;
          }
       }
+      for( u32 i=0; i<global_skateshop.t1_world_registry_count; i++ ){
+         struct registry_world *reg = &global_skateshop.world_registry[i];
 
-      if( global_skateshop.t1_registry_count == SKATESHOP_REGISTRY_MAX ){
-         vg_error( "You have too many boards installed!\n" );
-         break;
+         if( reg->workshop_id == id ){
+            reg->state = k_registry_board_state_indexed;
+            goto next_file_workshop;
+         }
       }
 
+      /* new one, lets find out what type it is
+       * ---------------------------------------------------------------*/
       vg_info( "new listing from the steam workshop!: "PRINTF_U64"\n", id );
+      vg_async_item *call1 = 
+         vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
 
-      struct registry_board *reg = &global_skateshop.registry[
-                                       global_skateshop.t1_registry_count ++ ];
+      char path[ 4096 ];
 
-      reg->cache_ptr = NULL;
-      snprintf( reg->filename, 64, PRINTF_U64, id );
-      reg->filename_hash = vg_strdjb2( reg->filename );
-      reg->workshop_id = id;
-      reg->state = k_registry_board_state_indexed;
+      struct async_workshop_filepath_info *info = call1->payload;
+      info->buf = path;
+      info->id = id;
+      info->len = vg_list_size(path);
+      vg_async_dispatch( call1, async_workshop_get_filepath );
+      vg_async_stall(); /* too bad! */
 
-      workshop_file_info_clear( &reg->workshop );
-      strcpy( reg->workshop.title, "Workshop file" );
+      vg_info( "%s\n", path );
+      vg_str folder = {.buffer = path, .i=strlen(path), .len=4096};
+      vg_str meta_path = folder;
+      vg_strcat( &meta_path, "/addon.inf" );
+      if( !vg_strgood( &meta_path ) ){
+         vg_error( "The metadata path is too long\n" );
+         goto next_file_workshop;
+      }
 
-      /* load the metadata off the disk */
-      vg_async_item *call = 
-         vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
+      u8 meta[512];
+      FILE *fp = fopen( meta_path.buffer, "rb" );
+      if( !fp ){
+         vg_error( "Could not open the '%s'\n", meta_path.buffer );
+         goto next_file_workshop;
+      }
 
-      const char *meta_file = "/board.mdl.inf";
-      char path[ 1024 ];
-      struct async_workshop_filepath_info *info = call->payload;
-      info->buf = path;
-      info->id = reg->workshop_id;
-      info->len = vg_list_size(path) - strlen(meta_file)-1;
-      vg_async_dispatch( call, async_workshop_get_filepath );
-      vg_async_stall(); /* too bad! */
+      u32 l = fread( meta, 1, 512, fp );
+      if( l != 512 ){
+         if( !feof(fp) ){
+            fclose(fp);
+            vg_error( "unknown error codition" );
+            goto next_file_workshop;
+         }
+      }
+      fclose(fp);
+
+      enum workshop_file_type type = k_workshop_file_type_none;
+      vg_msg msg;
+      vg_msg_init( &msg, meta, l );
+
+      vg_msg_cmd cmd;
+      while( vg_msg_next( &msg, &cmd ) ){
+         if( (msg.depth == 1) && (cmd.code == k_vg_msg_code_frame) ){
+            if( VG_STRDJB2_EQ( "workshop", cmd.key, cmd.key_djb2 ) ){
+               u32 depth = msg.depth;
+               while( (msg.depth == depth) && vg_msg_next( &msg, &cmd ) ){
+                  if( cmd.code & k_vg_msg_code_unsigned ){
+                     if( VG_STRDJB2_EQ( "type", cmd.key, cmd.key_djb2 ) ){
+                        type = cmd.value._u32;
+                     }
+                  }
+               }
+            }
+         }
+      }
+
+      if( type == k_workshop_file_type_none ){
+         vg_error( "Cannot determine addon type\n" );
+         goto next_file_workshop;
+      }
+
+      /* now that we have the type
+       * ------------------------------------------------------------------*/
+
+      if( type == k_workshop_file_type_board ){
+         if( global_skateshop.t1_registry_count == SKATESHOP_REGISTRY_MAX ){
+            vg_error( "You have too many boards installed!\n" );
+            goto next_file_workshop;
+         }
+
+         struct registry_board *reg = &global_skateshop.registry[
+                                       global_skateshop.t1_registry_count ++ ];
+
+         reg->cache_ptr = NULL;
+         snprintf( reg->foldername, 64, PRINTF_U64, id );
+         reg->foldername_hash = vg_strdjb2( reg->foldername );
+         reg->workshop_id = id;
+         reg->state = k_registry_board_state_indexed;
+      }
+      else if( type == k_workshop_file_type_world ){
+         if( global_skateshop.t1_world_registry_count == SKATESHOP_WORLDS_MAX ){
+            vg_error( "You have too many worlds installed!\n" );
+            goto next_file_workshop;
+         }
 
-      strcat( path, meta_file );
-      workshop_load_metadata( path, &reg->workshop );
+         struct registry_world *reg = &global_skateshop.world_registry[
+                                 global_skateshop.t1_world_registry_count ++ ];
+         
+         snprintf( reg->foldername, 64, PRINTF_U64, id );
+         reg->foldername_hash = vg_strdjb2( reg->foldername );
+         reg->type = k_world_load_type_workshop;
+         reg->workshop_id = id;
+         reg->state = k_registry_board_state_indexed;
+      }
 
 next_file_workshop:;
    }
@@ -283,6 +412,7 @@ VG_STATIC void workshop_scan_thread( void *_args )
       reg->state = k_registry_board_state_indexed_absent;
    }
 
+#if 0
    /*
     * Local disk scan
     */
@@ -318,19 +448,25 @@ VG_STATIC void workshop_scan_thread( void *_args )
 
          reg->cache_ptr = NULL;
          vg_strncpy( file.name, reg->filename, 64, k_strncpy_always_add_null );
+#if 0
          vg_strncpy( file.name, reg->workshop.title,
                      64, k_strncpy_always_add_null );
+#endif
          reg->filename_hash = hash;
          reg->workshop_id = 0;
          reg->state = k_registry_board_state_indexed;
+
+#if 0
          reg->workshop.author = 0;
          strcpy( reg->workshop.author_name, "custom" );
+#endif
       }
 
 next_file: tinydir_next( &dir );
    }
 
    tinydir_close(&dir);
+#endif
 
    if( steam_ready ) workshop_steam_scan();
    
@@ -527,6 +663,7 @@ VG_STATIC void callback_persona_statechange( CallbackMsg_t *msg )
    PersonaStateChange_t *info = (PersonaStateChange_t *)msg->m_pubParam;
    ISteamFriends *hSteamFriends = SteamAPI_SteamFriends();
 
+#if 0
    if( info->m_nChangeFlags & k_EPersonaChangeName ){
       for( u32 i=0; i<global_skateshop.registry_count; i++ ){
          struct registry_board *reg = &global_skateshop.registry[i];
@@ -537,6 +674,7 @@ VG_STATIC void callback_persona_statechange( CallbackMsg_t *msg )
          }
       }
    }
+#endif
 }
 
 /*
@@ -966,6 +1104,8 @@ fade_out:;
 
    struct registry_board *reg = 
       &global_skateshop.registry[cache_ptr->registry_id];
+
+#if 0
    struct workshop_file_info *info = &reg->workshop;
 
    /* Skin title
@@ -989,6 +1129,7 @@ fade_out:;
    mlocal[3][2] = 0.0f;
    m4x3_mul( mtext, mlocal, mmdl );
    font3d_simple_draw( &gui.font, 0, info->author_name, &main_camera, mmdl );
+#endif
 }
 
 VG_STATIC void skateshop_render_charshop(void)
index c368c8d3425cfd3f9592250e6e551b91407712a4..3b432c168a506a8bbc9df9f6557998de2ab3c39b 100644 (file)
@@ -47,11 +47,11 @@ struct{
       PublishedFileId_t workshop_id;
 
       /* only for steam workshop files */
-      struct workshop_file_info workshop;
+      //struct workshop_file_info workshop;
       struct cache_board *cache_ptr;
 
-      char filename[64]; /* if workshop, string version of its published ID. */
-      u32 filename_hash;
+      char foldername[64]; /* if workshop, string version of its published ID. */
+      u32 foldername_hash;
 
       enum registry_board_state{
          k_registry_board_state_none,
@@ -68,6 +68,7 @@ struct{
 
    /* worlds */
    struct registry_world{
+      PublishedFileId_t workshop_id;
       enum registry_board_state state;
       char foldername[64];
       u32 foldername_hash;
diff --git a/maps_src/mp_mtzero/main.mdl.meta b/maps_src/mp_mtzero/main.mdl.meta
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/maps_src/mp_spawn/addon.inf b/maps_src/mp_spawn/addon.inf
new file mode 100644 (file)
index 0000000..2530093
Binary files /dev/null and b/maps_src/mp_spawn/addon.inf differ
index 4d84fa082e0d14384f2ea044bde4cb1331699ea4..cf0e25a8628e43c384ad5dded311ff9dc0fb4610 100644 (file)
@@ -4,6 +4,7 @@
 #define VG_GAME
 #include "vg/vg.h"
 #include "vg/vg_tex.h"
+#include "vg/vg_msg.h"
 #include "ent_skateshop.h"
 
 #include "vg/vg_steam_auth.h"
@@ -19,11 +20,13 @@ struct workshop_form{
    struct {
       char title[80];
       char description[512];
+      char author[32];
+      struct ui_dropdown_value submission_type_selection;
+      enum workshop_file_type type;
 
       PublishedFileId_t file_id; /* 0 if not published yet */
 
       struct ui_dropdown_value visibility;
-
       int submit_title,       /* set if the respective controls are touched */
           submit_description,
           submit_file_and_image;
@@ -44,7 +47,7 @@ struct workshop_form{
     * -----------------------------
     */
 
-   char model_path[128];
+   char addon_folder[128];
    struct player_board board_model;
 
    /* what does the user want to do with the image preview? */
@@ -109,6 +112,12 @@ static struct ui_dropdown_opt workshop_form_visibility_opts[] = {
  { "Private",      k_ERemoteStoragePublishedFileVisibilityPrivate },
 };
 
+static struct ui_dropdown_opt workshop_form_type_opts[] = {
+ { "None",  k_workshop_file_type_none },
+ { "Board", k_workshop_file_type_board },
+ { "World", k_workshop_file_type_world },
+};
+
 /* 
  * Close the form and discard UGC query result
  */
@@ -138,12 +147,17 @@ VG_STATIC void workshop_reset_submission_data(void)
    workshop_form.submission.file_id = 0; /* assuming id of 0 is none/invalid */
    workshop_form.submission.description[0] = '\0';
    workshop_form.submission.title[0] = '\0';
+   workshop_form.submission.author[0] = '\0';
+   workshop_form.submission.submission_type_selection.value = 
+      k_workshop_file_type_none;
+   workshop_form.submission.submission_type_selection.index = 0;
+   workshop_form.submission.type = k_workshop_file_type_none;
 
    workshop_form.submission.visibility.value = 
       k_ERemoteStoragePublishedFileVisibilityPublic;
    workshop_form.submission.visibility.index = 0;
 
-   workshop_form.model_path[0] = '\0';
+   workshop_form.addon_folder[0] = '\0';
    player_board_unload( &workshop_form.board_model );
    workshop_form.file_intent = k_workshop_form_file_intent_none;
 }
@@ -230,38 +244,22 @@ VG_STATIC void on_workshop_update_result( void *data, void *user )
    skaterift_end_op();
 }
 
-struct workshop_package_info {
-   PublishedFileId_t publishing_file_id;
-
-   int success;
-   char abs_preview_image[ 1024 ];
-   char abs_content_folder[ 1024 ];
-   char abs_content_file[ 1024 ];
-
-   const char *failure_reason;
-};
-
 /*
  * reciever on completion of packaging the files, it will then start the item
  * update with Steam API
  */
-VG_STATIC void workshop_form_async_package_complete( void *data, u32 size )
+VG_STATIC void workshop_form_upload_submission( PublishedFileId_t file_id,
+                                                char *metadata )
 {
-   struct workshop_package_info *info = data;
-   if( !info->success ){
-      workshop_form.page = k_workshop_form_closing_bad;
-      workshop_form.failure_or_success_string = info->failure_reason;
-      skaterift_end_op();
-      return;
-   }
-
    ISteamUGC *hSteamUGC = SteamAPI_SteamUGC();
    UGCUpdateHandle_t handle 
       = SteamAPI_ISteamUGC_StartItemUpdate( hSteamUGC, SKATERIFT_APPID,
-                                            info->publishing_file_id );
+                                            file_id );
 
    /* TODO: Handle failure cases for these */
 
+   SteamAPI_ISteamUGC_SetItemMetadata( hSteamUGC, handle, metadata );
+
    if( workshop_form.submission.submit_title ){
       vg_info( "Setting title\n" );
       SteamAPI_ISteamUGC_SetItemTitle( hSteamUGC, handle, 
@@ -275,13 +273,27 @@ VG_STATIC void workshop_form_async_package_complete( void *data, u32 size )
    }
 
    if( workshop_form.submission.submit_file_and_image ){
-      vg_info( "Setting preview image\n" );
-      SteamAPI_ISteamUGC_SetItemPreview( hSteamUGC, 
-                                         handle, info->abs_preview_image );
+      char path_buf[4096];
+      vg_str folder;
+      vg_strnull( &folder, path_buf, 4096 );
+      vg_strcat( &folder, vg.base_path );
+
+      if( workshop_form.submission.type == k_workshop_file_type_board ){
+         vg_strcat( &folder, "boards/" );
+      }
+      else if( workshop_form.submission.type == k_workshop_file_type_world ){
+         vg_strcat( &folder, "maps/" );
+      }
+      vg_strcat( &folder, workshop_form.addon_folder );
 
       vg_info( "Setting item content\n" );
-      SteamAPI_ISteamUGC_SetItemContent( hSteamUGC, handle, 
-                                         info->abs_content_folder );
+      SteamAPI_ISteamUGC_SetItemContent( hSteamUGC, handle, folder.buffer );
+      
+      vg_str preview = folder;
+      vg_strcat( &preview, "/preview.jpg" );
+
+      vg_info( "Setting preview image\n" );
+      SteamAPI_ISteamUGC_SetItemPreview( hSteamUGC, handle, preview.buffer );
    }
 
    vg_info( "Setting visibility\n" );
@@ -295,118 +307,6 @@ VG_STATIC void workshop_form_async_package_complete( void *data, u32 size )
    call->id = SteamAPI_ISteamUGC_SubmitItemUpdate( hSteamUGC, handle, "" );
 }
 
-/*
- * Async thread for rearranging files into a reasonable workshop folder
- */
-struct workshop_package_thread_args{
-   PublishedFileId_t file_id;
-
-   u64_steamid steamid;
-   char username[32];
-};
-VG_STATIC void _workshop_package_thread( void *_args )
-{
-   struct workshop_package_thread_args *args = _args;
-   PublishedFileId_t file_id = args->file_id;
-
-   vg_info( "Packaging workshop content folder\n" );
-
-   vg_async_item *call = vg_async_alloc( sizeof(struct workshop_package_info) );
-   struct workshop_package_info *info = call->payload;
-   info->publishing_file_id = file_id;
-   info->failure_reason = "Unknown failure reason";
-   
-   /* build content folder path */
-   snprintf( info->abs_content_folder, 1024, "%smodels/boards/workshop/%lu", 
-             vg.base_path, file_id );
-
-   /* build content file path */
-   snprintf( info->abs_content_file, 1024, "%s/%s", info->abs_content_folder, 
-             "board.mdl" );
-
-   /* build workshop preview file path */
-   snprintf( info->abs_preview_image, 1024, "%sworkshop_preview.jpg", 
-             vg.base_path );
-
-   /* arange files */
-   if( !vg_mkdir( info->abs_content_folder ) ){
-      info->success = 0;
-      info->failure_reason = "Could not make directory.";
-      vg_async_dispatch( call, workshop_form_async_package_complete );
-      return;
-   }
-
-   vg_linear_clear( vg_mem.scratch );
-   if( !vg_file_copy( workshop_form.model_path, info->abs_content_file, 
-                      vg_mem.scratch ) ){
-      info->success = 0;
-      info->failure_reason = "Copy file failed.";
-      vg_async_dispatch( call, workshop_form_async_package_complete );
-      return;
-   }
-
-   /* write the metadata file */
-   struct workshop_file_info meta;
-   meta.author = args->steamid;
-   vg_strncpy( args->username, meta.author_name, vg_list_size(meta.author_name),
-               k_strncpy_always_add_null );
-   vg_strncpy( workshop_form.submission.title, meta.title, 
-               vg_list_size(meta.title), k_strncpy_always_add_null );
-
-   char _path[1024];
-   vg_str path;
-   vg_strnull( &path, _path, vg_list_size( _path ) );
-   vg_strcat( &path, info->abs_content_file );
-   vg_strcat( &path, ".inf" );
-   
-   if( vg_strgood( &path ) ){
-      FILE *fp = fopen( _path, "wb" );
-
-      if( fp ){
-         fwrite( &meta, sizeof(struct workshop_file_info), 1, fp );
-         fclose( fp );
-      }
-      else{
-         info->success = 0;
-         info->failure_reason = "Cant write .inf file";
-         vg_async_dispatch( call, workshop_form_async_package_complete );
-      }
-   }
-   else{
-      info->success = 0;
-      info->failure_reason = "Path too long";
-      vg_async_dispatch( call, workshop_form_async_package_complete );
-      return;
-   }
-
-   info->success = 1;
-   vg_async_dispatch( call, workshop_form_async_package_complete );
-}
-
-/*
- * Begins the packaging thread using file_id. Thread definition above.
- */
-VG_STATIC void workshop_package_submission( PublishedFileId_t file_id )
-{
-   vg_linear_clear( vg_mem.scratch );
-   struct workshop_package_thread_args *args = 
-      vg_linear_alloc( vg_mem.scratch, 
-                       sizeof(struct workshop_package_thread_args));
-
-   ISteamFriends *hSteamFriends = SteamAPI_SteamFriends();
-   ISteamUser *hSteamUser = SteamAPI_SteamUser();
-
-   args->steamid = SteamAPI_ISteamUser_GetSteamID( hSteamUser );
-
-   const char *username = SteamAPI_ISteamFriends_GetPersonaName(hSteamFriends);
-   str_utf8_collapse( username, args->username, vg_list_size( args->username ));
-   vg_info( "Steamid: "PRINTF_U64", Name: %s(%s)\n", 
-               args->steamid, username, args->username );
-
-   args->file_id = file_id;
-   vg_loader_start( _workshop_package_thread, args );
-}
-
 /*
  * Steam API call result for when we've created a new item on their network, or 
  * not, if it has failed
@@ -423,7 +323,7 @@ VG_STATIC void on_workshop_createitem( void *data, void *user )
          vg_warn( "Workshop agreement currently not accepted\n" );
       }
       
-      workshop_package_submission( result->m_nPublishedFileId );
+      workshop_form_upload_submission( result->m_nPublishedFileId, user );
    }
    else{
       const char *errstr = workshop_EResult_user_string( result->m_eResult );
@@ -444,26 +344,15 @@ VG_STATIC void on_workshop_createitem( void *data, void *user )
  */
 VG_STATIC void workshop_form_async_submit_begin( void *payload, u32 size )
 {
+
    /* use existing file */
    if( workshop_form.submission.file_id ){
-      if( workshop_form.submission.submit_file_and_image ){
-         workshop_package_submission( workshop_form.submission.file_id );
-      }
-      else{
-         struct workshop_package_info info;
-         info.abs_content_file[0] = '\0';
-         info.abs_content_folder[0] = '\0';
-         info.abs_preview_image[0] = '\0';
-         info.failure_reason = NULL;
-         info.publishing_file_id = workshop_form.submission.file_id;
-         info.success = 1;
-         workshop_form_async_package_complete( &info, 
-                                       sizeof(struct workshop_package_info) );
-      }
+      workshop_form_upload_submission( workshop_form.submission.file_id,
+                                       payload );
    }
    else{
       vg_steam_async_call *call = vg_alloc_async_steam_api_call();
-      call->userdata = NULL;
+      call->userdata = payload;
       call->p_handler = on_workshop_createitem;
       ISteamUGC *hSteamUGC = SteamAPI_SteamUGC();
       call->id = SteamAPI_ISteamUGC_CreateItem( hSteamUGC, SKATERIFT_APPID, 
@@ -499,15 +388,110 @@ VG_STATIC void _workshop_form_submit_thread( void *data )
    vg_async_call( workshop_form_async_download_image, NULL, 0 );
    vg_async_stall();
 
+   char path_buf[4096];
+   vg_str folder;
+   vg_strnull( &folder, path_buf, 4096 );
+
+   if( workshop_form.submission.type == k_workshop_file_type_board ){
+      vg_strcat( &folder, "boards/" );
+   }
+   else if( workshop_form.submission.type == k_workshop_file_type_world ){
+      vg_strcat( &folder, "maps/" );
+   }
+   vg_strcat( &folder, workshop_form.addon_folder );
+
+   if( !vg_strgood(&folder) ){
+      vg_error( "addon folder path too long\n" );
+      vg_async_call( workshop_async_any_complete, NULL, 0 );
+      return;
+   }
+
+   /* 
+    * Create the metadata file
+    * -----------------------------------------------------------------------*/
+   u8 descriptor_buf[ 512 ];
+   vg_msg descriptor;
+   vg_msg_init( &descriptor, descriptor_buf, 512 );
+   vg_msg_frame( &descriptor, "workshop" );
+      vg_msg_wkvstr( &descriptor, "title", workshop_form.submission.title );
+      //vg_msg_wkvstr( &descriptor, "author", "unknown" );
+      vg_msg_wkvuint( &descriptor, "type", 
+                      u32 value=workshop_form.submission.type);
+      vg_msg_wkvstr( &descriptor, "folder", workshop_form.addon_folder );
+   vg_msg_end_frame( &descriptor );
+   //vg_msg_wkvstr( &descriptor, "location", "USA" );
+   //
+   vg_linear_clear( vg_mem.scratch );
+   char *descriptor_str = vg_linear_alloc( vg_mem.scratch, 
+                                           vg_align8(descriptor.cur*2+1) );
+   vg_bin_str( descriptor_buf, descriptor_str, descriptor.cur );
+   descriptor_str[descriptor.cur*2] = '\0';
+   vg_info( "binstr: %s\n", descriptor_str );
+
+   DIR *dir = opendir( folder.buffer );
+   if( !dir ){
+      vg_error( "could not open addon folder '%s'\n", folder.buffer );
+      vg_async_call( workshop_async_any_complete, NULL, 0 );
+      return;
+   }
+
+   struct dirent *entry;
+   while( (entry = readdir(dir)) ){
+      if( entry->d_type == DT_REG ){
+         if( entry->d_name[0] == '.' ) continue;
+
+         vg_str file = folder;
+         vg_strcat( &file, "/" );
+         vg_strcat( &file, entry->d_name );
+         if( !vg_strgood( &file ) ) continue;
+
+         char *ext = vg_strch( &file, '.' );
+         if( !ext ) continue;
+         if( strcmp(ext,".mdl") ) continue;
+
+         vg_msg_wkvstr( &descriptor, "content", entry->d_name );
+         break;
+      }
+   }
+   closedir(dir);
+
+   vg_str descriptor_file = folder;
+   vg_strcat( &descriptor_file, "/addon.inf" );
+   if( !vg_strgood(&descriptor_file) ){
+      vg_error( "Addon info path too long\n" );
+      vg_async_call( workshop_async_any_complete, NULL, 0 );
+      return;
+   }
+   
+   FILE *fp = fopen( descriptor_file.buffer, "wb" );
+   if( !fp ){
+      vg_error( "Could not open addon info file '%s'\n", 
+                descriptor_file.buffer );
+      vg_async_call( workshop_async_any_complete, NULL, 0 );
+      return;
+   }
+   fwrite( descriptor_buf, descriptor.cur, 1, fp );
+   fclose( fp );
+
+   /* Save the preview 
+    * -----------------------------------------------------------------------*/
+   vg_str preview = folder;
+   vg_strcat( &preview, "/preview.jpg" );
+
+   if( !vg_strgood(&preview) ){
+      vg_error( "preview image path too long\n" );
+      vg_async_call( workshop_async_any_complete, NULL, 0 );
+      return;
+   }
+
    int w = workshop_form.img_w,
        h = workshop_form.img_h;
 
-   vg_info( "writing: workshop_preview.jpg (%dx%d @90%%)\n", w,h );
+   vg_info( "writing: %s (%dx%d @90%%)\n", preview.buffer, w,h );
    stbi_flip_vertically_on_write(1);
-   stbi_write_jpg( "workshop_preview.jpg", w,h, 3, 
-                   workshop_form.img_buffer, 90 );
+   stbi_write_jpg( preview.buffer, w,h, 3, workshop_form.img_buffer, 90 );
 
-   vg_async_call( workshop_form_async_submit_begin, NULL, 0 );
+   vg_async_call( workshop_form_async_submit_begin, descriptor_str, 0 );
 }
 
 /*
@@ -516,7 +500,6 @@ VG_STATIC void _workshop_form_submit_thread( void *data )
 VG_STATIC void workshop_op_submit(void)
 {
    /* TODO: Show these errors to the user */
-
    if( workshop_form.submission.submit_title ){
       if( !workshop_form.submission.title[0] ){
          vg_error( "Cannot submit because a title is required\n" );
@@ -579,16 +562,59 @@ VG_STATIC void workshop_form_loadmodel_async_error( void *payload, u32 size )
  */
 VG_STATIC void _workshop_form_load_thread( void *data )
 {
-   FILE *test = fopen( workshop_form.model_path, "rb" );
-   if( test ){
-      fclose( test );
-      player_board_load( &workshop_form.board_model, workshop_form.model_path );
-      vg_async_call( workshop_form_loadmodel_async_complete, NULL, 0 );
+   char path_buf[4096];
+   vg_str folder;
+   vg_strnull( &folder, path_buf, 4096 );
+
+   if( workshop_form.submission.type == k_workshop_file_type_world )
+      vg_strcat( &folder, "maps/" );
+   else vg_strcat( &folder, "boards/" );
+
+   vg_strcat( &folder, workshop_form.addon_folder );
+
+   if( !vg_strgood(&folder) ){
+      vg_error( "workshop async load failed: path too long\n" );
+      vg_async_call( workshop_form_loadmodel_async_error, NULL, 0 );
+      return;
    }
-   else{
-      vg_error( "workshop async load failed: file not found\n" );
+
+   DIR *dir = opendir( folder.buffer );
+   if( !dir ){
+      vg_error( "workshop async load failed: could not open folder\n" );
       vg_async_call( workshop_form_loadmodel_async_error, NULL, 0 );
+      return;
    }
+
+   vg_info( "Searching %s for model files\n", folder.buffer );
+
+   int found_mdl = 0;
+   struct dirent *entry;
+   while( (entry = readdir(dir)) ){
+      if( entry->d_type == DT_REG ){
+         if( entry->d_name[0] == '.' ) continue;
+
+         vg_str file = folder;
+         vg_strcat( &file, "/" );
+         vg_strcat( &file, entry->d_name );
+         if( !vg_strgood( &file ) ) continue;
+
+         char *ext = vg_strch( &file, '.' );
+         if( !ext ) continue;
+         if( strcmp(ext,".mdl") ) continue;
+         found_mdl = 1;
+         break;
+      }
+   }
+   closedir(dir);
+
+   if( !found_mdl ){
+      vg_error( "workshop async load failed: no model files found\n" );
+      vg_async_call( workshop_form_loadmodel_async_error, NULL, 0 );
+      return;
+   }
+
+   player_board_load( &workshop_form.board_model, path_buf );
+   vg_async_call( workshop_form_loadmodel_async_complete, NULL, 0 );
 }
 
 /*
@@ -596,6 +622,11 @@ VG_STATIC void _workshop_form_load_thread( void *data )
  */
 VG_STATIC void workshop_op_load_model(void)
 {
+   if( workshop_form.submission.type == k_workshop_file_type_world ){
+      vg_error( "Currently unsupported\n" );
+      return;
+   }
+
    skaterift_begin_op( k_workshop_form_op_loading_model );
    vg_loader_start( _workshop_form_load_thread, NULL );
 }
@@ -696,6 +727,13 @@ VG_STATIC void workshop_op_download_and_view_submission( int result_index )
       workshop_form.submission.submit_file_and_image = 0;
       workshop_form.submission.submit_title = 0;
 
+      u8 metadata_buf[512];
+      char metadata_str[1024+1];
+      int have_meta = SteamAPI_ISteamUGC_GetQueryUGCMetadata( hSteamUGC, 
+                                              workshop_form.ugc_query.handle,
+                                              result_index, metadata_str, 
+                                              1024+1 );
+
       vg_strncpy( details.m_rgchDescription, 
                   workshop_form.submission.description, 
                   vg_list_size( workshop_form.submission.description ),
@@ -706,22 +744,80 @@ VG_STATIC void workshop_op_download_and_view_submission( int result_index )
                   vg_list_size( workshop_form.submission.title ),
                   k_strncpy_always_add_null );
 
-      snprintf( workshop_form.model_path
-                 vg_list_size( workshop_form.model_path ),
+      snprintf( workshop_form.addon_folder
+                 vg_list_size( workshop_form.addon_folder ),
                  "Steam Cloud (%lu)", details.m_nPublishedFileId );
 
       workshop_form.submission.file_id = details.m_nPublishedFileId;
       workshop_form.file_intent = k_workshop_form_file_intent_keep_old;
       workshop_form.page = k_workshop_form_edit;
       workshop_form.submission.visibility.value = details.m_eVisibility;
+      workshop_form.submission.type = k_workshop_file_type_none;
+      workshop_form.submission.submission_type_selection.index = 0;
+      workshop_form.submission.submission_type_selection.value = 
+         k_workshop_file_type_none;
+
+      if( have_meta ){
+         u32 len = strlen(metadata_str);
+         vg_info( "Metadata: %s\n", metadata_str );
+         vg_str_bin( metadata_str, metadata_buf, len );
+         vg_msg msg;
+         vg_msg_init( &msg, metadata_buf, len/2 );
+         
+         vg_msg_cmd cmd;
+         while( vg_msg_next( &msg, &cmd ) ){
+            if( (msg.depth == 1) && (cmd.code == k_vg_msg_code_frame) ){
+               if( VG_STRDJB2_EQ( "workshop", cmd.key, cmd.key_djb2 ) ){
+                  u32 depth = msg.depth;
+                  while( (msg.depth == depth) && vg_msg_next( &msg, &cmd ) ){
+                     if( cmd.code & k_vg_msg_code_unsigned ){
+                        if( VG_STRDJB2_EQ( "type", cmd.key, cmd.key_djb2 ) ){
+                           workshop_form.submission.type = cmd.value._u32;
+   workshop_form.submission.submission_type_selection.value = cmd.value._u32;
+                        }
+                     }
+                     else if( cmd.code == k_vg_msg_code_kvstring ){
+                        if( VG_STRDJB2_EQ( "folder", cmd.key, cmd.key_djb2 ) ){
+                           vg_strncpy( cmd.value._buf,
+                                       workshop_form.addon_folder,
+                                       sizeof(workshop_form.addon_folder),
+                                       k_strncpy_always_add_null );
+                        }
+                     }
+                  }
+               }
+            }
+         }
+      }
+      else{
+         vg_error( "No metadata was returned with this item.\n" );
+      }
 
+      /* TODO.... */
       for( i32 i=0; i<vg_list_size(workshop_form_visibility_opts); i++ ){
          if( workshop_form_visibility_opts[i].value == details.m_eVisibility ){
             workshop_form.submission.visibility.index = i;
             break;
          }
       }
+      for( i32 i=0; i<vg_list_size(workshop_form_type_opts); i++ ){
+         if( workshop_form_type_opts[i].value == 
+               workshop_form.submission.submission_type_selection.value ){
+            workshop_form.submission.submission_type_selection.index = i;
+            break;
+         }
+      }
+
+      vg_error( "m_hPreviewFile is 0\n" );
+      render_fb_bind( gpipeline.fb_workshop_preview, 0 );
+      glClearColor( 0.2f, 0.0f, 0.0f, 1.0f );
+      glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
+      glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+      glViewport( 0,0, vg.window_x, vg.window_y );
 
+      skaterift_end_op();
+
+#if 0
       if( details.m_hPreviewFile == 0 ){
          vg_error( "m_hPreviewFile is 0\n" );
          skaterift_end_op();
@@ -747,6 +843,7 @@ VG_STATIC void workshop_op_download_and_view_submission( int result_index )
          vg_info( "preview file id: " PRINTF_U64 "\n", 
                details.m_hPreviewFile );
       }
+#endif
    }
    else{
       vg_error( "GetQueryUGCResult: Index out of range\n" );
@@ -881,6 +978,7 @@ VG_STATIC int workshop_submit_command( int argc, const char *argv[] )
                 k_EUserUGCListSortOrder_CreationOrderDesc,
                 SKATERIFT_APPID, SKATERIFT_APPID,
                 1 );
+   SteamAPI_ISteamUGC_SetReturnMetadata( hSteamUGC, handle, 1 );
    call->id = SteamAPI_ISteamUGC_SendQueryUGCRequest( hSteamUGC, handle );
    return 0;
 }
@@ -1016,6 +1114,48 @@ VG_STATIC void workshop_changed_description( char *buf, u32 len ){
 
 VG_STATIC void workshop_form_gui_edit_page( ui_rect content )
 {
+   if( workshop_form.submission.type == k_workshop_file_type_none ){
+      ui_rect box;
+      rect_copy( content, box );
+      box[3] = 128;
+      box[2] = (box[2]*2)/3;
+      ui_rect_center( content, box );
+
+      ui_rect row;
+      ui_split( box, k_ui_axis_h, 28, 0, row, box );
+      ui_text( row, "Select the type of item\n", 1, k_ui_align_middle_center,0);
+      ui_split( box, k_ui_axis_h, 28, 0, row, box );
+      ui_enum( row, "Type:", workshop_form_type_opts,
+               3, &workshop_form.submission.submission_type_selection );
+      ui_split( box, k_ui_axis_h, 8, 0, row, box );
+      ui_split( box, k_ui_axis_h, 28, 0, row, box );
+
+      ui_rect button_l, button_r;
+      rect_copy( row, button_l );
+      button_l[2] = 128*2;
+      ui_rect_center( row, button_l );
+      ui_split_ratio( button_l, k_ui_axis_v, 0.5f, 2, button_l, button_r );
+
+      if( workshop_form.submission.submission_type_selection.value !=
+            k_workshop_file_type_none ){
+         if( ui_button_text( button_l, "OK", 1 ) ){
+            workshop_form.submission.type = 
+               workshop_form.submission.submission_type_selection.value;
+         }
+      }
+      else{
+         ui_fill( button_l, ui_colour(k_ui_bg) );
+         ui_text( button_l, "OK", 1, k_ui_align_middle_center, 
+                  ui_colour(k_ui_bg+4) );
+      }
+      
+      if( ui_button_text( button_r, "Cancel", 1 ) ){
+         workshop_form.page = k_workshop_form_open;
+         workshop_form.file_intent = k_workshop_form_file_intent_none;
+      }
+      return;
+   }
+
    ui_rect image_plane;
    ui_split( content, k_ui_axis_h, 300, 0, image_plane, content );
    ui_fill( image_plane, ui_colour( k_ui_bg+0 ) );
@@ -1087,17 +1227,24 @@ VG_STATIC void workshop_form_gui_edit_page( ui_rect content )
    ui_split( content, k_ui_axis_h, 8, 0, null, content );
    ui_split( content, k_ui_axis_h, 28, 0, file_entry, content );
    ui_split( file_entry, k_ui_axis_v, -128, 0, file_entry, file_button );
-   ui_split_label( file_entry, "File:", 1, 8, file_label, file_entry );
-   ui_text( file_label, "File:", 1, k_ui_align_middle_left, 0 );
+
+   if( workshop_form.submission.type == k_workshop_file_type_board ){
+      ui_label( file_entry, "Addon folder: skaterift/boards/", 
+                1, 8, file_entry );
+   }
+   else{
+      ui_label( file_entry, "Addon folder: skaterift/maps/", 
+                1, 8, file_entry );
+   }
 
    if( workshop_form.file_intent != k_workshop_form_file_intent_none ){
-      ui_text( file_entry, workshop_form.model_path, 1, k_ui_align_middle_left,
-               ui_colour( k_ui_fg+4 ) );
+      ui_text( file_entry, workshop_form.addon_folder, 1, 
+               k_ui_align_middle_left, ui_colour( k_ui_fg+4 ) );
 
       if( ui_button_text( file_button, "Remove", 1 ) ){
          player_board_unload( &workshop_form.board_model );
          workshop_form.file_intent = k_workshop_form_file_intent_none;
-         workshop_form.model_path[0] = '\0';
+         workshop_form.addon_folder[0] = '\0';
       }
    }
    else{
@@ -1105,8 +1252,8 @@ VG_STATIC void workshop_form_gui_edit_page( ui_rect content )
          .change = workshop_changed_model_path
       };
 
-      ui_textbox( file_entry, workshop_form.model_path,
-                  vg_list_size(workshop_form.model_path), 0, &callbacks );
+      ui_textbox( file_entry, workshop_form.addon_folder,
+                  vg_list_size(workshop_form.addon_folder), 0, &callbacks );
 
       if( ui_button_text( file_button, "Load", 1 ) ){
          workshop_find_preview_entity();
@@ -1212,13 +1359,41 @@ VG_STATIC void workshop_form_gui_edit_page( ui_rect content )
 
 VG_STATIC void workshop_form_gui_sidebar( ui_rect sidebar )
 {
-   /* 
-    * sidebar existing entries panel
-    */
    ui_fill( sidebar, ui_colour( k_ui_bg+2 ) );
 
    ui_rect title;
    ui_split( sidebar, k_ui_axis_h, 28, 0, title, sidebar );
+
+   if( workshop_form.page == k_workshop_form_edit ){
+      ui_text( title, "Editing", 1, k_ui_align_middle_center, 0 );
+      ui_split( sidebar, k_ui_axis_h, 28, 0, title, sidebar );
+
+      if( workshop_form.submission.type != k_workshop_file_type_none ){
+         char buf[512];
+         vg_str str;
+         vg_strnull( &str, buf, 512 );
+
+         if( workshop_form.submission.file_id )
+            vg_strcat( &str, "Editing an existing " );
+         else
+            vg_strcat( &str, "Creating a new " );
+
+         if( workshop_form.submission.type == k_workshop_file_type_board )
+            vg_strcat( &str, "skateboard." );
+         else if( workshop_form.submission.type == k_workshop_file_type_world )
+            vg_strcat( &str, "world." );
+         else
+            vg_strcat( &str, "???." );
+
+         ui_text( title, buf, 1, k_ui_align_middle_center, 
+                  ui_colour(k_ui_fg+4) );
+      }
+      return;
+   }
+
+   /* 
+    * sidebar existing entries panel
+    */
    ui_text( title, "Your submissions", 1, k_ui_align_middle_center, 0 );
 
    ui_rect controls, btn_create_new;
@@ -1405,6 +1580,7 @@ VG_STATIC void async_workshop_get_filepath( void *data, u32 len )
    if( !SteamAPI_ISteamUGC_GetItemInstallInfo( hSteamUGC, info->id, &_size,
                                                info->buf, info->len, &_ts ))
    {
+      vg_error( "GetItemInstallInfo failed\n" );
       info->buf[0] = '\0';
    }
 }
@@ -1430,6 +1606,7 @@ VG_STATIC void async_workshop_get_installed_files( void *data, u32 len )
    *info->len = j;
 }
 
+#if 0
 VG_STATIC void vg_strsan_ascii( char *buf, u32 len )
 {
    for( u32 i=0; i<len-1; i ++ ){
@@ -1457,5 +1634,6 @@ VG_STATIC void workshop_load_metadata( const char *path,
       fclose( fp );
    }
 }
+#endif
 
 #endif /* WORKSHOP_C */
index b7b8a2614db9019b53d4072d2adbf18684f14ed0..36a6aa5ad2f0b7e2ce18ab4006104242ea72e8fe 100644 (file)
@@ -1,26 +1,14 @@
 #ifndef WORKSHOP_H
 #define WORKSHOP_H
 
+#include "workshop_types.h"
+
 #define VG_GAME
 #include "vg/vg.h"
 #include "vg/vg_steam_remote_storage.h"
 #include "skaterift.h"
 #include "pointcloud.h"
 
-struct workshop_file_info{
-   u64 author;
-   char author_name[32];
-   char title[64];
-};
-
-struct world_file_info{
-   char title[64];      /* extracted from ent_worldinfo */
-   char location[64];
-
-   u32 pointcloud_count;
-   pointcloud_vert pointcloud[];
-};
-
 struct async_workshop_filepath_info{
    PublishedFileId_t id;
    char *buf;
@@ -37,13 +25,6 @@ struct async_workshop_metadata_info{
    const char *path;
 };
 
-VG_STATIC void workshop_file_info_clear( struct workshop_file_info *info )
-{
-   info->author = 0ul;
-   info->author_name[0] = '\0';
-   info->title[0] = '\0';
-}
-
 VG_STATIC void async_workshop_get_filepath( void *data, u32 len );
 VG_STATIC void async_workshop_get_installed_files( void *data, u32 len );
 VG_STATIC void workshop_load_metadata( const char *path,
diff --git a/workshop_types.h b/workshop_types.h
new file mode 100644 (file)
index 0000000..2d80755
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef WORKSHOP_TYPES_H
+#define WORKSHOP_TYPES_H
+
+enum workshop_file_type{
+   k_workshop_file_type_none,
+   k_workshop_file_type_board,
+   k_workshop_file_type_world
+};
+
+#endif /* WORKSHOP_TYPES_H */