[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50063] branches/asset-browser/source/ blender: == assetbrowser ==
Andrea Weikert
elubie at gmx.net
Mon Aug 20 23:36:36 CEST 2012
Revision: 50063
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50063
Author: elubie
Date: 2012-08-20 21:36:35 +0000 (Mon, 20 Aug 2012)
Log Message:
-----------
== assetbrowser ==
WIP commit
* fixed some writing issues
* added basic linking of an ID datablock
Modified Paths:
--------------
branches/asset-browser/source/blender/blenkernel/intern/assets.c
branches/asset-browser/source/blender/blenloader/intern/readfile.c
branches/asset-browser/source/blender/blenloader/intern/writefile.c
branches/asset-browser/source/blender/editors/space_asset/space_asset.c
branches/asset-browser/source/blender/editors/space_view3d/space_view3d.c
branches/asset-browser/source/blender/makesdna/DNA_asset_types.h
branches/asset-browser/source/blender/windowmanager/intern/wm_operators.c
Modified: branches/asset-browser/source/blender/blenkernel/intern/assets.c
===================================================================
--- branches/asset-browser/source/blender/blenkernel/intern/assets.c 2012-08-20 21:20:38 UTC (rev 50062)
+++ branches/asset-browser/source/blender/blenkernel/intern/assets.c 2012-08-20 21:36:35 UTC (rev 50063)
@@ -36,6 +36,7 @@
#include "BLI_linklist.h"
#include "BLI_listbase.h"
#include "BLI_string.h"
+#include "BLI_path_util.h"
#include "BLO_readfile.h"
@@ -114,6 +115,7 @@
BLI_strncpy(asset->group, group, sizeof(asset->group));
BLI_strncpy(asset->name, blockname+2, sizeof(asset->name));
BLI_strncpy(asset->lib, filename, sizeof(asset->lib));
+ BLI_snprintf(asset->path, sizeof(asset->path), "%s/%s/%s", asset->lib, asset->group, asset->name);
BLI_addtail(assets, asset);
}
}
Modified: branches/asset-browser/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/asset-browser/source/blender/blenloader/intern/readfile.c 2012-08-20 21:20:38 UTC (rev 50062)
+++ branches/asset-browser/source/blender/blenloader/intern/readfile.c 2012-08-20 21:36:35 UTC (rev 50063)
@@ -6348,8 +6348,17 @@
static void direct_link_asset_collection(FileData *fd, bAssetCollection *asset_collection)
{
+ bAssetFile *asset_file;
+ bAssetDir *asset_dir;
+
link_list(fd, &asset_collection->asset_files);
+ for(asset_file = asset_collection->asset_files.first; asset_file; asset_file= asset_file->next ) {
+ link_list(fd, &asset_file->assets);
+ }
link_list(fd, &asset_collection->asset_dirs);
+ for(asset_dir = asset_collection->asset_dirs.first; asset_dir; asset_dir= asset_dir->next ) {
+ link_list(fd, &asset_dir->assets);
+ }
}
static void lib_link_asset_collection(FileData *fd, Main *main)
Modified: branches/asset-browser/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/asset-browser/source/blender/blenloader/intern/writefile.c 2012-08-20 21:20:38 UTC (rev 50062)
+++ branches/asset-browser/source/blender/blenloader/intern/writefile.c 2012-08-20 21:36:35 UTC (rev 50063)
@@ -2813,9 +2813,15 @@
static void write_asset_files(WriteData *wd, ListBase *asset_files)
{
bAssetFile *asset_file;
+ bAsset *asset;
+
for(asset_file = asset_files->first; asset_file; asset_file= asset_file->next ) {
writestruct(wd, DATA, "bAssetFile", 1, asset_file);
+ for (asset = asset_file->assets.first; asset; asset = asset->next) {
+ writestruct(wd, DATA, "bAsset", 1, asset);
+ }
+
/* Write ID Properties -- and copy this comment EXACTLY for easy finding
of library blocks that implement this.*/
if (asset_file->properties) {
Modified: branches/asset-browser/source/blender/editors/space_asset/space_asset.c
===================================================================
--- branches/asset-browser/source/blender/editors/space_asset/space_asset.c 2012-08-20 21:20:38 UTC (rev 50062)
+++ branches/asset-browser/source/blender/editors/space_asset/space_asset.c 2012-08-20 21:36:35 UTC (rev 50063)
@@ -228,7 +228,8 @@
cl = ar->regiondata = assetlist_new();
}
if (ac) {
- if (asset_collection_update(main, ac)) {
+ int do_update = asset_collection_update(main, ac) || contentlist_empty(cl);
+ if (do_update) {
contentlist_read(cl, C);
listview_layout_init(ar);
layout = contentlist_layout_get(cl);
Modified: branches/asset-browser/source/blender/editors/space_view3d/space_view3d.c
===================================================================
--- branches/asset-browser/source/blender/editors/space_view3d/space_view3d.c 2012-08-20 21:20:38 UTC (rev 50062)
+++ branches/asset-browser/source/blender/editors/space_view3d/space_view3d.c 2012-08-20 21:36:35 UTC (rev 50063)
@@ -42,6 +42,8 @@
#include "BLI_rand.h"
#include "BLI_utildefines.h"
+#include "BLO_readfile.h"
+
#include "BKE_object.h"
#include "BKE_context.h"
#include "BKE_screen.h"
@@ -469,6 +471,29 @@
return 0;
}
+static int view3d_link_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
+{
+ if (drag->type == WM_DRAG_PATH) {
+ char path[FILE_MAXDIR];
+ char dir[FILE_MAXDIR];
+ char group[GROUP_MAX];
+ char name[FILE_MAXFILE];
+ char *p;
+ int is_lib;
+
+ BLI_strncpy(path, drag->path, sizeof(path));
+ p = BLI_last_slash(path);
+ p++;
+ BLI_strncpy(name, p, sizeof(name));
+ *p = '\0';
+
+ is_lib = BLO_is_a_library(path, dir, group);
+ if (is_lib && group[0] != '\0')
+ return 1;
+ }
+ return 0;
+}
+
static int view3d_mat_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
{
if (drag->type == WM_DRAG_ID) {
@@ -540,7 +565,25 @@
RNA_string_set(drop->ptr, "filepath", drag->path);
}
+static void view3d_id_link_drop(wmDrag *drag, wmDropBox *drop)
+{
+ if (drag->path[0]) {
+ char dir[FILE_MAXDIR];
+ char name[FILE_MAXFILE];
+ char *p;
+ BLI_strncpy(dir, drag->path, sizeof(dir));
+ p = BLI_last_slash(dir);
+ p++;
+ BLI_strncpy(name, p, sizeof(name));
+ *p = '\0';
+
+ RNA_string_set(drop->ptr, "filepath", drag->path);
+ RNA_string_set(drop->ptr, "filename", name);
+ RNA_string_set(drop->ptr, "directory", dir);
+ }
+}
+
/* region dropbox definition */
static void view3d_dropboxes(void)
{
@@ -550,6 +593,7 @@
WM_dropbox_add(lb, "OBJECT_OT_drop_named_material", view3d_mat_drop_poll, view3d_id_drop_copy);
WM_dropbox_add(lb, "MESH_OT_drop_named_image", view3d_ima_ob_drop_poll, view3d_id_path_drop_copy);
WM_dropbox_add(lb, "VIEW3D_OT_background_image_add", view3d_ima_bg_drop_poll, view3d_id_path_drop_copy);
+ WM_dropbox_add(lb, "WM_OT_link_append", view3d_link_drop_poll, view3d_id_link_drop);
}
Modified: branches/asset-browser/source/blender/makesdna/DNA_asset_types.h
===================================================================
--- branches/asset-browser/source/blender/makesdna/DNA_asset_types.h 2012-08-20 21:20:38 UTC (rev 50062)
+++ branches/asset-browser/source/blender/makesdna/DNA_asset_types.h 2012-08-20 21:36:35 UTC (rev 50063)
@@ -39,6 +39,7 @@
typedef struct bAsset {
struct bAsset *next, *prev;
char lib[1024]; /* library */
+ char path[1024]; /* library */
char group[32]; /* ID group */
char name[66]; /* same length as ID->name */
short pad1;
Modified: branches/asset-browser/source/blender/windowmanager/intern/wm_operators.c
===================================================================
--- branches/asset-browser/source/blender/windowmanager/intern/wm_operators.c 2012-08-20 21:20:38 UTC (rev 50062)
+++ branches/asset-browser/source/blender/windowmanager/intern/wm_operators.c 2012-08-20 21:36:35 UTC (rev 50063)
@@ -843,17 +843,25 @@
};
- if (flag & WM_FILESEL_FILEPATH)
- RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "File Path", "Path to file");
+ if (flag & WM_FILESEL_FILEPATH) {
+ prop = RNA_def_string_file_path(ot->srna, "filepath", "", FILE_MAX, "File Path", "Path to file");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ }
- if (flag & WM_FILESEL_DIRECTORY)
- RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file");
+ if (flag & WM_FILESEL_DIRECTORY) {
+ prop = RNA_def_string_dir_path(ot->srna, "directory", "", FILE_MAX, "Directory", "Directory of the file");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ }
- if (flag & WM_FILESEL_FILENAME)
- RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file");
+ if (flag & WM_FILESEL_FILENAME) {
+ prop = RNA_def_string_file_name(ot->srna, "filename", "", FILE_MAX, "File Name", "Name of the file");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ }
- if (flag & WM_FILESEL_FILES)
- RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
+ if (flag & WM_FILESEL_FILES) {
+ prop = RNA_def_collection_runtime(ot->srna, "files", &RNA_OperatorFileListElement, "Files", "");
+ RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
+ }
if (action == FILE_SAVE) {
prop = RNA_def_boolean(ot->srna, "check_existing", 1, "Check Existing", "Check and warn on overwriting existing files");
More information about the Bf-blender-cvs
mailing list