Asset Pipeline v2 #145
@ -1,6 +1,6 @@
|
|||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
from . import ui, ops, props
|
from . import ui, ops, props, prefs
|
||||||
|
|
||||||
bl_info = {
|
bl_info = {
|
||||||
"name": "Asset Pipeline 2",
|
"name": "Asset Pipeline 2",
|
||||||
@ -20,9 +20,11 @@ def reload() -> None:
|
|||||||
global ui
|
global ui
|
||||||
global ops
|
global ops
|
||||||
global props
|
global props
|
||||||
|
global prefs
|
||||||
importlib.reload(ui)
|
importlib.reload(ui)
|
||||||
importlib.reload(ops)
|
importlib.reload(ops)
|
||||||
importlib.reload(props)
|
importlib.reload(props)
|
||||||
|
importlib.reload(prefs)
|
||||||
|
|
||||||
|
|
||||||
_need_reload = "ui" in locals()
|
_need_reload = "ui" in locals()
|
||||||
@ -36,9 +38,11 @@ def register() -> None:
|
|||||||
ui.register()
|
ui.register()
|
||||||
ops.register()
|
ops.register()
|
||||||
props.register()
|
props.register()
|
||||||
|
prefs.register()
|
||||||
|
|
||||||
|
|
||||||
def unregister() -> None:
|
def unregister() -> None:
|
||||||
ui.unregister()
|
ui.unregister()
|
||||||
ops.unregister()
|
ops.unregister()
|
||||||
props.unregister()
|
props.unregister()
|
||||||
|
prefs.unregister()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import bpy
|
import bpy
|
||||||
|
from . import config
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from .merge.publish import (
|
from .merge.publish import (
|
||||||
@ -26,6 +26,7 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
|||||||
_name = None
|
_name = None
|
||||||
_dir = None
|
_dir = None
|
||||||
_prefix = None
|
_prefix = None
|
||||||
|
_json_path = None
|
||||||
|
|
||||||
create_files: bpy.props.BoolProperty(
|
create_files: bpy.props.BoolProperty(
|
||||||
name="Create Files for Unselected Task Layers", default=True
|
name="Create Files for Unselected Task Layers", default=True
|
||||||
@ -48,9 +49,15 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
|||||||
|
|
||||||
def invoke(self, context: bpy.types.Context, event):
|
def invoke(self, context: bpy.types.Context, event):
|
||||||
# Dynamically Create Task Layer Bools
|
# Dynamically Create Task Layer Bools
|
||||||
all_task_layers = context.scene.asset_pipeline.all_task_layers
|
asset_pipe = context.scene.asset_pipeline
|
||||||
|
|
||||||
|
# TODO Check if this fails
|
||||||
|
config.verify_json_data(Path(asset_pipe.task_layer_config_type))
|
||||||
|
|
||||||
|
all_task_layers = asset_pipe.all_task_layers
|
||||||
all_task_layers.clear()
|
all_task_layers.clear()
|
||||||
for task_layer_key in constants.TASK_LAYER_TYPES:
|
|
||||||
|
for task_layer_key in config.TASK_LAYER_TYPES:
|
||||||
if task_layer_key == "NONE":
|
if task_layer_key == "NONE":
|
||||||
continue
|
continue
|
||||||
new_task_layer = all_task_layers.add()
|
new_task_layer = all_task_layers.add()
|
||||||
@ -93,6 +100,12 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
|||||||
for publish_type in constants.PUBLISH_KEYS:
|
for publish_type in constants.PUBLISH_KEYS:
|
||||||
os.mkdir(os.path.join(asset_path, publish_type))
|
os.mkdir(os.path.join(asset_path, publish_type))
|
||||||
|
|
||||||
|
# TODO Save Task Layer Config File
|
||||||
|
config.write_json_file(
|
||||||
|
asset_path=Path(asset_path),
|
||||||
|
source_file_path=Path(asset_pipe.task_layer_config_type),
|
||||||
|
)
|
||||||
|
|
||||||
# Setup Base File
|
# Setup Base File
|
||||||
asset_pipe = context.scene.asset_pipeline
|
asset_pipe = context.scene.asset_pipeline
|
||||||
asset_pipe.is_asset_pipeline_file = True
|
asset_pipe.is_asset_pipeline_file = True
|
||||||
@ -119,7 +132,7 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
|
|||||||
|
|
||||||
# TODO Support mulitple task layers in same file
|
# TODO Support mulitple task layers in same file
|
||||||
# Create the file for each task layer.
|
# Create the file for each task layer.
|
||||||
for task_layer_key in constants.TASK_LAYER_TYPES:
|
for task_layer_key in config.TASK_LAYER_TYPES:
|
||||||
if task_layer_key == "NONE" or task_layer_key in local_tls:
|
if task_layer_key == "NONE" or task_layer_key in local_tls:
|
||||||
continue
|
continue
|
||||||
name = self._name + "." + task_layer_key + ".blend"
|
name = self._name + "." + task_layer_key + ".blend"
|
||||||
|
28
scripts-blender/addons/asset_pipeline_2/prefs.py
Normal file
28
scripts-blender/addons/asset_pipeline_2/prefs.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import bpy
|
||||||
|
|
||||||
|
|
||||||
|
class ASSET_PIPELINE_addon_preferences(bpy.types.AddonPreferences):
|
||||||
|
bl_idname = __package__
|
||||||
|
|
||||||
|
custom_task_layers_dir: bpy.props.StringProperty( # type: ignore
|
||||||
|
name="Custom Task Layers",
|
||||||
|
description="TODO", # TODO Add Description
|
||||||
|
default="",
|
||||||
|
subtype="DIR_PATH",
|
||||||
|
)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
self.layout.prop(self, "custom_task_layers_dir")
|
||||||
|
|
||||||
|
|
||||||
|
classes = (ASSET_PIPELINE_addon_preferences,)
|
||||||
|
|
||||||
|
|
||||||
|
def register():
|
||||||
|
for cls in classes:
|
||||||
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
|
|
||||||
|
def unregister():
|
||||||
|
for cls in reversed(classes):
|
||||||
|
bpy.utils.unregister_class(cls)
|
@ -1,12 +1,29 @@
|
|||||||
import bpy
|
import bpy
|
||||||
from . import constants
|
from . import constants
|
||||||
from .merge.task_layer import get_local_task_layers
|
from .merge.task_layer import get_local_task_layers
|
||||||
|
from .config import get_task_layer_presets_path
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
""" NOTE Items in these properties groups should be generated by a function that finds the
|
""" NOTE Items in these properties groups should be generated by a function that finds the
|
||||||
avaliable task layers from the task_layer_defaults.json file that needs to be created.
|
avaliable task layers from the task_layer_defaults.json file that needs to be created.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
def get_task_layer_presets(self, context):
|
||||||
|
prefs = context.preferences.addons["asset_pipeline_2"].preferences
|
||||||
|
user_tls = Path(prefs.custom_task_layers_dir)
|
||||||
|
|
||||||
|
presets_dir = get_task_layer_presets_path()
|
||||||
|
items = []
|
||||||
|
|
||||||
|
for file in presets_dir.glob('*.json'):
|
||||||
|
items.append((file.__str__(), file.name.replace(".json", ""), file.name))
|
||||||
|
if user_tls.exists() and user_tls.is_dir():
|
||||||
|
for file in user_tls.glob('*.json'):
|
||||||
|
items.append((file.__str__(), file.name.replace(".json", ""), file.name))
|
||||||
|
return items
|
||||||
|
|
||||||
|
|
||||||
class AssetTransferData(bpy.types.PropertyGroup):
|
class AssetTransferData(bpy.types.PropertyGroup):
|
||||||
"""Properties to track transferable data on an object"""
|
"""Properties to track transferable data on an object"""
|
||||||
|
|
||||||
@ -73,6 +90,11 @@ class AssetPipeline(bpy.types.PropertyGroup):
|
|||||||
name="Prefix", description="Prefix for new Asset", default=""
|
name="Prefix", description="Prefix for new Asset", default=""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
task_layer_config_type: bpy.props.EnumProperty(
|
||||||
|
name="Task Layer Preset",
|
||||||
|
items=get_task_layer_presets,
|
||||||
|
)
|
||||||
|
|
||||||
all_task_layers: bpy.props.CollectionProperty(type=TaskLayerSettings)
|
all_task_layers: bpy.props.CollectionProperty(type=TaskLayerSettings)
|
||||||
local_task_layers: bpy.props.CollectionProperty(type=TaskLayerSettings)
|
local_task_layers: bpy.props.CollectionProperty(type=TaskLayerSettings)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user