-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathproperties.py
150 lines (126 loc) · 4.63 KB
/
properties.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
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import bpy
from bpy.types import PropertyGroup, AddonPreferences
from bpy.props import *
from .functions import *
class AT_Properties(PropertyGroup):
initialize: BoolProperty(
name="Initialize",
default=False
)
bone_category: EnumProperty(
name="Category",
items=bone_category_enum,
description='Select the template category of the current mapping'
)
templates: EnumProperty(
name="Template",
description='Select the template for the bone mapping',
items=template_list_enum,
update=update_templates
)
mapping_category: BoolProperty(
name="Mapping Category",
description='Show the mapping category of the current template',
default=False
)
bone_mapping: EnumProperty(
name="Bone Mapping",
description='Select the bone mapping of the template',
items=bone_mapping_enum,
update=update_apply_bone_mapping
)
ui_switching: BoolProperty(
default=False
)
active_temp_item_list: IntProperty(
name='Active item in the list',
min=0, soft_min=0, max=100000, soft_max=10000, default=0
)
active_temp_category_list: IntProperty(
name='Active item in the list',
min=0, soft_min=0, max=100000, soft_max=10000, default=0
)
for i in range(32):
exec((
f"armature_layer_{str(i)}: "
f"BoolProperty(name='Armature Layer {str(i)}', "
"update=update_armature_layers, "
"default=False)"
))
@property
def prefs(self):
return bpy.context.preferences.addons[__package__].preferences
class AT_Preferences(AddonPreferences):
bl_idname = __package__
experimental: BoolProperty(
name="Experimental Features",
description='Turn on/off access to experimental features',
default=False
)
def draw(self, context):
layout = self.layout
layout.prop(self, 'experimental')
class Search_Bones(PropertyGroup):
name: bpy.props.StringProperty(name="Source Name")
bone: bpy.props.StringProperty(
name="Target Bone",
update=update_mapping_list
)
category: bpy.props.StringProperty(name="Category")
class Bone_names_coll(PropertyGroup):
name: StringProperty(name="Bone Name")
class Item_List_Collection(PropertyGroup):
name: StringProperty(name="Item")
flag: BoolProperty(name="Flag", default=True)
index: IntProperty(name="List Index")
class Armature_settings_coll(PropertyGroup):
name: StringProperty(name="Name")
template: StringProperty(name="Template")
mapping: StringProperty(name="Mapping")
bone_list: StringProperty(name="Bone List")
mapping_data: StringProperty(name="Mapping Data")
classes = (
AT_Properties,
AT_Preferences,
Search_Bones,
Bone_names_coll,
Item_List_Collection,
Armature_settings_coll,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
wm = bpy.types.WindowManager
wm.armature_templates_props = PointerProperty(type=AT_Properties)
wm.at_search_list_props = CollectionProperty(type=Search_Bones)
wm.at_bone_data_search_list = CollectionProperty(type=Bone_names_coll)
wm.at_template_item_list = CollectionProperty(type=Item_List_Collection)
wm.at_template_category_list = CollectionProperty(type=Item_List_Collection)
armature = bpy.types.Armature
armature.armtemp_settings = PointerProperty(type=Armature_settings_coll)
def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
del bpy.types.WindowManager.armature_templates_props
del bpy.types.WindowManager.at_search_list_props
del bpy.types.WindowManager.at_bone_data_search_list
del bpy.types.WindowManager.at_template_item_list
del bpy.types.WindowManager.at_template_category_list
del bpy.types.Armature.armtemp_settings