forked from scaredyfish/blender-rhubarb-lipsync
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathui.py
80 lines (62 loc) · 2.71 KB
/
ui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import bpy
from .core import find_target_and_refresh_properties, initilize_mouth_values
class RHUBARB_PT_Main_Panel(bpy.types.Panel):
"""Panel to control options of rhubarb operator"""
bl_idname = "RHUBARB_PT_Main_Panel"
bl_space_type = "VIEW_3D"
bl_region_type = "UI"
bl_category = "Rhubarb Lipsync"
bl_label = "Rhubarb 2D Lipsync"
# Pointer definitions
bpy.types.Scene.obj_selection = bpy.props.PointerProperty(type=bpy.types.Object)
bpy.types.Scene.bone_selection = bpy.props.StringProperty()
def draw(self, context):
# Panel Definitions
rhubarb = context.window_manager.rhubarb_panel_settings
layout = self.layout
target_col = layout.column()
mode_row = target_col.row(align=True)
mode_row.prop(rhubarb, "obj_modes", text="Target Type", toggle=True)
obj = find_target_and_refresh_properties(context)
if not obj:
return
# if obj is Armature select a bone to target
if rhubarb.obj_modes == "bone" and context.active_object.type == "ARMATURE":
target_col.prop_search(
context.scene, "bone_selection", obj.id_data.pose, "bones", text="Bone"
)
# Load and Select Properties
if not rhubarb.obj_modes == "":
target_col.prop(
rhubarb,
"presets",
text="Properties",
)
# User editable Mouth Definitions
initilize_mouth_values(rhubarb)
prop_col = layout.column()
prop_col.prop(rhubarb, "mouth_a", text="Mouth A (MBP)")
prop_col.prop(rhubarb, "mouth_b", text="Mouth B (EE/etc)")
prop_col.prop(rhubarb, "mouth_c", text="Mouth C (E)")
prop_col.prop(rhubarb, "mouth_d", text="Mouth D (AI)")
prop_col.prop(rhubarb, "mouth_e", text="Mouth E (O)")
prop_col.prop(rhubarb, "mouth_f", text="Mouth F (WQ)")
prop_col.prop(rhubarb, "mouth_g", text="Mouth G (FV)")
prop_col.prop(rhubarb, "mouth_h", text="Mouth H (L)")
prop_col.prop(rhubarb, "mouth_x", text="Mouth X (rest)")
# Set Rhubarb Executable depencies
set_col = layout.column()
set_col.separator()
set_col.prop(rhubarb, "sound_file", text="Sound file")
set_col.prop(rhubarb, "dialog_file", text="Dialog file")
set_col.prop(rhubarb, "start_frame", text="Start frame")
# Button to execute rhubarb operation
set_col.separator()
set_col.operator(operator="rhubarb.execute_rhubarb_lipsync")
classes = (RHUBARB_PT_Main_Panel,)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)