]> git.tdb.fi Git - libs/gl.git/blobdiff - blender/io_mspgl/operators.py
Check the flat qualifier from the correct member
[libs/gl.git] / blender / io_mspgl / operators.py
index 8d214eacf4d0f83af2ecc740fc60db5c9224ece5..3741358406bad0cbf67ac12f4825220bbc5d9d82 100644 (file)
@@ -19,6 +19,7 @@ class ExportMspGLData(bpy.types.Operator):
        filepath: bpy.props.StringProperty(name="File path", description="File path for exporting the data", subtype='FILE_PATH')
        collection: bpy.props.BoolProperty(name="As a collection", description="Export all data as a single collection file", default=False)
        shared_resources: bpy.props.BoolProperty(name="Shared resources", description="Use global names for resource files to enable sharing", default=True)
+       debug_mode: bpy.props.BoolProperty(name="Debug mode", description="Enable debugging output to console")
 
        @classmethod
        def poll(cls, context):
@@ -34,11 +35,14 @@ class ExportMspGLData(bpy.types.Operator):
                return {'RUNNING_MODAL'}
 
        def execute(self, context):
+               from .context import ExportContext
                from .export import DataExporter
+
+               ex_ctx = ExportContext(context, verbose=self.debug_mode)
                exporter = DataExporter()
-               exporter.collection = self.collection
-               exporter.shared_resources = self.shared_resources
-               exporter.export_to_file(context, self.filepath)
+               ex_ctx.export(exporter.export_to_file, self.filepath,
+                       collection=self.collection,
+                       shared_resources=self.shared_resources)
                return {'FINISHED'}
 
        def draw(self, context):
@@ -47,6 +51,11 @@ class ExportMspGLData(bpy.types.Operator):
                col.prop(self, "collection")
                col.prop(self, "shared_resources")
 
+               self.layout.separator()
+
+               col = self.layout.column()
+               col.prop(self, "debug_mode")
+
 class ExportMspGLAnimation(bpy.types.Operator, ExportHelper):
        bl_idname = "export.mspgl_animation"
        bl_label = "Export Msp GL animation"
@@ -57,6 +66,7 @@ class ExportMspGLAnimation(bpy.types.Operator, ExportHelper):
        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)
        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)
+       debug_mode: bpy.props.BoolProperty(name="Debug mode", description="Enable debugging output to console")
 
        def check(self, context):
                ext_changed = self.set_extension(".mdc" if self.export_all and self.collection else ".anim")
@@ -64,12 +74,15 @@ class ExportMspGLAnimation(bpy.types.Operator, ExportHelper):
                return ext_changed or super_result
 
        def execute(self, context):
+               from .context import ExportContext
                from .export_animation import AnimationExporter
+
+               ex_ctx = ExportContext(context, verbose=self.debug_mode)
                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)
+               ex_ctx.export(exporter.export_to_file, self.filepath,
+                       export_all=self.export_all,
+                       collection=self.collection,
+                       looping_threshold=looping_threshold)
                return {'FINISHED'}
 
        def draw(self, context):
@@ -79,6 +92,11 @@ class ExportMspGLAnimation(bpy.types.Operator, ExportHelper):
                        col.prop(self, "collection")
                col.prop(self, "looping_threshold")
 
+               self.layout.separator()
+
+               col = self.layout.column()
+               col.prop(self, "debug_mode")
+
 class ExportMspGLScene(bpy.types.Operator, ExportHelper):
        bl_idname = "export_scene.mspgl_scene"
        bl_label = "Export Msp GL scene"
@@ -90,6 +108,7 @@ class ExportMspGLScene(bpy.types.Operator, ExportHelper):
        visible_only: bpy.props.BoolProperty(name="Visible only", description="Only export objects in visible collections", default=True)
        collection: bpy.props.BoolProperty(name="As a collection", description="Export the scene and all resources as a single collection file", default=False)
        skip_existing: bpy.props.BoolProperty(name="Skip existing files", description="Skip resources that already exist as files", default=True)
+       debug_mode: bpy.props.BoolProperty(name="Debug mode", description="Enable debugging output to console")
 
        def invoke(self, context, event):
                self.filepath = context.scene.name+".scene"
@@ -101,13 +120,16 @@ class ExportMspGLScene(bpy.types.Operator, ExportHelper):
                return ext_changed or super_result
 
        def execute(self, context):
+               from .context import ExportContext
                from .export_scene import SceneExporter
+
+               ex_ctx = ExportContext(context, verbose=self.debug_mode)
                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)
+               ex_ctx.export(exporter.export_to_file, 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):
@@ -118,12 +140,18 @@ class ExportMspGLScene(bpy.types.Operator, ExportHelper):
                if self.collection:
                        col.prop(self, "skip_existing")
 
+               self.layout.separator()
+
+               col = self.layout.column()
+               col.prop(self, "debug_mode")
+
 class ExportMspGLProject(bpy.types.Operator):
        bl_idname = "export.mspgl_project"
        bl_label = "Export Msp GL project"
        bl_description = "Export the entire project in Msp GL format"
 
        directory: bpy.props.StringProperty(name="Directory", description="Directory for exporting the data", subtype='FILE_PATH')
+       debug_mode: bpy.props.BoolProperty(name="Debug mode", description="Enable debugging output to console")
 
        def invoke(self, context, event):
                blend_filepath = context.blend_data.filepath
@@ -133,11 +161,42 @@ class ExportMspGLProject(bpy.types.Operator):
                return {'RUNNING_MODAL'}
 
        def execute(self, context):
+               from .context import ExportContext
                from .export import ProjectExporter
+
+               ex_ctx = ExportContext(context, verbose=self.debug_mode)
                exporter = ProjectExporter()
-               exporter.export_to_directory(context, self.directory)
+               ex_ctx.export(exporter.export_to_directory, self.directory)
                return {'FINISHED'}
 
+       def draw(self, context):
+               col = self.layout.column()
+               col.prop(self, "debug_mode")
+
+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 +221,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: