-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ui.py
309 lines (258 loc) · 11.3 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
from textwrap import TextWrapper
import bpy
from . import __init__, ops, utils
from .addon_updater_ops import get_user_preferences
def label_multiline(
context, text, parent, icon=""
): # Thanks to B3D Interplanetary for this code snippet
chars = int(context.region.width / 7) # 7 pix on 1 character
wrapper = TextWrapper(width=chars)
text_lines = wrapper.wrap(text=text)
for index, text_line in enumerate(text_lines):
if icon and index == 0:
parent.label(text=text_line, icon=icon)
else:
parent.label(text=text_line)
class SAT_PT_mainpanel(bpy.types.Panel): # Main panel that subpanels will use
bl_label = "Source Armature Toolkit"
bl_idname = "SAT_PT_mainpanel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
def draw(self, context):
satproperties = bpy.context.scene.satproperties
satinfo = bpy.context.scene.satinfo
layout = self.layout
col = layout.column()
col.prop(
satproperties, "target_armature"
) # Armature that will be affected by the utilities
if not satproperties.target_armature and not satinfo.creating_armature:
col.operator("sat.create_armature")
if satinfo.creating_armature:
col.prop(satproperties, "game_armature_type")
col.prop(satproperties, "game_armature")
# L4D2 survivors
if (
satproperties.game_armature_type == "PM"
and satproperties.game_armature == "L4D2"
):
col.prop(satproperties, "game_armature_l4d2")
col.operator("sat.create_armature_apply")
if satproperties.game_armature == "SBOX" and satinfo.creating_armature:
if satproperties.game_armature_type == "PM":
col.label(text="These may be prone to changing...")
else:
col.label(text="Not currently available...")
if satinfo.unconverted_armature:
col.operator("sat.convert_armature")
if not satinfo.creating_armature:
if satproperties.target_armature:
if satinfo.scheme == -1:
col.label(text="Type: Unknown Armature")
elif satinfo.viewmodel:
col.label(text="Type: Viewmodel Armature")
elif satinfo.goldsource:
col.label(text="Type: GoldSource Armature")
elif satinfo.titanfall:
col.label(text="Type: Titanfall Armature")
elif satinfo.sbox:
col.label(text="Type: S&Box Armature")
else:
col.label(text="Type: Default Source Armature")
else:
col.label(text="No Armature...")
else:
col.label(text="Select armature in plugin once done")
class SAT_PT_armaturerename(bpy.types.Panel): # Armature rename panel
bl_label = "Armature Renaming"
bl_parent_id = "SAT_PT_mainpanel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "data"
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
satproperties = bpy.context.scene.satproperties
satinfo = bpy.context.scene.satinfo
preferences = get_user_preferences()
layout = self.layout
row = layout.row()
row.operator("sat.armaturerename_blender", text="Convert")
row.operator("sat.armaturerename_source", text="Restore")
if satproperties.target_armature:
col = layout.column()
if satinfo.sbox or satinfo.tf2:
col.label(text="Already Blender friendly...")
elif satinfo.scheme == 0:
col.label(text="Current: Default Scheme")
elif satinfo.scheme == 1:
col.label(text="Current: Blender Friendly Scheme")
if preferences.show_info:
box = layout.box()
label_multiline(
context,
"Meant for weight painting. Allows for weight symmetry. Remember to restore before export",
box,
icon="INFO",
)
class SAT_PT_constraintsymmetry(bpy.types.Panel): # Constraint Symmetry panel
bl_label = "Constraint Symmetry"
bl_parent_id = "SAT_PT_mainpanel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "data"
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
satproperties = bpy.context.scene.satproperties
satinfo = bpy.context.scene.satinfo
preferences = get_user_preferences()
layout = self.layout
row = layout.row()
row.operator("sat.constraintsymmetry_create", text="Add")
row.operator("sat.constraintsymmetry_delete", text="Remove")
row = layout.row()
row.prop(satproperties, "affected_side", expand=True)
col = layout.column()
col.operator(
"sat.constraintsymmetry_apply", text="Apply", icon="OUTLINER_DATA_ARMATURE"
)
if satproperties.target_armature:
if (
satproperties.affected_side == "LTR"
and satinfo.symmetry == 2
or satproperties.affected_side == "RTL"
and satinfo.symmetry == 1
):
col.label(text="Already applied on the opposite side")
if satinfo.tf2:
col.label(text="Incompatible with this armature type")
col = layout.column()
col.prop(satproperties, "symmetry_offset")
col.prop(satproperties, "symmetry_upperarm_rotation_fix")
if preferences.show_info:
box = layout.box()
label_multiline(
context,
"Meant for armature reproportioning. Allows for symmetry while keeping corrected roll values",
box,
icon="INFO",
)
class SAT_PT_weightarmature(bpy.types.Panel): # Weight Armature panel
bl_label = "Weight Armature"
bl_parent_id = "SAT_PT_mainpanel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "data"
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
satinfo = bpy.context.scene.satinfo
preferences = get_user_preferences()
layout = self.layout
row = layout.row()
row.operator("sat.weightarmature_create", text="Generate")
row.operator("sat.weightarmature_delete", text="Delete")
if preferences.show_info:
box = layout.box()
label_multiline(
context,
"Meant for weight creation. Allows more spread out vertex weights, requiring less tweaking overall",
box,
icon="INFO",
)
class SAT_PT_rigifyretarget(bpy.types.Panel): # Rigify Retargetting panel
bl_label = "Rigify Retarget"
bl_idname = "SAT_PT_rigifyretarget"
bl_parent_id = "SAT_PT_mainpanel"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "data"
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
satproperties = bpy.context.scene.satproperties
satinfo = bpy.context.scene.satinfo
preferences = get_user_preferences()
layout = self.layout
if not preferences.enable_rigify_retarget:
col = layout.column()
label_multiline(
context,
"Rigify Retarget is disabled by default due to its buggy nature. You can enable it in the preferences if you really want it.",
col,
icon="CANCEL",
)
return
if not bpy.context.preferences.addons.get("rigify"):
col = layout.column()
col.label(text="Rigify is not installed", icon="CANCEL")
col.label(text="Please enable it in the preferences")
return
row = layout.row()
row.operator("sat.rigifyretarget_create", text="Generate")
row.operator("sat.rigifyretarget_delete", text="Delete")
col = layout.column()
if not satinfo.animation_armature:
col.prop(satproperties, "target_object")
col.label(text="Used to check for facial expressions")
if satproperties.target_armature and satinfo.animation_armature:
if satinfo.animation_armature_setup:
if (
bpy.context.object.name
!= satproperties.target_armature.name + ".anim"
):
col.operator(
"sat.rigifyretarget_generate_and_link",
text="Generate & Link",
icon="OUTLINER_DATA_ARMATURE",
)
if satproperties.target_object:
col.label(
text="Reposition facial drivers correctly", icon="INFO"
)
col.label(text="and edit bone parameters to your need")
else:
col.label(text="Edit bone parameters to your need", icon="INFO")
else:
col.prop(satproperties, "retarget_constraints")
if preferences.show_info:
box = layout.box()
label_multiline(
context,
"Meant for complex animation. Creates animation ready armature. Remember to bake action before export",
box,
icon="INFO",
)
class SAT_PT_rigifyretargetexport(bpy.types.Panel):
bl_label = "Bake/Export"
bl_parent_id = "SAT_PT_rigifyretarget"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "data"
@classmethod
def poll(self, context):
preferences = get_user_preferences()
return preferences.enable_rigify_retarget
def draw(self, context):
layout = self.layout
col = layout.column()
satproperties = bpy.context.scene.satproperties
col.label(text="Action bake:")
row = layout.row()
row.operator("sat.rigifyretarget_bake_single", text="Single", icon="ACTION")
row.operator("sat.rigifyretarget_bake_all", text="All", icon="ACTION")
col = layout.column()
col.prop(satproperties, "bake_helper_bones")
if not satproperties.retarget_constraints:
col.label(text="Retarget constraints are disabled...")
col = layout.column()
# If Blender Source Tools is enabled
if bpy.context.preferences.addons.get("io_scene_valvesource"):
col.label(text="Export: (Only for Source 1)")
col.operator(
"sat.rigifyretarget_export_all", text="Export All", icon="ACTION"
)
if satproperties.retarget_constraints == True:
col = layout.column()
col.label(text="Retarget constraints are enabled...")
else:
col.label(text="Blender Source Tools is not installed", icon="CANCEL")
col.label(text="Please install if you want to use this feature")