]> git.tdb.fi Git - libs/gl.git/commitdiff
Refactor export extension change into the exporter base class
authorMikko Rasa <tdb@tdb.fi>
Fri, 26 Jun 2020 23:07:02 +0000 (02:07 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 27 Jun 2020 09:02:16 +0000 (12:02 +0300)
blender/io_mspgl/__init__.py

index bb13c48873f2cf28008b2886a7a4ba6b79ce95ea..a1869e3ecd74ee7ca2efb5e8c79477483c0c44b4 100644 (file)
@@ -18,6 +18,14 @@ from bpy_extras.io_utils import ExportHelper
 class ExportMspGLBase(ExportHelper):
        show_progress = bpy.props.BoolProperty(name="Show progress", description="Display progress indicator while exporting", default=True)
 
+       def set_extension(self, ext):
+               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
+               return ext_changed
+
        def execute(self, context):
                exporter = self.create_exporter()
                self.prepare_exporter(exporter)
@@ -102,17 +110,8 @@ class ExportMspGLAnimation(bpy.types.Operator, ExportMspGLBase):
        looping_threshold = bpy.props.FloatProperty(name="Looping threshold", description="Tolerance for curve beginning and end values for looping", min=0.0, soft_max=1.0, precision=4, default=0.001)
 
        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
-
+               ext_changed = self.set_extension(".mdc" if self.export_all and self.collection else ".anim")
                super_result = super().check(context)
-
                return ext_changed or super_result
 
        def create_exporter(self):