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,9 +1007,11 @@ class EditorSession(QtCore.QObject):
self.tr("Structure Block Files") + " (*.nbt)") self.tr("Structure Block Files") + " (*.nbt)")
if result: if result:
def _export():
filename = result[0] filename = result[0]
if filename: if filename:
if sx > 1 or sy > 1 or sz > 1: if sx > 1 or sy > 1 or sz > 1:
total = sx * sy * sz
dirname = os.path.dirname(filename) dirname = os.path.dirname(filename)
basename = os.path.join(dirname, os.path.splitext(os.path.basename(filename))[0]) basename = os.path.join(dirname, os.path.splitext(os.path.basename(filename))[0])
for tx in range(sx): for tx in range(sx):
@ -1021,8 +1023,12 @@ class EditorSession(QtCore.QObject):
box = BoundingBox(origin, (32, 32, 32)) box = BoundingBox(origin, (32, 32, 32))
tileSelection = box.intersect(self.currentSelection) tileSelection = box.intersect(self.currentSelection)
exportStructure(tilename, self.currentDimension, tileSelection, author, excludedBlocks) exportStructure(tilename, self.currentDimension, tileSelection, author, excludedBlocks)
yield tx * sy * sz + ty * sz + tz, total, os.path.basename(tilename)
else: else:
exportStructure(filename, self.currentDimension, self.currentSelection, author, excludedBlocks) 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 --- # --- Drag-and-drop ---