Fix move tool misbehaving on overlapping source/dest areas

- Move tool clears before copying when areas overlap
This commit is contained in:
David Vierra 2016-05-06 15:42:03 -10:00
parent 524ed31b80
commit a84b004253

View File

@ -231,19 +231,31 @@ class MoveTool(EditorTool):
log.info("Move: starting") log.info("Move: starting")
sourceDim, selection = self.currentImport.getSourceForDim(destDim) sourceDim, selection = self.currentImport.getSourceForDim(destDim)
# Copy to destination def _copy():
log.info("Move: copying") # Copy to destination
task = destDim.copyBlocksIter(sourceDim, selection, log.info("Move: copying")
self.currentImport.importPos, task = destDim.copyBlocksIter(sourceDim, selection,
biomes=True, create=True, self.currentImport.importPos,
copyAir=self.copyAirCheckbox.isChecked()) biomes=True, create=True,
copyAir=self.copyAirCheckbox.isChecked())
showProgress(self.tr("Pasting..."), task) showProgress(self.tr("Pasting..."), task)
log.info("Move: clearing") def _clear():
# Clear source log.info("Move: clearing")
if self.currentImport.isMove: # Clear source
fill = destDim.fillBlocksIter(self.currentImport.selection, "air") if self.currentImport.isMove:
showProgress(self.tr("Clearing..."), fill) fill = destDim.fillBlocksIter(self.currentImport.selection, "air")
showProgress(self.tr("Clearing..."), fill)
# XXX PendingImport knows about this, defer copy/clear to it?
if sourceDim is self.currentImport.importDim:
# copying from original source, copy before clear
_copy()
_clear()
else:
# temp schematic used, source and dest overlap, clear before copy
_clear()
_copy()
self.editorSession.pushCommand(command) self.editorSession.pushCommand(command)