diff --git a/gui/col_ot.py b/gui/col_ot.py index b525c25..b964d31 100644 --- a/gui/col_ot.py +++ b/gui/col_ot.py @@ -67,6 +67,9 @@ def draw(self, context): ####################################################### def execute(self, context): + if self.only_selected and not context.selected_objects: + self.report({"WARNING"}, "No objects selected for 'Only Selected' export") + return {'CANCELLED'} col_exporter.export_col( { diff --git a/gui/dff_ot.py b/gui/dff_ot.py index e6019f6..a1f054a 100644 --- a/gui/dff_ot.py +++ b/gui/dff_ot.py @@ -168,6 +168,9 @@ def get_selected_rw_version(self): ####################################################### def execute(self, context): + if self.only_selected and not context.selected_objects: + self.report({"WARNING"}, "No objects selected for 'Only Selected' export") + return {'CANCELLED'} if self.export_version == "custom": if not self.verify_rw_version(): @@ -706,17 +709,28 @@ class EXPORT_OT_txd(bpy.types.Operator, ExportHelper): default = True ) + only_selected : bpy.props.BoolProperty( + name = "Only Selected", + description = "Export only textures used by selected objects", + default = False + ) + ####################################################### def draw(self, context): layout = self.layout layout.prop(self, "mass_export") layout.prop(self, "only_used_textures") + layout.prop(self, "only_selected") return None ####################################################### def execute(self, context): + if self.only_selected and not context.selected_objects: + self.report({"WARNING"}, "No objects selected for 'Only Selected' export") + return {'CANCELLED'} + start = time.time() try: from ..ops import txd_exporter @@ -726,6 +740,7 @@ def execute(self, context): "directory" : self.directory, "mass_export" : self.mass_export, "only_used_textures" : self.only_used_textures, + "only_selected" : self.only_selected, "version" : 0x36003, # TODO: more versions support } ) diff --git a/gui/map_ot.py b/gui/map_ot.py index 96a0f44..1524078 100644 --- a/gui/map_ot.py +++ b/gui/map_ot.py @@ -230,6 +230,9 @@ def draw(self, context): ####################################################### def execute(self, context): + if self.only_selected and not context.selected_objects: + self.report({"WARNING"}, "No objects selected for 'Only Selected' export") + return {'CANCELLED'} start = time.time() try: diff --git a/ops/txd_exporter.py b/ops/txd_exporter.py index 999e9a2..c3f31c4 100644 --- a/ops/txd_exporter.py +++ b/ops/txd_exporter.py @@ -29,6 +29,7 @@ class txd_exporter: mass_export = False only_used_textures = True + only_selected = False version = None file_name = "" path = "" @@ -121,6 +122,9 @@ def populate_textures(objects_to_scan=None): if objects_to_scan is not None: # Mass export mode: only export textures used by specific objects used_textures = self.get_used_textures(objects_to_scan) + elif self.only_selected: + # Single export with "only selected" option + used_textures = self.get_used_textures(bpy.context.selected_objects) elif self.only_used_textures: # Single export with "only used textures" option used_textures = self.get_used_textures() @@ -208,6 +212,7 @@ def export_txd(options): txd_exporter.mass_export = options.get('mass_export', False) txd_exporter.only_used_textures = options.get('only_used_textures', True) + txd_exporter.only_selected = options.get('only_selected', False) txd_exporter.version = options.get('version', 0x36003) txd_exporter.path = options['directory']