#ifndef WORKSHOP_C
#define WORKSHOP_C
+#include "workshop.h"
+
#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"
#include "vg/vg_steam_ugc.h"
#include "vg/vg_steam_friends.h"
+#include "steam.h"
+#include "highscores.h"
+
+static struct ui_dropdown_opt workshop_form_visibility_opts[] = {
+ { "Public", k_ERemoteStoragePublishedFileVisibilityPublic },
+ { "Unlisted", k_ERemoteStoragePublishedFileVisibilityUnlisted },
+ { "Friends Only", k_ERemoteStoragePublishedFileVisibilityFriendsOnly },
+ { "Private", k_ERemoteStoragePublishedFileVisibilityPrivate },
+};
-#define WORKSHOP_VIEW_PER_PAGE 15
-
-struct workshop_form{
- struct {
- char title[80];
- char description[512];
-
- PublishedFileId_t file_id; /* 0 if not published yet */
- ERemoteStoragePublishedFileVisibility visibility;
-
- int submit_title, /* set if the respective controls are touched */
- submit_description,
- submit_file_and_image;
- }
- submission;
-
- enum workshop_form_page{
- k_workshop_form_hidden,
- k_workshop_form_open, /* open but not looking at anything */
- k_workshop_form_edit, /* editing a submission */
- k_workshop_form_cclosing,
- k_workshop_form_closing_good, /* post upload screen */
- k_workshop_form_closing_bad,
- }
- page;
-
- enum workshop_form_operation{
- k_workshop_form_op_none,
- k_workshop_form_op_loading_model,
- k_workshop_form_op_downloading_submission,
- k_workshop_form_op_publishing_update,
- }
- operation;
-
- /* model viewer
- * -----------------------------
- */
-
- char model_path[128];
-
- struct player_board board_model;
-
- /* what does the user want to do with the image preview? */
- enum workshop_form_file_intent{
- k_workshop_form_file_intent_none, /* loading probably */
- k_workshop_form_file_intent_new, /* board_model is valid */
- k_workshop_form_file_intent_keep_old /* just browsing */
- }
- file_intent;
-
- world_instance *view_world;
- ent_swspreview *ptr_ent;
- v2f view_angles,
- view_angles_begin;
- v3f view_offset,
- view_offset_begin;
-
- float view_dist;
- int view_changed;
-
- /*
- * published UGC request
- * ------------------------------
- */
-
- struct {
- UGCQueryHandle_t handle;
- EResult result;
-
- int all_item_count,
- returned_item_count;
- }
- ugc_query;
-
- /*
- * UI information
- * ------------------------------------------
- */
-
- const char *failure_or_success_string;
-
- int img_w, img_h;
- u8 *img_buffer;
-
- int view_published_page_count,
- view_published_page_id;
-
- struct published_file{
- EResult result;
- int result_index;
- char title[80];
- }
- published_files_list[WORKSHOP_VIEW_PER_PAGE];
- int published_files_list_length;
-}
-static workshop_form;
-
-/*
- * Start a new operation and crash if we are already running one.
- */
-VG_STATIC void workshop_begin_op( enum workshop_form_operation op )
-{
- if( workshop_form.operation != k_workshop_form_op_none ){
- vg_fatal_error( "Workshop form currently executing op(%d), tried to "
- "start op(%d)\n", workshop_form.operation, op );
- }
-
- workshop_form.operation = op;
- vg_info( "Starting op( %d )\n", op );
-}
-
-/*
- * Finished operation, otheres can now run
- */
-VG_STATIC void workshop_end_op(void)
-{
- vg_info( "Finishing op( %d )\n", workshop_form.operation );
- workshop_form.operation = k_workshop_form_op_none;
-}
+static struct ui_dropdown_opt workshop_form_type_opts[] = {
+ { "None", k_addon_type_none },
+ { "Board", k_addon_type_board },
+ { "World", k_addon_type_world },
+ { "Player", k_addon_type_player },
+};
/*
* Close the form and discard UGC query result
*/
-VG_STATIC void workshop_quit_form(void)
-{
- workshop_begin_op( k_workshop_form_op_none ); /* safeguard */
+VG_STATIC void workshop_quit_form(void){
player_board_unload( &workshop_form.board_model );
workshop_form.file_intent = k_workshop_form_file_intent_none;
}
workshop_form.page = k_workshop_form_hidden;
+ workshop_form.op = k_workshop_op_none;
}
/*
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.model_path[0] = '\0';
+ workshop_form.submission.author[0] = '\0';
+ workshop_form.submission.submission_type_selection.value =
+ k_addon_type_none;
+ workshop_form.submission.submission_type_selection.index = 0;
+ workshop_form.submission.type = k_addon_type_none;
+
+ workshop_form.submission.visibility.value =
+ k_ERemoteStoragePublishedFileVisibilityPublic;
+ workshop_form.submission.visibility.index = 0;
+
+ workshop_form.addon_folder[0] = '\0';
player_board_unload( &workshop_form.board_model );
workshop_form.file_intent = k_workshop_form_file_intent_none;
}
vg_error( "Error with the submitted file (%d)\n", result->m_eResult );
}
-
- workshop_end_op();
+ workshop_form.op = k_workshop_op_none;
}
-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 ];
+VG_STATIC const char *workshop_filetype_folder(void){
+ enum addon_type type = workshop_form.submission.type;
+ if ( type == k_addon_type_board ) return "boards/";
+ else if( type == k_addon_type_player ) return "playermodels/";
+ else if( type == k_addon_type_world ) return "worlds/";
- const char *failure_reason;
-};
+ return "unknown_addon_type/";
+}
/*
* 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;
- workshop_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,
}
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 );
+
+ vg_strcat( &folder, workshop_filetype_folder() );
+ 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" );
SteamAPI_ISteamUGC_SetItemVisibility( hSteamUGC, handle,
- workshop_form.submission.visibility );
+ workshop_form.submission.visibility.value );
vg_info( "Submitting updates\n" );
vg_steam_async_call *call = vg_alloc_async_steam_api_call();
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;
-};
-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;
- }
-
- 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));
-
- 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
if( result->m_bUserNeedsToAcceptWorkshopLegalAgreement ){
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 );
workshop_form.page = k_workshop_form_closing_bad;
workshop_form.failure_or_success_string = errstr;
- workshop_end_op();
}
}
*/
VG_STATIC void workshop_form_async_submit_begin( void *payload, u32 size )
{
+
/* use existing file */
if( workshop_form.submission.file_id ){
- workshop_package_submission( workshop_form.submission.file_id );
+ 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,
- k_EWorkshopFileTypeCommunity );
+ k_EWorkshopFileTypeCommunity );
}
}
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 );
+
+ vg_strcat( &folder, workshop_filetype_folder() );
+ vg_strcat( &folder, workshop_form.addon_folder );
+
+ if( !vg_strgood(&folder) ){
+ vg_error( "addon folder path too long\n" );
+ workshop_form.op = k_workshop_op_none;
+ return;
+ }
+
+ /*
+ * Create the metadata file
+ * -----------------------------------------------------------------------*/
+ u8 descriptor_buf[ 512 ];
+ vg_msg descriptor = {0};
+ descriptor.buf = descriptor_buf;
+ descriptor.max = sizeof(descriptor_buf);
+
+ vg_linear_clear( vg_mem.scratch );
+
+ /* short description */
+ vg_msg_frame( &descriptor, "workshop" );
+ vg_msg_wkvstr( &descriptor, "title", workshop_form.submission.title );
+ //vg_msg_wkvstr( &descriptor, "author", "unknown" );
+ vg_msg_wkvu32( &descriptor, "type", workshop_form.submission.type );
+ vg_msg_wkvstr( &descriptor, "folder", workshop_form.addon_folder );
+ vg_msg_end_frame( &descriptor );
+ //vg_msg_wkvstr( &descriptor, "location", "USA" );
+
+ char *short_descriptor_str = vg_linear_alloc( vg_mem.scratch,
+ vg_align8(descriptor.cur*2+1));
+ vg_bin_str( descriptor_buf, short_descriptor_str, descriptor.cur );
+ short_descriptor_str[descriptor.cur*2] = '\0';
+ vg_info( "binstr: %s\n", short_descriptor_str );
+
+ vg_dir dir;
+ if( !vg_dir_open( &dir, folder.buffer ) ){
+ vg_error( "could not open addon folder '%s'\n", folder.buffer );
+ workshop_form.op = k_workshop_op_none;
+ return;
+ }
+
+ while( vg_dir_next_entry(&dir) ){
+ if( vg_dir_entry_type(&dir) == k_vg_entry_type_file ){
+ const char *d_name = vg_dir_entry_name(&dir);
+ if( d_name[0] == '.' ) continue;
+
+ vg_str file = folder;
+ vg_strcat( &file, "/" );
+ vg_strcat( &file, 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", d_name );
+ break;
+ }
+ }
+ vg_dir_close(&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" );
+ workshop_form.op = k_workshop_op_none;
+ return;
+ }
+
+ FILE *fp = fopen( descriptor_file.buffer, "wb" );
+ if( !fp ){
+ vg_error( "Could not open addon info file '%s'\n",
+ descriptor_file.buffer );
+ workshop_form.op = k_workshop_op_none;
+ 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" );
+ workshop_form.op = k_workshop_op_none;
+ 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, short_descriptor_str, 0 );
}
/*
* Entry point for the publishing submission operation
*/
-VG_STATIC void workshop_op_submit(void)
-{
+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" );
+ ui_start_modal( "Cannot submit because a title is required\n",
+ UI_MODAL_WARN);
+ workshop_form.op = k_workshop_op_none;
return;
}
}
if( workshop_form.submission.submit_description ){
if( !workshop_form.submission.description[0] ){
- vg_error( "Cannot submit because a description is required\n" );
+ ui_start_modal( "Cannot submit because a description is required\n",
+ UI_MODAL_WARN );
+ workshop_form.op = k_workshop_op_none;
return;
}
}
if( workshop_form.submission.submit_file_and_image ){
if( workshop_form.file_intent == k_workshop_form_file_intent_none ){
- vg_error( "Cannot submit because the file is empty or unspecified\n" );
+ ui_start_modal( "Cannot submit because the file is "
+ "empty or unspecified\n", UI_MODAL_WARN );
+ workshop_form.op = k_workshop_op_none;
return;
}
}
- workshop_begin_op( k_workshop_form_op_publishing_update );
-
player_board_unload( &workshop_form.board_model );
workshop_form.file_intent = k_workshop_form_file_intent_none;
+ workshop_form.op = k_workshop_op_publishing_update;
vg_loader_start( _workshop_form_submit_thread, NULL );
}
workshop_form.file_intent = k_workshop_form_file_intent_new;
vg_success( "workshop async load complete\n" );
- workshop_end_op();
+ workshop_form.op = k_workshop_op_none;
+}
+
+/*
+ * Reciever for failure to load
+ */
+VG_STATIC void workshop_form_loadmodel_async_error( void *payload, u32 size ){
}
/*
*/
VG_STATIC void _workshop_form_load_thread( void *data )
{
- player_board_load( &workshop_form.board_model, workshop_form.model_path );
+ char path_buf[4096];
+ vg_str folder;
+ vg_strnull( &folder, path_buf, 4096 );
+
+ vg_strcat( &folder, workshop_filetype_folder() );
+ 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 );
+ workshop_form.op = k_workshop_op_none;
+ return;
+ }
+
+ vg_dir dir;
+ if( !vg_dir_open( &dir, folder.buffer ) ){
+ vg_error( "workshop async load failed: could not open folder\n" );
+ vg_async_call( workshop_form_loadmodel_async_error, NULL, 0 );
+ workshop_form.op = k_workshop_op_none;
+ return;
+ }
+
+ vg_info( "Searching %s for model files\n", folder.buffer );
+
+ int found_mdl = 0;
+ while( vg_dir_next_entry(&dir) ){
+ if( vg_dir_entry_type(&dir) == k_vg_entry_type_file ){
+ const char *d_name = vg_dir_entry_name(&dir);
+ if( d_name[0] == '.' ) continue;
+
+ vg_str file = folder;
+ vg_strcat( &file, "/" );
+ vg_strcat( &file, d_name );
+ if( !vg_strgood( &file ) ) continue;
+
+ char *ext = vg_strch( &file, '.' );
+ if( !ext ) continue;
+ if( strcmp(ext,".mdl") ) continue;
+ found_mdl = 1;
+ break;
+ }
+ }
+ vg_dir_close(&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 );
+ workshop_form.op = k_workshop_op_none;
+ return;
+ }
+
+ if( workshop_form.submission.type == k_addon_type_board )
+ player_board_load( &workshop_form.board_model, path_buf );
+ else if( workshop_form.submission.type == k_addon_type_player )
+ player_model_load( &workshop_form.player_model, path_buf );
+
vg_async_call( workshop_form_loadmodel_async_complete, NULL, 0 );
}
/*
* Entry point for load model operation
*/
-VG_STATIC void workshop_op_load_model(void)
-{
- workshop_begin_op( k_workshop_form_op_loading_model );
+VG_STATIC void workshop_op_load_model(void){
+ world_instance *world = world_current_instance();
+ workshop_form.view_world = world;
+
+ if( workshop_form.submission.type == k_addon_type_board ){
+ if( mdl_arrcount( &world->ent_swspreview ) ){
+ workshop_form.ptr_ent =
+ mdl_arritm( &world->ent_swspreview, 0 );
+ }
+ else{
+ ui_start_modal( "There is no ent_swspreview in the level. \n"
+ "Cannot publish here\n", UI_MODAL_BAD );
+ workshop_form.op = k_workshop_op_none;
+ return;
+ }
+ }
+ else if( workshop_form.submission.type == k_addon_type_player ){}
+ else {
+ ui_start_modal( "Don't know how to prepare for this item type. \n"
+ "Please contact the developers.\n", UI_MODAL_BAD );
+ workshop_form.op = k_workshop_op_none;
+ return;
+ }
+
+ workshop_form.op = k_workshop_op_loading_model;
vg_loader_start( _workshop_form_load_thread, NULL );
}
stbi_image_free( data );
vg_success( "Loaded workshop preview image\n" );
}
-
- workshop_end_op();
+ else{
+ snprintf( workshop_form.error_msg, sizeof(workshop_form.error_msg),
+ "Preview image could not be loaded. Reason: %s\n",
+ stbi_failure_reason() );
+ ui_start_modal( workshop_form.error_msg, UI_MODAL_BAD );
+ }
+ workshop_form.op = k_workshop_op_none;
}
-struct workshop_loadpreview_info {
- char abs_preview_image[ 1024 ];
-};
-
/*
* Load the image located at ./workshop_preview.jpg into our framebuffer
*/
-VG_STATIC void _workshop_load_preview_thread( void *data )
-{
- struct workshop_loadpreview_info *info = data;
-
- stbi_set_flip_vertically_on_load(1);
- int x, y, nc;
- u8 *rgb = stbi_load( info->abs_preview_image, &x, &y, &nc, 3 );
-
- if( rgb ){
- if( (x == WORKSHOP_PREVIEW_WIDTH) && (y == WORKSHOP_PREVIEW_HEIGHT) ){
- vg_async_call( workshop_form_async_imageload, rgb, x*y*3 );
+VG_STATIC void _workshop_load_preview_thread( void *data ){
+ char path_buf[ 4096 ];
+ vg_str path;
+ vg_strnull( &path, path_buf, 4096 );
+ vg_strcat( &path, workshop_filetype_folder() );
+ vg_strcat( &path, workshop_form.addon_folder );
+ vg_strcat( &path, "/preview.jpg" );
+
+ if( vg_strgood( &path ) ){
+ stbi_set_flip_vertically_on_load(1);
+ int x, y, nc;
+ u8 *rgb = stbi_load( path.buffer, &x, &y, &nc, 3 );
+
+ if( rgb ){
+ if( (x == WORKSHOP_PREVIEW_WIDTH) && (y == WORKSHOP_PREVIEW_HEIGHT) ){
+ vg_async_call( workshop_form_async_imageload, rgb, x*y*3 );
+ }
+ else{
+ vg_error( "Resolution does not match framebuffer, so we can't"
+ " show it\n" );
+ stbi_image_free( rgb );
+ vg_async_call( workshop_form_async_imageload, NULL, 0 );
+ }
}
else{
- vg_error( "Resolution does not match framebuffer, so we can't"
- " show it\n" );
- stbi_image_free( rgb );
vg_async_call( workshop_form_async_imageload, NULL, 0 );
}
}
else{
- vg_error( "Failed to load workshop_preview.jpg: '%s'\n",
- stbi_failure_reason() );
vg_async_call( workshop_form_async_imageload, NULL, 0 );
}
}
-/*
- * Reciever for the preview download result
- */
-VG_STATIC void on_workshop_download_ugcpreview( void *data, void *user )
-{
- struct workshop_loadpreview_info *info = user;
- RemoteStorageDownloadUGCResult_t *result = data;
-
- if( result->m_eResult == k_EResultOK ){
- ISteamRemoteStorage *hSteamRemoteStorage = SteamAPI_SteamRemoteStorage();
- vg_loader_start( _workshop_load_preview_thread, info );
- }
- else{
- vg_error( "Error while donwloading UGC preview( %d )\n",
- result->m_eResult );
- workshop_end_op();
- }
-}
-
/*
* Entry point to view operation
*/
VG_STATIC void workshop_op_download_and_view_submission( int result_index )
{
+ workshop_form.op = k_workshop_op_downloading_submission;
ISteamUGC *hSteamUGC = SteamAPI_SteamUGC();
ISteamRemoteStorage *hSteamRemoteStorage = SteamAPI_SteamRemoteStorage();
SteamUGCDetails_t details;
result_index,
&details ) )
{
- workshop_begin_op( k_workshop_form_op_downloading_submission );
workshop_reset_submission_data();
+ workshop_form.submission.submit_description = 0;
+ 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.title ),
k_strncpy_always_add_null );
- snprintf( workshop_form.model_path,
- vg_list_size( workshop_form.model_path ),
- "Steam Cloud (%lu)", details.m_nPublishedFileId );
+ snprintf( workshop_form.addon_folder,
+ vg_list_size( workshop_form.addon_folder ),
+ "Steam Cloud ("PRINTF_U64")", 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;
-
- if( details.m_hPreviewFile == 0 ){
- vg_error( "m_hPreviewFile is 0\n" );
- workshop_end_op();
+ workshop_form.submission.visibility.value = details.m_eVisibility;
+ workshop_form.submission.type = k_addon_type_none;
+ workshop_form.submission.submission_type_selection.index = 0;
+ workshop_form.submission.submission_type_selection.value =
+ k_addon_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 root = {0};
+ root.buf = metadata_buf;
+ root.len = len/2;
+ root.max = len/2;
+
+ vg_msg workshop = root;
+ if( vg_msg_seekframe( &workshop, "workshop", k_vg_msg_first )){
+ u32 type = vg_msg_seekkvu32( &workshop, "type", k_vg_msg_first );
+ workshop_form.submission.type = type;
+ workshop_form.submission.submission_type_selection.value = type;
+
+ const char *kv_folder = vg_msg_seekkvstr( &workshop, "folder",
+ k_vg_msg_first );
+ if( kv_folder ){
+ vg_strncpy( kv_folder, workshop_form.addon_folder,
+ sizeof(workshop_form.addon_folder),
+ k_strncpy_always_add_null );
+ }
+ }
}
else{
- /* Now need to begin downloading the image so we can display it */
- vg_steam_async_call *call = vg_alloc_async_steam_api_call();
-
- struct workshop_loadpreview_info *info =
- vg_linear_alloc( vg_mem.scratch,
- sizeof( struct workshop_loadpreview_info ) );
+ vg_error( "No metadata was returned with this item.\n" );
+ }
- snprintf( info->abs_preview_image, 1024,
- "%smodels/boards/workshop/%lu.jpg",
- vg.base_path, details.m_hPreviewFile );
+ /* 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;
+ }
+ }
- call->p_handler = on_workshop_download_ugcpreview;
- call->userdata = info;
- call->id = SteamAPI_ISteamRemoteStorage_UGCDownloadToLocation(
- hSteamRemoteStorage,
- details.m_hPreviewFile, info->abs_preview_image, 1 );
+ 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 );
- vg_info( "preview file id: %lu\n", details.m_hPreviewFile );
- }
+ vg_loader_start( _workshop_load_preview_thread, NULL );
}
else{
vg_error( "GetQueryUGCResult: Index out of range\n" );
- workshop_end_op();
+ workshop_form.op = k_workshop_op_none;
}
}
{
if( workshop_form.ugc_query.result != k_EResultOK ){
vg_error( "Tried to change page without complete data\n" );
+ workshop_form.op = k_workshop_op_none;
return;
}
VG_STATIC int workshop_submit_command( int argc, const char *argv[] )
{
if( !steam_ready ){
- vg_error( "Steam API is not ready or loaded\n" );
+ ui_start_modal( "Steam API is not initialized\n", UI_MODAL_BAD );
return 0;
}
k_EUserUGCListSortOrder_CreationOrderDesc,
SKATERIFT_APPID, SKATERIFT_APPID,
1 );
+ SteamAPI_ISteamUGC_SetReturnMetadata( hSteamUGC, handle, 1 );
call->id = SteamAPI_ISteamUGC_SendQueryUGCRequest( hSteamUGC, handle );
return 0;
}
vg_console_reg_cmd( "workshop_submit", workshop_submit_command, NULL );
}
-VG_STATIC void workshop_find_preview_entity(void)
-{
- workshop_form.view_world = get_active_world();
+VG_STATIC void workshop_render_world_preview(void){
+ render_fb_bind( gpipeline.fb_workshop_preview, 0 );
- if( mdl_arrcount( &workshop_form.view_world->ent_swspreview ) ){
- workshop_form.ptr_ent =
- mdl_arritm( &workshop_form.view_world->ent_swspreview, 0 );
- workshop_form.page = k_workshop_form_edit;
- }
- else{
- vg_error( "There is no ent_swspreview in the level. "
- "Cannot publish here\n" );
- }
+ glClearColor( 0.0f, 0.0f, 0.3f, 1.0f );
+ glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
+ glEnable( GL_DEPTH_TEST );
+ glDisable( GL_BLEND );
+
+ render_world( localplayer.viewable_world, &skaterift.cam, 1 );
+
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+ glViewport( 0,0, vg.window_x, vg.window_y );
+}
+
+/*
+ * Redraw the playermodel into the workshop framebuffer
+ */
+VG_STATIC void workshop_render_player_preview(void){
+ render_fb_bind( gpipeline.fb_workshop_preview, 0 );
+ glClearColor( 0.16f, 0.15f, 0.15f, 1.0f );
+ glClear( GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT );
+ glEnable( GL_DEPTH_TEST );
+ glDisable( GL_BLEND );
+
+ struct skeleton *sk = &localplayer.playeravatar->sk;
+
+ player_pose res;
+ res.type = k_player_pose_type_ik;
+
+ struct skeleton_anim *anim = skeleton_get_anim( sk, "idle_cycle+y" );
+ skeleton_sample_anim( sk, anim, vg.time*0.1f, res.keyframes );
+ q_axis_angle( res.root_q, (v3f){0.0f,1.0f,0.0f}, VG_PIf );
+ v3_zero( res.root_co );
+ res.root_co[1] = 200.0f;
+
+ m4x3f transform;
+ q_m3x3( res.root_q, transform );
+ v3_copy( res.root_co, transform[3] );
+
+ /* TODO: Function. */
+ skeleton_apply_pose( sk, res.keyframes, k_anim_apply_defer_ik );
+ skeleton_apply_ik_pass( sk );
+ skeleton_apply_pose( sk, res.keyframes, k_anim_apply_deffered_only );
+ skeleton_apply_inverses( sk );
+ skeleton_apply_transform( sk, transform );
+
+ camera cam;
+ v3_copy( (v3f){ 0.0f, 201.7f, 1.2f }, cam.pos );
+
+ cam.nearz = 0.01f;
+ cam.farz = 100.0f;
+ cam.fov = 57.0f;
+ v3_zero( cam.angles );
+
+ camera_update_transform( &cam );
+ camera_update_view( &cam );
+ camera_update_projection( &cam );
+ camera_finalize( &cam );
+
+ world_instance *world = localplayer.viewable_world;
+ render_playermodel( &cam, world, 0, &workshop_form.player_model, sk );
+
+ glBindFramebuffer( GL_FRAMEBUFFER, 0 );
+ glViewport( 0,0, vg.window_x, vg.window_y );
}
/*
* Redraw the model file into the workshop framebuffer
*/
-VG_STATIC void workshop_render_preview(void)
-{
+VG_STATIC void workshop_render_board_preview(void){
if( !workshop_form.ptr_ent ){
return;
}
sizeof(struct ub_world_lighting), &world->ub_lighting );
render_world( world, &cam, 1 );
- render_board( &cam, world, board, mmdl, k_board_shader_entity );
- render_board( &cam, world, board, mmdl1, k_board_shader_entity );
+ struct player_board_pose pose = {0};
+ render_board( &cam, world, board, mmdl, &pose, k_board_shader_entity );
+ render_board( &cam, world, board, mmdl1, &pose, k_board_shader_entity );
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
glViewport( 0,0, vg.window_x, vg.window_y );
workshop_form.submission.submit_description = 1;
}
-VG_STATIC void workshop_form_gui_edit_page( ui_rect content )
-{
- ui_rect image_plane;
- ui_split_px( content, k_ui_axis_h, 300, 0, image_plane, content );
- ui_fill( image_plane, ui_colour( k_ui_bg+0 ) );
-
- ui_rect img_box;
- ui_fit_item( image_plane, (ui_px[2]){ 3, 2 }, img_box );
+VG_STATIC void workshop_form_gui_page_undecided( ui_rect content ){
+ 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,
+ 4, &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_addon_type_none ){
+ if( ui_button_text( button_l, "OK", 1 ) ){
+ enum addon_type type =
+ workshop_form.submission.submission_type_selection.value;
+ workshop_form.submission.type = type;
+
+ if( type == k_addon_type_world ){
+ workshop_form.view_changed = 1;
+ workshop_form.file_intent = k_workshop_form_file_intent_new;
+ }
+ }
+ }
+ 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;
+ }
+}
+VG_STATIC void workshop_form_gui_draw_preview( ui_rect img_box ){
+ enum addon_type type = workshop_form.submission.type;
if( workshop_form.file_intent == k_workshop_form_file_intent_keep_old ){
ui_image( img_box, gpipeline.fb_workshop_preview->attachments[0].id );
}
else if( workshop_form.file_intent == k_workshop_form_file_intent_new ){
ui_image( img_box, gpipeline.fb_workshop_preview->attachments[0].id );
+
+ if( type == k_addon_type_world ){
+ return;
+ }
+
int hover = ui_inside_rect( img_box, vg_ui.mouse ),
target = ui_inside_rect( img_box, vg_ui.mouse_click );
ui_text( img_box, "No image", 1, k_ui_align_middle_center,
ui_colour( k_ui_orange ) );
}
+}
- /* file path */
- ui_rect null, file_entry, file_button;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, 28, 0, file_entry, content );
- ui_split_px( file_entry, k_ui_axis_v, file_entry[2]-128, 0,
- file_entry, file_button );
-
- 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 ) );
+VG_STATIC void workshop_form_gui_edit_page( ui_rect content ){
+ enum addon_type type = workshop_form.submission.type;
- 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';
- }
+ if( type == k_addon_type_none ){
+ workshop_form_gui_page_undecided( content );
+ return;
}
- else{
+
+ 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 ) );
+
+ ui_rect img_box;
+ ui_fit_item( image_plane, (ui_px[2]){ 3, 2 }, img_box );
+ workshop_form_gui_draw_preview( img_box );
+
+ /* file path */
+ ui_rect null, file_entry, file_button, file_label;
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, 28, 0, file_entry, content );
+
+ char buf[128];
+ snprintf( buf, 128, "Addon folder: skaterift/%s",
+ workshop_filetype_folder() );
+
+ ui_label( file_entry, buf, 1, 8, file_entry );
+
+ if( type == k_addon_type_world ){
struct ui_textbox_callbacks callbacks = {
.change = workshop_changed_model_path
};
+ ui_textbox( file_entry, workshop_form.addon_folder,
+ vg_list_size(workshop_form.addon_folder), 0, &callbacks );
+ }
+ else{
+ ui_split( file_entry, k_ui_axis_v, -128, 0, file_entry, file_button );
+ if( workshop_form.file_intent != k_workshop_form_file_intent_none ){
+ 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 ) ){
+ if( type == k_addon_type_board )
+ player_board_unload( &workshop_form.board_model );
+ else if( type == k_addon_type_player )
+ player_model_unload( &workshop_form.player_model );
+
+ workshop_form.file_intent = k_workshop_form_file_intent_none;
+ workshop_form.addon_folder[0] = '\0';
+ }
+ }
+ else{
+ struct ui_textbox_callbacks callbacks = {
+ .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();
- workshop_op_load_model();
+ if( ui_button_text( file_button, "Load", 1 ) ){
+ workshop_op_load_model();
+ }
}
}
ui_rect title_entry, label;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, 28, 0, title_entry, content );
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, 28, 0, title_entry, content );
const char *str_title = "Title:", *str_desc = "Description:";
- ui_split_px( title_entry, k_ui_axis_v,
+ ui_split( title_entry, k_ui_axis_v,
ui_text_line_width(str_title)+8, 0, label, title_entry );
+ ui_rect vis_dropdown;
+ ui_split_ratio( title_entry, k_ui_axis_v, 0.6f, 16,
+ title_entry, vis_dropdown );
+
/* title box */
{
struct ui_textbox_callbacks callbacks = {
vg_list_size(workshop_form.submission.title), 0, &callbacks );
}
+ /* visibility option */
+ {
+ ui_enum( vis_dropdown, "Visibility:", workshop_form_visibility_opts,
+ 4, &workshop_form.submission.visibility );
+ }
+
/* description box */
{
struct ui_textbox_callbacks callbacks = {
.change = workshop_changed_description
};
ui_rect desc_entry;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, 28, 0, label, content );
- ui_split_px( content, k_ui_axis_h, 28*4, 0, desc_entry, content );
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, 28, 0, label, content );
+ ui_split( content, k_ui_axis_h, 28*4, 0, desc_entry, content );
ui_text( label, str_desc, 1, k_ui_align_middle_left, 0 );
ui_textbox( desc_entry, workshop_form.submission.description,
vg_list_size(workshop_form.submission.description),
/* submissionable */
ui_rect submission_row;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, content[3]-32-8, 0, content,
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, content[3]-32-8, 0, content,
submission_row );
ui_rect submission_center;
workshop_op_submit();
}
if( ui_button_text( btn_right, "Cancel", 1 ) ){
- vg_info( "left\n" );
+ workshop_form.page = k_workshop_form_open;
+ player_board_unload( &workshop_form.board_model );
+ workshop_form.file_intent = k_workshop_form_file_intent_none;
}
/* disclaimer */
- /* TODO!! OPEN THIS LINK */
const char *disclaimer_text =
"By submitting this item, you agree to the workshop terms of service";
ui_rect disclaimer_row, inner, link;
- ui_split_px( content, k_ui_axis_h, 8, 0, null, content );
- ui_split_px( content, k_ui_axis_h, content[3]-32, 0, content,
+ ui_split( content, k_ui_axis_h, 8, 0, null, content );
+ ui_split( content, k_ui_axis_h, content[3]-32, 0, content,
disclaimer_row );
ui_px btn_width = 32;
inner[2] = ui_text_line_width( disclaimer_text ) + btn_width+8;
ui_rect_center( disclaimer_row, inner );
- ui_split_px( inner, k_ui_axis_v, inner[2]-btn_width, 0, label, btn_right);
- ui_rect_pad( btn_right, 2 );
+ ui_split( inner, k_ui_axis_v, inner[2]-btn_width, 0, label, btn_right);
+ ui_rect_pad( btn_right, (ui_px[2]){2,2} );
- if( ui_button_text( btn_right, "\x91", 2 ) ){
+ if( ui_button_text( btn_right, "\xbf", 2 ) ){
ISteamFriends *hSteamFriends = SteamAPI_SteamFriends();
SteamAPI_ISteamFriends_ActivateGameOverlayToWebPage( hSteamFriends,
"https://steamcommunity.com/sharedfiles/workshoplegalagreement",
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_px( sidebar, k_ui_axis_h, 28, 0, title, sidebar );
+ 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_addon_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_addon_type_board )
+ vg_strcat( &str, "skateboard." );
+ else if( workshop_form.submission.type == k_addon_type_world )
+ vg_strcat( &str, "world." );
+ else if( workshop_form.submission.type == k_addon_type_player )
+ vg_strcat( &str, "playermodel." );
+ 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;
- ui_split_px( sidebar, k_ui_axis_h, 32, 0, controls, sidebar );
- ui_split_px( sidebar, k_ui_axis_h, sidebar[3]-32, 0,
- sidebar, btn_create_new );
+ ui_split( sidebar, k_ui_axis_h, 32, 0, controls, sidebar );
+ ui_split( sidebar, k_ui_axis_h, -32, 0, sidebar, btn_create_new );
ui_fill( controls, ui_colour( k_ui_bg+1 ) );
- ui_outline( controls, -1, ui_colour( k_ui_bg+4 ) );
char buf[32];
strcpy( buf, "page " );
int i = 5;
-
- /* TODO: for what it is, this code is getting a bit.. special */
- if( workshop_form.view_published_page_id )
- i += highscore_intl( buf+i, workshop_form.view_published_page_id, 4 );
- else buf[ i ++ ] = '0';
- ;
+ i += highscore_intl( buf+i, workshop_form.view_published_page_id+1, 4 );
buf[ i ++ ] = '/';
i += highscore_intl( buf+i, workshop_form.view_published_page_count, 4 );
buf[ i ++ ] = '\0';
+ ui_rect_pad( controls, (ui_px[2]){0,4} );
ui_rect info;
ui_split_ratio( controls, k_ui_axis_v, 0.25f, 0, info, controls );
ui_text( info, buf, 1, k_ui_align_middle_center, 0 );
workshop_form.submission.submit_description = 1;
workshop_form.submission.submit_file_and_image = 1;
workshop_form.page = k_workshop_form_edit;
- workshop_find_preview_entity();
}
for( int i=0; i<workshop_form.published_files_list_length; i++ ){
ui_rect item;
- ui_split_px( sidebar, k_ui_axis_h, 28, 0, item, sidebar );
- ui_rect_pad( item, 4 );
+ ui_split( sidebar, k_ui_axis_h, 28, 0, item, sidebar );
+ ui_rect_pad( item, (ui_px[2]){4,4} );
struct published_file *pfile = &workshop_form.published_files_list[i];
if( ui_button_text( item, pfile->title, 1 ) ){
ui_outline( window, 1, ui_colour( k_ui_bg+7 ) );
ui_rect title, panel;
- ui_split_px( window, k_ui_axis_h, 28, 0, title, panel );
+ ui_split( window, k_ui_axis_h, 28, 0, title, panel );
ui_fill( title, ui_colour( k_ui_bg+7 ) );
ui_text( title, "Workshop tool", 1, k_ui_align_middle_center,
ui_colourcont(k_ui_bg+7) );
ui_rect quit_button;
- ui_split_px( title, k_ui_axis_v, title[2]-title[3], 2, title, quit_button );
+ ui_split( title, k_ui_axis_v, title[2]-title[3], 2, title, quit_button );
- if( workshop_form.operation == k_workshop_form_op_none ){
+ if( vg_loader_availible() ){
if( ui_button_text( quit_button, "X", 1 ) ){
workshop_quit_form();
return;
* escapes here and we show them a basic string
*/
- if( workshop_form.operation != k_workshop_form_op_none ){
+ if( workshop_form.op != k_workshop_op_none ){
const char *op_string = "The programmer has not bothered to describe "
"the current operation that is running.";
- switch(workshop_form.operation){
- case k_workshop_form_op_loading_model:
+ switch( workshop_form.op ){
+ case k_workshop_op_loading_model:
op_string = "Operation in progress: Loading model file.";
break;
- case k_workshop_form_op_publishing_update:
+ case k_workshop_op_publishing_update:
op_string = "Operation in progress: publishing submission update "
"to steam.";
break;
- case k_workshop_form_op_downloading_submission:
+ case k_workshop_op_downloading_submission:
op_string = "Operation in progress: downloading existing submission"
" from Steam services.";
break;
workshop_form.view_changed &&
workshop_form.file_intent == k_workshop_form_file_intent_new )
{
- workshop_render_preview();
+ enum addon_type type = workshop_form.submission.type;
+ if( type == k_addon_type_board ){
+ workshop_render_board_preview();
+ }
+ else if( type == k_addon_type_world ){
+ vg_success( "Renders world preview\n" );
+ workshop_render_world_preview();
+ }
+ else if( type == k_addon_type_player ){
+ workshop_render_player_preview();
+ }
+
workshop_form.view_changed = 0;
}
ui_split_ratio( panel, k_ui_axis_v, 0.3f, 1, sidebar, content );
/* content page */
- ui_rect_pad( content, 8 );
+ ui_rect_pad( content, (ui_px[2]){8,8} );
if( stable_page == k_workshop_form_edit ){
workshop_form_gui_edit_page( content );
}
else if( stable_page >= k_workshop_form_cclosing ){
ui_rect submission_row;
- ui_split_px( content, k_ui_axis_h, content[3]-32-8, 0, content,
+ ui_split( content, k_ui_axis_h, content[3]-32-8, 0, content,
submission_row );
u32 colour;
rect_copy( submission_row, submission_center );
submission_center[2] = 128;
ui_rect_center( submission_row, submission_center );
- ui_rect_pad( submission_center, 8 );
+ ui_rect_pad( submission_center, (ui_px[2]){8,8} );
if( ui_button_text( submission_center, "OK", 1 ) ){
workshop_form.page = k_workshop_form_open;
workshop_form_gui_sidebar( sidebar );
}
+/*
+ * Some async api stuff
+ * -----------------------------------------------------------------------------
+ */
+
+VG_STATIC void async_workshop_get_filepath( void *data, u32 len )
+{
+ struct async_workshop_filepath_info *info = data;
+
+ u64 _size;
+ u32 _ts;
+
+ ISteamUGC *hSteamUGC = SteamAPI_SteamUGC();
+ if( !SteamAPI_ISteamUGC_GetItemInstallInfo( hSteamUGC, info->id, &_size,
+ info->buf, info->len, &_ts ))
+ {
+ vg_error( "GetItemInstallInfo failed\n" );
+ info->buf[0] = '\0';
+ }
+}
+
+VG_STATIC void async_workshop_get_installed_files( void *data, u32 len )
+{
+ struct async_workshop_installed_files_info *info = data;
+
+ ISteamUGC *hSteamUGC = SteamAPI_SteamUGC();
+ u32 count = SteamAPI_ISteamUGC_GetSubscribedItems( hSteamUGC, info->buffer,
+ *info->len );
+
+ vg_info( "Found %u subscribed items\n", count );
+
+ u32 j=0;
+ for( u32 i=0; i<count; i++ ){
+ u32 state = SteamAPI_ISteamUGC_GetItemState( hSteamUGC, info->buffer[i] );
+ if( state & k_EItemStateInstalled ){
+ info->buffer[j ++] = info->buffer[i];
+ }
+ }
+
+ *info->len = j;
+}
+
#endif /* WORKSHOP_C */