Add progress bar to structure export
This commit is contained in:
parent
cb8d6e16ce
commit
e00a3b2a38
@ -1007,22 +1007,28 @@ class EditorSession(QtCore.QObject):
|
|||||||
self.tr("Structure Block Files") + " (*.nbt)")
|
self.tr("Structure Block Files") + " (*.nbt)")
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
filename = result[0]
|
def _export():
|
||||||
if filename:
|
filename = result[0]
|
||||||
if sx > 1 or sy > 1 or sz > 1:
|
if filename:
|
||||||
dirname = os.path.dirname(filename)
|
if sx > 1 or sy > 1 or sz > 1:
|
||||||
basename = os.path.join(dirname, os.path.splitext(os.path.basename(filename))[0])
|
total = sx * sy * sz
|
||||||
for tx in range(sx):
|
dirname = os.path.dirname(filename)
|
||||||
for ty in range(sy):
|
basename = os.path.join(dirname, os.path.splitext(os.path.basename(filename))[0])
|
||||||
for tz in range(sz):
|
for tx in range(sx):
|
||||||
tilename = "%s_%s_%s_%s.nbt" % (basename, tx, ty, tz)
|
for ty in range(sy):
|
||||||
origin = self.currentSelection.origin
|
for tz in range(sz):
|
||||||
origin += (tx * 32, ty * 32, tz * 32)
|
tilename = "%s_%s_%s_%s.nbt" % (basename, tx, ty, tz)
|
||||||
box = BoundingBox(origin, (32, 32, 32))
|
origin = self.currentSelection.origin
|
||||||
tileSelection = box.intersect(self.currentSelection)
|
origin += (tx * 32, ty * 32, tz * 32)
|
||||||
exportStructure(tilename, self.currentDimension, tileSelection, author, excludedBlocks)
|
box = BoundingBox(origin, (32, 32, 32))
|
||||||
else:
|
tileSelection = box.intersect(self.currentSelection)
|
||||||
exportStructure(filename, self.currentDimension, self.currentSelection, author, excludedBlocks)
|
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 ---
|
# --- Drag-and-drop ---
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user