From e413c80371c1714d80262034d0e83b4e10e6cbe5 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Mon, 14 Dec 2020 13:39:41 +0100 Subject: Asset System: Support custom asset library paths through Preferences One of the core design aspects of the Asset Browser is that users can "mount" custom asset libraries via the Preferences. Currently an asset library is just a directory with one or more .blend files in it. We could easily support a single .blend file as asset library as well (rather than a directory). It's just disabled currently. Note that in earlier designs, asset libraries were called repositories. Idea is simple: In Preferences > File Paths, you can create custom libraries, by setting a name and selecting a path. The name is ensured to be unique. If the name or path are empty, the Asset Browser will not show it in the list of available asset libraries. The library path is not checked for validity, the Asset Browser will allow selecting invalid libraries, but show a message instead of the file list, to help the user understand what's going on. Of course the actual Asset Browser UI is not part of this commit, it's in one of the following ones. {F9497950} Part of the first Asset Browser milestone. Check the #asset_browser_milestone_1 project milestone on developer.blender.org. Differential Revision: https://developer.blender.org/D9722 Reviewed by: Brecht Van Lommel, Hans Goudey --- source/blender/blenloader/intern/readfile.c | 1 + source/blender/blenloader/intern/versioning_userdef.c | 4 ++++ source/blender/blenloader/intern/writefile.c | 4 ++++ 3 files changed, 9 insertions(+) (limited to 'source/blender/blenloader') diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 8dff1aa1ed0..a3e793038f7 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3904,6 +3904,7 @@ static BHead *read_userdef(BlendFileData *bfd, FileData *fd, BHead *bhead) BLO_read_list(reader, &user->user_menus); BLO_read_list(reader, &user->addons); BLO_read_list(reader, &user->autoexec_paths); + BLO_read_list(reader, &user->asset_libraries); LISTBASE_FOREACH (wmKeyMap *, keymap, &user->user_keymaps) { keymap->modal_items = NULL; diff --git a/source/blender/blenloader/intern/versioning_userdef.c b/source/blender/blenloader/intern/versioning_userdef.c index 5ed7ab55851..f1572c563bf 100644 --- a/source/blender/blenloader/intern/versioning_userdef.c +++ b/source/blender/blenloader/intern/versioning_userdef.c @@ -44,6 +44,7 @@ #include "BKE_idprop.h" #include "BKE_keyconfig.h" #include "BKE_main.h" +#include "BKE_preferences.h" #include "BLO_readfile.h" @@ -830,6 +831,9 @@ void blo_do_versions_userdef(UserDef *userdef) */ { /* Keep this block, even when empty. */ + if (BLI_listbase_is_empty(&userdef->asset_libraries)) { + BKE_preferences_asset_library_default_add(userdef); + } } LISTBASE_FOREACH (bTheme *, btheme, &userdef->themes) { diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c index c64a7dc1b9f..e7d55538f7e 100644 --- a/source/blender/blenloader/intern/writefile.c +++ b/source/blender/blenloader/intern/writefile.c @@ -756,6 +756,10 @@ static void write_userdef(BlendWriter *writer, const UserDef *userdef) BLO_write_struct(writer, bPathCompare, path_cmp); } + LISTBASE_FOREACH (const bUserAssetLibrary *, asset_library, &userdef->asset_libraries) { + BLO_write_struct(writer, bUserAssetLibrary, asset_library); + } + LISTBASE_FOREACH (const uiStyle *, style, &userdef->uistyles) { BLO_write_struct(writer, uiStyle, style); } -- cgit v1.2.3