def __init__(self, tool): Panel.__init__(self) self.tool = tool self.autoPlaceCheckBox = CheckBox( ref=AttrRef(tool, "placeImmediately")) self.autoPlaceLabel = Label("Place Immediately") self.autoPlaceLabel.mouse_down = self.autoPlaceCheckBox.mouse_down tooltipText = "When the clone tool is chosen, place the clone at the selection right away." self.autoPlaceLabel.tooltipText = self.autoPlaceCheckBox.tooltipText = tooltipText spaceLabel = Label("") cloneNudgeLabel = Label("Clone Fast Nudge Settings") cloneNudgeCheckBox = CheckBoxLabel( "Move by the width of selection ", ref=config.fastNudgeSettings.cloneWidth, tooltipText="Moves clone by his width") cloneNudgeNumber = IntInputRow( "Width of clone movement: ", ref=config.fastNudgeSettings.cloneWidthNumber, width=100, min=2, max=50) row = Row((self.autoPlaceCheckBox, self.autoPlaceLabel)) col = Column((Label("Clone Options"), row, spaceLabel, cloneNudgeLabel, cloneNudgeCheckBox, cloneNudgeNumber, Button("OK", action=self.dismiss))) self.add(col) self.shrink_wrap()
def __init__(self, tool): Panel.__init__(self) self.tool = tool self.autoChooseCheckBox = CheckBoxLabel("Choose Block Immediately", ref=config.fill.chooseBlockImmediately, tooltipText="When the fill tool is chosen, prompt for a block type.") col = Column((Label("Fill Options"), self.autoChooseCheckBox, Button("OK", action=self.dismiss))) self.add(col) self.shrink_wrap()
def __init__(self, tool): Panel.__init__(self) self.tool = tool importNudgeLabel = Label("Import Fast Nudge Settings:") importNudgeCheckBox = CheckBoxLabel( "Move by the width of schematic ", ref=config.fastNudgeSettings.importWidth, tooltipText="Moves selection by his width") importNudgeNumber = IntInputRow( "Width of import movement: ", ref=config.fastNudgeSettings.importWidthNumber, width=100, min=2, max=50) col = Column( (Label("Import Options"), importNudgeLabel, importNudgeCheckBox, importNudgeNumber, Button("OK", action=self.dismiss))) self.add(col) self.shrink_wrap()
def GeneratorPanel(): panel = Widget() panel.chunkHeight = 64 panel.grass = True panel.simulate = False jarStorage = MCServerChunkGenerator.getDefaultJarStorage() if jarStorage: jarStorage.reloadVersions() generatorChoice = ChoiceButton(["Minecraft Server", "Flatland"]) panel.generatorChoice = generatorChoice col = [Row((Label("Generator:"), generatorChoice))] noVersionsRow = Label( "Will automatically download and use the latest version") versionContainer = Widget() heightinput = IntInputRow("Height: ", ref=AttrRef(panel, "chunkHeight"), min=0, max=128) grassinput = CheckBoxLabel("Grass", ref=AttrRef(panel, "grass")) flatPanel = Column([heightinput, grassinput], align="l") def generatorChoiceChanged(): serverPanel.visible = generatorChoice.selectedChoice == "Minecraft Server" flatPanel.visible = not serverPanel.visible generatorChoice.choose = generatorChoiceChanged versionChoice = None if len(jarStorage.versions): def checkForUpdates(): def _check(): yield jarStorage.downloadCurrentServer() yield showProgress("Checking for server updates...", _check()) versionChoice.choices = sorted(jarStorage.versions, reverse=True) versionChoice.choiceIndex = 0 versionChoice = ChoiceButton(sorted(jarStorage.versions, reverse=True)) versionChoiceRow = (Row( (Label("Server version:"), versionChoice, Label("or"), Button("Check for Updates", action=checkForUpdates)))) panel.versionChoice = versionChoice versionContainer.add(versionChoiceRow) else: versionContainer.add(noVersionsRow) versionContainer.shrink_wrap() menu = Menu("Advanced", [("Open Server Storage", "revealStorage"), ("Reveal World Cache", "revealCache"), ("Delete World Cache", "clearCache")]) def presentMenu(): i = menu.present(advancedButton.parent, advancedButton.topleft) if i != -1: (revealStorage, revealCache, clearCache)[i]() advancedButton = Button("Advanced...", presentMenu) @alertException def revealStorage(): mcplatform.platform_open(jarStorage.cacheDir) @alertException def revealCache(): mcplatform.platform_open(MCServerChunkGenerator.worldCacheDir) #revealCacheRow = Row((Label("Minecraft Server Storage: "), Button("Open Folder", action=revealCache, tooltipText="Click me to install your own minecraft_server.jar if you have any."))) @alertException def clearCache(): MCServerChunkGenerator.clearWorldCache() simRow = CheckBoxLabel( "Simulate world", ref=AttrRef(panel, "simulate"), tooltipText= "Simulate the world for a few seconds after generating it. Reduces the save file size by processing all of the TileTicks." ) simRow = Row((simRow, advancedButton), anchor="lrh") #deleteCacheRow = Row((Label("Delete Temporary World File Cache?"), Button("Delete Cache!", action=clearCache, tooltipText="Click me if you think your chunks are stale."))) serverPanel = Column([ versionContainer, simRow, ], align="l") col.append(serverPanel) col = Column(col, align="l") col.add(flatPanel) flatPanel.topleft = serverPanel.topleft flatPanel.visible = False panel.add(col) panel.shrink_wrap() def generate(level, arg): useServer = generatorChoice.selectedChoice == "Minecraft Server" if useServer: def _createChunks(): if versionChoice: version = versionChoice.selectedChoice else: version = None gen = MCServerChunkGenerator(version=version) if isinstance(arg, pymclevel.BoundingBox): for i in gen.createLevelIter(level, arg, simulate=panel.simulate): yield i else: for i in gen.generateChunksInLevelIter( level, arg, simulate=panel.simulate): yield i else: def _createChunks(): height = panel.chunkHeight grass = panel.grass and pymclevel.alphaMaterials.Grass.ID or pymclevel.alphaMaterials.Dirt.ID if isinstance(arg, pymclevel.BoundingBox): chunks = list(arg.chunkPositions) else: chunks = arg if level.dimNo in (-1, 1): maxskylight = 0 else: maxskylight = 15 for i, (cx, cz) in enumerate(chunks): yield i, len(chunks) #surface = blockInput.blockInfo #for cx, cz in : try: level.createChunk(cx, cz) except ValueError, e: # chunk already present print e continue else: ch = level.getChunk(cx, cz) if height > 0: stoneHeight = max(0, height - 5) grassHeight = max(0, height - 1) ch.Blocks[:, :, grassHeight] = grass ch.Blocks[:, :, stoneHeight: grassHeight] = pymclevel.alphaMaterials.Dirt.ID ch.Blocks[:, :, : stoneHeight] = pymclevel.alphaMaterials.Stone.ID ch.Blocks[:, :, 0] = pymclevel.alphaMaterials.Bedrock.ID ch.SkyLight[:, :, height:] = maxskylight if maxskylight: ch.HeightMap[:] = height else: ch.SkyLight[:] = maxskylight ch.needsLighting = False ch.dirty = True return _createChunks()
def __init__(self, tool): Panel.__init__(self) self.tool = tool useStyleBox = CheckBoxLabel(title="Use Bullet Styles", ref=config.nbtTreeSettings.useBulletStyles) self.useStyleBox = useStyleBox useTextBox = CheckBoxLabel(title="Use Bullet Text", ref=config.nbtTreeSettings.useBulletText) self.useTextBox = useTextBox useImagesBox = CheckBoxLabel( title="Use Bullet Images", ref=config.nbtTreeSettings.useBulletImages) self.useImagesBox = useImagesBox bulletFilePath = Row( (Button("Bullet Images File", action=self.open_bullet_file), TextFieldWrapped(ref=config.nbtTreeSettings.bulletFileName, width=300)), margin=0) def mouse_down(e): if self.bulletFilePath.subwidgets[1].enabled: TextFieldWrapped.mouse_down(self.bulletFilePath.subwidgets[1], e) bulletFilePath.subwidgets[1].mouse_down = mouse_down self.bulletFilePath = bulletFilePath def mouse_down(e): CheckBox.mouse_down(useImagesBox.subwidgets[1], e) for sub in bulletFilePath.subwidgets: sub.enabled = config.nbtTreeSettings.useBulletImages.get() if type(sub) == TextFieldWrapped: if config.nbtTreeSettings.useBulletImages.get(): sub.fg_color = fg_color else: sub.fg_color = disabled_color useImagesBox.subwidgets[0].mouse_down = useImagesBox.subwidgets[ 1].mouse_down = mouse_down def mouse_down(e): CheckBox.mouse_down(useStyleBox.subwidgets[1], e) useImagesBox.mouse_down(e) self.useStyleBox_click(e) useStyleBox.subwidgets[0].mouse_down = useStyleBox.subwidgets[ 1].mouse_down = mouse_down showAllTags = CheckBoxLabel(title="Show all the tags in the tree", ref=config.nbtTreeSettings.showAllTags) col = Column(( Label("NBT Tree Settings"), Row((useStyleBox, useTextBox, useImagesBox)), bulletFilePath, showAllTags, # Button("Load NBT file...", action=tool.loadFile), Button("OK", action=self.dismiss), )) self.add(col) self.shrink_wrap() self.useStyleBox_click(None)
def __init__(self, blockInfo, materials, *a, **kw): self.allowWildcards = False Dialog.__init__(self, *a, **kw) panelWidth = 350 self.materials = materials self.anySubtype = blockInfo.wildcard self.matchingBlocks = materials.allBlocks try: self.selectedBlockIndex = self.matchingBlocks.index(blockInfo) except ValueError: self.selectedBlockIndex = 0 for i, b in enumerate(self.matchingBlocks): if blockInfo.ID == b.ID and blockInfo.blockData == b.blockData: self.selectedBlockIndex = i break lbl = Label("Search") # lbl.rect.topleft = (0,0) fld = TextField(300) # fld.rect.topleft = (100, 10) # fld.centery = lbl.centery # fld.left = lbl.right fld.change_action = self.textEntered fld.enter_action = self.ok fld.escape_action = self.cancel self.awesomeField = fld searchRow = Row((lbl, fld)) def formatBlockName(x): block = self.matchingBlocks[x] r = "({id}:{data}) {name}".format(name=block.name, id=block.ID, data=block.blockData) if block.aka: r += " [{0}]".format(block.aka) return r tableview = TableView(columns=[ TableColumn(" ", 24, "l", lambda x: ""), TableColumn("(ID) Name [Aliases]", 276, "l", formatBlockName) ]) tableicons = [ blockview.BlockView(materials) for i in range(tableview.rows.num_rows()) ] for t in tableicons: t.size = (16, 16) t.margin = 0 icons = Column(tableicons, spacing=2) # tableview.margin = 5 tableview.num_rows = lambda: len(self.matchingBlocks) tableview.row_data = lambda x: (self.matchingBlocks[x], x, x) tableview.row_is_selected = lambda x: x == self.selectedBlockIndex tableview.click_row = self.selectTableRow draw_table_cell = tableview.draw_table_cell def draw_block_table_cell(surf, i, data, cell_rect, column): if isinstance(data, Block): tableicons[i - tableview.rows.scroll].blockInfo = data else: draw_table_cell(surf, i, data, cell_rect, column) tableview.draw_table_cell = draw_block_table_cell tableview.width = panelWidth tableview.anchor = "lrbt" # self.add(tableview) self.tableview = tableview tableWidget = Widget() tableWidget.add(tableview) tableWidget.shrink_wrap() def wdraw(*args): for t in tableicons: t.blockInfo = materials.Air tableWidget.draw = wdraw self.blockButton = blockView = thumbview.BlockThumbView( materials, self.blockInfo) blockView.centerx = self.centerx blockView.top = tableview.bottom # self.add(blockview) but = Button("OK") but.action = self.ok but.top = blockView.bottom but.centerx = self.centerx but.align = "c" but.height = 30 if self.allowWildcards: # self.add(but) anyRow = CheckBoxLabel( "Any Subtype", ref=AttrRef(self, 'anySubtype'), tooltipText= "Replace blocks with any data value. Only useful for Replace operations." ) col = Column((searchRow, tableWidget, anyRow, blockView, but)) else: col = Column((searchRow, tableWidget, blockView, but)) col.anchor = "wh" self.anchor = "wh" panel = GLBackground() panel.bg_color = [i / 255. for i in self.bg_color] panel.anchor = "tlbr" self.add(panel) self.add(col) self.add(icons) icons.topleft = tableWidget.topleft icons.top += tableWidget.margin + 30 icons.left += tableWidget.margin + 4 self.shrink_wrap() panel.size = self.size try: self.tableview.rows.scroll_to_item(self.selectedBlockIndex) except: pass
def __init__(self, tool): Panel.__init__(self) self.tool = tool replacing = tool.replacing self.blockButton = BlockButton(tool.editor.level.materials) self.blockButton.blockInfo = tool.blockInfo self.blockButton.action = self.pickFillBlock self.fillWithLabel = Label("Fill with:", width=self.blockButton.width, align="c") self.fillButton = Button("Fill", action=tool.confirm, width=self.blockButton.width) self.fillButton.tooltipText = "Shortcut: Enter" rollkey = config.keys.replaceShortcut.get() self.replaceLabel = replaceLabel = Label("Replace", width=self.blockButton.width) replaceLabel.mouse_down = lambda a: self.tool.toggleReplacing() replaceLabel.fg_color = (177, 177, 255, 255) # replaceLabelRow = Row( (Label(rollkey), replaceLabel) ) replaceLabel.tooltipText = _("Shortcut: {0}").format(rollkey) replaceLabel.align = "c" self.noDataCheckBox = CheckBoxLabel("Keep Data Intact", ref=AttrRef(self.tool, "noData")) col = ( self.fillWithLabel, self.blockButton, # swapRow, replaceLabel, # self.replaceBlockButton, self.noDataCheckBox, self.fillButton) if replacing: self.fillWithLabel = Label("Find:", width=self.blockButton.width, align="c") self.replaceBlockButton = BlockButton(tool.editor.level.materials) self.replaceBlockButton.blockInfo = tool.replaceBlockInfo self.replaceBlockButton.action = self.pickReplaceBlock self.replaceLabel.text = "Replace with:" self.swapButton = Button("Swap", action=self.swapBlockTypes, width=self.blockButton.width) self.swapButton.fg_color = (255, 255, 255, 255) self.swapButton.highlight_color = (60, 255, 60, 255) swapkey = config.keys.swap.get() self.swapButton.tooltipText = _("Shortcut: {0}").format(swapkey) self.fillButton = Button("Replace", action=tool.confirm, width=self.blockButton.width) self.fillButton.tooltipText = "Shortcut: Enter" col = (self.fillWithLabel, self.blockButton, replaceLabel, self.replaceBlockButton, self.noDataCheckBox, self.swapButton, self.fillButton) col = Column(col) self.add(col) self.shrink_wrap()