Pose Library: better support for legacy pose libraries
Rename "old-style pose library" to "legacy pose library" for consistency with other code, and add pose library conversion operator for use in the "Pose Library (Legacy)" Armature properties panel.
This commit is contained in:
parent
8bc8400155
commit
baa581415c
|
@ -435,7 +435,7 @@ class POSELIB_OT_apply_pose_asset_for_keymap(Operator):
|
|||
|
||||
class POSELIB_OT_convert_old_poselib(Operator):
|
||||
bl_idname = "poselib.convert_old_poselib"
|
||||
bl_label = "Convert Old-Style Pose Library"
|
||||
bl_label = "Convert Legacy Pose Library"
|
||||
bl_description = "Create a pose asset for each pose marker in the current action"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
|
@ -446,7 +446,7 @@ class POSELIB_OT_convert_old_poselib(Operator):
|
|||
cls.poll_message_set("Active object has no Action")
|
||||
return False
|
||||
if not action.pose_markers:
|
||||
cls.poll_message_set("Action %r is not a old-style pose library" % action.name)
|
||||
cls.poll_message_set("Action %r is not a legacy pose library" % action.name)
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -464,11 +464,46 @@ class POSELIB_OT_convert_old_poselib(Operator):
|
|||
return {'FINISHED'}
|
||||
|
||||
|
||||
class POSELIB_OT_convert_old_object_poselib(Operator):
|
||||
bl_idname = "poselib.convert_old_object_poselib"
|
||||
bl_label = "Convert Legacy Pose Library"
|
||||
bl_description = "Create a pose asset for each pose marker in this legacy pose library data-block"
|
||||
|
||||
# Mark this one as "internal", as it converts `context.object.pose_library`
|
||||
# instead of its current animation Action.
|
||||
bl_options = {"REGISTER", "UNDO", "INTERNAL"}
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context: Context) -> bool:
|
||||
action = context.object and context.object.pose_library
|
||||
if not action:
|
||||
cls.poll_message_set("Active object has no pose library Action")
|
||||
return False
|
||||
if not action.pose_markers:
|
||||
cls.poll_message_set("Action %r is not a legacy pose library" % action.name)
|
||||
return False
|
||||
return True
|
||||
|
||||
def execute(self, context: Context) -> Set[str]:
|
||||
from . import conversion
|
||||
|
||||
old_poselib = context.object.pose_library
|
||||
new_actions = conversion.convert_old_poselib(old_poselib)
|
||||
|
||||
if not new_actions:
|
||||
self.report({'ERROR'}, "Unable to convert to pose assets")
|
||||
return {'CANCELLED'}
|
||||
|
||||
self.report({'INFO'}, "Converted %d poses to pose assets" % len(new_actions))
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
classes = (
|
||||
ASSET_OT_assign_action,
|
||||
POSELIB_OT_apply_pose_asset_for_keymap,
|
||||
POSELIB_OT_blend_pose_asset_for_keymap,
|
||||
POSELIB_OT_convert_old_poselib,
|
||||
POSELIB_OT_convert_old_object_poselib,
|
||||
POSELIB_OT_copy_as_asset,
|
||||
POSELIB_OT_create_pose_asset,
|
||||
POSELIB_OT_paste_asset,
|
||||
|
|
Loading…
Reference in New Issue