Asset Pipeline: Improve Push Operator UI #199

Merged
2 changed files with 28 additions and 57 deletions

View File

@ -168,17 +168,13 @@ class ASSETPIPE_OT_create_new_asset(bpy.types.Operator):
for obj in bpy.data.objects: for obj in bpy.data.objects:
bpy.data.objects.remove(obj) bpy.data.objects.remove(obj)
bpy.ops.outliner.orphans_purge( bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=False, do_recursive=True)
do_local_ids=True, do_linked_ids=False, do_recursive=True
)
def _task_layer_collections_set(self, context, asset_col, local_tls): def _task_layer_collections_set(self, context, asset_col, local_tls):
for task_layer_key in config.TASK_LAYER_TYPES: for task_layer_key in config.TASK_LAYER_TYPES:
if task_layer_key not in local_tls: if task_layer_key not in local_tls:
continue continue
col_name = ( col_name = (f"{self._name}{constants.NAME_DELIMITER}{task_layer_key}").lower()
f"{self._name}{constants.NAME_DELIMITER}{task_layer_key}"
).lower()
bpy.data.collections.new(col_name) bpy.data.collections.new(col_name)
task_layer_col = bpy.data.collections.get(col_name) task_layer_col = bpy.data.collections.get(col_name)
task_layer_col.asset_id_owner = task_layer_key task_layer_col.asset_id_owner = task_layer_key
@ -278,7 +274,7 @@ class ASSETPIPE_OT_update_ownership(bpy.types.Operator):
class ASSETPIPE_OT_sync_pull(bpy.types.Operator): class ASSETPIPE_OT_sync_pull(bpy.types.Operator):
bl_idname = "assetpipe.sync_pull" bl_idname = "assetpipe.sync_pull"
bl_label = "Pull from Publish" bl_label = "Pull Asset"
bl_description = """Pull Task Layers from the published sync target""" bl_description = """Pull Task Layers from the published sync target"""
_temp_transfer_data = None _temp_transfer_data = None
@ -328,8 +324,8 @@ class ASSETPIPE_OT_sync_pull(bpy.types.Operator):
class ASSETPIPE_OT_sync_push(bpy.types.Operator): class ASSETPIPE_OT_sync_push(bpy.types.Operator):
bl_idname = "assetpipe.sync_push" bl_idname = "assetpipe.sync_push"
bl_label = "Push from Publish" bl_label = "Sync Asset"
bl_description = """Push the current Task Layer to the published sync target""" bl_description = """Sync the current Task Layer to the published sync target. File will be saved as part of the Push process"""
_temp_transfer_data = None _temp_transfer_data = None
_invalid_objs = [] _invalid_objs = []
@ -350,12 +346,6 @@ class ASSETPIPE_OT_sync_push(bpy.types.Operator):
description="Pull in any new data from the Published file before Pushing", description="Pull in any new data from the Published file before Pushing",
) )
save: bpy.props.BoolProperty(
name="Save File & Images",
default=True,
description="Save Current File and Images before Push",
)
@classmethod @classmethod
def poll(cls, context: bpy.types.Context) -> bool: def poll(cls, context: bpy.types.Context) -> bool:
if context.mode == 'OBJECT': if context.mode == 'OBJECT':
@ -368,16 +358,15 @@ class ASSETPIPE_OT_sync_push(bpy.types.Operator):
return context.window_manager.invoke_props_dialog(self, width=400) return context.window_manager.invoke_props_dialog(self, width=400)
def draw(self, context: bpy.types.Context): def draw(self, context: bpy.types.Context):
prefs = get_addon_prefs() if not self.pull:
if prefs.is_advanced_mode: col = self.layout.column()
self.layout.prop(self, "pull") col.label(text="Force Pushing without pulling can cause data loss", icon="ERROR")
self.layout.prop(self, "save") col.separator()
sync_draw(self, context) sync_draw(self, context)
def execute(self, context: bpy.types.Context): def execute(self, context: bpy.types.Context):
if self.save: save_images()
save_images() bpy.ops.wm.save_mainfile()
bpy.ops.wm.save_mainfile()
# Find current task Layer # Find current task Layer
sync_execute_update_ownership(self, context) sync_execute_update_ownership(self, context)
@ -466,9 +455,7 @@ class ASSETPIPE_OT_publish_staged_as_active(bpy.types.Operator):
def execute(self, context: bpy.types.Context): def execute(self, context: bpy.types.Context):
current_file = Path(bpy.data.filepath) current_file = Path(bpy.data.filepath)
staged_file = find_latest_publish( staged_file = find_latest_publish(current_file, publish_type=constants.STAGED_PUBLISH_KEY)
current_file, publish_type=constants.STAGED_PUBLISH_KEY
)
# Delete Staged File # Delete Staged File
staged_file.unlink() staged_file.unlink()
catalog_id = context.scene.asset_pipeline.asset_catalog_id catalog_id = context.scene.asset_pipeline.asset_catalog_id
@ -479,9 +466,7 @@ class ASSETPIPE_OT_publish_staged_as_active(bpy.types.Operator):
class ASSETPIPE_OT_reset_ownership(bpy.types.Operator): class ASSETPIPE_OT_reset_ownership(bpy.types.Operator):
bl_idname = "assetpipe.reset_ownership" bl_idname = "assetpipe.reset_ownership"
bl_label = "Reset Ownership" bl_label = "Reset Ownership"
bl_description = ( bl_description = """Reset the Object owner and Transferable Data on selected object(s)"""
"""Reset the Object owner and Transferable Data on selected object(s)"""
)
@classmethod @classmethod
def poll(cls, context: bpy.types.Context) -> bool: def poll(cls, context: bpy.types.Context) -> bool:
@ -510,9 +495,7 @@ class ASSETPIPE_OT_update_local_task_layers(bpy.types.Operator):
@classmethod @classmethod
def poll(cls, context: bpy.types.Context) -> bool: def poll(cls, context: bpy.types.Context) -> bool:
asset_pipe = context.scene.asset_pipeline asset_pipe = context.scene.asset_pipeline
new_local_tl = [ new_local_tl = [tl.name for tl in asset_pipe.all_task_layers if tl.is_local == True]
tl.name for tl in asset_pipe.all_task_layers if tl.is_local == True
]
local_tl = [tl.name for tl in asset_pipe.local_task_layers] local_tl = [tl.name for tl in asset_pipe.local_task_layers]
if new_local_tl == local_tl: if new_local_tl == local_tl:
cls.poll_message_set("Local Task Layers already match current selection") cls.poll_message_set("Local Task Layers already match current selection")
@ -529,9 +512,7 @@ class ASSETPIPE_OT_update_local_task_layers(bpy.types.Operator):
text="Caution, this only affects current file.", text="Caution, this only affects current file.",
icon="ERROR", icon="ERROR",
) )
layout.label( layout.label(text="Two files owning the same task layer can break merge process.")
text="Two files owning the same task layer can break merge process."
)
def execute(self, context: bpy.types.Context): def execute(self, context: bpy.types.Context):
asset_pipe = context.scene.asset_pipeline asset_pipe = context.scene.asset_pipeline
@ -544,9 +525,7 @@ class ASSETPIPE_OT_update_local_task_layers(bpy.types.Operator):
class ASSETPIPE_OT_revert_file(bpy.types.Operator): class ASSETPIPE_OT_revert_file(bpy.types.Operator):
bl_idname = "assetpipe.revert_file" bl_idname = "assetpipe.revert_file"
bl_label = "Revert File" bl_label = "Revert File"
bl_description = ( bl_description = """Revert File to Pre-Sync State. Revert will not affect Published files"""
"""Revert File to Pre-Sync State. Revert will not affect Published files"""
)
_temp_file = "" _temp_file = ""
_source_file = "" _source_file = ""
@ -645,9 +624,7 @@ class ASSETPIPE_OT_update_surrendered_transfer_data(bpy.types.Operator):
bl_label = "Claim Surrendered" bl_label = "Claim Surrendered"
bl_description = """Claim Surrended Transferable Data Owner""" bl_description = """Claim Surrended Transferable Data Owner"""
transfer_data_item_name: bpy.props.StringProperty( transfer_data_item_name: bpy.props.StringProperty(name="Transferable Data Item Name")
name="Transferable Data Item Name"
)
_surrendered_transfer_data = None _surrendered_transfer_data = None
_old_onwer = "" _old_onwer = ""
@ -776,9 +753,7 @@ class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
transfer_data_items_to_update = [] transfer_data_items_to_update = []
if self.data_type == "TRANSFER_DATA": if self.data_type == "TRANSFER_DATA":
for obj in objs: for obj in objs:
filtered_transfer_data = self._filter_by_name( filtered_transfer_data = self._filter_by_name(context, obj.transfer_data_ownership)
context, obj.transfer_data_ownership
)
for transfer_data_item in filtered_transfer_data: for transfer_data_item in filtered_transfer_data:
if self.transfer_data_type != "NONE": if self.transfer_data_type != "NONE":
if transfer_data_item.type == self.transfer_data_type: if transfer_data_item.type == self.transfer_data_type:
@ -790,8 +765,7 @@ class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
return [ return [
item item
for item in transfer_data_items_to_update for item in transfer_data_items_to_update
if item.surrender if item.surrender and item.owner not in asset_pipe.get_local_task_layers()
and item.owner not in asset_pipe.get_local_task_layers()
] ]
if self.filter_owners == "LOCAL": if self.filter_owners == "LOCAL":
@ -801,17 +775,13 @@ class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
if item.owner in asset_pipe.get_local_task_layers() if item.owner in asset_pipe.get_local_task_layers()
] ]
if self.set_surrender: if self.set_surrender:
return [ return [item for item in transfer_data_items_to_update if not item.surrender]
item for item in transfer_data_items_to_update if not item.surrender
]
return transfer_data_items_to_update return transfer_data_items_to_update
def _get_objects(self, context): def _get_objects(self, context):
asset_objs = context.scene.asset_pipeline.asset_collection.all_objects asset_objs = context.scene.asset_pipeline.asset_collection.all_objects
selected_asset_objs = [ selected_asset_objs = [obj for obj in asset_objs if obj in context.selected_objects]
obj for obj in asset_objs if obj in context.selected_objects
]
return asset_objs if self.data_source == "ALL" else selected_asset_objs return asset_objs if self.data_source == "ALL" else selected_asset_objs
def _get_filtered_objects(self, context): def _get_filtered_objects(self, context):
@ -840,11 +810,7 @@ class ASSETPIPE_OT_batch_ownership_change(bpy.types.Operator):
transfer_data_items_to_update = self._get_transfer_data_to_update(context) transfer_data_items_to_update = self._get_transfer_data_to_update(context)
data_type_name = "Transferable Data Item(s)" data_type_name = "Transferable Data Item(s)"
length = ( length = len(transfer_data_items_to_update) if transfer_data_items_to_update else 0
len(transfer_data_items_to_update)
if transfer_data_items_to_update
else 0
)
if self.claim_surrender: if self.claim_surrender:
action = "Claim Surrendered on" action = "Claim Surrendered on"
if self.set_surrender: if self.set_surrender:

View File

@ -59,12 +59,17 @@ class ASSETPIPE_PT_sync(bpy.types.Panel):
staged = is_staged_publish(Path(bpy.data.filepath)) staged = is_staged_publish(Path(bpy.data.filepath))
sync_target_name = "Staged" if staged else "Active" sync_target_name = "Staged" if staged else "Active"
layout.operator("assetpipe.sync_push", text=f"Push to {sync_target_name}", icon="TRIA_UP")
layout.operator( layout.operator(
"assetpipe.sync_pull", "assetpipe.sync_pull",
text=f"Pull from {sync_target_name}", text=f"Pull from {sync_target_name}",
icon="TRIA_DOWN", icon="TRIA_DOWN",
) )
layout.operator(
"assetpipe.sync_push", text=f"Sync from {sync_target_name}", icon="FILE_REFRESH"
).pull = True
layout.operator(
"assetpipe.sync_push", text=f"Force Push to {sync_target_name}", icon="TRIA_UP"
).pull = False
layout.separator() layout.separator()
if staged: if staged: