Blender Kitsu: Set Custom Thumbnail during Playblast #77

Merged
Nick Alberelli merged 12 commits from feature/custom-playblast-thumbnails into main 2023-06-15 21:26:54 +02:00
Showing only changes of commit 9822252c22 - Show all commits

View File

@ -69,7 +69,12 @@ class KITSU_OT_playblast_create(bpy.types.Operator):
use_user_shading: bpy.props.BoolProperty(
name="Use Current Viewport Shading", default=True
)
frame_number: bpy.props.IntProperty(name="Thumbnail Frame")
thumbnail_frame: bpy.props.IntProperty(
name="Thumbnail Frame",
description="Frame to use as the thumbnail on Kitsu",
min=0,
)
thumbnail_frame_final: bpy.props.IntProperty(name="Thumbnail Frame Final")
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
@ -87,6 +92,19 @@ class KITSU_OT_playblast_create(bpy.types.Operator):
self.report({"ERROR"}, "Failed to create playblast. Missing task status")
return {"CANCELLED"}
# Playblast file always starts at frame 0, account for this in thumbnail frame selection
self.thumbnail_frame_final = self.thumbnail_frame - context.scene.frame_start
# Ensure thumbnail frame is not outside of rendered frame range
if self.thumbnail_frame_final not in range(
0, context.scene.frame_start - context.scene.frame_end
):
self.report(
{"ERROR"},
f"Thumbnail frame '{self.thumbnail_frame}' is outside of rendered frame range ",
)
return {"CANCELLED"}
shot_active = cache.shot_active_get()
# Save playblast task status id for next time.
@ -199,7 +217,7 @@ class KITSU_OT_playblast_create(bpy.types.Operator):
def invoke(self, context, event):
# Initialize comment and playblast task status variable.
self.comment = ""
self.frame_number = context.scene.frame_current
self.thumbnail_frame = context.scene.frame_current
prev_task_status_id = context.scene.kitsu.playblast_task_status_id
if prev_task_status_id:
@ -220,7 +238,7 @@ class KITSU_OT_playblast_create(bpy.types.Operator):
row.prop(self, "comment")
row = layout.row(align=True)
row.prop(self, "use_user_shading")
row.prop(self, "frame_number")
row.prop(self, "thumbnail_frame")
def _upload_playblast(self, context: bpy.types.Context, filepath: Path) -> None:
# Get shot.
@ -251,11 +269,10 @@ class KITSU_OT_playblast_create(bpy.types.Operator):
)
# Add_preview_to_comment
# Playblast file always starts at frame 0, account for this in thumbnail frame selection
task.add_preview_to_comment(
comment,
filepath.as_posix(),
frame_number=self.frame_number - context.scene.frame_start,
self.thumbnail_frame_final,
)
# Preview.set_main_preview()