Example #1
0
def testCopyRelight(anvilLevel, sourceLevel):
    destDim = anvilLevel.getDimension()
    exhaust(
        destDim.copyBlocksIter(sourceLevel.getDimension(),
                               BoundingBox((0, 0, 0), (
                                   32,
                                   64,
                                   32,
                               )), destDim.bounds.origin))
    anvilLevel.saveChanges()
Example #2
0
def testCopyRelight(pc_world, schematic_world):
    destDim = pc_world.getDimension()
    exhaust(
        destDim.copyBlocksIter(schematic_world.getDimension(),
                               BoundingBox((0, 0, 0), (
                                   32,
                                   64,
                                   32,
                               )), destDim.bounds.origin))
    pc_world.saveChanges()
Example #3
0
def timeFillCeiling():
    temp = bench_temp_level("AnvilWorld")
    editor = temp
    dim = editor.getDimension()
    bounds = dim.bounds
    x, y, z = bounds.center
    y = 254
    x -= size // 2
    z -= size // 2
    bounds = BoundingBox((x, y, z), (size, 1, size))
    exhaust(dim.fillBlocksIter(bounds, editor.blocktypes["planks"]))
Example #4
0
def timeFillCeiling():
    temp = bench_temp_level("AnvilWorld")
    editor = temp
    dim = editor.getDimension()
    bounds = dim.bounds
    x, y, z = bounds.center
    y = 254
    x -= size//2
    z -= size//2
    bounds = BoundingBox((x, y, z), (size, 1, size))
    exhaust(dim.fillBlocksIter(bounds, editor.blocktypes["planks"]))
Example #5
0
    def updateSelection(self):
        if self.dimension is None or self.selection is None:
            return

        selection = self.selection
        self.renderSelection = selection & NonAirMaskSelection(self.dimension, selection)
        self.groupNode.clear()
        self._loader = None
        if selection.chunkCount < 16:
            exhaust(self.loadSections())

            self.loadTimer.setInterval(333)
Example #6
0
    def updateSelection(self):
        if self.dimension is None or self.selection is None:
            return

        selection = self.selection
        self.renderSelection = selection & NonAirMaskSelection(self.dimension, selection)
        self.groupNode.clear()
        self._loader = None
        if selection.chunkCount < 16:
            exhaust(self.loadSections())

            self.loadTimer.setInterval(333)
Example #7
0
 def exportSchematic(self, selection):
     """
     :type selection: mceditlib.box.BoundingBox
     :return:
     :rtype: WorldEditor
     """
     return exhaust(self.exportSchematicIter(selection))
Example #8
0
 def exportSchematic(self, selection):
     """
     :type selection: mceditlib.box.BoundingBox
     :return:
     :rtype: WorldEditor
     """
     return exhaust(self.exportSchematicIter(selection))
Example #9
0
 def copyBlocks(self,
                sourceLevel,
                sourceSelection,
                destinationPoint,
                blocksToCopy=None,
                entities=True,
                create=False,
                biomes=False):
     return exhaust(
         self.copyBlocksIter(sourceLevel, sourceSelection, destinationPoint,
                             blocksToCopy, entities, create, biomes))
Example #10
0
    def displaySchematic(self, schematic, offset):
        if schematic is not None:
            dim = schematic.getDimension()

            if self.worldScene:
                self.sceneHolderNode.removeChild(self.worldScene)
                self.loader.timer.stop()
                self.loader = None

            atlas = self.editorSession.textureAtlas
            self.worldScene = WorldScene(dim, atlas)
            self.sceneTranslate.translateOffset = offset
            self.sceneHolderNode.addChild(self.worldScene)

            self.loader = WorldLoader(self.worldScene)
            if dim.chunkCount() <= self.instantDisplayChunks:
                exhaust(self.loader.work())
            else:
                self.loader.startLoader()
        else:
            self.clearSchematic()
Example #11
0
    def displaySchematic(self, schematic, offset):
        if schematic is not None:
            dim = schematic.getDimension()

            if self.worldScene:
                self.sceneHolderNode.removeChild(self.worldScene)
                self.loader.timer.stop()
                self.loader = None

            atlas = self.editorSession.textureAtlas
            self.worldScene = WorldScene(dim, atlas)
            self.sceneHolderNode.translateOffset = offset
            self.sceneHolderNode.addChild(self.worldScene)

            self.loader = WorldLoader(self.worldScene)
            if dim.chunkCount() <= self.instantDisplayChunks:
                exhaust(self.loader.work())
            else:
                self.loader.timer.start()
        else:
            self.clearSchematic()
Example #12
0
 def copyBlocks(
     self,
     sourceLevel,
     sourceSelection,
     destinationPoint,
     blocksToCopy=None,
     entities=True,
     create=False,
     biomes=False,
     updateLights=False,
 ):
     return exhaust(
         self.copyBlocksIter(
             sourceLevel, sourceSelection, destinationPoint, blocksToCopy, entities, create, biomes, updateLights
         )
     )
Example #13
0
def extractSchematicFrom(sourceDim, box, *a, **kw):
    """
    Extract a schematic from the given dimension within the given selection box. The
    minimum corner of the given box becomes the schematic's (0,0,0) coordinate.

    Parameters
    ----------
    sourceDim : WorldEditorDimension
    box : SelectionBox
    a :
    kw :

    Returns
    -------
    WorldEditor

    """
    return exhaust(extractSchematicFromIter(sourceDim, box, *a, **kw))
Example #14
0
def extractSchematicFrom(sourceDim, box, *a, **kw):
    """
    Extract a schematic from the given dimension within the given selection box. The
    minimum corner of the given box becomes the schematic's (0,0,0) coordinate.

    Parameters
    ----------
    sourceDim : WorldEditorDimension
    box : SelectionBox
    a :
    kw :

    Returns
    -------
    WorldEditor

    """
    return exhaust(extractSchematicFromIter(sourceDim, box, *a, **kw))
Example #15
0
 def copyBlocks(self, *a, **kw):
     return exhaust(self.copyBlocksIter(*a, **kw))
Example #16
0
 def syncToDisk(self):
     exhaust(self.syncToDiskIter())
Example #17
0
 def saveChanges(self):
     exhaust(self.saveChangesIter())
Example #18
0
def showProgress(text, *tasks, **kwargs):
    """
    Show a progress dialog for the given task(s). Each task should be an iterable,
    yielding progress info as (current, max) or (current, max, statusString) tuples.
    Return the last value yielded by the task.

    :param text:
    :type text:
    :param iter:
    :type iter:
    :param cancel:
    :type cancel:
    :return:
    :rtype:
    """
    global _progressBarActive

    if _progressBarActive:
        for task in tasks:
            exhaust(task)
        return

    progress = None
    cancel = kwargs.pop('cancel', None)
    start = time.time()
    shown = False
    try:
        with LoaderTimer.stopCtx():

            dialog = MCEProgressDialog(QtGui.qApp.mainWindow)
            if not cancel:
                dialog.setCancelButtonText(None)
            dialog.setWindowTitle(text)
            dialog.setWindowModality(Qt.WindowModal)
            log.info("Starting progress: %d tasks." % len(tasks))
            totalMaximum = len(tasks) * 100
            for i, task in enumerate(tasks):
                log.info("Task #%d", i)
                task = rescaleProgress(task, i * 100, i * 100 + 100)
                for progress in task:
                    if isinstance(progress, basestring):
                        current = 0
                        maximum = 0
                        status = progress
                    elif isinstance(progress, tuple):
                        if len(progress) > 2:
                            current, maximum, status = progress[:3]
                        else:
                            current, maximum = progress
                            status = ""
                    else:
                        current = 0
                        maximum = 0
                        status = ""

                    dialog.setValue(current)
                    if maximum == 0:
                        # Task progress is indeterminate
                        dialog.setMaximum(0)
                    else:
                        dialog.setMaximum(totalMaximum)
                    dialog.setLabelText(status)
                    if time.time() > start + timeBeforeDialog:
                        if not shown:
                            dialog.show()
                            shown = True
                        QtGui.QApplication.processEvents()

                    if dialog.wasCanceled():
                        return False

            dialog.reset()
            return progress
    finally:
        _progressBarActive = False
Example #19
0
    def loadImmediateChunks(self):
        if self.selection.chunkCount < 16:
            exhaust(self.loadSections())

            self.loadTimer.setInterval(333)
Example #20
0
 def fillBlocks(self, box, block, blocksToReplace=(), updateLights=True):
     return exhaust(
         self.fillBlocksIter(box, block, blocksToReplace, updateLights))
Example #21
0
def timeFill():
    temp = TempLevel("AnvilWorld")
    editor = temp
    dim = editor.getDimension()
    editor.loadedChunkLimit = 1
    exhaust(dim.fillBlocksIter(dim.bounds, editor.blocktypes.OakWoodPlanks))
Example #22
0
 def commitUndo(self, revisionInfo=None):
     exhaust(self.commitUndoIter(revisionInfo))
Example #23
0
 def saveChanges(self):
     exhaust(self.saveChangesIter())
Example #24
0
 def commitUndo(self):
     exhaust(self.commitUndoIter())
Example #25
0
 def createLevel(self, level, box, simulate=False, **kw):
     return exhaust(self.createLevelIter(level, box, simulate, **kw))
Example #26
0
def extractAnySchematic(level, box):
    return exhaust(level.extractAnySchematicIter(box))
Example #27
0
def extractZipSchematicFrom(sourceLevel, box, zipfilename=None, entities=True):
    return exhaust(extractZipSchematicFromIter(sourceLevel, box, zipfilename, entities))
Example #28
0
def extractSchematicFrom(sourceDim, box, entities=True):
    return exhaust(extractSchematicFromIter(sourceDim, box, entities))
Example #29
0
    def loadImmediateChunks(self):
        if self.selection.chunkCount < 16:
            exhaust(self.loadSections())

            self.loadTimer.setInterval(333)
Example #30
0
 def generateChunksInLevel(self, level, chunks):
     return exhaust(self.generateChunksInLevelIter(level, chunks))
Example #31
0
def extractSchematicFrom(sourceDim, box, *a, **kw):
    return exhaust(extractSchematicFromIter(sourceDim, box, *a, **kw))
Example #32
0
 def createLevel(self, level, box, simulate=False, **kw):
     return exhaust(self.createLevelIter(level, box, simulate, **kw))
Example #33
0
 def perform(self):
     if len(self.points) > 10:
         showProgress("Performing brush...", self._perform(), cancel=True)
     else:
         exhaust(self._perform())
Example #34
0
 def generateAtPosition(self, tempWorld, tempDir, cx, cz):
     return exhaust(self.generateAtPositionIter(tempWorld, tempDir, cx, cz))
Example #35
0
def showProgress(text, *tasks, **kwargs):
    """
    Show a progress dialog for the given task(s). Each task should be an iterable,
    yielding progress info as (current, max) or (current, max, statusString) tuples.
    Return the last value yielded by the task.

    :param text:
    :type text:
    :param iter:
    :type iter:
    :param cancel:
    :type cancel:
    :return:
    :rtype:
    """
    global _progressBarActive

    if _progressBarActive:
        for task in tasks:
            exhaust(task)
        return

    progress = None
    cancel = kwargs.pop('cancel', None)
    start = time.time()
    shown = False
    try:
        with LoaderTimer.stopCtx():

            dialog = MCEProgressDialog(QtGui.qApp.mainWindow)
            if not cancel:
                dialog.setCancelButtonText(None)
            dialog.setWindowTitle(text)
            dialog.setWindowModality(Qt.WindowModal)
            log.info("Starting progress: %d tasks." % len(tasks))
            totalMaximum = len(tasks) * 100
            for i, task in enumerate(tasks):
                log.info("Task #%d", i)
                task = rescaleProgress(task, i*100, i*100+100)
                for progress in task:
                    if isinstance(progress, basestring):
                        current = 0
                        maximum = 0
                        status = progress
                    elif isinstance(progress, tuple):
                        if len(progress) > 2:
                            current, maximum, status = progress[:3]
                        else:
                            current, maximum = progress
                            status = ""
                    else:
                        current = 0
                        maximum = 0
                        status = ""

                    dialog.setValue(current)
                    if maximum == 0:
                        # Task progress is indeterminate
                        dialog.setMaximum(0)
                    else:
                        dialog.setMaximum(totalMaximum)
                    dialog.setLabelText(status)
                    if time.time() > start + timeBeforeDialog:
                        if not shown:
                            dialog.show()
                            shown = True
                        QtGui.QApplication.processEvents()

                    if dialog.wasCanceled():
                        return False

            dialog.reset()
            return progress
    finally:
        _progressBarActive = False
Example #36
0
 def commitUndo(self, revisionInfo=None):
     exhaust(self.commitUndoIter(revisionInfo))
Example #37
0
def extractSchematicFrom(sourceDim, box, *a, **kw):
    return exhaust(extractSchematicFromIter(sourceDim, box, *a, **kw))
Example #38
0
def testCopyRelight(anvilLevel, sourceLevel):
    destDim = anvilLevel.getDimension()
    exhaust(destDim.copyBlocksIter(sourceLevel.getDimension(), BoundingBox((0, 0, 0), (32, 64, 32,)),
            destDim.bounds.origin))
    anvilLevel.saveChanges()
Example #39
0
 def generateAtPosition(self, tempWorld, tempDir, cx, cz):
     return exhaust(self.generateAtPositionIter(tempWorld, tempDir, cx, cz))
Example #40
0
 def commitUndo(self):
     exhaust(self.commitUndoIter())
Example #41
0
 def generateChunksInLevel(self, level, chunks):
     return exhaust(self.generateChunksInLevelIter(level, chunks))
Example #42
0
 def perform(self):
     if len(self.points) > 10:
         showProgress("Performing brush...", self._perform(), cancel=True)
     else:
         exhaust(self._perform())
Example #43
0
 def syncToDisk(self):
     exhaust(self.syncToDiskIter())
Example #44
0
def extractSchematicFrom(sourceDim, box, entities=True):
    return exhaust(extractSchematicFromIter(sourceDim, box, entities))
Example #45
0
 def copyBlocks(self, *a, **kw):
     return exhaust(self.copyBlocksIter(*a, **kw))
Example #46
0
def extractZipSchematicFrom(sourceLevel, box, zipfilename=None, entities=True):
    return exhaust(
        extractZipSchematicFromIter(sourceLevel, box, zipfilename, entities))
Example #47
0
 def fillBlocks(self, box, block, blocksToReplace=(), updateLights=True):
     return exhaust(self.fillBlocksIter(box, block, blocksToReplace, updateLights))
Example #48
0
def extractAnySchematic(level, box):
    return exhaust(level.extractAnySchematicIter(box))
Example #49
0
def timeFill():
    temp = bench_temp_level("AnvilWorld")
    editor = temp
    dim = editor.getDimension()
    editor.loadedChunkLimit = 1
    exhaust(dim.fillBlocksIter(dim.bounds, editor.blocktypes.OakWoodPlanks))
Example #50
0
def testCopyRelight(pc_world, schematic_world):
    destDim = pc_world.getDimension()
    exhaust(destDim.copyBlocksIter(schematic_world.getDimension(), BoundingBox((0, 0, 0), (32, 64, 32,)),
            destDim.bounds.origin))
    pc_world.saveChanges()