X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=ent_skateshop.c;h=ce0ca5d2b55236f98164197d906a469df462b681;hb=b8ff92a2caafa557608b84f4a037a5b3ce2628f7;hp=40362219b37b9d8ae1c6479c7ebad3b6077cd469;hpb=38e07d851915d4ea3d25eeb28a3ace78fb0d1c12;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/ent_skateshop.c b/ent_skateshop.c index 4036221..ce0ca5d 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -4,12 +4,15 @@ #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" #include "gui.h" #include "menu.h" #include "pointcloud.h" +#include "highscores.h" +#include "steam.h" /* * Checks string equality but does a hash check first @@ -60,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; @@ -68,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 ); @@ -102,12 +105,6 @@ VG_STATIC void skateshop_update_viewpage(void) } } -/* generic reciever */ -VG_STATIC void workshop_async_any_complete( void *data, u32 size ) -{ - skaterift_end_op(); -} - /* * op/subroutine: k_workshop_op_item_load * ----------------------------------------------------------------------------- @@ -128,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 ); } /* @@ -137,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; ipayload; - 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 ); } - player_board_load( &cache_ptr->board, path ); + 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, 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 ); @@ -225,8 +275,9 @@ VG_STATIC void workshop_steam_scan(void) vg_async_stall(); for( u32 j=0; jworkshop_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( ®->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; + } - strcat( path, meta_file ); - workshop_load_metadata( path, ®->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; + } + + 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:; } @@ -288,6 +412,7 @@ VG_STATIC void workshop_scan_thread( void *_args ) reg->state = k_registry_board_state_indexed_absent; } +#if 0 /* * Local disk scan */ @@ -323,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(); @@ -353,6 +484,148 @@ VG_STATIC void workshop_op_item_scan(void) vg_loader_start( workshop_scan_thread, NULL ); } +/* + * op: k_async_op_world_scan + * ----------------------------------------------------------------------------- + */ + +/* + * Reciever for scan completion. copies the registry_count back into t0 + */ +VG_STATIC void workshop_async_world_reg_update( void *data, u32 size ) +{ + vg_info( "World registry update notify\n" ); + global_skateshop.world_registry_count = + global_skateshop.t1_world_registry_count; + skaterift_end_op(); +} + +/* + * Add a local world folder to the registry, it will verify existing ones are + * still there too. + */ +VG_STATIC void world_scan_register_local( const char *folder_name ) +{ + u32 hash = vg_strdjb2( folder_name ); + for( u32 i=0; ifoldername ) ){ + reg->state = k_registry_board_state_indexed; + return; + } + } + + if( global_skateshop.t1_world_registry_count == SKATESHOP_WORLDS_MAX ){ + vg_error( "You have too many worlds installed!\n" ); + return; + } + + vg_info( "new listing!: %s\n", folder_name ); + + struct registry_world *reg = &global_skateshop.world_registry[ + global_skateshop.t1_world_registry_count ++ ]; + + 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->type = k_world_load_type_local; +} + +/* + * Async thread which scans local files for boards, as well as scheduling + * synchronous calls to the workshop + */ +VG_STATIC void world_scan_thread( void *_args ) +{ + vg_linear_clear( vg_mem.scratch ); + + for( u32 i=0; istate = k_registry_board_state_indexed_absent; + } + + /* + * Local disk scan + */ + vg_info( "Scanning maps/*.mdl\n" ); + + char path_buf[4096]; + vg_str path; + vg_strnull( &path, path_buf, 4096 ); + vg_strcat( &path, "maps/" ); + + DIR *dir = opendir( path.buffer ); + if( !dir ){ + vg_error( "opendir('maps') failed\n" ); + vg_async_call( workshop_async_any_complete, NULL, 0 ); + return; + } + + struct dirent *entry; + while( (entry = readdir(dir)) ){ + if( entry->d_type == DT_DIR ){ + if( entry->d_name[0] == '.' ) continue; + + vg_str folder = path; + char *folder_name = folder.buffer+folder.i; + + if( strlen( entry->d_name ) > + vg_list_size(global_skateshop.world_registry[0].foldername)){ + vg_warn( "Map folder too long: %s\n", entry->d_name ); + continue; + } + + vg_strcat( &folder, entry->d_name ); + if( !vg_strgood( &folder ) ) break; + + DIR *subdir = opendir( folder.buffer ); + while( (entry = readdir(subdir)) ){ + 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_strcat( &folder, "" ); + world_scan_register_local( folder_name ); + } + } + closedir(subdir); + } + } + closedir(dir); + + vg_async_call( workshop_async_world_reg_update, NULL, 0 ); + +#if 0 + tinydir_close(&dir); + + if( steam_ready ) workshop_steam_scan(); + + vg_async_call( workshop_async_reg_update, NULL, 0 ); + vg_async_stall(); + workshop_visibile_load_loop_thread(NULL); +#endif +} + +/* + * Asynchronous scan of local disk for worlds + */ +VG_STATIC void skateshop_op_world_scan(void) +{ + skaterift_begin_op( k_async_op_world_scan ); + vg_loader_start( world_scan_thread, NULL ); +} + /* * Regular stuff * ----------------------------------------------------------------------------- @@ -390,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; itype == 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 */ @@ -461,8 +801,7 @@ VG_STATIC void global_skateshop_preupdate(void) if( !global_skateshop.active ) return; - world_instance *world = get_active_world(); - + world_instance *world = world_current_instance(); ent_skateshop *shop = global_skateshop.ptr_ent; /* camera positioning */ @@ -573,23 +912,79 @@ VG_STATIC void global_skateshop_preupdate(void) } } else if( shop->type == k_skateshop_type_worldshop ){ - gui_helper_action( axis_display_string( k_sraxis_mbrowse_h ), "browse" ); + 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( browseable ){ + if( button_down( k_srbind_mleft ) ){ + if( global_skateshop.selected_world_id > 0 ) + { + global_skateshop.selected_world_id --; + change = 1; + } + } - v2f input; - joystick_state( k_srjoystick_steer, input ); - pointcloud.control[0] += input[0] * vg.time_delta; - pointcloud.control[2] += input[1] * vg.time_delta; + 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_idle() ){ + pointcloud_animate( k_pointcloud_anim_hiding ); + } - pointcloud.control[0] = vg_clampf( pointcloud.control[0], -10.0f, 10.0f ); - pointcloud.control[2] = vg_clampf( pointcloud.control[2], -10.0f, 10.0f ); + if( skaterift.async_op == k_async_op_none ){ + struct registry_world *rw = &global_skateshop.world_registry[ + global_skateshop.selected_world_id ]; - if( button_press( k_srbind_trick1 ) ){ - pointcloud.control[3] += vg.time_delta*0.2f; + /* 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 ); + } + } + } } - if( button_press( k_srbind_trick0 ) ){ - pointcloud.control[3] -= vg.time_delta*0.2f; -} - pointcloud.control[3] = vg_clampf( pointcloud.control[3], 0.001f, 10.0f ); } else{ vg_fatal_error( "Unknown store (%u)\n", shop->type ); @@ -603,7 +998,7 @@ VG_STATIC void global_skateshop_preupdate(void) VG_STATIC void skateshop_render_boardshop(void) { - world_instance *world = get_active_world(); + world_instance *world = world_current_instance(); ent_skateshop *shop = global_skateshop.ptr_ent; u32 slot_count = vg_list_size(global_skateshop.shop_view_slots); @@ -676,7 +1071,7 @@ fade_out:; float scale = 0.2f, thickness = 0.03f; - font3d_bind( &world_global.font, &main_camera ); + font3d_bind( &gui.font, &main_camera ); shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); /* Selection counter @@ -690,7 +1085,7 @@ fade_out:; m4x3_mul( mrack, mlocal, mmdl ); if( global_skateshop.registry_count == 0 ){ - font3d_simple_draw( &world_global.font, 0, + font3d_simple_draw( &gui.font, 0, "Nothing installed", &main_camera, mmdl ); } else{ @@ -701,7 +1096,7 @@ fade_out:; i+=highscore_intl( buf+i, global_skateshop.registry_count, 3 ); buf[i++] = '\0'; - font3d_simple_draw( &world_global.font, 0, buf, &main_camera, mmdl ); + font3d_simple_draw( &gui.font, 0, buf, &main_camera, mmdl ); } struct cache_board *cache_ptr = skateshop_selected_cache_if_loaded(); @@ -709,29 +1104,32 @@ fade_out:; struct registry_board *reg = &global_skateshop.registry[cache_ptr->registry_id]; + +#if 0 struct workshop_file_info *info = ®->workshop; /* Skin title * ----------------------------------------------------------------- */ m3x3_zero( mlocal ); m3x3_setdiagonalv3( mlocal, (v3f){ scale, scale, thickness } ); - mlocal[3][0] = -font3d_string_width( &world_global.font, 0, info->title ); + mlocal[3][0] = -font3d_string_width( &gui.font, 0, info->title ); mlocal[3][0] *= scale*0.5f; mlocal[3][1] = 0.1f; + mlocal[3][2] = 0.0f; m4x3_mul( mtext, mlocal, mmdl ); - font3d_simple_draw( &world_global.font, 0, info->title, &main_camera, mmdl ); + font3d_simple_draw( &gui.font, 0, info->title, &main_camera, mmdl ); /* Author name * ----------------------------------------------------------------- */ scale *= 0.4f; m3x3_setdiagonalv3( mlocal, (v3f){ scale, scale, thickness } ); - mlocal[3][0] = -font3d_string_width( &world_global.font, 0, - info->author_name ); + mlocal[3][0] = -font3d_string_width( &gui.font, 0, info->author_name ); mlocal[3][0] *= scale*0.5f; mlocal[3][1] = 0.0f; + mlocal[3][2] = 0.0f; m4x3_mul( mtext, mlocal, mmdl ); - font3d_simple_draw( &world_global.font, 0, - info->author_name, &main_camera, mmdl ); + font3d_simple_draw( &gui.font, 0, info->author_name, &main_camera, mmdl ); +#endif } VG_STATIC void skateshop_render_charshop(void) @@ -740,52 +1138,77 @@ VG_STATIC void skateshop_render_charshop(void) VG_STATIC void skateshop_render_worldshop(void) { - world_instance *world = get_active_world(); + world_instance *world = world_current_instance(); - m4x3f mmdl; ent_skateshop *shop = global_skateshop.ptr_ent; ent_marker *mark_display = mdl_arritm( &world->ent_marker, - mdl_entity_id_id(shop->worlds.id_display)); - mdl_transform_m4x3( &mark_display->transform, mmdl ); - - /* TODO? ... */ -#if 0 - v3f vol; - v3_sub( world->scene_geo.bbx[1], world->scene_geo.bbx[0], vol ); - - v2f rect = { 1.0f, 1.0f }, - map = { vol[0], vol[2] }, - result; - - f32 rp = rect[0] * map[1], - rc = rect[1] * map[0]; + mdl_entity_id_id(shop->worlds.id_display)), + *mark_info = mdl_arritm( &world->ent_marker, + mdl_entity_id_id(shop->boards.id_info)); + + /* Text */ + char buftext[128], bufsubtext[128]; + vg_str info, subtext; + vg_strnull( &info, buftext, 128 ); + vg_strnull( &subtext, bufsubtext, 128 ); - u32 axis, other; - if( rc > rp ) axis = 0; - else axis = 1; - other = axis ^ 0x1; + if( global_skateshop.world_registry_count ){ + struct registry_world *rw = &global_skateshop.world_registry[ + global_skateshop.selected_world_id ]; + + info.i+=highscore_intl( info.buffer+info.i, + global_skateshop.selected_world_id+1, 3 ); + info.buffer[info.i++] = '/'; + info.i+=highscore_intl( info.buffer+info.i, + global_skateshop.world_registry_count, 3 ); + info.buffer[info.i++] = ' '; + info.buffer[info.i] = '\0'; + + 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( &subtext, "No information" ); + } + } + else{ + vg_strcat( &info, "No worlds installed" ); + } - result[axis] = rect[axis]; - result[other] = (rect[axis] * map[other]) / map[axis]; - m4x3f mlocal, mx; - m4x3_identity( mlocal ); + m4x3f mtext,mlocal,mtextmdl; + mdl_transform_m4x3( &mark_info->transform, mtext ); - mlocal[0][0] = result[0]; - mlocal[2][2] = result[1]; - mlocal[1][1] = (vol[1]/vol[0]) * mlocal[0][0]; - mlocal[3][0] = (rect[0]-result[0])*0.5f - rect[0]*0.5f; /* sea level? */ - mlocal[3][2] = (rect[1]-result[1])*0.5f - rect[1]*0.5f; - m4x3_mul( mmdl, mlocal, mx ); -#endif + font3d_bind( &gui.font, &main_camera ); + shader_model_font_uColour( (v4f){1.0f,1.0f,1.0f,1.0f} ); + float scale = 0.2f, thickness = 0.015f, scale1 = 0.08f; + m3x3_zero( mlocal ); + m3x3_setdiagonalv3( mlocal, (v3f){ scale, scale, thickness } ); + mlocal[3][0] = -font3d_string_width( &gui.font, 0, buftext ); + mlocal[3][0] *= scale*0.5f; + mlocal[3][1] = 0.1f; + mlocal[3][2] = 0.0f; + m4x3_mul( mtext, mlocal, mtextmdl ); + font3d_simple_draw( &gui.font, 0, buftext, &main_camera, mtextmdl ); + + m3x3_setdiagonalv3( mlocal, (v3f){ scale1, scale1, thickness } ); + mlocal[3][0] = -font3d_string_width( &gui.font, 0, bufsubtext ); + mlocal[3][0] *= scale1*0.5f; + mlocal[3][1] = -scale1*0.3f; + m4x3_mul( mtext, mlocal, mtextmdl ); + font3d_simple_draw( &gui.font, 0, bufsubtext, &main_camera, mtextmdl ); + + /* pointcloud */ + m4x3f mmdl; + mdl_transform_m4x3( &mark_display->transform, mmdl ); m4x3_rotate_y( mmdl, vg.time * 0.2 ); -#if 1 glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE); glDisable(GL_DEPTH_TEST); -#endif pointcloud_render( world, &main_camera, mmdl ); glDisable(GL_BLEND); glEnable(GL_DEPTH_TEST); @@ -846,6 +1269,10 @@ VG_STATIC void ent_skateshop_call( world_instance *world, ent_call *call ) skateshop_update_viewpage(); workshop_op_item_scan(); } + else if( shop->type == k_skateshop_type_worldshop ){ + pointcloud_animate( k_pointcloud_anim_opening ); + skateshop_op_world_scan(); + } } }