From daf729eedb02b210c5aa9bdb1a5b63e438b9c0a5 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Tue, 8 Sep 2015 10:45:04 -1000 Subject: [PATCH] Copy-paste no longer clears previous selection. --- src/mcedit2/editorsession.py | 3 ++- src/mcedit2/editortools/move.py | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/mcedit2/editorsession.py b/src/mcedit2/editorsession.py index 3609e20..7401fe5 100644 --- a/src/mcedit2/editorsession.py +++ b/src/mcedit2/editorsession.py @@ -60,11 +60,12 @@ currentViewSetting = sessionSettings.getOption("currentview", unicode, "cam") # chunks into its viewports. class PendingImport(object): - def __init__(self, sourceDim, pos, selection, text): + def __init__(self, sourceDim, pos, selection, text, isMove=False): self.selection = selection self.text = text self.pos = pos self.sourceDim = sourceDim + self.isMove = isMove def __repr__(self): return "%s(%r, %r, %r)" % (self.__class__.__name__, self.sourceDim, self.selection, self.pos) diff --git a/src/mcedit2/editortools/move.py b/src/mcedit2/editortools/move.py index 54fc2fd..5bf3593 100644 --- a/src/mcedit2/editortools/move.py +++ b/src/mcedit2/editortools/move.py @@ -341,7 +341,8 @@ class MoveTool(EditorTool): # blocks will be moved. pos = self.editorSession.currentSelection.origin pendingImport = PendingImport(self.editorSession.currentDimension, pos, - self.editorSession.currentSelection, self.tr("")) + self.editorSession.currentSelection, self.tr(""), + isMove=True) moveCommand = MoveSelectionCommand(self, pendingImport) self.editorSession.pushCommand(moveCommand) @@ -360,13 +361,18 @@ class MoveTool(EditorTool): with command.begin(): # TODO don't use intermediate schematic... - export = self.currentImport.sourceDim.exportSchematicIter(self.currentImport.selection) - schematic = showProgress("Copying...", export) + if self.currentImport.isMove: + export = self.currentImport.sourceDim.exportSchematicIter(self.currentImport.selection) + schematic = showProgress("Copying...", export) + dim = schematic.getDimension() + fill = self.editorSession.currentDimension.fillBlocksIter(self.currentImport.selection, "air") + showProgress("Clearing...", fill) + else: + dim = self.currentImport.sourceDim - fill = self.editorSession.currentDimension.fillBlocksIter(self.editorSession.currentSelection, "air") - showProgress("Clearing...", fill) - - task = self.editorSession.currentDimension.importSchematicIter(schematic, self.currentImport.pos) + task = self.editorSession.currentDimension.copyBlocksIter(dim, dim.bounds, + self.currentImport.pos, + biomes=True, create=True) showProgress(self.tr("Pasting..."), task) self.editorSession.pushCommand(command)