Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gui/col_ot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down
15 changes: 15 additions & 0 deletions gui/dff_ot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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
Expand All @@ -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
}
)
Expand Down
3 changes: 3 additions & 0 deletions gui/map_ot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions ops/txd_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class txd_exporter:

mass_export = False
only_used_textures = True
only_selected = False
version = None
file_name = ""
path = ""
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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']
Expand Down