Brush Assets: Add library choice to "Save As" operator #118021

Merged
Hans Goudey merged 14 commits from HooglyBoogly/blender:brush-assets-save-library-option into brush-assets-project 2024-02-14 17:36:57 +01:00
1 changed files with 0 additions and 32 deletions
Showing only changes of commit 525908a4d5 - Show all commits

View File

@ -1205,38 +1205,6 @@ static bool brush_asset_save_as_poll(bContext *C)
return true;
}

If there is no user asset library at all, I think it's still fine for this poll to return false.

If there is no user asset library at all, I think it's still fine for this poll to return false.
static bool asset_is_editable(const AssetWeakReference &asset_weak_ref)
{
/* Fairly simple checks, based on filepath only:
* - The blendlib filepath ends up with the `.asset.blend` extension.
* - The blendlib is located in the expected sub-directory of the editable asset library.
*
* TODO: Right now no check is done on file content, e.g. to ensure that the blendlib file has
* not been manually edited by the user (that it does not have any UI IDs e.g.). */
char path_buffer[FILE_MAX_LIBEXTRA];
char *dir, *group, *name;
AS_asset_full_path_explode_from_weak_ref(&asset_weak_ref, path_buffer, &dir, &group, &name);
if (!StringRef(dir).endswith(BLENDER_ASSET_FILE_SUFFIX)) {
return false;
}
bUserAssetLibrary *library = BKE_preferences_asset_library_find_by_name(
&U, asset_weak_ref.asset_library_identifier);
if (!library) {
return false;
}
std::string root_path_for_save = brush_asset_root_path_for_save(*library);
if (root_path_for_save.empty() || !StringRef(dir).startswith(root_path_for_save)) {
return false;
}
/* TODO: Do we want more checks here? E.g. check actual content of the file? */
return true;
}
static bool asset_is_editable(const AssetWeakReference &asset_weak_ref)
{
/* Fairly simple checks, based on filepath only: