{
vg_info( "Running load loop\n" );
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];
/* continue with the request */
SDL_AtomicUnlock( &global_skateshop.sl_cache_access );
-
cache_ptr->reg_ptr = get_addon_from_index( k_workshop_file_type_board,
cache_ptr->reg_index );
- if( cache_ptr->reg_ptr->workshop_id ){
- vg_async_item *call =
- vg_async_alloc( sizeof(struct async_workshop_filepath_info) );
-
- struct async_workshop_filepath_info *info = call->payload;
- info->buf = path_buf;
- info->id = cache_ptr->reg_ptr->workshop_id;
- info->len = vg_list_size(path_buf);
- vg_async_dispatch( call, async_workshop_get_filepath );
- vg_async_stall(); /* too bad! */
-
- if( path_buf[0] == '\0' ){
- vg_error( "Failed SteamAPI_GetItemInstallInfo(" PRINTF_U64 ")\n",
- cache_ptr->reg_ptr->workshop_id );
- goto file_is_broken;
- }
+ vg_str folder;
+ vg_strnull( &folder, path_buf, 4096 );
+ if( !addon_get_content_folder( cache_ptr->reg_ptr, &folder ) )
+ goto file_is_broken;
- folder.buffer = path_buf;
- folder.i = strlen(path_buf);
- folder.len = 4096;
- }
- else{
- vg_strnull( &folder, path_buf, 4096 );
- vg_strcat( &folder, "boards/" );
- vg_strcat( &folder, cache_ptr->reg_ptr->foldername );
- }
/* load content files
* --------------------------------- */
VG_STATIC void skateshop_preview_loader_thread( void *_data )
{
addon_reg *reg = _data;
+
+ char path_buf[4096];
+ vg_str path;
+ vg_strnull( &path, path_buf, 4096 );
+ addon_get_content_folder( reg, &path );
+ vg_strcat( &path, "/preview.bin" );
+
+ vg_linear_clear(vg_mem.scratch);
+ u32 size;
- if( reg->workshop_id ){
- vg_error( "Workshop files unsupported\n" );
- vg_async_call( pointcloud_clear_async, NULL, 0 );
- }
- else{
- char path_buf[4096];
- vg_str path;
- vg_strnull( &path, path_buf, 4096 );
- vg_strcat( &path, "maps/" );
- vg_strcat( &path, reg->foldername );
- vg_strcat( &path, "/preview.bin" );
-
- vg_linear_clear(vg_mem.scratch);
- u32 size;
-
- void *data = vg_file_read( vg_mem.scratch, path_buf, &size );
- if( data ){
- if( size < sizeof(pointcloud_buffer) ){
- vg_async_call( pointcloud_clear_async, NULL, 0 );
- return;
- }
-
- vg_async_item *call = vg_async_alloc(size);
- pointcloud_buffer *pcbuf = call->payload;
- memcpy( pcbuf, data, size );
-
- u32 point_count = (size-sizeof(pointcloud_buffer)) /
- sizeof(struct pointcloud_vert);
- pcbuf->max = point_count;
- pcbuf->count = point_count;
- pcbuf->op = k_pointcloud_op_clear;
-
- vg_async_dispatch( call, async_pointcloud_sub );
- vg_async_call( pointcloud_async_end, NULL, 0 );
- }
- else{
+ void *data = vg_file_read( vg_mem.scratch, path_buf, &size );
+ if( data ){
+ if( size < sizeof(pointcloud_buffer) ){
vg_async_call( pointcloud_clear_async, NULL, 0 );
+ return;
}
+
+ vg_async_item *call = vg_async_alloc(size);
+ pointcloud_buffer *pcbuf = call->payload;
+ memcpy( pcbuf, data, size );
+
+ u32 point_count = (size-sizeof(pointcloud_buffer)) /
+ sizeof(struct pointcloud_vert);
+ pcbuf->max = point_count;
+ pcbuf->count = point_count;
+ pcbuf->op = k_pointcloud_op_clear;
+
+ vg_async_dispatch( call, async_pointcloud_sub );
+ vg_async_call( pointcloud_async_end, NULL, 0 );
+ }
+ else{
+ vg_async_call( pointcloud_clear_async, NULL, 0 );
}
}
if( loadable && button_down( k_srbind_maccept ) ){
vg_info( "Select rift (%u)\n",
global_skateshop.selected_world_id );
- skaterift_change_world( reg->foldername );
+ world_loader.reg = reg;
+ world_loader.override_name[0] = '\0';
+ skaterift_change_world_start();
return;
}
else{
}
if( global_skateshop.render.reg_id != global_skateshop.selected_board_id ){
+ global_skateshop.render.item_title = "";
+ global_skateshop.render.item_desc = "";
addon_reg *reg = cache_ptr->reg_ptr;
vg_msg root;
vg_msg_init( &root, reg->metadata, reg->metadata_len );
mdl_entity_id_id(shop->boards.id_info));
if( global_skateshop.render.world_reg != global_skateshop.selected_world_id){
+ global_skateshop.render.world_title = "";
+
addon_reg *reg = get_addon_from_index( k_workshop_file_type_world,
global_skateshop.selected_world_id );
vg_msg root;
vg_strcat( &subtext, "Loading..." );
}
else{
+ addon_reg *reg = get_addon_from_index( k_workshop_file_type_world,
+ global_skateshop.selected_world_id );
+
+ if( reg->workshop_id )
+ vg_strcat( &subtext, "(Workshop) " );
+
vg_strcat( &subtext, global_skateshop.render.world_loc );
}
}
VG_STATIC void workshop_op_load_model(void)
{
if( workshop_form.submission.type == k_workshop_file_type_world ){
- vg_error( "Currently unsupported\n" );
+ vg_warn( "WORLD LOAD INFO Currently unsupported\n" );
+ return;
+ }
+
+ workshop_form.view_world = world_current_instance();
+
+ if( mdl_arrcount( &workshop_form.view_world->ent_swspreview ) ){
+ workshop_form.ptr_ent =
+ mdl_arritm( &workshop_form.view_world->ent_swspreview, 0 );
+ }
+ else{
+ vg_error( "There is no ent_swspreview in the level. "
+ "Cannot publish here\n" );
return;
}
vg_msg root;
vg_msg_init( &root, metadata_buf, len/2 );
- vg_msg workshop;
+ vg_msg workshop = root;
if( vg_msg_seekframe( &workshop, "workshop", k_vg_msg_first )){
vg_msg_cmd kv_type = vg_msg_seekkv( &workshop, "type",
k_vg_msg_first );
vg_console_reg_cmd( "workshop_submit", workshop_submit_command, NULL );
}
-VG_STATIC void workshop_find_preview_entity(void)
-{
- workshop_form.view_world = world_current_instance();
+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, &main_camera, 1 );
+
+ 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;
}
workshop_form.submission.submit_description = 1;
}
-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 =
+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,
+ 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 ) ){
+ enum workshop_file_type type =
workshop_form.submission.submission_type_selection.value;
+ workshop_form.submission.type = type;
+
+ if( type == k_workshop_file_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;
- }
- return;
}
-
- if( workshop_form.submission.type == k_workshop_file_type_world ){
- 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, "World submissions are currently not ready, sorry.",
- 1, k_ui_align_middle_center,0);
- 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;
- rect_copy( row, button );
- button[2] = 128;
- ui_rect_center( row, button );
- if( ui_button_text( button, "OK", 1 ) ){
- workshop_form.page = k_workshop_form_open;
- workshop_form.file_intent = k_workshop_form_file_intent_none;
- }
-
- return;
+ 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;
+ }
+}
- 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 );
-
+VG_STATIC void workshop_form_gui_draw_preview( ui_rect img_box ){
+ enum workshop_file_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_workshop_file_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 ) );
}
+}
+
+VG_STATIC void workshop_form_gui_edit_page( ui_rect content ){
+ enum workshop_file_type type = workshop_form.submission.type;
+
+ if( type == k_workshop_file_type_none ){
+ workshop_form_gui_page_undecided( content );
+ 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 ) );
+
+ 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 );
- ui_split( file_entry, k_ui_axis_v, -128, 0, file_entry, file_button );
if( workshop_form.submission.type == k_workshop_file_type_board ){
ui_label( file_entry, "Addon folder: skaterift/boards/",
1, 8, file_entry );
}
- 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 ) ){
- player_board_unload( &workshop_form.board_model );
- workshop_form.file_intent = k_workshop_form_file_intent_none;
- workshop_form.addon_folder[0] = '\0';
- }
- }
- else{
+ if( type == k_workshop_file_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 ) ){
+ player_board_unload( &workshop_form.board_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.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();
+ }
}
}
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++ ){
workshop_form.view_changed &&
workshop_form.file_intent == k_workshop_form_file_intent_new )
{
- workshop_render_preview();
+ enum workshop_file_type type = workshop_form.submission.type;
+ if( type == k_workshop_file_type_board ){
+ workshop_render_board_preview();
+ }
+ else if( type == k_workshop_file_type_world ){
+ vg_success( "Renders world preview\n" );
+ workshop_render_world_preview();
+ }
workshop_form.view_changed = 0;
}