3131
3232import bpy
3333import json
34+ from bpy_extras .io_utils import ExportHelper ,ImportHelper
3435
3536from . import fun_script
3637
@@ -343,15 +344,21 @@ def execute(self, context):
343344 scene .frame_set (lastframe )
344345 return {'FINISHED' }
345346
346- class FunscriptExport (bpy .types .Operator ):
347+ class FunscriptExport (bpy .types .Operator , ExportHelper ):
347348 """Export as Funscript file button.
348349
349350 Button that exports all Launch position keyframes in the sequences as
350351 Funscript file.
351352 """
352353 bl_idname = "funscript.export"
353354 bl_label = "Export as Funscript"
354- filepath = bpy .props .StringProperty (subtype = 'FILE_PATH' )
355+
356+ filename_ext = ".funscript"
357+ filter_glob = bpy .props .StringProperty (
358+ default = "*.funscript" ,
359+ options = {'HIDDEN' },
360+ maxlen = 255 ,
361+ )
355362 inverted = bpy .props .BoolProperty (name = "inverted" ,
356363 description = "Flip up and down positions" , default = False )
357364
@@ -369,15 +376,7 @@ def execute(self, context):
369376 json .dump (script , outfile )
370377 return {'FINISHED' }
371378
372- def draw (self ,context ):
373- layout = self .layout
374- layout .prop (self , "inverted" , text = "Inverted" )
375-
376- def invoke (self , context , event ):
377- context .window_manager .fileselect_add (self )
378- return {'RUNNING_MODAL' }
379-
380- class FunscriptImport (bpy .types .Operator ):
379+ class FunscriptImport (bpy .types .Operator , ImportHelper ):
381380 """Import as Funscript file button.
382381
383382 Button that imports Launch position keyframes in the sequences from a
@@ -386,7 +385,13 @@ class FunscriptImport(bpy.types.Operator):
386385 bl_idname = "funscript.import"
387386 bl_label = "Import Funscript on frame"
388387 bl_options = {'REGISTER' , 'UNDO' }
389- filepath = bpy .props .StringProperty (subtype = 'FILE_PATH' )
388+
389+ filename_ext = ".funscript"
390+ filter_glob = bpy .props .StringProperty (
391+ default = "*.funscript" ,
392+ options = {'HIDDEN' },
393+ maxlen = 255 ,
394+ )
390395
391396 def execute (self , context ):
392397 if len (context .selected_sequences ) < 1 :
@@ -401,10 +406,6 @@ def execute(self, context):
401406 fun_script .insert_actions (seq , fs ["actions" ], context .scene .frame_current )
402407 return {'FINISHED' }
403408
404- def invoke (self , context , event ):
405- context .window_manager .fileselect_add (self )
406- return {'RUNNING_MODAL' }
407-
408409class FunscriptSelectionInvert (bpy .types .Operator ):
409410 """Invert the Launch value for selected points.
410411
0 commit comments