Пример #1
0
 def deleteBlocks(self):
     command = SimpleRevisionCommand(self, "Delete Blocks")
     with command.begin():
         fillTask = self.currentDimension.fillBlocksIter(
             self.currentSelection, "air")
         showProgress("Deleting...", fillTask)
     self.pushCommand(command)
Пример #2
0
 def deleteEntities(self):
     command = SimpleRevisionCommand(self, "Delete Entities")
     with command.begin():
         entitiesTask = RemoveEntitiesOperation(self.currentDimension,
                                                self.currentSelection)
         showProgress("Deleting...", entitiesTask)
     self.pushCommand(command)
Пример #3
0
    def removeEntity(self):
        if self.entity is None:
            return

        command = SimpleRevisionCommand(self.editorSession, "Remove Entity")
        with command.begin():
            self.entity.chunk.Entities.remove(self.entity)
Пример #4
0
 def deleteSelection(self):
     command = SimpleRevisionCommand(self, "Delete")
     with command.begin():
         fillTask = self.currentDimension.fillBlocksIter(self.currentSelection, "air")
         entitiesTask = RemoveEntitiesOperation(self.currentDimension, self.currentSelection)
         task = ComposeOperations(fillTask, entitiesTask)
         showProgress("Deleting...", task)
     self.pushCommand(command)
Пример #5
0
 def cut(self):
     command = SimpleRevisionCommand(self, "Cut")
     with command.begin():
         task = self.currentDimension.exportSchematicIter(self.currentSelection)
         self.copiedSchematic = showProgress("Cutting...", task)
         task = self.currentDimension.fillBlocksIter(self.currentSelection, "air")
         showProgress("Cutting...", task)
     self.undoStack.push(command)
Пример #6
0
 def doReplace(self):
     replacements = self.getReplacements()
     command = SimpleRevisionCommand(self.editorSession, "Replace")
     selection = self.editorSession.currentDimension.bounds
     # selection = self.editorSession.currentSelection
     with command.begin():
         task = self.editorSession.currentDimension.fillBlocksIter(selection, replacements, updateLights=False)
         showProgress("Replacing...", task)
     self.editorSession.pushCommand(command)
Пример #7
0
def replaceCommand(editorSession):
    dialog = ReplaceDialog(editorSession)
    if dialog.exec_():
        replacements = dialog.getReplacements()
        command = SimpleRevisionCommand(editorSession, "Replace")
        with command.begin():
            task = editorSession.currentDimension.fillBlocksIter(editorSession.currentSelection, replacements)
            showProgress("Replacing...", task)
        editorSession.pushCommand(command)
Пример #8
0
    def deleteChunks(self):
        if self.currentSelection is None:
            return

        command = SimpleRevisionCommand(self, self.tr("Delete Chunks"))
        with command.begin():
            for cx in range(self.currentSelection.mincx, self.currentSelection.maxcx):
                for cz in range(self.currentSelection.mincz, self.currentSelection.maxcz):
                    self.currentDimension.deleteChunk(cx, cz)
        self.pushCommand(command)
Пример #9
0
 def doReplace(self):
     replacements = self.widget.replacementList.getReplacements()
     command = SimpleRevisionCommand(self.editorSession, "Replace")
     if self.widget.replaceBlocksInSelectionCheckbox.isChecked():
         selection = self.editorSession.currentSelection
     else:
         selection = self.editorSession.currentDimension.bounds
     with command.begin():
         task = self.editorSession.currentDimension.fillBlocksIter(
             selection, replacements)
         showProgress("Replacing...", task)
     self.editorSession.pushCommand(command)
Пример #10
0
 def showDialog(self):
     dialog = SimpleOptionsDialog(self.displayName, self.options,
                                  self.editorSession)
     result = dialog.exec_()
     if result == QtGui.QDialog.Accepted:
         command = SimpleRevisionCommand(self.editorSession,
                                         self.displayName)
         with self.editorSession.beginCommand(command):
             result = self.perform(self.editorSession.currentDimension,
                                   self.editorSession.currentSelection,
                                   dialog.getOptions())
         if result is not None:
             self.editorSession.placeSchematic(result,
                                               name=self.displayName)
Пример #11
0
    def movePlayerToCamera(self):
        view = self.editorSession.editorTab.currentView()
        if view.viewID == "Cam":
            command = SimpleRevisionCommand(self.editorSession, "Move Player")
            with command.begin():
                self.selectedPlayer.Position = view.centerPoint
                try:
                    self.selectedPlayer.Rotation = view.yawPitch
                except AttributeError:
                    pass

                self.selectedPlayer.dirty = True  # xxx do in AnvilPlayerRef
            self.editorSession.pushCommand(command)
        else:
            raise ValueError("Current view is not camera view.")
Пример #12
0
def fillCommand(editorSession):
    """

    :type editorSession: mcedit2.editorsession.EditorSession
    """
    box = editorSession.currentSelection
    if box is None or box.volume == 0:
        return

    widget = getFillWidget(editorSession)
    if widget.exec_():
        command = SimpleRevisionCommand(editorSession, "Fill")
        with command.begin():
            task = editorSession.currentDimension.fillBlocksIter(box, widget.blockTypeInput.block)
            showProgress("Filling...", task)
        editorSession.pushCommand(command)