Use addon pref to store default texture dir, allowing per-scene override.
This commit is contained in:
parent
c10107b887
commit
afbc36a70a
@ -23,6 +23,11 @@ class BlenderCloudPreferences(AddonPreferences):
|
|||||||
default='https://pillar.blender.org:5000/'
|
default='https://pillar.blender.org:5000/'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
local_texture_dir = StringProperty(
|
||||||
|
name='Default Blender Cloud texture storage directory',
|
||||||
|
subtype='DIR_PATH',
|
||||||
|
default='//textures')
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
@ -53,6 +58,11 @@ class BlenderCloudPreferences(AddonPreferences):
|
|||||||
sub.label(text=blender_id_text, icon=blender_id_icon)
|
sub.label(text=blender_id_text, icon=blender_id_icon)
|
||||||
sub.label(text="* " + blender_id_help)
|
sub.label(text="* " + blender_id_help)
|
||||||
|
|
||||||
|
sub = layout.column()
|
||||||
|
sub.label(text='Local directory for downloaded textures')
|
||||||
|
sub.prop(self, "local_texture_dir", text='Default')
|
||||||
|
sub.prop(context.scene, "local_texture_dir", text='Current scene')
|
||||||
|
|
||||||
# options for Pillar
|
# options for Pillar
|
||||||
sub = layout.column()
|
sub = layout.column()
|
||||||
sub.enabled = blender_id_icon != 'ERROR'
|
sub.enabled = blender_id_icon != 'ERROR'
|
||||||
@ -111,10 +121,19 @@ def register():
|
|||||||
name="Blender Cloud node UUID",
|
name="Blender Cloud node UUID",
|
||||||
default='') # empty == top-level of project
|
default='') # empty == top-level of project
|
||||||
|
|
||||||
Scene.blender_cloud_dir = StringProperty(
|
addon_prefs = preferences()
|
||||||
name='Blender Cloud texture storage directory',
|
|
||||||
|
def default_if_empty(scene, context):
|
||||||
|
"""The scene's local_texture_dir, if empty, reverts to the addon prefs."""
|
||||||
|
|
||||||
|
if not scene.local_texture_dir:
|
||||||
|
scene.local_texture_dir = addon_prefs.local_texture_dir
|
||||||
|
|
||||||
|
Scene.local_texture_dir = StringProperty(
|
||||||
|
name='Blender Cloud texture storage directory for current scene',
|
||||||
subtype='DIR_PATH',
|
subtype='DIR_PATH',
|
||||||
default='//textures')
|
default=addon_prefs.local_texture_dir,
|
||||||
|
update=default_if_empty)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
|
@ -600,7 +600,7 @@ class BlenderCloudBrowser(bpy.types.Operator):
|
|||||||
node_path_components = [node['name'] for node in self.path_stack if node is not None]
|
node_path_components = [node['name'] for node in self.path_stack if node is not None]
|
||||||
local_path_components = [self.project_uuid] + node_path_components + [self.node['name']]
|
local_path_components = [self.project_uuid] + node_path_components + [self.node['name']]
|
||||||
|
|
||||||
top_texture_directory = bpy.path.abspath(context.scene.blender_cloud_dir)
|
top_texture_directory = bpy.path.abspath(context.scene.local_texture_dir)
|
||||||
local_path = os.path.join(top_texture_directory, *local_path_components)
|
local_path = os.path.join(top_texture_directory, *local_path_components)
|
||||||
meta_path = os.path.join(top_texture_directory, '.blender_cloud')
|
meta_path = os.path.join(top_texture_directory, '.blender_cloud')
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user