Changeset View
Changeset View
Standalone View
Standalone View
release/scripts/startup/bl_operators/image.py
| Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | def invoke(self, context, _event): | ||||
| filepath = bpy.path.abspath(filepath, library=image.library) | filepath = bpy.path.abspath(filepath, library=image.library) | ||||
| self.filepath = os.path.normpath(filepath) | self.filepath = os.path.normpath(filepath) | ||||
| self.execute(context) | self.execute(context) | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| class SaveDirty(Operator): | |||||
| """Save all modified textures""" | |||||
| bl_idname = "image.save_dirty" | |||||
| bl_label = "Save Dirty" | |||||
| bl_options = {'REGISTER', 'UNDO'} | |||||
| def execute(self, _context): | |||||
| unique_paths = set() | |||||
| for image in bpy.data.images: | |||||
| if image.is_dirty: | |||||
| if image.packed_file: | |||||
| if image.library: | |||||
| self.report({'WARNING'}, | |||||
| "Packed library image: %r from library %r" | |||||
| " can't be re-packed" % | |||||
| (image.name, image.library.filepath)) | |||||
| else: | |||||
| image.pack() | |||||
| else: | |||||
| filepath = bpy.path.abspath(image.filepath, | |||||
| library=image.library) | |||||
| if "\\" not in filepath and "/" not in filepath: | |||||
| self.report({'WARNING'}, "Invalid path: " + filepath) | |||||
| elif filepath in unique_paths: | |||||
| self.report({'WARNING'}, | |||||
| "Path used by more than one image: %r" % | |||||
| filepath) | |||||
| else: | |||||
| unique_paths.add(filepath) | |||||
| image.save() | |||||
| return {'FINISHED'} | |||||
| class ProjectEdit(Operator): | class ProjectEdit(Operator): | ||||
| """Edit a snapshot of the view-port in an external image editor""" | """Edit a snapshot of the view-port in an external image editor""" | ||||
| bl_idname = "image.project_edit" | bl_idname = "image.project_edit" | ||||
| bl_label = "Project Edit" | bl_label = "Project Edit" | ||||
| bl_options = {'REGISTER'} | bl_options = {'REGISTER'} | ||||
| _proj_hack = [""] | _proj_hack = [""] | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | def execute(self, _context): | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| classes = ( | classes = ( | ||||
| EditExternally, | EditExternally, | ||||
| ProjectApply, | ProjectApply, | ||||
| ProjectEdit, | ProjectEdit, | ||||
| SaveDirty, | |||||
| ) | ) | ||||