Asset Pipeline v2 #145

Closed
Nick Alberelli wants to merge 431 commits from (deleted):feature/asset-pipeline-v2 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
4 changed files with 69 additions and 49 deletions
Showing only changes of commit 11a23c7e64 - Show all commits

View File

@ -39,43 +39,75 @@ def get_transfer_data_owner(td_type_key: str, use_default_owner: bool, name=""):
def draw_task_layer_selection(
row,
scene,
data,
data_owner,
data_owner_name,
layout: bpy.types.UILayout,
data: bpy.types.CollectionProperty or bpy.types.ID,
show_all_task_layers=False,
show_local=False,
show_local_task_layers=False,
text="",
):
# TODO Simplify Arguments and add Type Hints / Doc String
data_owner_name="",
current_data_owner=None,
) -> None:
"""Draw an prop search UI for ownership of either OBJ/COL or Task Layer.
It has three modes, 'Show All Task Layers" "Show All Task Layers Greyed Out" and
"Only Show Local Task Layers"
- When the property is already set to a local task layer show: "Only Show Local Task Layers"
- When a property is owned by an external task layer: "Show All Task Layers Greyed Out" so they user cannot edit it
- When a user is overriding or the object is new (using default ownership): "Show All Task Layers"
Args:
layout (bpy.types.UILayout): Any UI Layout element like self.layout or row
data (bpy.types.CollectionProperty or bpy.types.ID): Object, Collection or Transfer Data Item
show_all_task_layers (bool, optional): Used when user is overriding or default ownership is set. Defaults to False.
show_local_task_layers (bool, optional): Force Showing Local Task Layers Only. Defaults to False.
text (str, optional): Title of prop search. Defaults to "".
data_owner_name(str, optional): Name of Data if it needs to be specified
current_data_owner(str, optional): Property that is named by data_owner_name so it can be checked, property should return a string
"""
# Set data_owner_name based on type of it hasn't been passed
if data_owner_name == "":
# These rna_type.names are defined by class names in props.py
if data.rna_type.name in ["AssetTransferData", 'AssetTransferDataTemp']:
data_owner_name = "owner"
else:
data_owner_name = "asset_id_owner"
# Get the current data owner from OBJ/COL or Transfer Data Item if it hasn't been passed
if current_data_owner is None:
current_data_owner = data.get(data_owner_name)
asset_pipe = bpy.context.scene.asset_pipeline
if show_all_task_layers == True:
row.prop_search(
# Show All Task Layers
layout.prop_search(
data,
data_owner_name,
scene.asset_pipeline,
asset_pipe,
'all_task_layers',
text=text,
)
return
if (
data_owner not in [tl.name for tl in scene.asset_pipeline.local_task_layers]
and not show_local
current_data_owner not in [tl.name for tl in asset_pipe.local_task_layers]
and not show_local_task_layers
):
row.enabled = False
row.prop_search(
# Show All Task Layers Greyed Out
layout.enabled = False
layout.prop_search(
data,
data_owner_name,
scene.asset_pipeline,
asset_pipe,
'all_task_layers',
text=text,
)
return
else:
row.prop_search(
# Only Show Local Task Layers
layout.prop_search(
data,
data_owner_name,
scene.asset_pipeline,
asset_pipe,
'local_task_layers',
text=text,
)

View File

@ -39,12 +39,9 @@ def draw_transfer_data_type(
else:
row.prop(transfer_data_item, "surrender", text="Surrender")
draw_task_layer_selection(
row,
scene,
transfer_data_item,
transfer_data_item.owner,
"owner",
transfer_data_item.get("use_default_owner"),
layout=row,
data=transfer_data_item,
show_all_task_layers=transfer_data_item.get("use_default_owner"),
)

View File

@ -480,13 +480,10 @@ class ASSETPIPE_OT_update_surrendered_object(bpy.types.Operator):
row = layout.row()
draw_task_layer_selection(
row,
context.scene,
self._obj,
self._obj.asset_id_owner,
"asset_id_owner",
False,
True,
layout=row,
data=self._obj,
show_all_task_layers=False,
show_local_task_layers=True,
)
def execute(self, context: bpy.types.Context):
@ -524,13 +521,12 @@ class ASSETPIPE_OT_update_surrendered_transfer_data(bpy.types.Operator):
row = layout.row()
draw_task_layer_selection(
row,
context.scene,
self._surrendered_transfer_data,
self._surrendered_transfer_data.owner,
"owner",
self._surrendered_transfer_data.get("use_default_owner"),
True,
layout=row,
data=self._surrendered_transfer_data,
show_all_task_layers=self._surrendered_transfer_data.get(
"use_default_owner"
),
show_local_task_layers=True,
)
def execute(self, context: bpy.types.Context):
@ -701,13 +697,12 @@ class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
owner_row.enabled = grey_out
draw_task_layer_selection(
owner_row,
context.scene,
self,
self.owner_selection,
'owner_selection',
layout=owner_row,
data=self,
data_owner_name='owner_selection',
current_data_owner=self.owner_selection,
show_all_task_layers=show_all_task_layers,
show_local=show_local,
show_local_task_layers=show_local,
text="Set To",
)
owner_row.prop(self, "avaliable_owners", text="")

View File

@ -116,9 +116,7 @@ class ASSETPIPE_PT_ownership_inspector(bpy.types.Panel):
text=f"{col.name}: ",
icon="OUTLINER_COLLECTION",
)
draw_task_layer_selection(
row, scene, col, col.asset_id_owner, "asset_id_owner"
)
draw_task_layer_selection(layout=row, data=col)
if not context.active_object:
layout.label(text="Set an Active Object to Inspect", icon="OBJECT_DATA")
@ -135,9 +133,7 @@ class ASSETPIPE_PT_ownership_inspector(bpy.types.Panel):
row.enabled = enabled
else:
row.prop(obj, "asset_id_surrender", text="Surrender")
draw_task_layer_selection(
row, scene, obj, obj.asset_id_owner, "asset_id_owner"
)
draw_task_layer_selection(layout=row, data=obj)
draw_transfer_data(transfer_data, layout)