Add progress bar to structure export

This commit is contained in:
David Vierra 2016-05-30 16:04:19 -10:00
parent cb8d6e16ce
commit e00a3b2a38

View File

@ -1007,22 +1007,28 @@ class EditorSession(QtCore.QObject):
self.tr("Structure Block Files") + " (*.nbt)")
if result:
filename = result[0]
if filename:
if sx > 1 or sy > 1 or sz > 1:
dirname = os.path.dirname(filename)
basename = os.path.join(dirname, os.path.splitext(os.path.basename(filename))[0])
for tx in range(sx):
for ty in range(sy):
for tz in range(sz):
tilename = "%s_%s_%s_%s.nbt" % (basename, tx, ty, tz)
origin = self.currentSelection.origin
origin += (tx * 32, ty * 32, tz * 32)
box = BoundingBox(origin, (32, 32, 32))
tileSelection = box.intersect(self.currentSelection)
exportStructure(tilename, self.currentDimension, tileSelection, author, excludedBlocks)
else:
exportStructure(filename, self.currentDimension, self.currentSelection, author, excludedBlocks)
def _export():
filename = result[0]
if filename:
if sx > 1 or sy > 1 or sz > 1:
total = sx * sy * sz
dirname = os.path.dirname(filename)
basename = os.path.join(dirname, os.path.splitext(os.path.basename(filename))[0])
for tx in range(sx):
for ty in range(sy):
for tz in range(sz):
tilename = "%s_%s_%s_%s.nbt" % (basename, tx, ty, tz)
origin = self.currentSelection.origin
origin += (tx * 32, ty * 32, tz * 32)
box = BoundingBox(origin, (32, 32, 32))
tileSelection = box.intersect(self.currentSelection)
exportStructure(tilename, self.currentDimension, tileSelection, author, excludedBlocks)
yield tx * sy * sz + ty * sz + tz, total, os.path.basename(tilename)
else:
exportStructure(filename, self.currentDimension, self.currentSelection, author, excludedBlocks)
yield 1, 1, os.path.basename(filename)
showProgress(self.tr("Exporting structure blocks..."), _export())
# --- Drag-and-drop ---