Unify calls to armature and pose library
This commit is contained in:
63
gui.py
63
gui.py
@ -20,7 +20,8 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
||||
# Detect Armature object and parent
|
||||
armature_layout = dspl_panel_layout.column(align=True)
|
||||
active_obj = context.active_object
|
||||
arm_object = getArmatureObject(context)
|
||||
arm_object, pose_library = getArmatureData(context)
|
||||
pose_library_action = getArmatureAction(context)
|
||||
|
||||
if arm_object:
|
||||
if arm_object == active_obj:
|
||||
@ -29,44 +30,32 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
||||
armature_layout.label(text=arm_object.name + " (Parent)")
|
||||
|
||||
# Attach or create pose library
|
||||
pose_library_dspl = getDsplAction(context)
|
||||
pose_library_action = getArmatureAction(context)
|
||||
pose_library_legacy = getLegacyPoseLibrary(context)
|
||||
|
||||
if pose_library_dspl or pose_library_action or pose_library_legacy:
|
||||
if pose_library_dspl and not pose_library_action:
|
||||
active_pose_library = pose_library_dspl
|
||||
if pose_library or pose_library_action:
|
||||
if pose_library and not pose_library_action:
|
||||
armature_layout.template_ID(
|
||||
arm_object, "pose_library", new="dspl.create_pose_library", unlink="dspl.unlink_pose_library")
|
||||
|
||||
elif pose_library_legacy and not pose_library_dspl:
|
||||
active_pose_library = pose_library_legacy
|
||||
armature_layout.template_ID(
|
||||
arm_object, "pose_library", new="dspl.create_pose_library", unlink="dspl.unlink_pose_library")
|
||||
|
||||
elif pose_library_action and not pose_library_dspl:
|
||||
active_pose_library = pose_library_action
|
||||
elif pose_library_action and not pose_library:
|
||||
armature_layout.template_ID(
|
||||
arm_object.animation_data, "action", new="dspl.create_pose_library")
|
||||
armature_layout.label(
|
||||
text="Legacy Pose Library detected.")
|
||||
text="Pose Library detected as Action")
|
||||
armature_layout.label(
|
||||
text="You may convert to avoid problems")
|
||||
text="You should convert to avoid problems")
|
||||
armature_layout.operator(
|
||||
"dspl.convert_pose_library", icon='PLUGIN', text="Convert to DSPL")
|
||||
"dspl.convert_pose_library", icon='PLUGIN', text="Convert to Pose Library")
|
||||
|
||||
elif pose_library_action and pose_library_dspl:
|
||||
elif pose_library and pose_library_action:
|
||||
armature_layout.template_ID(
|
||||
arm_object, "pose_library", new="dspl.create_pose_library")
|
||||
armature_layout.label(text="Double pose configuration!!")
|
||||
armature_layout.label(text="You should not proceed")
|
||||
armature_layout.label(text="Pose Library is opened as Action")
|
||||
armature_layout.label(text="Keyframes will affect pose")
|
||||
armature_layout.operator(
|
||||
"dspl.convert_pose_library", icon='PLUGIN', text="Convert to DSPL")
|
||||
active_pose_library = pose_library_dspl
|
||||
"dspl.convert_pose_library", icon='PLUGIN', text="Unlink from Action")
|
||||
|
||||
|
||||
# List poses in pose library
|
||||
if active_pose_library:
|
||||
if pose_library:
|
||||
pose_box_layout = dspl_panel_layout.column()
|
||||
|
||||
# Menu switcher
|
||||
@ -78,14 +67,14 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
||||
quick_pose_controls_layout = pose_box_layout.column()
|
||||
quick_pose_controls_layout.menu(
|
||||
OBJECT_MT_AddPoseMenu.bl_idname, icon='ADD', text="New Pose")
|
||||
if active_pose_library.pose_markers.active:
|
||||
if pose_library.pose_markers.active:
|
||||
quick_apply_layout = quick_pose_controls_layout.split(
|
||||
align=True)
|
||||
quick_apply_layout.operator(
|
||||
"dspl.browse_poses", icon='CON_ARMATURE', text="Browse")
|
||||
if dsplsettings.new_menu == False:
|
||||
quick_apply_layout.operator(
|
||||
"dspl.apply_pose", icon='ARMATURE_DATA', text="Apply Pose").posename = active_pose_library.pose_markers.active.name
|
||||
"dspl.apply_pose", icon='ARMATURE_DATA', text="Apply Pose").posename = pose_library.pose_markers.active.name
|
||||
else:
|
||||
quick_apply_layout.prop(dsplsettings,
|
||||
"edit_mode", icon='GREASEPENCIL', text="Edit", toggle=True)
|
||||
@ -94,11 +83,11 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
||||
if dsplsettings.new_menu == True:
|
||||
pose_button_layout = pose_box_layout.row()
|
||||
pose_button_entries_layout = pose_button_layout.column(align=True)
|
||||
for pm in active_pose_library.pose_markers:
|
||||
for pm in pose_library.pose_markers:
|
||||
row = pose_button_entries_layout.row(align=True)
|
||||
|
||||
# Selected indicator
|
||||
selected = pm.frame == active_pose_library.pose_markers.active.frame
|
||||
selected = pm.frame == pose_library.pose_markers.active.frame
|
||||
if dsplsettings.edit_mode == False:
|
||||
row.label(text="", icon='PMARKER_ACT' if selected else 'PMARKER_SEL')
|
||||
|
||||
@ -125,19 +114,19 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
||||
# Pose list
|
||||
pose_list_entries_layout = pose_list_layout.row()
|
||||
pose_list_entries_layout.template_list("UI_UL_list","pose_markers",
|
||||
active_pose_library, "pose_markers",
|
||||
active_pose_library.pose_markers, "active_index", rows=4)
|
||||
pose_library, "pose_markers",
|
||||
pose_library.pose_markers, "active_index", rows=4)
|
||||
|
||||
# Pose operators
|
||||
pose_ops_layout = pose_list_entries_layout.column(align=True)
|
||||
pose_ops_layout.operator(
|
||||
"wm.call_menu", icon='ADD', text="").name = "OBJECT_MT_AddPoseMenu"
|
||||
if active_pose_library.pose_markers.active:
|
||||
if pose_library.pose_markers.active:
|
||||
pose_ops_layout.operator(
|
||||
"dspl.remove_pose", icon='REMOVE', text="")
|
||||
pose_ops_layout.operator(
|
||||
"dspl.apply_pose", icon='ARMATURE_DATA', text=""
|
||||
).posename = active_pose_library.pose_markers.active.name
|
||||
).posename = pose_library.pose_markers.active.name
|
||||
pose_ops_layout.operator(
|
||||
"dspl.move_pose", icon='TRIA_UP', text="").direction = "UP"
|
||||
pose_ops_layout.operator(
|
||||
@ -158,13 +147,12 @@ class OBJECT_MT_AddPoseMenu(bpy.types.Menu):
|
||||
bl_label = "Add Pose"
|
||||
|
||||
def draw(self, context):
|
||||
arm_object = getArmatureObject(context)
|
||||
action_object = getPoseLib(context)
|
||||
arm_object, pose_library = getArmatureData(context)
|
||||
|
||||
dspl_add_menu_layout = self.layout
|
||||
dspl_add_menu_layout.operator(
|
||||
"dspl.add_pose", icon='ADD', text="Add New Pose")
|
||||
if len(action_object.pose_markers):
|
||||
if len(pose_library.pose_markers):
|
||||
dspl_add_menu_layout.menu(
|
||||
"OBJECT_MT_ReplacePoseMenu", text="Replace Existing Pose", icon="DECORATE_OVERRIDE")
|
||||
|
||||
@ -174,11 +162,10 @@ class OBJECT_MT_ReplacePoseMenu(bpy.types.Menu):
|
||||
bl_label = "Add Pose"
|
||||
|
||||
def draw(self, context):
|
||||
arm_object = getArmatureObject(context)
|
||||
action_object = getPoseLib(context)
|
||||
arm_object, pose_library = getArmatureData(context)
|
||||
|
||||
dspl_replace_menu_layout = self.layout
|
||||
for pm in action_object.pose_markers:
|
||||
for pm in pose_library.pose_markers:
|
||||
op = dspl_replace_menu_layout.operator("dspl.add_pose", text=pm.name, icon="PMARKER")
|
||||
op.replace = True
|
||||
op.posename = pm.name
|
||||
|
Reference in New Issue
Block a user