From fee9867cee40c393a7142178039e8bcda964e004 Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 26 May 2023 07:57:54 +0100 Subject: [PATCH] load title basic --- addon.c | 8 ++++++++ ent_skateshop.c | 36 +++++++++++++++++++++++++++++++++--- ent_skateshop.h | 47 +++++++---------------------------------------- 3 files changed, 48 insertions(+), 43 deletions(-) diff --git a/addon.c b/addon.c index c2ad38c..aa9c00e 100644 --- a/addon.c +++ b/addon.c @@ -152,6 +152,14 @@ VG_STATIC void addon_mount_workshop_folder( PublishedFileId_t workshop_id, return; } + /* TODO: we definitely need a different, robust interface for this + * + * msg_frame f = msg_get_frame( hello ) + * msg_kv kv = get_kv( f, "" ); + * if( kv.type == unsigned ) + * ... + */ + enum workshop_file_type type = k_workshop_file_type_none; vg_msg msg; vg_msg_init( &msg, reg->metadata, reg->metadata_len ); diff --git a/ent_skateshop.c b/ent_skateshop.c index b3e648f..fafd376 100644 --- a/ent_skateshop.c +++ b/ent_skateshop.c @@ -691,7 +691,35 @@ fade_out:; } struct cache_board *cache_ptr = skateshop_selected_cache_if_loaded(); - if( !cache_ptr ) return; + if( !cache_ptr ){ + global_skateshop.render.item_title = ""; + global_skateshop.render.item_desc = ""; + return; + } + + if( global_skateshop.render.reg_id != global_skateshop.selected_board_id ){ + addon_reg *reg = cache_ptr->reg_ptr; + vg_msg msg; + vg_msg_init( &msg, reg->metadata, reg->metadata_len ); + + 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_kvstring ){ + if( VG_STRDJB2_EQ( "title", cmd.key, cmd.key_djb2 ) ){ + global_skateshop.render.item_title = cmd.value._buf; + } + } + } + } + } + } + + global_skateshop.render.reg_id = global_skateshop.selected_board_id; + } addon_reg *reg = cache_ptr->reg_ptr; @@ -699,12 +727,14 @@ fade_out:; * ----------------------------------------------------------------- */ m3x3_zero( mlocal ); m3x3_setdiagonalv3( mlocal, (v3f){ scale, scale, thickness } ); - mlocal[3][0] = -font3d_string_width( &gui.font, 0, "Flubber" ); + mlocal[3][0] = -font3d_string_width( &gui.font, 0, + global_skateshop.render.item_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( &gui.font, 0, "Flubber", &main_camera, mmdl ); + font3d_simple_draw( &gui.font, 0, global_skateshop.render.item_title, + &main_camera, mmdl ); /* Author name * ----------------------------------------------------------------- */ diff --git a/ent_skateshop.h b/ent_skateshop.h index ff11e62..03f0544 100644 --- a/ent_skateshop.h +++ b/ent_skateshop.h @@ -42,50 +42,17 @@ struct{ } shop_view_slots[ SKATESHOP_VIEW_SLOT_MAX ]; -#if 0 - struct registry_board{ - PublishedFileId_t workshop_id; - - /* only for steam workshop files */ - //struct workshop_file_info workshop; - struct cache_board *cache_ptr; - - char foldername[64]; /* if workshop, string version of its published ID. */ - u32 foldername_hash; - - enum registry_board_state{ - k_registry_board_state_none, - k_registry_board_state_indexed, - k_registry_board_state_indexed_absent /*was found but is now missing*/ - } - state; - } - *registry; - u32 t1_registry_count, - registry_count; - - /* worlds */ - struct registry_world{ - PublishedFileId_t workshop_id; - enum registry_board_state state; - char foldername[64]; - u32 foldername_hash; - enum world_load_type type; - -#if 0 - int meta_present; - ent_worldinfo info; -#endif - } - *world_registry; - u32 t1_world_registry_count, - world_registry_count; -#endif u32 selected_world_id, selected_board_id, pointcloud_world_id; + + struct { + const char *item_title, *item_desc; + u32 reg_id; + } + render; } -static global_skateshop; +static global_skateshop={.render={.reg_id=0xffffffff}}; VG_STATIC void global_skateshop_exit(void); VG_STATIC void watch_cache_board( struct cache_board *ptr ); -- 2.25.1