本文整理汇总了Python中mcedit2.util.showprogress.showProgress函数的典型用法代码示例。如果您正苦于以下问题:Python showProgress函数的具体用法?Python showProgress怎么用?Python showProgress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showProgress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirmImport
def confirmImport(self):
if self.currentImport is None:
return
command = MoveFinishCommand(self, self.currentImport)
destDim = self.editorSession.currentDimension
with command.begin():
log.info("Move: starting")
sourceDim, selection = self.currentImport.getSourceForDim(destDim)
# Copy to destination
log.info("Move: copying")
task = destDim.copyBlocksIter(sourceDim, selection,
self.currentImport.importPos,
biomes=True, create=True,
copyAir=self.copyAirCheckbox.isChecked())
showProgress(self.tr("Pasting..."), task)
log.info("Move: clearing")
# Clear source
if self.currentImport.isMove:
fill = destDim.fillBlocksIter(self.currentImport.selection, "air")
showProgress(self.tr("Clearing..."), fill)
self.editorSession.pushCommand(command)
示例2: applyToSelections
def applyToSelections(self, command, selections):
"""
:type command: BrushCommand
"""
fill = command.editorSession.currentDimension.fillBlocksIter(selections[0], command.options['blockInfo'])
showProgress("Applying brush...", fill)
示例3: generateClicked
def generateClicked(self):
if self.currentGenerator is None:
return
if self.schematicBounds is None:
log.info("schematicBounds is None, not generating")
return
if self.currentSchematic is None:
log.info("Generating new schematic for import")
currentSchematic = self.currentGenerator.generate(self.schematicBounds, self.editorSession.worldEditor.blocktypes)
else:
log.info("Importing previously generated schematic.")
currentSchematic = self.currentSchematic
command = GenerateCommand(self, self.schematicBounds)
try:
with command.begin():
if currentSchematic is not None:
task = self.editorSession.currentDimension.importSchematicIter(currentSchematic, self.schematicBounds.origin)
showProgress(self.tr("Importing generated object..."), task)
else:
task = self.currentGenerator.generateInWorld(self.schematicBounds, self.editorSession.currentDimension)
showProgress(self.tr("Generating object in world..."), task)
except Exception as e:
log.exception("Error while importing or generating in world: %r" % e)
command.undo()
else:
self.editorSession.pushCommand(command)
示例4: replaceEntries
def replaceEntries(self, entries):
shouldReplaceName = self.widget.replaceNameCheckbox.isChecked()
newName = self.widget.replaceNameField.text()
shouldReplaceValue = self.widget.replaceValueCheckbox.isChecked()
newValue = self.widget.replaceValueField.text()
# newTagType = self.widget.replaceTagTypeComboBox.currentIndex()
def _replaceInTag(result, tag):
for component in result.path:
tag = tag[component]
if shouldReplaceName:
subtag = tag.pop(result.tagName)
tag[newName] = subtag
result.setTagName(newName)
if shouldReplaceValue:
subtag = tag[result.tagName]
# xxx newTagType
if subtag.tagID in (nbt.ID_BYTE, nbt.ID_SHORT, nbt.ID_INT, nbt.ID_LONG):
try:
value = int(newValue)
except ValueError:
log.warn("Could not assign value %s to tag %s (could not convert to int)", newValue, subtag)
return
elif subtag.tagID in (nbt.ID_FLOAT, nbt.ID_DOUBLE):
try:
value = float(newValue)
except ValueError:
log.warn("Could not assign value %s to tag %s (could not convert to float)", newValue, subtag)
return
else:
value = newValue
subtag.value = value
def _replace():
for result in entries:
if result.resultType == result.TileEntityResult:
tileEntity = self.editorSession.currentDimension.getTileEntity(result.position)
if tileEntity:
tag = tileEntity.raw_tag()
_replaceInTag(result, tag)
tileEntity.dirty()
if result.resultType == result.EntityResult:
entity = result.getEntity(self.editorSession.currentDimension) # xxx put dimension in result!!!!
if entity:
tag = entity.raw_tag()
_replaceInTag(result, tag)
entity.dirty()
# if result.resultType == result.ItemResult: # xxx
yield
command = NBTReplaceCommand(self.editorSession, "Replace NBT data") # xxx replace details
with command.begin():
replacer = _replace()
showProgress("Replacing NBT data...", replacer)
self.editorSession.pushCommand(command)
示例5: begin
def begin(self):
self.previousRevision = self.editorSession.currentRevision
self.editorSession.beginUndo()
yield
task = self.editorSession.commitUndoIter()
showProgress(QtGui.qApp.tr("Writing undo history"), task)
self.currentRevision = self.editorSession.currentRevision
示例6: cut
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)
示例7: deleteSelection
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)
示例8: _copy
def _copy():
# Copy to destination
log.info("Move: copying")
task = destDim.copyBlocksIter(sourceDim, selection,
self.currentImport.importPos,
biomes=True, create=True,
copyAir=self.copyAirCheckbox.isChecked())
showProgress(self.tr("Pasting..."), task)
示例9: doReplace
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)
示例10: analyze
def analyze(self):
if self.currentSelection is None:
return
task = self.currentDimension.analyzeIter(self.currentSelection)
showProgress("Analyzing...", task)
outputDialog = AnalyzeOutputDialog(self, task.blocks,
task.entityCounts,
task.tileEntityCounts,
task.dimension.worldEditor.displayName)
示例11: redo
def redo(self):
if not self.performed:
self.editorSession.beginUndo()
self.perform()
task = self.editorSession.commitUndoIter()
showProgress(QtGui.qApp.tr("Writing undo history"), task)
else:
self.editorSession.undoForward()
示例12: doReplace
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, updateLights=False)
showProgress("Replacing...", task)
self.editorSession.pushCommand(command)
示例13: confirmImport
def confirmImport(self):
if self.currentImport is None:
return
command = MoveFinishCommand(self, self.currentImport)
with command.begin():
task = self.editorSession.currentDimension.importSchematicIter(self.currentImport.schematic, self.currentImport.pos)
showProgress(self.tr("Pasting..."), task)
self.editorSession.pushCommand(command)
示例14: replaceEntries
def replaceEntries(self, entries):
shouldReplaceName = nbtReplaceSettings.replaceNameEnabled.value()
newName = nbtReplaceSettings.replaceNameField.value()
shouldReplaceValue = nbtReplaceSettings.replaceValueEnabled.value()
newValue = nbtReplaceSettings.replaceValueField.value()
# newTagType = self.replaceTagTypeComboBox.currentIndex()
def _replaceInTag(result, tag):
for component in result.path:
tag = tag[component]
if shouldReplaceName:
subtag = tag.pop(result.tagName)
tag[newName] = subtag
result.setTagName(newName)
if shouldReplaceValue:
subtag = tag[result.tagName]
# xxx newTagType
if subtag.tagID in (nbt.ID_BYTE, nbt.ID_SHORT, nbt.ID_INT, nbt.ID_LONG):
try:
value = int(newValue)
except ValueError:
log.warn("Could not assign value %s to tag %s (could not convert to int)", newValue, subtag)
return
elif subtag.tagID in (nbt.ID_FLOAT, nbt.ID_DOUBLE):
try:
value = float(newValue)
except ValueError:
log.warn("Could not assign value %s to tag %s (could not convert to float)", newValue, subtag)
return
else:
value = newValue
subtag.value = value
result.value = value
def _replace():
for result in entries:
ref = result.getTargetRef()
tag = result.getTargetTag()
_replaceInTag(result, tag)
ref.dirty = True
yield
with self.editorSession.beginSimpleCommand(self.tr("Replace NBT data")):
showProgress("Replacing NBT data...", _replace())
示例15: generate
def generate(self, bounds, blocktypes):
# self.systemsBox.value()
schematic = createSchematic(bounds.size, blocktypes)
dim = schematic.getDimension()
system = koch.Snowflake(dim.bounds, blocktype=self.blocktypeButton.block)
symbol_list = [system]
max_iterations = self.iterationsSlider.value()
def process(_symbol_list):
for iteration, _symbol_list in applyReplacementsIterated(_symbol_list, max_iterations):
yield iteration, max_iterations
yield _symbol_list
symbol_list = showProgress("Generating...", process(symbol_list), cancel=True)
if symbol_list is False:
return
import pprint
pprint.pprint(symbol_list)
rendering = renderBlocks(symbol_list)
print("Rendering %d blocks" % len(rendering))
for x, y, z, blockType in rendering:
dim.setBlock(x, y, z, blockType)
return schematic