Skip to content

Commit

Permalink
display_popup() call no longer required in 4.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
p2or committed Jul 10, 2024
1 parent efc2df2 commit 9f9a1d4
Showing 1 changed file with 22 additions and 19 deletions.
41 changes: 22 additions & 19 deletions loom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2175,7 +2175,7 @@ def display_popup(self, context):
bpy.ops.loom.batch_render_dialog('INVOKE_DEFAULT')

def cancel(self, context):
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)

def invoke(self, context, event):
self.cursor_pos = [event.mouse_x, event.mouse_y]
Expand Down Expand Up @@ -2221,7 +2221,7 @@ def execute(self, context):
self.report({'INFO'}, "Nothing selected")

lum.batch_render_idx = len(lum.batch_render_coll)-1
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)
return {'FINISHED'}


Expand Down Expand Up @@ -2275,7 +2275,7 @@ def execute(self, context):

blend_files = self.blend_files(self.directory, self.sub_folders)
if next(blend_files, None) is None:
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)
self.report({'WARNING'},"No blend files found in {}".format(self.directory))
return {'CANCELLED'}

Expand Down Expand Up @@ -2304,11 +2304,11 @@ def execute(self, context):
self.report({'WARNING'}, "Skipped {}, invalid .blend file(s)".format(", ".join(invalid_files)))

lum.batch_render_idx = len(lum.batch_render_coll)-1
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)
return {'FINISHED'}

def cancel(self, context):
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)

def invoke(self, context, event):
self.cursor_pos = [event.mouse_x, event.mouse_y]
Expand Down Expand Up @@ -3139,12 +3139,12 @@ def execute(self, context):

if not os.path.isfile(self.filepath):
self.report({'WARNING'},"Please select one image of an image sequence")
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)
return {"CANCELLED"}

if not frame_suff:
self.report({'WARNING'},"No valid image sequence")
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)
return {"CANCELLED"}

sequence_name = filename.replace(frame_suff,'#'*len(frame_suff))
Expand Down Expand Up @@ -3201,11 +3201,11 @@ def execute(self, context):
lum.sequence_rename = name_real
lum.sequence_encode = sequence_path

self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)
return {'FINISHED'}

def cancel(self, context):
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)

def invoke(self, context, event):
s = context.scene.loom.sequence_encode
Expand Down Expand Up @@ -3258,11 +3258,11 @@ def execute(self, context):
lum.movie_path = os.path.join(folder, "{}{}.mov".format(filename,ext))
else:
lum.movie_path = self.filepath #self.report({'WARNING'},"No valid file type")
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)
return {'FINISHED'}

def cancel(self, context):
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)

def invoke(self, context, event):
self.filename = self.name_from_sequence(context)
Expand Down Expand Up @@ -5182,7 +5182,7 @@ def display_popup(self, context):
bpy.ops.loom.set_project_dialog('INVOKE_DEFAULT')

def cancel(self, context):
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)

def invoke(self, context, event):
self.cursor_pos = [event.mouse_x, event.mouse_y]
Expand All @@ -5193,7 +5193,7 @@ def execute(self, context):
scn = context.scene
lum = scn.loom
lum.project_directory = os.path.dirname(self.filepath)
self.display_popup(context)
if bpy.app.version < (4, 1, 0): self.display_popup(context)
return {'FINISHED'}


Expand All @@ -5202,9 +5202,9 @@ class LOOM_OT_project_dialog(bpy.types.Operator):
bl_idname = "loom.set_project_dialog"
bl_label = "Setup Project Directory"
bl_options = {'REGISTER'}

directory: bpy.props.StringProperty(name="Project Directory")

directory: bpy.props.StringProperty(name="Project Directory")

@classmethod
def poll(cls, context):
return True
Expand All @@ -5218,7 +5218,11 @@ def execute(self, context):
bpy.ops.wm.save_as_mainfile('INVOKE_DEFAULT')
return {'CANCELLED'}

if not self.directory or not os.path.isdir(self.directory):
project_dir = lum.project_directory
if not self.options.is_invoke:
project_dir = self.directory

if not project_dir or not os.path.isdir(project_dir):
self.report({'ERROR'}, "Please specify a valid Project Directory")
bpy.ops.loom.set_project_dialog('INVOKE_DEFAULT')
return {'CANCELLED'}
Expand All @@ -5227,7 +5231,7 @@ def execute(self, context):
prefs = context.preferences.addons[__name__].preferences
for d in prefs.project_directory_coll:
if d.creation_flag and d.name:
pdir = os.path.join(self.directory, d.name)
pdir = os.path.join(project_dir, d.name)
bpy.ops.loom.create_directory(directory=pdir)
if not os.path.isdir(bpy.path.abspath(pdir)):
errors.append(d.name)
Expand All @@ -5251,7 +5255,6 @@ def invoke(self, context, event):
lum = context.scene.loom
if not context.scene.loom.project_directory:
lum.project_directory = bpy.path.abspath('//')
self.directory = lum.project_directory
return context.window_manager.invoke_props_dialog(self, width=prefs.project_dialog_width)

def check(self, context):
Expand All @@ -5278,7 +5281,7 @@ def draw(self, context):
col.operator(LOOM_OT_directories_ui.bl_idname, icon='REMOVE', text="").action = 'REMOVE'
layout.separator()
row = layout.row(align=True)
row.prop(self, "directory")
row.prop(lum, "project_directory")
row.operator(LOOM_OT_select_project_directory.bl_idname, icon='FILE_FOLDER', text="")
layout.separator()

Expand Down

0 comments on commit 9f9a1d4

Please sign in to comment.