X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=ent_skateshop.c;h=a667599bc31afaa5a07b95005d615db1f93f0a02;hb=5d5d5f394cbe2212769bc58a70fa622b4ed46205;hp=19b868fe6b986e5f6e2570936d836ee05e63c259;hpb=342fcbf6fda017bdd38d56ce0fa7c9e59e589f3b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/ent_skateshop.c b/ent_skateshop.c index 19b868f..a667599 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -394,7 +394,8 @@ VG_STATIC void world_scan_register_local( const char *folder_name ) vg_strncpy( folder_name, reg->foldername, 64, k_strncpy_overflow_fatal ); reg->foldername_hash = hash; reg->state = k_registry_board_state_indexed; - reg->meta_present = 0; + //reg->meta_present = 0; + reg->type = k_world_load_type_local; } /* @@ -587,6 +588,69 @@ VG_STATIC struct cache_board *skateshop_selected_cache_if_loaded(void) return NULL; } +VG_STATIC void pointcloud_async_end(void *_, u32 __) +{ + pointcloud_animate( k_pointcloud_anim_opening ); + skaterift_end_op(); +} + +VG_STATIC void pointcloud_clear_async(void *_, u32 __) +{ + pointcloud.count = 0; + pointcloud_animate( k_pointcloud_anim_opening ); + skaterift_end_op(); +} + +VG_STATIC void skateshop_preview_loader_thread( void *_data ) +{ + struct registry_world *reg = _data; + + if( reg->type == k_world_load_type_local ){ + 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{ + vg_async_call( pointcloud_clear_async, NULL, 0 ); + } + } + else{ + vg_async_call( pointcloud_clear_async, NULL, 0 ); + } +} + +VG_STATIC void skateshop_load_world_preview( struct registry_world *reg ) +{ + skaterift_begin_op( k_async_op_world_load_preview ); + vg_loader_start( skateshop_preview_loader_thread, reg ); +} + /* * VG event preupdate */ @@ -600,7 +664,6 @@ VG_STATIC void global_skateshop_preupdate(void) if( !global_skateshop.active ) return; world_instance *world = world_current_instance(); - ent_skateshop *shop = global_skateshop.ptr_ent; /* camera positioning */ @@ -711,45 +774,78 @@ VG_STATIC void global_skateshop_preupdate(void) } } else if( shop->type == k_skateshop_type_worldshop ){ - if( global_skateshop.world_registry_count ){ + int browseable = 0, + loadable = 0; + + if( global_skateshop.world_registry_count && + ((skaterift.async_op == k_async_op_none)|| + (skaterift.async_op == k_async_op_world_load_preview))){ gui_helper_action( axis_display_string(k_sraxis_mbrowse_h), "browse" ); + browseable = 1; } if( skaterift.async_op == k_async_op_none ){ gui_helper_action( button_display_string(k_srbind_maccept), "load" ); + loadable = 1; } int change = 0; - if( button_down( k_srbind_mleft ) ){ - if( global_skateshop.selected_world_id > 0 ){ - global_skateshop.selected_world_id --; - change = 1; + + if( browseable ){ + if( button_down( k_srbind_mleft ) ){ + if( global_skateshop.selected_world_id > 0 ) + { + global_skateshop.selected_world_id --; + change = 1; + } } - } - if( button_down( k_srbind_mright ) ){ - if( global_skateshop.selected_world_id+1 < - global_skateshop.world_registry_count ){ - global_skateshop.selected_world_id ++; - change = 1; + if( button_down( k_srbind_mright ) ){ + if( global_skateshop.selected_world_id+1 < + global_skateshop.world_registry_count ) + { + global_skateshop.selected_world_id ++; + change = 1; + } } } - if( change && (pointcloud.anim == k_pointcloud_anim_idle) && - pointcloud.visibility == 1.0f ){ - pointcloud.anim = k_pointcloud_anim_hiding; - pointcloud.anim_start = vg.time; + if( change && pointcloud_idle() ){ + pointcloud_animate( k_pointcloud_anim_hiding ); } - if( (skaterift.async_op == k_async_op_none ) && - button_down( k_srbind_maccept ) ) - { + if( skaterift.async_op == k_async_op_none ){ struct registry_world *rw = &global_skateshop.world_registry[ global_skateshop.selected_world_id ]; - vg_info( "Select world (%u)\n", global_skateshop.selected_world_id ); - skaterift_change_world( rw->foldername ); - return; + /* automatically load in clouds */ + if( loadable && button_down( k_srbind_maccept ) ){ + vg_info( "Select world (%u)\n", + global_skateshop.selected_world_id ); + skaterift_change_world( rw->foldername ); + return; + } + else{ + if( pointcloud.anim == k_pointcloud_anim_idle_closed ){ + if( global_skateshop.pointcloud_world_id != + global_skateshop.selected_world_id ) + { + global_skateshop.pointcloud_world_id = + global_skateshop.selected_world_id; + skateshop_load_world_preview( rw ); + } + else{ + pointcloud_animate( k_pointcloud_anim_opening ); + } + } + else if( pointcloud.anim == k_pointcloud_anim_idle_open ){ + if( global_skateshop.pointcloud_world_id != + global_skateshop.selected_world_id ) + { + pointcloud_animate( k_pointcloud_anim_hiding ); + } + } + } } } else{ @@ -927,11 +1023,12 @@ VG_STATIC void skateshop_render_worldshop(void) info.buffer[info.i++] = ' '; info.buffer[info.i] = '\0'; - if( rw->meta_present ){ - vg_fatal_error(""); + vg_strcat( &info, rw->foldername ); + if( skaterift.async_op == k_async_op_world_loading || + skaterift.async_op == k_async_op_world_preloading ){ + vg_strcat( &subtext, "Loading..." ); } else{ - vg_strcat( &info, rw->foldername ); vg_strcat( &subtext, "No information" ); } } @@ -939,10 +1036,6 @@ VG_STATIC void skateshop_render_worldshop(void) vg_strcat( &info, "No worlds installed" ); } - if( skaterift.async_op == k_async_op_world_loading || - skaterift.async_op == k_async_op_world_preloading ){ - vg_strcat( &info, "Loading..." ); - } m4x3f mtext,mlocal,mtextmdl; mdl_transform_m4x3( &mark_info->transform, mtext ); @@ -1036,8 +1129,7 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ) workshop_op_item_scan(); } else if( shop->type == k_skateshop_type_worldshop ){ - pointcloud.anim = k_pointcloud_anim_opening; - pointcloud.anim_start = vg.time; + pointcloud_animate( k_pointcloud_anim_opening ); skateshop_op_world_scan(); } }