From 5fc3a2ccc36cdbad47501cf1e23f19e7d7b638b8 Mon Sep 17 00:00:00 2001 From: David Vierra Date: Sat, 28 May 2016 03:39:33 -1000 Subject: [PATCH] Implement mark/unmark chunks for repop --- src/mcedit2/editorsession.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/mcedit2/editorsession.py b/src/mcedit2/editorsession.py index 78551e5..4039a65 100644 --- a/src/mcedit2/editorsession.py +++ b/src/mcedit2/editorsession.py @@ -353,6 +353,8 @@ class EditorSession(QtCore.QObject): self.actionCreateChunks = QtGui.QAction(self.tr("Create Chunks"), self, triggered=self.createChunks) self.actionRepopChunks = QtGui.QAction(self.tr("Mark Chunks For Repopulation"), self, triggered=self.repopChunks) + self.actionRepopChunks = QtGui.QAction(self.tr("Unmark Chunks For Repopulation"), + self, triggered=self.unRepopChunks) self.menuChunk.addAction(self.actionDeleteChunks) self.menuChunk.addAction(self.actionCreateChunks) @@ -852,7 +854,28 @@ class EditorSession(QtCore.QObject): QtGui.QMessageBox.warning(QtGui.qApp.mainWindow, "Not implemented.", "Create chunks is not implemented yet!") def repopChunks(self): - QtGui.QMessageBox.warning(QtGui.qApp.mainWindow, "Not implemented.", "Repop chunks is not implemented yet!") + if self.currentSelection is None: + return + + with self.beginSimpleCommand(self.tr("Mark Chunks For Repop")): + for cx, cz in self.currentSelection.chunkPositions(): + try: + chunk = self.currentDimension.getChunk(cx, cz) + chunk.TerrainPopulated = False + except ChunkNotPresent: + pass + + def unRepopChunks(self): + if self.currentSelection is None: + return + + with self.beginSimpleCommand(self.tr("Unmark Chunks For Repop")): + for cx, cz in self.currentSelection.chunkPositions(): + try: + chunk = self.currentDimension.getChunk(cx, cz) + chunk.TerrainPopulated = True + except ChunkNotPresent: + pass # - Dimensions - @@ -1018,6 +1041,16 @@ class EditorSession(QtCore.QObject): self.pushCommand(command) def pushCommand(self, command): + """ + + Parameters + ---------- + command : QtGui.QUndoCommand + + Returns + ------- + + """ log.info("Pushing command %s" % command.text()) self.undoStack.push(command) self.actionSave.setEnabled(True)