Asset Pipeline v2 #145
@ -39,43 +39,75 @@ def get_transfer_data_owner(td_type_key: str, use_default_owner: bool, name=""):
|
|||||||
|
|
||||||
|
|
||||||
def draw_task_layer_selection(
|
def draw_task_layer_selection(
|
||||||
row,
|
layout: bpy.types.UILayout,
|
||||||
scene,
|
data: bpy.types.CollectionProperty or bpy.types.ID,
|
||||||
data,
|
|
||||||
data_owner,
|
|
||||||
data_owner_name,
|
|
||||||
show_all_task_layers=False,
|
show_all_task_layers=False,
|
||||||
show_local=False,
|
show_local_task_layers=False,
|
||||||
text="",
|
text="",
|
||||||
):
|
data_owner_name="",
|
||||||
# TODO Simplify Arguments and add Type Hints / Doc String
|
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:
|
if show_all_task_layers == True:
|
||||||
row.prop_search(
|
# Show All Task Layers
|
||||||
|
layout.prop_search(
|
||||||
data,
|
data,
|
||||||
data_owner_name,
|
data_owner_name,
|
||||||
scene.asset_pipeline,
|
asset_pipe,
|
||||||
'all_task_layers',
|
'all_task_layers',
|
||||||
text=text,
|
text=text,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
if (
|
if (
|
||||||
data_owner not in [tl.name for tl in scene.asset_pipeline.local_task_layers]
|
current_data_owner not in [tl.name for tl in asset_pipe.local_task_layers]
|
||||||
and not show_local
|
and not show_local_task_layers
|
||||||
):
|
):
|
||||||
row.enabled = False
|
# Show All Task Layers Greyed Out
|
||||||
row.prop_search(
|
layout.enabled = False
|
||||||
|
layout.prop_search(
|
||||||
data,
|
data,
|
||||||
data_owner_name,
|
data_owner_name,
|
||||||
scene.asset_pipeline,
|
asset_pipe,
|
||||||
'all_task_layers',
|
'all_task_layers',
|
||||||
text=text,
|
text=text,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
row.prop_search(
|
# Only Show Local Task Layers
|
||||||
|
layout.prop_search(
|
||||||
data,
|
data,
|
||||||
data_owner_name,
|
data_owner_name,
|
||||||
scene.asset_pipeline,
|
asset_pipe,
|
||||||
'local_task_layers',
|
'local_task_layers',
|
||||||
text=text,
|
text=text,
|
||||||
)
|
)
|
||||||
|
@ -39,12 +39,9 @@ def draw_transfer_data_type(
|
|||||||
else:
|
else:
|
||||||
row.prop(transfer_data_item, "surrender", text="Surrender")
|
row.prop(transfer_data_item, "surrender", text="Surrender")
|
||||||
draw_task_layer_selection(
|
draw_task_layer_selection(
|
||||||
row,
|
layout=row,
|
||||||
scene,
|
data=transfer_data_item,
|
||||||
transfer_data_item,
|
show_all_task_layers=transfer_data_item.get("use_default_owner"),
|
||||||
transfer_data_item.owner,
|
|
||||||
"owner",
|
|
||||||
transfer_data_item.get("use_default_owner"),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -480,13 +480,10 @@ class ASSETPIPE_OT_update_surrendered_object(bpy.types.Operator):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|
||||||
draw_task_layer_selection(
|
draw_task_layer_selection(
|
||||||
row,
|
layout=row,
|
||||||
context.scene,
|
data=self._obj,
|
||||||
self._obj,
|
show_all_task_layers=False,
|
||||||
self._obj.asset_id_owner,
|
show_local_task_layers=True,
|
||||||
"asset_id_owner",
|
|
||||||
False,
|
|
||||||
True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context):
|
def execute(self, context: bpy.types.Context):
|
||||||
@ -524,13 +521,12 @@ class ASSETPIPE_OT_update_surrendered_transfer_data(bpy.types.Operator):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|
||||||
draw_task_layer_selection(
|
draw_task_layer_selection(
|
||||||
row,
|
layout=row,
|
||||||
context.scene,
|
data=self._surrendered_transfer_data,
|
||||||
self._surrendered_transfer_data,
|
show_all_task_layers=self._surrendered_transfer_data.get(
|
||||||
self._surrendered_transfer_data.owner,
|
"use_default_owner"
|
||||||
"owner",
|
),
|
||||||
self._surrendered_transfer_data.get("use_default_owner"),
|
show_local_task_layers=True,
|
||||||
True,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def execute(self, context: bpy.types.Context):
|
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
|
owner_row.enabled = grey_out
|
||||||
|
|
||||||
draw_task_layer_selection(
|
draw_task_layer_selection(
|
||||||
owner_row,
|
layout=owner_row,
|
||||||
context.scene,
|
data=self,
|
||||||
self,
|
data_owner_name='owner_selection',
|
||||||
self.owner_selection,
|
current_data_owner=self.owner_selection,
|
||||||
'owner_selection',
|
|
||||||
show_all_task_layers=show_all_task_layers,
|
show_all_task_layers=show_all_task_layers,
|
||||||
show_local=show_local,
|
show_local_task_layers=show_local,
|
||||||
text="Set To",
|
text="Set To",
|
||||||
)
|
)
|
||||||
owner_row.prop(self, "avaliable_owners", text="")
|
owner_row.prop(self, "avaliable_owners", text="")
|
||||||
|
@ -116,9 +116,7 @@ class ASSETPIPE_PT_ownership_inspector(bpy.types.Panel):
|
|||||||
text=f"{col.name}: ",
|
text=f"{col.name}: ",
|
||||||
icon="OUTLINER_COLLECTION",
|
icon="OUTLINER_COLLECTION",
|
||||||
)
|
)
|
||||||
draw_task_layer_selection(
|
draw_task_layer_selection(layout=row, data=col)
|
||||||
row, scene, col, col.asset_id_owner, "asset_id_owner"
|
|
||||||
)
|
|
||||||
|
|
||||||
if not context.active_object:
|
if not context.active_object:
|
||||||
layout.label(text="Set an Active Object to Inspect", icon="OBJECT_DATA")
|
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
|
row.enabled = enabled
|
||||||
else:
|
else:
|
||||||
row.prop(obj, "asset_id_surrender", text="Surrender")
|
row.prop(obj, "asset_id_surrender", text="Surrender")
|
||||||
draw_task_layer_selection(
|
draw_task_layer_selection(layout=row, data=obj)
|
||||||
row, scene, obj, obj.asset_id_owner, "asset_id_owner"
|
|
||||||
)
|
|
||||||
draw_transfer_data(transfer_data, layout)
|
draw_transfer_data(transfer_data, layout)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user