Blender Kitsu: Add Frame Range Pop-up #128

Merged
Nick Alberelli merged 18 commits from :fix/frame-range-popup into main 2023-07-19 17:32:39 +02:00
Showing only changes of commit 0afa39fc5a - Show all commits

View File

@ -255,3 +255,83 @@ def playblast_user_shading_settings(self, context, file_path):
# Make opengl render. # Make opengl render.
bpy.ops.render.opengl(animation=True) bpy.ops.render.opengl(animation=True)
return output_path return output_path
def draw_frame_range_failed_context(self, context):
layout = self.layout
layout.alert = True
layout.label(text="Kitsu Context could not be detected from current file")
def draw_frame_range_warning(self, context):
active_shot = cache.shot_active_get()
layout = self.layout
layout.alert = True
layout.label(
text="Frame Range on server does not match the active shot. Please 'pull' the correct frame range from the server"
)
layout.label(
text=f" File Frame Range: {context.scene.frame_start}-{context.scene.frame_end}"
)
layout.label(
text=f' Server Frame Range: {int(active_shot.data["3d_start"])}-{int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1}'
)
layout.operator("kitsu.pull_frame_range", icon='TRIA_DOWN')
def set_frame_range_in(frame_in: int):
shot = cache.shot_active_pull_update()
shot.data["3d_start"] = frame_in
shot.update()
return shot
def get_frame_range():
active_shot = cache.shot_active_get()
if not active_shot:
logger.warning("Active Shot was not found on server.")
bpy.context.window_manager.popup_menu(
draw_frame_range_failed_context,
title="Warning: Kitsu Context Failed.",
icon='ERROR',
)
return
# Pull update for shot.
cache.shot_active_pull_update()
if "3d_start" not in active_shot.data:
logger.warning(
"Failed to check frame range. Shot %s missing '3d_start' attribute on server",
active_shot.name,
)
return
frame_in = int(active_shot.data["3d_start"])
frame_out = int(active_shot.data["3d_start"]) + int(active_shot.nb_frames) - 1
return frame_in, frame_out
def check_frame_range():
"""
Compare the current scene's frame range with that of the active shot on kitsu.
If there's a mismatch, set kitsu_error.frame_range -> True. This will enable
a warning in the Animation Tools Tab UI.
"""
frame_in, frame_out = get_frame_range()
frame_range_correct = bpy.context.scene.kitsu_error.frame_range
if (
frame_in == bpy.context.scene.frame_start
and frame_out == bpy.context.scene.frame_end
):
frame_range_correct = True
return frame_range_correct
bpy.context.window_manager.popup_menu(
draw_frame_range_warning,
title="Warning: Frame Range Error.",
icon='ERROR',
)
frame_range_correct = False
logger.warning("Current frame range is outdated!")
return frame_range_correct