+ ui_rect 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( title, k_ui_axis_v, title[2]-title[3], 2, title, quit_button );
+
+ if( vg_loader_availible() ){
+ if( ui_button_text( quit_button, "X", 1 ) ){
+ workshop_quit_form();
+ return;
+ }
+ }
+
+ /*
+ * temporary operation blinders, we don't yet have a nice way to show the
+ * user that we're doing something uninterruptable, so the code just
+ * escapes here and we show them a basic string
+ */
+
+ if( !vg_loader_availible() ){
+ const char *op_string = "The programmer has not bothered to describe "
+ "the current operation that is running.";
+
+ switch( skaterift.op ){
+ case k_workshop_form_op_loading_model:
+ op_string = "Operation in progress: Loading model file.";
+ break;
+ case k_workshop_form_op_publishing_update:
+ op_string = "Operation in progress: publishing submission update "
+ "to steam.";
+ break;
+ case k_workshop_form_op_downloading_submission:
+ op_string = "Operation in progress: downloading existing submission"
+ " from Steam services.";
+ break;
+ default: break;
+ }
+
+ ui_text( panel, op_string, 1, k_ui_align_middle_center, 0 );
+ return;
+ }
+
+ /* re draw board preview if need to */
+ if( (stable_page == k_workshop_form_edit) &&
+ workshop_form.view_changed &&
+ workshop_form.file_intent == k_workshop_form_file_intent_new )
+ {
+ 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();
+ }
+ workshop_form.view_changed = 0;
+ }
+
+ struct workshop_form *form = &workshop_form;
+
+ ui_rect sidebar, content;
+ ui_split_ratio( panel, k_ui_axis_v, 0.3f, 1, sidebar, content );
+
+ /* content page */
+ 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_open ){
+ ui_text( content, "Nothing selected.", 1, k_ui_align_middle_center,
+ ui_colour( k_ui_fg+4 ) );
+ }
+ else if( stable_page >= k_workshop_form_cclosing ){
+ ui_rect submission_row;
+ ui_split( content, k_ui_axis_h, content[3]-32-8, 0, content,
+ submission_row );
+
+ u32 colour;
+
+ if( stable_page == k_workshop_form_closing_bad )
+ colour = ui_colour( k_ui_red+k_ui_brighter );
+ else
+ colour = ui_colour( k_ui_green+k_ui_brighter );
+
+ ui_text( content, workshop_form.failure_or_success_string, 1,
+ k_ui_align_middle_center, colour );
+
+ ui_rect submission_center;
+ rect_copy( submission_row, submission_center );
+ submission_center[2] = 128;
+ ui_rect_center( submission_row, submission_center );
+ 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;
+}