WIP: Brush assets project #106303
|
@ -1581,6 +1581,7 @@ class USERPREF_PT_file_paths_asset_libraries(FilePathsPanel, Panel):
|
|||
layout.prop(active_library, "path")
|
||||
layout.prop(active_library, "import_method", text="Import Method")
|
||||
layout.prop(active_library, "use_relative_path")
|
||||
layout.prop(active_library, "is_default")
|
||||
|
||||
|
||||
class USERPREF_UL_asset_libraries(UIList):
|
||||
|
|
|
@ -1051,11 +1051,15 @@ static AssetWeakReference *brush_asset_create_weakref_hack(const bUserAssetLibra
|
|||
|
||||
static const bUserAssetLibrary *brush_asset_get_editable_library()
|
||||
{
|
||||
/* TODO: take into account which one is marked as default. */
|
||||
LISTBASE_FOREACH (const bUserAssetLibrary *, asset_library, &U.asset_libraries) {
|
||||
return asset_library;
|
||||
if (BLI_listbase_is_empty(&U.asset_libraries)) {
|
||||
return nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
LISTBASE_FOREACH (const bUserAssetLibrary *, asset_library, &U.asset_libraries) {
|
||||
if (asset_library->flag & ASSET_LIBRARY_DEFAULT) {
|
||||
return asset_library;
|
||||
}
|
||||
}
|
||||
return static_cast<const bUserAssetLibrary *>(U.asset_libraries.first);
|
||||
}
|
||||
|
||||
static void brush_asset_refresh_editable_library(const bContext *C)
|
||||
|
|
|
@ -126,6 +126,7 @@ typedef enum eAssetImportMethod {
|
|||
|
||||
typedef enum eAssetLibrary_Flag {
|
||||
ASSET_LIBRARY_RELATIVE_PATH = (1 << 0),
|
||||
ASSET_LIBRARY_DEFAULT = (1 << 1),
|
||||
} eAssetLibrary_Flag;
|
||||
|
||||
/**
|
||||
|
|
|
@ -358,6 +358,18 @@ static void rna_userdef_asset_library_path_set(PointerRNA *ptr, const char *valu
|
|||
BKE_preferences_asset_library_path_set(library, value);
|
||||
}
|
||||
|
||||
static void rna_UserAssetLibrary_is_default_set(PointerRNA *ptr, bool value)
|
||||
{
|
||||
bUserAssetLibrary *library = static_cast<bUserAssetLibrary *>(ptr->data);
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
LISTBASE_FOREACH (bUserAssetLibrary *, library_iter, &U.asset_libraries) {
|
||||
library_iter->flag &= ~ASSET_LIBRARY_DEFAULT;
|
||||
}
|
||||
library->flag |= ASSET_LIBRARY_DEFAULT;
|
||||
}
|
||||
|
||||
static void rna_userdef_extension_repo_name_set(PointerRNA *ptr, const char *value)
|
||||
{
|
||||
bUserExtensionRepo *repo = (bUserExtensionRepo *)ptr->data;
|
||||
|
@ -6576,6 +6588,11 @@ static void rna_def_userdef_filepaths_asset_library(BlenderRNA *brna)
|
|||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", ASSET_LIBRARY_RELATIVE_PATH);
|
||||
RNA_def_property_ui_text(
|
||||
prop, "Relative Path", "Use relative path when linking assets from this asset library");
|
||||
|
||||
prop = RNA_def_property(srna, "is_default", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, nullptr, "flag", ASSET_LIBRARY_DEFAULT);
|
||||
RNA_def_property_boolean_funcs(prop, nullptr, "rna_UserAssetLibrary_is_default_set");
|
||||
RNA_def_property_ui_text(prop, "Default", "Use this library for saving new assets");
|
||||
}
|
||||
|
||||
static void rna_def_userdef_filepaths_extension_repo(BlenderRNA *brna)
|
||||
|
|
Loading…
Reference in New Issue