load title basic
authorhgn <hgodden00@gmail.com>
Fri, 26 May 2023 06:57:54 +0000 (07:57 +0100)
committerhgn <hgodden00@gmail.com>
Fri, 26 May 2023 06:57:54 +0000 (07:57 +0100)
addon.c
ent_skateshop.c
ent_skateshop.h

diff --git a/addon.c b/addon.c
index c2ad38c0d929f34ab96c48da70a155b221d3715b..aa9c00e0f68e84c4188fc212864173ac53defa87 100644 (file)
--- 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 );
index b3e648f45aff2a7676a667c792d6d0a3b4543c26..fafd37634d2be72484f5049d292f2ad3245650a5 100644 (file)
@@ -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
     * ----------------------------------------------------------------- */
index ff11e62f84ff863230358d2eb0fe294b8e68a6c9..03f05441bc223937d08653ec7914d3fcb9df3c3d 100644 (file)
@@ -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 );