本文整理汇总了Python中mceutils.showProgress函数的典型用法代码示例。如果您正苦于以下问题:Python showProgress函数的具体用法?Python showProgress怎么用?Python showProgress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了showProgress函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: extractUndoChunks
def extractUndoChunks(self, level, chunks, chunkCount = None):
if not isinstance(level, pymclevel.MCInfdevOldLevel):
chunks = numpy.array(list(chunks))
mincx, mincz = numpy.min(chunks, 0)
maxcx, maxcz = numpy.max(chunks, 0)
box = BoundingBox((mincx << 4, 0, mincz << 4), (maxcx << 4, level.Height, maxcz << 4))
return self.extractUndoSchematic(level, box)
undoLevel = pymclevel.MCInfdevOldLevel(mkundotemp(), create=True)
if not chunkCount:
try:
chunkCount = len(chunks)
except TypeError:
chunkCount = -1
def _extractUndo():
yield 0, 0, "Recording undo..."
for i, (cx, cz) in enumerate(chunks):
undoLevel.copyChunkFrom(level, cx, cz)
yield i, chunkCount, "Copying chunk %s..." % ((cx, cz),)
undoLevel.saveInPlace()
if chunkCount > 25 or chunkCount < 1:
showProgress("Recording undo...", _extractUndo())
else:
exhaust(_extractUndo())
return undoLevel
开发者ID:DiEvAl,项目名称:mcedit,代码行数:29,代码来源:operation.py
示例2: undo
def undo(self):
""" Undo the operation. Ought to leave the Operation in a state where it can be performed again.
Default implementation copies all chunks in undoLevel back into level. Non-chunk-based operations
should override this."""
if self.undoLevel:
self.redoLevel = self.extractUndo(self.level, self.dirtyBox())
def _undo():
yield 0, 0, "Undoing..."
if hasattr(self.level, 'copyChunkFrom'):
for i, (cx, cz) in enumerate(self.undoLevel.allChunks):
self.level.copyChunkFrom(self.undoLevel, cx, cz)
yield i, self.undoLevel.chunkCount, "Copying chunk %s..." % ((cx, cz),)
else:
for i in self.level.copyBlocksFromIter(self.undoLevel, self.undoLevel.bounds,
self.undoLevel.sourcePoint, biomes=True):
yield i, self.undoLevel.chunkCount, "Copying..."
if self.undoLevel.chunkCount > 25:
showProgress("Undoing...", _undo())
else:
exhaust(_undo())
self.editor.invalidateChunks(self.undoLevel.allChunks)
开发者ID:Alexhb61,项目名称:MCEdit-Unified,代码行数:25,代码来源:operation.py
示例3: checkForUpdates
def checkForUpdates():
def _check():
yield
jarStorage.downloadCurrentServer(panel.snapshot)
yield
showProgress("Checking for server updates...", _check())
versionChoice.choices = sorted(jarStorage.versions, reverse=True)
versionChoice.choiceIndex = 0
开发者ID:LaChal,项目名称:MCEdit-Unified,代码行数:9,代码来源:chunk.py
示例4: perform
def perform(self, recordUndo=True):
if recordUndo:
self.undoLevel = self.extractUndo(self.level, self.destBox)
destBox = self.destBox
if self.level.bounds == self.destBox:
destBox = None
fill = self.level.fillBlocksIter(destBox, self.blockInfo, blocksToReplace=self.blocksToReplace)
showProgress("Replacing blocks...", fill, cancel=True)
开发者ID:MrMr01,项目名称:mcedit,代码行数:10,代码来源:fill.py
示例5: relightChunks
def relightChunks(self):
def _relightChunks():
for i in self.editor.level.generateLightsIter(self.selectedChunks()):
yield i
with setWindowCaption("RELIGHTING - "):
showProgress(_("Lighting {0} chunks...").format(len(self.selectedChunks())),
_relightChunks(), cancel=True)
self.editor.invalidateChunks(self.selectedChunks())
self.editor.addUnsavedEdit()
开发者ID:LaChal,项目名称:MCEdit-Unified,代码行数:12,代码来源:chunk.py
示例6: perform
def perform(self, recordUndo=True):
if self.level.saving:
alert(_("Cannot perform action while saving is taking place"))
return
if recordUndo:
self.undoLevel = self.extractUndo(self.level, self.destBox)
destBox = self.destBox
if self.level.bounds == self.destBox:
destBox = None
fill = self.level.fillBlocksIter(destBox, self.blockInfo, blocksToReplace=self.blocksToReplace)
showProgress("Replacing blocks...", fill, cancel=True)
开发者ID:freundTech,项目名称:MCEdit-Unified,代码行数:13,代码来源:fill.py
示例7: redo
def redo(self):
if self.redoLevel:
def _redo():
yield 0, 0, "Redoing..."
if hasattr(self.level, 'copyChunkFrom'):
for i, (cx, cz) in enumerate(self.redoLevel.allChunks):
self.level.copyChunkFrom(self.redoLevel, cx, cz)
yield i, self.redoLevel.chunkCount, "Copying chunk %s..." % ((cx, cz),)
else:
for i in self.level.copyBlocksFromIter(self.redoLevel, self.redoLevel.bounds,
self.redoLevel.sourcePoint, biomes=True):
yield i, self.undoLevel.chunkCount, "Copying..."
if self.redoLevel.chunkCount > 25:
showProgress("Redoing...", _redo())
else:
exhaust(_redo())
开发者ID:Alexhb61,项目名称:MCEdit-Unified,代码行数:17,代码来源:operation.py
示例8: undo
def undo(self):
""" Undo the operation. Ought to leave the Operation in a state where it can be performed again.
Default implementation copies all chunks in undoLevel back into level. Non-chunk-based operations
should override this."""
if self.undoLevel:
def _undo():
yield 0, 0, "Undoing..."
for i, (cx, cz) in enumerate(self.undoLevel.allChunks):
self.level.copyChunkFrom(self.undoLevel, cx, cz)
yield i, self.undoLevel.chunkCount, "Copying chunk %s..." % ((cx, cz),)
if self.undoLevel.chunkCount > 25:
showProgress("Undoing...", _undo())
else:
exhaust(_undo())
self.editor.invalidateChunks(self.undoLevel.allChunks)
开发者ID:PavelHejny,项目名称:mcedit,代码行数:19,代码来源:operation.py
示例9: createChunks
def createChunks(self):
panel = GeneratorPanel()
col = [panel]
label = Label("Create chunks using the settings above? This cannot be undone.")
col.append(Row([Label("")]))
col.append(label)
col = Column(col)
if Dialog(client=col, responses=["OK", "Cancel"]).present() == "Cancel":
return
chunks = self.selectedChunks()
createChunks = panel.generate(self.editor.level, chunks)
try:
with setWindowCaption("CREATING - "):
showProgress("Creating {0} chunks...".format(len(chunks)), createChunks, cancel=True)
except Exception, e:
traceback.print_exc()
alert(_("Failed to start the chunk generator. {0!r}").format(e))
开发者ID:LaChal,项目名称:MCEdit-Unified,代码行数:19,代码来源:chunk.py
示例10: perform
def perform(level, box, options):
global GlobalLevel
GlobalLevel = level
filePath = options["Convert"]
if filePath == "n/a":
try:
filePath = askOpenFile("Select *.txt or *.docx file to convert to Book...", defaults=False, suffixes=["txt", "docx"])
except:
try:
openFile = win32ui.CreateFileDialog(1, None, None, 0, "All Files (*.*)|*.*|Text Files (*.txt)|*.txt|Word Files (*.docx)|*.docx|")
openFile.DoModal()
filePath = openFile.GetPathName()
except:
raise Exception("win32ui could not be imported! Please enter the file path manually.")
fileName = filePath
while "/" in fileName:
fileName = fileName[fileName.find("/")+1:]
fileExtension = fileName[fileName.find(".")+1:]
if options["as the book title"]:
bookTitle = options["Use"]
else:
bookTitle = fileName
if options["Use the file name"] == "with extension":
bookTitle += "." + fileExtension
if filePath is None or fileName == "":
raise Exception("Please select a file!")
mceutils.showProgress("Generating Book", progressIter())
totalText = decodeFile(filePath, fileExtension, options)
makeBook(level, box, options, totalText, bookTitle)
开发者ID:badhaloninja,项目名称:MCEdit-Filters,代码行数:42,代码来源:TextToBook.py
示例11: extractUndoSchematic
def extractUndoSchematic(self, level, box):
if box.volume > 131072:
sch = showProgress("Recording undo...", level.extractZipSchematicIter(box), cancel=True)
else:
sch = level.extractZipSchematic(box)
if sch == "Cancel":
raise Cancel
if sch:
sch.sourcePoint = box.origin
return sch
开发者ID:LaChal,项目名称:mcedit,代码行数:11,代码来源:operation.py
示例12: perform
def perform(self, recordUndo=True):
sourceBox = self.sourceBox
if recordUndo:
self.undoLevel = self.extractUndo(self.level, BoundingBox(self.destPoint, self.sourceBox.size))
blocksToCopy = None
if not (self.copyAir and self.copyWater):
blocksToCopy = range(pymclevel.materials.id_limit)
if not self.copyAir:
blocksToCopy.remove(0)
if not self.copyWater:
blocksToCopy.remove(8)
if not self.copyWater:
blocksToCopy.remove(9)
with setWindowCaption("Copying - "):
i = self.level.copyBlocksFromIter(self.sourceLevel, self.sourceBox, self.destPoint, blocksToCopy,
create=True, biomes=self.copyBiomes, staticCommands=self.staticCommands, first=False)
showProgress(_("Copying {0:n} blocks...").format(self.sourceBox.volume), i)
开发者ID:LaChal,项目名称:MCEdit-Unified,代码行数:20,代码来源:clone.py
示例13: perform
def perform(self, recordUndo=True):
sourceBox = self.sourceBox
if recordUndo:
self.undoLevel = self.extractUndo(self.level, BoundingBox(self.destPoint, self.sourceBox.size))
blocksToCopy = None
if not (self.copyAir and self.copyWater):
blocksToCopy = range(256)
if not self.copyAir:
blocksToCopy.remove(0)
if not self.copyWater:
blocksToCopy.remove(8)
if not self.copyWater:
blocksToCopy.remove(9)
with setWindowCaption("Copying - "):
i = self.level.copyBlocksFromIter(self.sourceLevel, self.sourceBox, self.destPoint, blocksToCopy, create=True)
showProgress("Copying {0:n} blocks...".format(self.sourceBox.volume), i)
开发者ID:s32ialx,项目名称:mcedit,代码行数:20,代码来源:clone.py
示例14: extractUndoChunks
def extractUndoChunks(self, level, chunks, chunkCount = None):
undoLevel = pymclevel.MCInfdevOldLevel(mkundotemp(), create=True)
if not chunkCount:
try:
chunkCount = len(chunks)
except TypeError:
chunkCount = -1
def _extractUndo():
yield 0, 0, "Recording undo..."
for i, (cx, cz) in enumerate(chunks):
undoLevel.copyChunkFrom(level, cx, cz)
yield i, chunkCount, "Copying chunk %s..." % ((cx, cz),)
undoLevel.saveInPlace()
if chunkCount > 25 or chunkCount < 1:
showProgress("Recording undo...", _extractUndo())
else:
exhaust(_extractUndo())
return undoLevel
开发者ID:PavelHejny,项目名称:mcedit,代码行数:21,代码来源:operation.py
示例15: deleteFromWorld
def deleteFromWorld():
i = chestWidget.selectedItemIndex
item = tileEntityTag["Items"][i]
id = item["id"].value
Damage = item["Damage"].value
deleteSameDamage = mceutils.CheckBoxLabel("Only delete items with the same damage value")
deleteBlocksToo = mceutils.CheckBoxLabel("Also delete blocks placed in the world")
if id not in (8, 9, 10, 11): # fluid blocks
deleteBlocksToo.value = True
w = wrapped_label(
"WARNING: You are about to modify the entire world. This cannot be undone. Really delete all copies of this item from all land, chests, furnaces, dispensers, dropped items, item-containing tiles, and player inventories in this world?",
60)
col = (w, deleteSameDamage)
if id < 256:
col += (deleteBlocksToo,)
d = Dialog(Column(col), ["OK", "Cancel"])
if d.present() == "OK":
def deleteItemsIter():
i = 0
if deleteSameDamage.value:
def matches(t):
return t["id"].value == id and t["Damage"].value == Damage
else:
def matches(t):
return t["id"].value == id
def matches_itementity(e):
if e["id"].value != "Item":
return False
if "Item" not in e:
return False
t = e["Item"]
return matches(t)
for player in self.editor.level.players:
tag = self.editor.level.getPlayerTag(player)
l = len(tag["Inventory"])
tag["Inventory"].value = [t for t in tag["Inventory"].value if not matches(t)]
for chunk in self.editor.level.getChunks():
if id < 256 and deleteBlocksToo.value:
matchingBlocks = chunk.Blocks == id
if deleteSameDamage.value:
matchingBlocks &= chunk.Data == Damage
if any(matchingBlocks):
chunk.Blocks[matchingBlocks] = 0
chunk.Data[matchingBlocks] = 0
chunk.chunkChanged()
self.editor.invalidateChunks([chunk.chunkPosition])
for te in chunk.TileEntities:
if "Items" in te:
l = len(te["Items"])
te["Items"].value = [t for t in te["Items"].value if not matches(t)]
if l != len(te["Items"]):
chunk.dirty = True
entities = [e for e in chunk.Entities if matches_itementity(e)]
if len(entities) != len(chunk.Entities):
chunk.Entities.value = entities
chunk.dirty = True
yield (i, self.editor.level.chunkCount)
i += 1
progressInfo = _("Deleting the item {0} from the entire world ({1} chunks)").format(
itemName(chestWidget.id, 0), self.editor.level.chunkCount)
mceutils.showProgress(progressInfo, deleteItemsIter(), cancel=True)
self.editor.addUnsavedEdit()
chestWidget.selectedItemIndex = min(chestWidget.selectedItemIndex, len(tileEntityTag["Items"]) - 1)
开发者ID:Dominic001,项目名称:MCEdit-Unified,代码行数:76,代码来源:camera.py
示例16: _pruneChunks
def _pruneChunks():
maxChunks = self.editor.level.chunkCount
selectedChunks = self.selectedChunks()
for i, cPos in enumerate(list(self.editor.level.allChunks)):
if cPos not in selectedChunks:
try:
self.editor.level.deleteChunk(*cPos)
except Exception, e:
print "Error during chunk delete: ", e
yield i, maxChunks
with setWindowCaption("PRUNING - "):
showProgress("Pruning chunks...", _pruneChunks())
self.editor.renderer.invalidateChunkMarkers()
self.editor.discardAllChunks()
# self.editor.addUnsavedEdit()
@alertException
def relightChunks(self):
def _relightChunks():
for i in self.editor.level.generateLightsIter(self.selectedChunks()):
yield i
with setWindowCaption("RELIGHTING - "):
showProgress(_("Lighting {0} chunks...").format(len(self.selectedChunks())),
开发者ID:LaChal,项目名称:MCEdit-Unified,代码行数:30,代码来源:chunk.py
示例17: apply
def apply(self, op, point):
undoLevel = pymclevel.MCInfdevOldLevel(mkundotemp(), create=True)
dirtyChunks = set()
def saveUndoChunk(cx, cz):
if (cx, cz) in dirtyChunks:
return
dirtyChunks.add((cx, cz))
undoLevel.copyChunkFrom(op.level, cx, cz)
doomedBlock = op.level.blockAt(*point)
doomedBlockData = op.level.blockDataAt(*point)
checkData = (doomedBlock not in (8, 9, 10, 11))
indiscriminate = op.options['Indiscriminate']
if indiscriminate:
checkData = False
if doomedBlock == 2: # grass
doomedBlock = 3 # dirt
if doomedBlock == op.options['Block'].ID and (doomedBlockData == op.options['Block'].blockData or checkData == False):
return
x, y, z = point
saveUndoChunk(x // 16, z // 16)
op.level.setBlockAt(x, y, z, op.options['Block'].ID)
op.level.setBlockDataAt(x, y, z, op.options['Block'].blockData)
def processCoords(coords):
newcoords = collections.deque()
for (x, y, z) in coords:
for _dir, offsets in pymclevel.faceDirections:
dx, dy, dz = offsets
p = (x + dx, y + dy, z + dz)
nx, ny, nz = p
b = op.level.blockAt(nx, ny, nz)
if indiscriminate:
if b == 2:
b = 3
if b == doomedBlock:
if checkData:
if op.level.blockDataAt(nx, ny, nz) != doomedBlockData:
continue
saveUndoChunk(nx // 16, nz // 16)
op.level.setBlockAt(nx, ny, nz, op.options['Block'].ID)
op.level.setBlockDataAt(nx, ny, nz, op.options['Block'].blockData)
newcoords.append(p)
return newcoords
def spread(coords):
while len(coords):
start = datetime.datetime.now()
num = len(coords)
coords = processCoords(coords)
d = datetime.datetime.now() - start
progress = "Did {0} coords in {1}".format(num, d)
log.info(progress)
yield progress
showProgress("Flood fill...", spread([point]), cancel=True)
op.editor.invalidateChunks(dirtyChunks)
op.undoLevel = undoLevel
开发者ID:Alexhb61,项目名称:MCEdit-Unified,代码行数:67,代码来源:Flood+Fill.py
注:本文中的mceutils.showProgress函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论