diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_filebrowser.py | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/asset.cc | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_asset_types.h | 4 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_asset.c | 42 |
4 files changed, 52 insertions, 0 deletions
diff --git a/release/scripts/startup/bl_ui/space_filebrowser.py b/release/scripts/startup/bl_ui/space_filebrowser.py index 927a30f0ae0..086df46d799 100644 --- a/release/scripts/startup/bl_ui/space_filebrowser.py +++ b/release/scripts/startup/bl_ui/space_filebrowser.py @@ -734,6 +734,7 @@ class ASSETBROWSER_PT_metadata(asset_utils.AssetBrowserPanel, Panel): row.operator("asset.open_containing_blend_file", text="", icon='TOOL_SETTINGS') layout.prop(asset_file_handle.asset_data, "description") + layout.prop(asset_file_handle.asset_data, "author") class ASSETBROWSER_PT_metadata_preview(asset_utils.AssetMetaDataPanel, Panel): diff --git a/source/blender/blenkernel/intern/asset.cc b/source/blender/blenkernel/intern/asset.cc index ae9ded3c754..dfe568729db 100644 --- a/source/blender/blenkernel/intern/asset.cc +++ b/source/blender/blenkernel/intern/asset.cc @@ -53,6 +53,7 @@ void BKE_asset_metadata_free(AssetMetaData **asset_data) if ((*asset_data)->properties) { IDP_FreeProperty((*asset_data)->properties); } + MEM_SAFE_FREE((*asset_data)->author); MEM_SAFE_FREE((*asset_data)->description); BLI_freelistN(&(*asset_data)->tags); @@ -158,6 +159,9 @@ void BKE_asset_metadata_write(BlendWriter *writer, AssetMetaData *asset_data) IDP_BlendWrite(writer, asset_data->properties); } + if (asset_data->author) { + BLO_write_string(writer, asset_data->author); + } if (asset_data->description) { BLO_write_string(writer, asset_data->description); } @@ -175,6 +179,7 @@ void BKE_asset_metadata_read(BlendDataReader *reader, AssetMetaData *asset_data) IDP_BlendDataRead(reader, &asset_data->properties); } + BLO_read_data_address(reader, &asset_data->author); BLO_read_data_address(reader, &asset_data->description); BLO_read_list(reader, &asset_data->tags); BLI_assert(BLI_listbase_count(&asset_data->tags) == asset_data->tot_tags); diff --git a/source/blender/makesdna/DNA_asset_types.h b/source/blender/makesdna/DNA_asset_types.h index f5bdad3e79e..60de254fec7 100644 --- a/source/blender/makesdna/DNA_asset_types.h +++ b/source/blender/makesdna/DNA_asset_types.h @@ -72,8 +72,12 @@ typedef struct AssetMetaData { * #catalog_id is updated. */ char catalog_simple_name[64]; /* MAX_NAME */ + /** Optional name of the author for display in the UI. Dynamic length. */ + char *author; + /** Optional description of this asset for display in the UI. Dynamic length. */ char *description; + /** User defined tags for this asset. The asset manager uses these for filtering, but how they * function exactly (e.g. how they are registered to provide a list of searchable available tags) * is up to the asset-engine. */ diff --git a/source/blender/makesrna/intern/rna_asset.c b/source/blender/makesrna/intern/rna_asset.c index 979d0882dd5..5d83da170b5 100644 --- a/source/blender/makesrna/intern/rna_asset.c +++ b/source/blender/makesrna/intern/rna_asset.c @@ -139,6 +139,40 @@ static IDProperty **rna_AssetMetaData_idprops(PointerRNA *ptr) return &asset_data->properties; } +static void rna_AssetMetaData_author_get(PointerRNA *ptr, char *value) +{ + AssetMetaData *asset_data = ptr->data; + + if (asset_data->author) { + strcpy(value, asset_data->author); + } + else { + value[0] = '\0'; + } +} + +static int rna_AssetMetaData_author_length(PointerRNA *ptr) +{ + AssetMetaData *asset_data = ptr->data; + return asset_data->author ? strlen(asset_data->author) : 0; +} + +static void rna_AssetMetaData_author_set(PointerRNA *ptr, const char *value) +{ + AssetMetaData *asset_data = ptr->data; + + if (asset_data->author) { + MEM_freeN(asset_data->author); + } + + if (value[0]) { + asset_data->author = BLI_strdup(value); + } + else { + asset_data->author = NULL; + } +} + static void rna_AssetMetaData_description_get(PointerRNA *ptr, char *value) { AssetMetaData *asset_data = ptr->data; @@ -347,6 +381,14 @@ static void rna_def_asset_data(BlenderRNA *brna) RNA_def_struct_idprops_func(srna, "rna_AssetMetaData_idprops"); RNA_def_struct_flag(srna, STRUCT_NO_DATABLOCK_IDPROPERTIES); /* Mandatory! */ + prop = RNA_def_property(srna, "author", PROP_STRING, PROP_NONE); + RNA_def_property_editable_func(prop, "rna_AssetMetaData_editable"); + RNA_def_property_string_funcs(prop, + "rna_AssetMetaData_author_get", + "rna_AssetMetaData_author_length", + "rna_AssetMetaData_author_set"); + RNA_def_property_ui_text(prop, "Author", "Name of the creator of the asset"); + prop = RNA_def_property(srna, "description", PROP_STRING, PROP_NONE); RNA_def_property_editable_func(prop, "rna_AssetMetaData_editable"); RNA_def_property_string_funcs(prop, |