Assets: Cleanup/deduplicate usages of RNA enum for asset lib types.

The same data was essentially defined twice.

Pull Request: https://projects.blender.org/blender/blender/pulls/115353
This commit is contained in:
Bastien Montagne 2023-11-24 14:24:30 +01:00 committed by Gitea
parent ec772ed2f1
commit 9c2330d821
2 changed files with 23 additions and 22 deletions

View File

@ -20,6 +20,8 @@
#include "UI_resources.hh"
#include "RNA_define.hh"
#include "RNA_enum_types.hh"
#include "RNA_prototypes.h"
#include "ED_asset_library.h"
@ -78,25 +80,16 @@ const EnumPropertyItem *ED_asset_library_reference_to_rna_enum_itemf(const bool
int totitem = 0;
if (include_generated) {
const EnumPropertyItem generated_items[] = {
{ASSET_LIBRARY_ALL, "ALL", 0, "All", "Show assets from all of the listed asset libraries"},
RNA_ENUM_ITEM_SEPR,
{ASSET_LIBRARY_LOCAL,
"LOCAL",
ICON_CURRENT_FILE,
"Current File",
"Show the assets currently available in this Blender session"},
{ASSET_LIBRARY_ESSENTIALS,
"ESSENTIALS",
0,
"Essentials",
"Show the basic building blocks and utilities coming with Blender"},
{0, nullptr, 0, nullptr, nullptr},
};
/* Add predefined libraries that are generated and not simple directories that can be written
* to. */
RNA_enum_items_add(&item, &totitem, generated_items);
BLI_assert(rna_enum_asset_library_type_items[0].value == ASSET_LIBRARY_ALL);
RNA_enum_item_add(&item, &totitem, &rna_enum_asset_library_type_items[0]);
RNA_enum_item_add_separator(&item, &totitem);
BLI_assert(rna_enum_asset_library_type_items[1].value == ASSET_LIBRARY_LOCAL);
RNA_enum_item_add(&item, &totitem, &rna_enum_asset_library_type_items[1]);
BLI_assert(rna_enum_asset_library_type_items[2].value == ASSET_LIBRARY_ESSENTIALS);
RNA_enum_item_add(&item, &totitem, &rna_enum_asset_library_type_items[2]);
}
/* Add separator if needed. */

View File

@ -20,10 +20,18 @@
#include "rna_internal.h"
const EnumPropertyItem rna_enum_asset_library_type_items[] = {
{ASSET_LIBRARY_LOCAL, "LOCAL", 0, "Local", ""},
{ASSET_LIBRARY_ALL, "ALL", 0, "All", ""},
{ASSET_LIBRARY_ESSENTIALS, "ESSENTIALS", 0, "Essentials", ""},
{ASSET_LIBRARY_CUSTOM, "CUSTOM", 0, "Custom", ""},
{ASSET_LIBRARY_ALL, "ALL", 0, "All", "Show assets from all of the listed asset libraries"},
{ASSET_LIBRARY_LOCAL,
"LOCAL",
0,
"Current File",
"Show the assets currently available in this Blender session"},
{ASSET_LIBRARY_ESSENTIALS,
"ESSENTIALS",
0,
"Essentials",
"Show the basic building blocks and utilities coming with Blender"},
{ASSET_LIBRARY_CUSTOM, "CUSTOM", 0, "Custom", "All external 'normal' asset repositories"},
{0, nullptr, 0, nullptr, nullptr},
};
@ -701,7 +709,7 @@ PropertyRNA *rna_def_asset_library_reference_common(StructRNA *srna,
const char *set)
{
PropertyRNA *prop = RNA_def_property(srna, "asset_library_reference", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, rna_enum_dummy_NULL_items);
RNA_def_property_enum_items(prop, rna_enum_asset_library_type_items);
RNA_def_property_enum_funcs(prop, get, set, "rna_asset_library_reference_itemf");
return prop;