Organise Code and fixes.
- Organised some of the code better. - Fixed sort order loop. - Added typing in some places there wasn't. This is a very basic start to Viesme creation, I still need to add translations for some stuff and improve it. This is very much inspired from the Cats Version.
This commit is contained in:
+20
-15
@@ -11,22 +11,27 @@ class AvatarToolkitVisemePanel(bpy.types.Panel):
|
||||
bl_category = "Avatar Toolkit"
|
||||
bl_parent_id = "OBJECT_PT_avatar_toolkit"
|
||||
|
||||
def draw(self, context):
|
||||
def draw(self, context: bpy.types.Context) -> None:
|
||||
layout = self.layout
|
||||
mesh = context.active_object
|
||||
|
||||
# Check if there's an active object and it's a mesh
|
||||
if context.active_object and context.active_object.type == 'MESH':
|
||||
mesh = context.active_object
|
||||
|
||||
# Check if the mesh has shape keys
|
||||
if mesh.data.shape_keys:
|
||||
layout.prop_search(context.scene, "mouth_a", mesh.data.shape_keys, "key_blocks", text=t('Scene.mouth_a.label'))
|
||||
layout.prop_search(context.scene, "mouth_o", mesh.data.shape_keys, "key_blocks", text=t('Scene.mouth_o.label'))
|
||||
layout.prop_search(context.scene, "mouth_ch", mesh.data.shape_keys, "key_blocks", text=t('Scene.mouth_ch.label'))
|
||||
|
||||
if not mesh or mesh.type != 'MESH':
|
||||
layout.prop(context.scene, 'shape_intensity')
|
||||
|
||||
layout.operator("avatar_toolkit.create_visemes", icon='TRIA_RIGHT')
|
||||
else:
|
||||
layout.label(text=t('VisemePanel.error.noShapekeys'), icon='ERROR')
|
||||
else:
|
||||
layout.label(text=t('VisemePanel.error.noMesh'), icon='ERROR')
|
||||
return
|
||||
|
||||
if not mesh.data.shape_keys:
|
||||
layout.label(text=t('VisemePanel.error.noShapekeys'), icon='ERROR')
|
||||
return
|
||||
|
||||
layout.prop_search(context.scene, "mouth_a", mesh.data.shape_keys, "key_blocks", text=t('Scene.mouth_a.label'))
|
||||
layout.prop_search(context.scene, "mouth_o", mesh.data.shape_keys, "key_blocks", text=t('Scene.mouth_o.label'))
|
||||
layout.prop_search(context.scene, "mouth_ch", mesh.data.shape_keys, "key_blocks", text=t('Scene.mouth_ch.label'))
|
||||
|
||||
layout.prop(context.scene, 'shape_intensity')
|
||||
|
||||
layout.operator("avatar_toolkit.create_visemes", icon='TRIA_RIGHT')
|
||||
# Always show some information or options
|
||||
layout.separator()
|
||||
layout.label(text=t('VisemePanel.info.selectMesh'))
|
||||
|
||||
Reference in New Issue
Block a user