-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path__init__.py
191 lines (141 loc) · 4.93 KB
/
__init__.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
import bpy
from bpy.props import (
BoolProperty,
EnumProperty,
FloatProperty,
StringProperty,
)
from bpy_extras.io_utils import (
ImportHelper,
ExportHelper,
)
bl_info = {
"name": "GTA Animation",
"author": "Psycrow",
"version": (0, 0, 6),
"blender": (2, 81, 0),
"location": "File > Import-Export",
"description": "Import / Export GTA Animation (.ifp)",
"warning": "",
"wiki_url": "",
"support": 'COMMUNITY',
"category": "Import-Export"
}
if "bpy" in locals():
import importlib
if "import_gta_ifp" in locals():
importlib.reload(import_gta_ifp)
if "export_gta_ifp" in locals():
importlib.reload(export_gta_ifp)
class MissingBonesAlert(bpy.types.Operator):
bl_idname = "message.missing_bones"
bl_label = "Missing bones"
message: StringProperty(default='')
def execute(self, context):
self.report({'WARNING'}, 'Missing bones:\n' + self.message)
return {'FINISHED'}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self, width=240)
def draw(self, context):
layout = self.layout
for text in self.message.split('\n'):
if text:
layout.label(text=text, icon='BONE_DATA')
class MissingBoneIds(bpy.types.Operator):
bl_idname = "message.missing_bone_ids"
bl_label = "Missing bone ids"
message: StringProperty(default='')
def execute(self, context):
self.report({'WARNING'}, 'Missing bone ids:\n' + self.message)
return {'FINISHED'}
def invoke(self, context, event):
return context.window_manager.invoke_props_dialog(self, width=240)
def draw(self, context):
layout = self.layout
for text in self.message.split('\n'):
if text:
layout.label(text=text, icon='BONE_DATA')
class IFP_ActionProps(bpy.types.PropertyGroup):
use_export: BoolProperty(name="Use Export", default=True)
def register():
bpy.types.Action.ifp = bpy.props.PointerProperty(type=IFP_ActionProps)
class ImportGtaIfp(bpy.types.Operator, ImportHelper):
bl_idname = "import_scene.gta_ifp"
bl_label = "Import GTA Animation"
bl_options = {'PRESET', 'UNDO'}
filter_glob: StringProperty(default="*.ifp", options={'HIDDEN'})
filename_ext = ".ifp"
fps: FloatProperty(
name="FPS",
description="Value by which the keyframe time is multiplied (GTA 3/VC)",
default=30.0,
)
def execute(self, context):
from . import import_gta_ifp
keywords = self.as_keywords(ignore=("axis_forward",
"axis_up",
"filter_glob",
))
return import_gta_ifp.load(context, **keywords)
class ExportGtaIfp(bpy.types.Operator, ExportHelper):
bl_idname = "export_scene.gta_ifp"
bl_label = "Export GTA Animation"
bl_options = {'PRESET'}
filter_glob: StringProperty(default="*.ifp", options={'HIDDEN'})
filename_ext = ".ifp"
ifp_version: EnumProperty(
name='Version',
description='IFP version',
items={
('ANP3', 'GTA SA', 'IFP version for GTA San Andreas'),
('ANPK', 'GTA 3/VC', 'IFP version for GTA 3 and GTA Vice City')},
default='ANP3',
)
ifp_name: StringProperty(
name="Name",
description="IFP name",
default='Model',
maxlen=23,
)
fps: FloatProperty(
name="FPS",
description="Value by which the keyframe time is divided (GTA 3/VC)",
default=30.0,
)
def draw(self, context):
layout = self.layout
layout.prop(self, "ifp_version")
layout.prop(self, "ifp_name")
layout.prop(self, "fps")
box = layout.box()
box.label(text="Actions")
for act in bpy.data.actions:
box.prop(act.ifp, "use_export", text=act.name)
def execute(self, context):
from . import export_gta_ifp
return export_gta_ifp.save(context, self.filepath, self.ifp_name, self.ifp_version, self.fps)
def menu_func_import(self, context):
self.layout.operator(ImportGtaIfp.bl_idname,
text="GTA Animation (.ifp)")
def menu_func_export(self, context):
self.layout.operator(ExportGtaIfp.bl_idname,
text="GTA Animation (.ifp)")
classes = (
IFP_ActionProps,
ImportGtaIfp,
ExportGtaIfp,
MissingBonesAlert,
MissingBoneIds,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
def unregister():
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
for cls in classes:
bpy.utils.unregister_class(cls)
if __name__ == "__main__":
register()