]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/operators.py
Replace the instance variables of exporters by function parameters
[libs/gl.git] / blender / io_mspgl / operators.py
index 8d214eacf4d0f83af2ecc740fc60db5c9224ece5..920f025141cde05add6a40631a902b6777de511e 100644 (file)
@@ -36,9 +36,9 @@ class ExportMspGLData(bpy.types.Operator):
        def execute(self, context):
                from .export import DataExporter
                exporter = DataExporter()
-               exporter.collection = self.collection
-               exporter.shared_resources = self.shared_resources
-               exporter.export_to_file(context, self.filepath)
+               exporter.export_to_file(context, self.filepath,
+                       collection=self.collection,
+                       shared_resources=self.shared_resources)
                return {'FINISHED'}
 
        def draw(self, context):
@@ -66,10 +66,10 @@ class ExportMspGLAnimation(bpy.types.Operator, ExportHelper):
        def execute(self, context):
                from .export_animation import AnimationExporter
                exporter = AnimationExporter()
-               exporter.export_all = self.export_all
-               exporter.collection = self.collection
-               exporter.looping_threshold = self.looping_threshold
-               exporter.export_to_file(context, self.filepath)
+               exporter.export_to_file(context, self.filepath,
+                       export_all=self.export_all,
+                       collection=self.collection,
+                       looping_threshold=looping_threshold)
                return {'FINISHED'}
 
        def draw(self, context):
@@ -103,11 +103,11 @@ class ExportMspGLScene(bpy.types.Operator, ExportHelper):
        def execute(self, context):
                from .export_scene import SceneExporter
                exporter = SceneExporter()
-               exporter.selected_only = self.selected_only
-               exporter.visible_only = self.visible_only
-               exporter.collection = self.collection
-               exporter.skip_existing = self.skip_existing
-               exporter.export_to_file(context, self.filepath)
+               exporter.export_to_file(context, self.filepath,
+                       selected_only=self.selected_only,
+                       visible_only=self.visible_only,
+                       collection=self.collection,
+                       skip_existing=self.skip_existing)
                return {'FINISHED'}
 
        def draw(self, context):
@@ -138,6 +138,30 @@ class ExportMspGLProject(bpy.types.Operator):
                exporter.export_to_directory(context, self.directory)
                return {'FINISHED'}
 
+class AddRenderMethod(bpy.types.Operator):
+       bl_idname = "material.add_render_method"
+       bl_label = "Add Render Method"
+       bl_description = "Add a new render method to the material"
+
+       def execute(self, context):
+               mat = context.active_object.active_material
+               mat.render_methods.add()
+               mat.active_render_method_index = len(mat.uniforms)-1
+
+               return {"FINISHED"}
+
+class RemoveRenderMethod(bpy.types.Operator):
+       bl_idname = "material.remove_render_method"
+       bl_label = "Remove Render Method"
+       bl_description = "Remove the selected render method from the material"
+
+       def execute(self, context):
+               mat = context.active_object.active_material
+               mat.render_methods.remove(mat.active_render_method_index)
+               mat.active_render_method_index = min(mat.active_render_method_index, len(mat.render_methods)-1)
+
+               return {"FINISHED"}
+
 class AddUniform(bpy.types.Operator):
        bl_idname = "material.add_uniform"
        bl_label = "Add Uniform"
@@ -162,7 +186,8 @@ class RemoveUniform(bpy.types.Operator):
 
                return {"FINISHED"}
 
-classes = [ExportMspGLData, ExportMspGLAnimation, ExportMspGLScene, ExportMspGLProject, AddUniform, RemoveUniform]
+classes = [ExportMspGLData, ExportMspGLAnimation, ExportMspGLScene, ExportMspGLProject, AddRenderMethod,
+       RemoveRenderMethod, AddUniform, RemoveUniform]
 
 def register_operators():
        for c in classes: