Asset Pipeline v2 #145
@ -362,8 +362,6 @@ class ASSETPIPE_OT_update_local_task_layers(bpy.types.Operator):
|
||||
bl_label = "Update Local Task Layers"
|
||||
bl_description = """Change the Task Layers that are Local to your file"""
|
||||
|
||||
# box
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context: bpy.types.Context) -> bool:
|
||||
asset_pipe = context.scene.asset_pipeline
|
||||
@ -398,6 +396,24 @@ class ASSETPIPE_OT_update_local_task_layers(bpy.types.Operator):
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class ASSETPIPE_OT_revert_file(bpy.types.Operator):
|
||||
bl_idname = "assetpipe.revert_file"
|
||||
bl_label = "Revert File"
|
||||
bl_description = """Revert File to Pre-Sync State. Revert will not affect Published files"""
|
||||
|
||||
_temp_file = ""
|
||||
_source_file = ""
|
||||
|
||||
def execute(self, context: bpy.types.Context):
|
||||
asset_pipe = context.scene.asset_pipeline
|
||||
self._temp_file = asset_pipe.temp_file
|
||||
self._source_file = asset_pipe.source_file
|
||||
# TODO Add Error Messages if path is empty
|
||||
bpy.ops.wm.open_mainfile(filepath=self._temp_file)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=self._source_file)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
classes = (
|
||||
ASSETPIPE_OT_update_ownership,
|
||||
ASSETPIPE_OT_sync_push,
|
||||
@ -406,6 +422,7 @@ classes = (
|
||||
ASSETPIPE_OT_create_new_asset,
|
||||
ASSETPIPE_OT_reset_ownership,
|
||||
ASSETPIPE_OT_update_local_task_layers,
|
||||
ASSETPIPE_OT_revert_file,
|
||||
)
|
||||
|
||||
|
||||
|
@ -101,6 +101,10 @@ class AssetPipeline(bpy.types.PropertyGroup):
|
||||
items=get_task_layer_presets,
|
||||
)
|
||||
|
||||
temp_file: bpy.props.StringProperty(name="Pre-Sync Backup")
|
||||
source_file: bpy.props.StringProperty(name="File that started Sync")
|
||||
sync_error: bpy.props.BoolProperty(name="Sync Error", default=False)
|
||||
|
||||
all_task_layers: bpy.props.CollectionProperty(type=TaskLayerSettings)
|
||||
local_task_layers: bpy.props.CollectionProperty(type=TaskLayerSettings)
|
||||
|
||||
|
@ -112,11 +112,23 @@ def sync_execute_prepare_sync(self, context):
|
||||
bpy.data.objects.remove(obj)
|
||||
|
||||
|
||||
def sync_execute_pull(self, context):
|
||||
def create_temp_file_backup(self, context):
|
||||
temp_file = self._temp_dir.joinpath(
|
||||
self._current_file.name.replace(".blend", "") + "_Asset_Pipe_Backup.blend"
|
||||
)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=temp_file.__str__(), copy=True)
|
||||
context.scene.asset_pipeline.temp_file = temp_file.__str__()
|
||||
return temp_file.__str__()
|
||||
|
||||
def update_temp_file_paths(self, context, temp_file_path):
|
||||
asset_pipe = context.scene.asset_pipeline
|
||||
asset_pipe.temp_file = temp_file_path
|
||||
asset_pipe.source_file = self._current_file.__str__()
|
||||
|
||||
def sync_execute_pull(self, context):
|
||||
temp_file_path = create_temp_file_backup(self, context)
|
||||
update_temp_file_paths(self, context, temp_file_path)
|
||||
bpy.ops.wm.save_as_mainfile(filepath=temp_file_path, copy=True)
|
||||
|
||||
error_msg = merge_task_layer(
|
||||
context,
|
||||
local_tls=self._task_layer_keys,
|
||||
@ -124,21 +136,25 @@ def sync_execute_pull(self, context):
|
||||
)
|
||||
|
||||
if error_msg:
|
||||
bpy.ops.wm.open_mainfile(filepath=temp_file.__str__())
|
||||
bpy.ops.wm.save_as_mainfile(filepath=self._current_file.__str__())
|
||||
context.scene.asset_pipeline.sync_error = True
|
||||
self.report({'ERROR'}, error_msg)
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
||||
def sync_execute_push(self, context):
|
||||
temp_file_path = create_temp_file_backup(self, context)
|
||||
push_targets = find_all_published(self._current_file, constants.ACTIVE_PUBLISH_KEY)
|
||||
|
||||
if self._sync_target not in push_targets:
|
||||
push_targets.append(self._sync_target)
|
||||
|
||||
|
||||
for file in push_targets:
|
||||
file_path = file.__str__()
|
||||
bpy.ops.wm.open_mainfile(filepath=file_path)
|
||||
|
||||
update_temp_file_paths(self, context, temp_file_path)
|
||||
|
||||
# SKIP DEPRECIATED FILES
|
||||
if context.scene.asset_pipeline.is_depreciated:
|
||||
continue
|
||||
@ -155,7 +171,7 @@ def sync_execute_push(self, context):
|
||||
external_file=self._current_file,
|
||||
)
|
||||
if error_msg:
|
||||
bpy.ops.wm.open_mainfile(filepath=self._current_file.__str__())
|
||||
context.scene.asset_pipeline.sync_error = True
|
||||
self.report({'ERROR'}, error_msg)
|
||||
return {'CANCELLED'}
|
||||
|
||||
|
@ -4,6 +4,7 @@ from pathlib import Path
|
||||
from .merge.transfer_data.transfer_ui import draw_transfer_data
|
||||
from .merge.task_layer import draw_task_layer_selection
|
||||
from .config import verify_json_data
|
||||
from . import constants
|
||||
|
||||
|
||||
class ASSETPIPE_PT_sync(bpy.types.Panel):
|
||||
@ -27,6 +28,15 @@ class ASSETPIPE_PT_sync(bpy.types.Panel):
|
||||
if not Path(bpy.data.filepath).exists:
|
||||
layout.label(text="File is not saved", icon="ERROR")
|
||||
return
|
||||
|
||||
if asset_pipe.sync_error or asset_pipe.asset_collection.name.endswith(
|
||||
constants.LOCAL_SUFFIX
|
||||
):
|
||||
layout.alert = True
|
||||
row = layout.row()
|
||||
row.label(text="Merge Process has Failed", icon='ERROR')
|
||||
row.operator("assetpipe.revert_file", text="Revert", icon="FILE_TICK")
|
||||
return
|
||||
|
||||
# TODO Move this call out of the UI because we keep re-loading this file every draw
|
||||
if not verify_json_data():
|
||||
@ -67,7 +77,9 @@ class ASSETPIPE_PT_sync_advanced(bpy.types.Panel):
|
||||
def draw(self, context: bpy.types.Context) -> None:
|
||||
layout = self.layout
|
||||
box = layout.box()
|
||||
box.operator("assetpipe.reset_ownership")
|
||||
box.operator("assetpipe.reset_ownership", icon="LOOP_BACK")
|
||||
box.operator("assetpipe.revert_file", icon="FILE_TICK")
|
||||
|
||||
|
||||
# Task Layer Updater
|
||||
box = layout.box()
|
||||
|
Loading…
Reference in New Issue
Block a user