]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/__init__.py
Add an option to export all animations for all selected objects
[libs/gl.git] / blender / io_mspgl / __init__.py
index d555ab4b30d54e59f48f5453c2612dfef73ec2ba..f0cb6579266c6ecdf1850676c36689934137eabe 100644 (file)
@@ -96,10 +96,33 @@ class ExportMspGLAnimation(bpy.types.Operator, ExportMspGLBase):
 
        filename_ext = ".anim"
 
 
        filename_ext = ".anim"
 
+       export_all = bpy.props.BoolProperty(name="Export all animations", description="Export all animations present on the selected objects' NLA tracks")
+       collection = bpy.props.BoolProperty(name="As a collection", description="Export the animations as a single collection file", default=True)
+
+       def check(self, context):
+               result = False
+
+               ext = ".mdc" if self.export_all and self.collection else ".anim"
+               ext_changed = (ext!=self.filename_ext)
+               if ext_changed:
+                       if self.filepath.endswith(self.filename_ext):
+                               self.filepath = self.filepath[:-len(self.filename_ext)]
+                       self.filename_ext = ext
+
+               super_result = super().check(context)
+
+               return ext_changed or super_result
+
        def create_exporter(self):
                from .export_animation import AnimationExporter
                return AnimationExporter()
 
        def create_exporter(self):
                from .export_animation import AnimationExporter
                return AnimationExporter()
 
+       def draw(self, context):
+               col = self.layout.column()
+               col.prop(self, "export_all")
+               if self.export_all:
+                       col.prop(self, "collection")
+
 class ExportMspGLScene(bpy.types.Operator, ExportMspGLBase):
        bl_idname = "export_scene.mspgl_scene"
        bl_label = "Export Msp GL scene"
 class ExportMspGLScene(bpy.types.Operator, ExportMspGLBase):
        bl_idname = "export_scene.mspgl_scene"
        bl_label = "Export Msp GL scene"