Esempio n. 1
0
    def __init__(self, materials, blockInfo=None, ref=None, recentBlocks=None, *a, **kw):
        self.allowWildcards = False
        if 'name' not in kw.keys():
            kw['name'] = 'Panel.BlockButton'
        Panel.__init__(self, *a, **kw)

        self.bg_color = (1, 1, 1, 0.25)
        self._ref = ref
        if blockInfo is None and ref is not None:
            blockInfo = ref.get()
        blockInfo = blockInfo or materials.Air

        if recentBlocks is not None:
            self.recentBlocks = recentBlocks
        else:
            self.recentBlocks = []

        self.blockView = thumbview.BlockThumbView(materials, blockInfo, size=(48, 48))
        self.blockLabel = ValueDisplay(ref=AttrRef(self, 'labelText'), width=180, align="l")
        row = Row((self.blockView, self.blockLabel), align="b")

        # col = Column( (self.blockButton, self.blockNameLabel) )
        self.add(row)
        self.shrink_wrap()

        # self.blockLabel.bottom = self.blockButton.bottom
        # self.blockLabel.centerx = self.blockButton.centerx

        # self.add(self.blockLabel)

        self.materials = materials
        self.blockInfo = blockInfo
        # self._ref = ref
        self.updateRecentBlockView()
 def __init__(self, inventory, data):
     Panel.__init__(self)
     self.inventory = inventory
     slot, id, count, damage = data
     self.former_id_text = id
     self.slot = slot
     self.id = TextFieldWrapped(text=id, doNotTranslate=True, width=300)
     #&# Prototype for blocks/items names
     self.menu = None
     m = Menu("", [""])
     h = m.font.get_linesize()
     self.menu = Menu("", [""], scrolling=True, scroll_items=(self.root.local_to_global(self.root.bottomleft)[1] - self.root.local_to_global(self.bottomleft)[1] - (m.margin * 2)) / h)
     del m
     self.id.change_action = self.text_entered
     self.id.escape_action = self.close_menu
     self.menu.key_down = self.id.key_down
     #&#
     self.count = IntField(text="%s"%count, min=-64, max=64)
     self.damage = IntField(text="%s"%damage, min=-32768, max=32767)
     header = Label(_("Inventory Slot #%s")%slot, doNotTranslate=True)
     row = Row([Label("id"), self.id,
                Label("Count"), self.count,
                Label("Damage"), self.damage,
                ])
     buttons = Row([Button("Save", action=self.dismiss), Button("Cancel", action=self.cancel)])
     col = Column([header, row, buttons], spacing=2)
     self.add(col)
     self.shrink_wrap()
Esempio n. 3
0
    def __init__(self, tool):
        Panel.__init__(self, name="Panel.FilterToolPanel")
        self.macro_steps = []
        self.current_step = 0
        self._filter_json = None
        self.keys_panel = None
        self.filterOptionsPanel = None
        self.filterSelect = ChoiceButton([], choose=self.filterChanged, doNotTranslate=True)
        self.binding_button = Button("", action=self.bind_key, tooltipText="Click to bind this filter to a key")

        self.filterLabel = Label("Filter:", fg_color=(177, 177, 255, 255))
        self.filterLabel.mouse_down = lambda x: mcplatform.platform_open(directories.getFiltersDir())
        self.filterLabel.tooltipText = "Click to open filters folder"

        self.macro_button = Button("Record Macro", action=self.start_record_macro)
        self.filterSelectRow = Row((self.filterLabel, self.filterSelect, self.macro_button, self.binding_button))

        self.confirmButton = Button("Filter", action=self.confirm)

        self._recording = False
        self._save_macro = False
        self.tool = tool
        self.selectedName = self.filter_json.get("Last Filter Opened", "")

        utils = FilterUtils(
            editor=tool.editor,
            materials=self.tool.editor.level.materials,
            custom_widget=tool.editor.addExternalWidget,
            resize_selection_box=tool.editor._resize_selection_box,
        )
        utils_module = imp.new_module("filter_utils")
        utils_module = utils
        sys.modules["filter_utils"] = utils_module
Esempio n. 4
0
    def __init__(self, editor):
        Panel.__init__(self)
        self.editor = editor

        self.bg_color = (0, 0, 0, 0.8)

        header = self.getHeader()
        keysColumn = [Label("")]
        buttonsColumn = [header]

        hotkeys = ([(config.keys.newWorld.get(), "Create New World",
                     editor.mcedit.createNewWorld),
                    (config.keys.quickLoad.get(), "Quick Load", editor.askLoadWorld),
                    (config.keys.open.get(), "Open...", editor.askOpenFile),
                    (config.keys.save.get(), "Save", editor.saveFile),
                    (config.keys.reloadWorld.get(), "Reload", editor.reload),
                    (config.keys.closeWorld.get(), "Close", editor.closeEditor),
                    (config.keys.gotoPanel.get(), "Goto", editor.showGotoPanel),
                    (config.keys.worldInfo.get(), "World Info", editor.showWorldInfo),
                    (config.keys.undo.get(), "Undo", editor.undo),
                    (config.keys.redo.get(), "Redo", editor.redo),
                    (config.keys.selectAll.get(), "Select All", editor.selectAll),
                    (config.keys.deselect.get(), "Deselect", editor.deselect),
                    (config.keys.viewDistance.get(),
                     AttrRef(editor, 'viewDistanceLabelText'), editor.swapViewDistance),
                    (config.keys.quit.get(), "Quit", editor.quit),
                   ])

        buttons = mceutils.HotkeyColumn(hotkeys, keysColumn, buttonsColumn)

        sideColumn = editor.mcedit.makeSideColumn()

        self.add(Row([buttons, sideColumn]))
        self.shrink_wrap()
Esempio n. 5
0
    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()
Esempio n. 6
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.macro_steps = []
        self.current_step = 0
        self._filter_json = None
        self.keys_panel = None
        self.filterOptionsPanel = None
        self.filterSelect = ChoiceButton([],
                                         choose=self.filterChanged,
                                         doNotTranslate=True)
        self.binding_button = Button(
            "",
            action=self.bind_key,
            tooltipText="Click to bind this filter to a key")

        self.filterLabel = Label("Filter:", fg_color=(177, 177, 255, 255))
        self.filterLabel.mouse_down = lambda x: mcplatform.platform_open(
            directories.getFiltersDir())
        self.filterLabel.tooltipText = "Click to open filters folder"

        self.macro_button = Button("Record Macro",
                                   action=self.start_record_macro)
        self.filterSelectRow = Row((self.filterLabel, self.filterSelect,
                                    self.macro_button, self.binding_button))

        self.confirmButton = Button("Filter", action=self.confirm)

        self._recording = False
        self._save_macro = False
        self.tool = tool
        self.selectedName = self.filter_json.get("Last Filter Opened", "")
Esempio n. 7
0
    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()
Esempio n. 8
0
    def __init__(self, materials, blockInfo=None, ref=None, recentBlocks=None, *a, **kw):
        self.allowWildcards = False
        Panel.__init__(self, *a, **kw)

        self.bg_color = (1, 1, 1, 0.25)
        self._ref = ref
        if blockInfo is None and ref is not None:
            blockInfo = ref.get()
        blockInfo = blockInfo or materials.Air

        if recentBlocks is not None:
            self.recentBlocks = recentBlocks
        else:
            self.recentBlocks = []

        self.blockView = thumbview.BlockThumbView(materials, blockInfo, size=(48, 48))
        self.blockLabel = ValueDisplay(ref=AttrRef(self, 'labelText'), width=180, align="l")
        row = Row((self.blockView, self.blockLabel), align="b")

        # col = Column( (self.blockButton, self.blockNameLabel) )
        self.add(row)
        self.shrink_wrap()

        # self.blockLabel.bottom = self.blockButton.bottom
        # self.blockLabel.centerx = self.blockButton.centerx

        # self.add(self.blockLabel)

        self.materials = materials
        self.blockInfo = blockInfo
        # self._ref = ref
        self.updateRecentBlockView()
Esempio n. 9
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        level = tool.editor.level
        if hasattr(level, 'players'):
            players = level.players or ["[No players]"]
        else:
            players = ["Player"]
        self.players = players
        tableview = TableView(columns=[
            TableColumn("Player Name", 200),
        ])
        tableview.index = 0
        tableview.num_rows = lambda: len(players)
        tableview.row_data = lambda i: (players[i],)
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow
        self.table = tableview
        l = Label("Player: ")
        col = [l, tableview]

        gotoButton = Button("Goto Player", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto Player's View", action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move Player", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align Player to Camera", action=self.tool.movePlayerToCamera)
        col.extend([gotoButton, gotoCameraButton, moveButton, moveToCameraButton])

        col = Column(col)
        self.add(col)
        self.shrink_wrap()
Esempio n. 10
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.macro_steps = []
        self.current_step = 0
        self._filter_json = None
        self.keys_panel = None
        self.filterOptionsPanel = None
        self.filterSelect = ChoiceButton([], choose=self.filterChanged, doNotTranslate=True)
        self.binding_button = Button("", action=self.bind_key,
                                     tooltipText="Click to bind this filter to a key")

        self.filterLabel = Label("Filter:", fg_color=(177, 177, 255, 255))
        self.filterLabel.mouse_down = lambda x: mcplatform.platform_open(directories.getFiltersDir())
        self.filterLabel.tooltipText = "Click to open filters folder"

        self.macro_button = Button("Record Macro", action=self.start_record_macro)
        self.filterSelectRow = Row((self.filterLabel, self.filterSelect,
                                    self.macro_button, self.binding_button))

        self.confirmButton = Button("Filter", action=self.confirm)

        self._recording = False
        self._save_macro = False
        self.tool = tool
        self.selectedName = self.filter_json.get("Last Filter Opened", "")
Esempio n. 11
0
    def __init__(self, tool, *a, **kw):
        Panel.__init__(self, *a, **kw)

        self.tool = tool

        self.anchor = "whl"

        chunkToolLabel = Label("Selected Chunks:")

        self.chunksLabel = ValueDisplay(ref=AttrRef(self, 'chunkSizeText'), width=115)
        self.chunksLabel.align = "c"
        self.chunksLabel.tooltipText = "..."

        extractButton = Button("Extract")
        extractButton.tooltipText = "Extract these chunks to individual chunk files"
        extractButton.action = tool.extractChunks
        extractButton.highlight_color = (255, 255, 255)

        deselectButton = Button("Deselect",
                                tooltipText=None,
                                action=tool.editor.deselect,
        )

        createButton = Button("Create")
        createButton.tooltipText = "Create new chunks within the selection."
        createButton.action = tool.createChunks
        createButton.highlight_color = (0, 255, 0)

        destroyButton = Button("Delete")
        destroyButton.tooltipText = "Delete the selected chunks from disk. Minecraft will recreate them the next time you are near."
        destroyButton.action = tool.destroyChunks

        pruneButton = Button("Prune")
        pruneButton.tooltipText = "Prune the world, leaving only the selected chunks. Any chunks outside of the selection will be removed, and empty region files will be deleted from disk"
        pruneButton.action = tool.pruneChunks

        relightButton = Button("Relight")
        relightButton.tooltipText = "Recalculate light values across the selected chunks"
        relightButton.action = tool.relightChunks
        relightButton.highlight_color = (255, 255, 255)

        repopButton = Button("Repop")
        repopButton.tooltipText = "Mark the selected chunks for repopulation. The next time you play Minecraft, the chunks will have trees, ores, and other features regenerated."
        repopButton.action = tool.repopChunks
        repopButton.highlight_color = (255, 200, 155)

        dontRepopButton = Button("Don't Repop")
        dontRepopButton.tooltipText = "Unmark the selected chunks. They will not repopulate the next time you play the game."
        dontRepopButton.action = tool.dontRepopChunks
        dontRepopButton.highlight_color = (255, 255, 255)

        col = Column((
        chunkToolLabel, self.chunksLabel, deselectButton, createButton, destroyButton, pruneButton, relightButton,
        extractButton, repopButton, dontRepopButton))
        # col.right = self.width - 10;
        self.width = col.width
        self.height = col.height
        #self.width = 120
        self.add(col)
Esempio n. 12
0
    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)
Esempio n. 13
0
    def __init__(self, tool, *a, **kw):
        Panel.__init__(self, *a, **kw)

        self.tool = tool

        self.anchor = "whl"

        chunkToolLabel = Label("Selected Chunks:")

        self.chunksLabel = ValueDisplay(ref=AttrRef(self, 'chunkSizeText'), width=115)
        self.chunksLabel.align = "c"
        self.chunksLabel.tooltipText = "..."

        extractButton = Button("Extract")
        extractButton.tooltipText = "Extract these chunks to individual chunk files"
        extractButton.action = tool.extractChunks
        extractButton.highlight_color = (255, 255, 255)

        deselectButton = Button("Deselect",
                                tooltipText=None,
                                action=tool.editor.deselect,
        )

        createButton = Button("Create")
        createButton.tooltipText = "Create new chunks within the selection."
        createButton.action = tool.createChunks
        createButton.highlight_color = (0, 255, 0)

        destroyButton = Button("Delete")
        destroyButton.tooltipText = "Delete the selected chunks from disk. Minecraft will recreate them the next time you are near."
        destroyButton.action = tool.destroyChunks

        pruneButton = Button("Prune")
        pruneButton.tooltipText = "Prune the world, leaving only the selected chunks. Any chunks outside of the selection will be removed, and empty region files will be deleted from disk"
        pruneButton.action = tool.pruneChunks

        relightButton = Button("Relight")
        relightButton.tooltipText = "Recalculate light values across the selected chunks"
        relightButton.action = tool.relightChunks
        relightButton.highlight_color = (255, 255, 255)

        repopButton = Button("Repop")
        repopButton.tooltipText = "Mark the selected chunks for repopulation. The next time you play Minecraft, the chunks will have trees, ores, and other features regenerated."
        repopButton.action = tool.repopChunks
        repopButton.highlight_color = (255, 200, 155)

        dontRepopButton = Button("Don't Repop")
        dontRepopButton.tooltipText = "Unmark the selected chunks. They will not repopulate the next time you play the game."
        dontRepopButton.action = tool.dontRepopChunks
        dontRepopButton.highlight_color = (255, 255, 255)

        col = Column((
        chunkToolLabel, self.chunksLabel, deselectButton, createButton, destroyButton, pruneButton, relightButton,
        extractButton, repopButton, dontRepopButton))
        # col.right = self.width - 10;
        self.width = col.width
        self.height = col.height
        #self.width = 120
        self.add(col)
Esempio n. 14
0
    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"

        col = (self.fillWithLabel,
               self.blockButton,
               # swapRow,
               replaceLabel,
               # self.replaceBlockButton,
               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.swapButton,
                   self.fillButton)

        col = Column(col)

        self.add(col)
        self.shrink_wrap()
Esempio n. 15
0
    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.config.get("Keys", "Roll").upper()

        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"

        col = (self.fillWithLabel,
                self.blockButton,
                # swapRow,
                replaceLabel,
                # self.replaceBlockButton,
                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.config.get("Keys", "Swap").upper()

            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.swapButton,
                    self.fillButton)

        col = Column(col)

        self.add(col)
        self.shrink_wrap()
Esempio n. 16
0
    def __init__(self, tool):
        Panel.__init__(self)

        self.savedOptions = {}

        self.tool = tool
        self.selectedFilterName = None
        if len(self.tool.filterModules):
            self.reload()
Esempio n. 17
0
    def __init__(self, editor, nbtObject=None, fileName=None, savePolicy=0, dataKeyName='Data', close_text="Close",
                 load_text="Open", **kwargs):
        """..."""
        Panel.__init__(self)
        self.editor = editor
        self.nbtObject = nbtObject
        self.fileName = fileName
        self.savePolicy = savePolicy
        self.displayed_item = None
        self.dataKeyName = dataKeyName
        self.copy_data = kwargs.get('copy_data', True)
        self.init_data()
        btns = []
        if load_text:
            btns.append(Button(load_text, action=self.editor.nbtTool.loadFile))
        btns += [
            Button({True: "Save", False: "OK"}[fileName != None], action=kwargs.get('ok_action', self.save_NBT),
                   tooltipText="Save your change in the NBT data."),
            Button("Reset", action=kwargs.get('reset_action', self.reset),
                   tooltipText="Reset ALL your changes in the NBT data."),
        ]
        if close_text:
            btns.append(Button(close_text, action=kwargs.get('close_action', self.close)))

        btnRow = Row(btns, margin=1, spacing=4)

        btnRow.shrink_wrap()
        self.btnRow = btnRow

        if kwargs.get('no_header', False):
            self.max_height = max_height = kwargs.get('height', editor.mainViewport.height - editor.toolbar.height -
                                                      editor.subwidgets[0].height) - (
                                               self.margin * 2) - btnRow.height - 2
        else:
            title = _("NBT Explorer")
            if fileName:
                title += " - %s" % os.path.split(fileName)[-1]
            header = Label(title, doNotTranslate=True)
            self.max_height = max_height = kwargs.get('height', editor.mainViewport.height - editor.toolbar.height -
                                                      editor.subwidgets[0].height) - header.height - (
                                               self.margin * 2) - btnRow.height - 2
        self.setCompounds()
        self.tree = NBTTree(height=max_height - btnRow.height - 2, inner_width=250, data=self.data,
                            compound_types=self.compounds,
                            copyBuffer=editor.nbtCopyBuffer, draw_zebra=False, _parent=self, styles=bullet_styles)
        self.tree.update_side_panel = self.update_side_panel
        self.side_panel_width = 350
        row = [self.tree, Column([Label("", width=self.side_panel_width), ], margin=0)]
        self.displayRow = Row(row, height=max_height, margin=0, spacing=0)
        if kwargs.get('no_header', False):
            self.add(Column([self.displayRow, btnRow], margin=0))
        else:
            self.add(Column([header, self.displayRow, btnRow], margin=0))
        self.shrink_wrap()
        self.side_panel = None
        # &# Prototype for Blocks/item names
        mclangres.buildResources(lang=getLang())
Esempio n. 18
0
    def __init__(self, editor, nbtObject=None, fileName=None, savePolicy=0, dataKeyName='Data', close_text="Close",
                 load_text="Open", **kwargs):
        """..."""
        Panel.__init__(self)
        self.editor = editor
        self.nbtObject = nbtObject
        self.fileName = fileName
        self.savePolicy = savePolicy
        self.displayed_item = None
        self.dataKeyName = dataKeyName
        self.copy_data = kwargs.get('copy_data', True)
        self.init_data()
        btns = []
        if load_text:
            btns.append(Button(load_text, action=self.editor.nbtTool.loadFile))
        btns += [
            Button({True: "Save", False: "OK"}[fileName != None], action=kwargs.get('ok_action', self.save_NBT),
                   tooltipText="Save your change in the NBT data."),
            Button("Reset", action=kwargs.get('reset_action', self.reset),
                   tooltipText="Reset ALL your changes in the NBT data."),
        ]
        if close_text:
            btns.append(Button(close_text, action=kwargs.get('close_action', self.close)))

        btnRow = Row(btns, margin=1, spacing=4)

        btnRow.shrink_wrap()
        self.btnRow = btnRow

        if kwargs.get('no_header', False):
            self.max_height = max_height = kwargs.get('height', editor.mainViewport.height - editor.toolbar.height -
                                                      editor.subwidgets[0].height) - (
                                               self.margin * 2) - btnRow.height - 2
        else:
            title = _("NBT Explorer")
            if fileName:
                title += " - %s" % os.path.split(fileName)[-1]
            header = Label(title, doNotTranslate=True)
            self.max_height = max_height = kwargs.get('height', editor.mainViewport.height - editor.toolbar.height -
                                                      editor.subwidgets[0].height) - header.height - (
                                               self.margin * 2) - btnRow.height - 2
        self.setCompounds()
        self.tree = NBTTree(height=max_height - btnRow.height - 2, inner_width=250, data=self.data,
                            compound_types=self.compounds,
                            copyBuffer=editor.nbtCopyBuffer, draw_zebra=False, _parent=self, styles=bullet_styles)
        self.tree.update_side_panel = self.update_side_panel
        self.side_panel_width = 350
        row = [self.tree, Column([Label("", width=self.side_panel_width), ], margin=0)]
        self.displayRow = Row(row, height=max_height, margin=0, spacing=0)
        if kwargs.get('no_header', False):
            self.add(Column([self.displayRow, btnRow], margin=0))
        else:
            self.add(Column([header, self.displayRow, btnRow], margin=0))
        self.shrink_wrap()
        self.side_panel = None
        # &# Prototype for Blocks/item names
        mclangres.buildResources(lang=getLang())
Esempio n. 19
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.player_UUID = {}
        self.level = tool.editor.level
        if hasattr(self.level, 'players'):
            players = self.level.players or ["[No players]"]
            if not self.level.oldPlayerFolderFormat:
                for player in players:
                    if player != "Player" and player != "[No players]":
                        self.player_UUID[version_utils.getPlayerNameFromUUID(player)] = player
                if "Player" in players:
                    self.player_UUID["Player"] = "Player"
                if "[No players]" not in players:
                    players = sorted(self.player_UUID.keys(), key=lambda x: False if x == "Player" else x.lower())

        else:
            players = ["Player"]
        self.players = players

        max_height = self.tool.editor.mainViewport.height - self.tool.editor.netherPanel.height - self.tool.editor.subwidgets[0].height - self.margin - 2

        addButton = Button("Add Player", action=self.tool.addPlayer)
        removeButton = Button("Remove Player", action=self.tool.removePlayer)
        gotoButton = Button("Goto Player", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto Player's View", action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move Player", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align Player to Camera", action=self.tool.movePlayerToCamera)
        reloadSkin = Button("Reload Skins", action=self.tool.reloadSkins, tooltipText="This pulls skins from the online server, so this may take a while")

        print max_height
        max_height -= sum((a.height for a in (addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin)))
        print max_height

        tableview = TableView(columns=[
            TableColumn("Player Name(s):", 200),
        ], height=max_height)
        tableview.index = 0
        tableview.num_rows = lambda: len(players)
        tableview.row_data = lambda i: (players[i],)
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow
        self.table = tableview
        col = [self.table]

        col.extend([addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin])

        col = Column(col, margin=0, spacing=2)
        col.shrink_wrap()
        self.add(col)
        self.shrink_wrap()
Esempio n. 20
0
    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)
Esempio n. 21
0
    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()
Esempio n. 22
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.autoChooseCheckBox = CheckBoxLabel("Choose Block Immediately",
                                                ref=FillSettings.chooseBlockImmediately.propertyRef(),
                                                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()
Esempio n. 23
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.autoChooseCheckBoxFill = CheckBoxLabel("Open Block Picker for Fill",
                                                ref=config.fill.chooseBlockImmediately,
                                                tooltipText="When the fill tool is chosen, prompt for a block type.")
        self.autoChooseCheckBoxReplace = CheckBoxLabel("Open Block Picker for Replace",
                                                       ref=config.fill.chooseBlockImmediatelyReplace,
                                                       tooltipText="When the replace tool is chosen, prompt for a block type.")
        col = Column((Label("Fill and Replace Options"), self.autoChooseCheckBoxFill, self.autoChooseCheckBoxReplace, Button("OK", action=self.dismiss)))

        self.add(col)
        self.shrink_wrap()
Esempio n. 24
0
    def __init__(self, tool):
        Panel.__init__(self, name='Panel.BrushPanel')
        self.tool = tool
        """
        presets, modeRow and styleRow are always created, no matter
        what brush is selected. styleRow can be disabled by putting disableStyleButton = True
        in the brush file.
        """
        presets = self.createPresetRow()

        self.brushModeButtonLabel = Label("Mode:")
        self.brushModeButton = ChoiceButton(
            sorted([mode for mode in tool.brushModes]),
            width=150,
            choose=self.brushModeChanged,
            doNotTranslate=True,
        )
        modeRow = Row([self.brushModeButtonLabel, self.brushModeButton])

        self.brushStyleButtonLabel = Label("Style:")
        self.brushStyleButton = ValueButton(ref=ItemRef(
            self.tool.options, "Style"),
                                            action=self.tool.swapBrushStyles,
                                            width=150)

        styleRow = Row([self.brushStyleButtonLabel, self.brushStyleButton])
        self.brushModeButton.selectedChoice = self.tool.selectedBrushMode
        optionsColumn = []
        optionsColumn.extend([presets, modeRow])
        if not getattr(tool.brushMode, 'disableStyleButton', False):
            optionsColumn.append(styleRow)
        """
        We're going over all options in the selected brush module, and making
        a field for all of them.
        """
        for r in tool.brushMode.inputs:
            row = []
            for key, value in r.items():
                field = self.createField(key, value)
                row.append(field)
            row = Row(row)
            optionsColumn.append(row)
        if getattr(tool.brushMode, 'addPasteButton', False):
            importButton = Button("Import", action=tool.importPaste)
            importRow = Row([importButton])
            optionsColumn.append(importRow)
        optionsColumn = Column(optionsColumn, spacing=0)
        self.add(optionsColumn)
        self.shrink_wrap()
Esempio n. 25
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.spawnProtectionCheckBox = CheckBox(ref=AttrRef(tool, "spawnProtection"))
        self.spawnProtectionLabel = Label("Spawn Position Safety")
        self.spawnProtectionLabel.mouse_down = self.spawnProtectionCheckBox.mouse_down

        tooltipText = "Minecraft will randomly move your spawn point if you try to respawn in a column where there are no blocks at Y=63 and Y=64. Only uncheck this box if Minecraft is changed."
        self.spawnProtectionLabel.tooltipText = self.spawnProtectionCheckBox.tooltipText = tooltipText

        row = Row((self.spawnProtectionCheckBox, self.spawnProtectionLabel))
        col = Column((Label("Spawn Point Options"), row, Button("OK", action=self.dismiss)))

        self.add(col)
        self.shrink_wrap()
Esempio n. 26
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.spawnProtectionCheckBox = CheckBox(ref=AttrRef(tool, "spawnProtection"))
        self.spawnProtectionLabel = Label("Spawn Position Safety")
        self.spawnProtectionLabel.mouse_down = self.spawnProtectionCheckBox.mouse_down

        tooltipText = "Minecraft will randomly move your spawn point if you try to respawn in a column where there are no blocks at Y=63 and Y=64. Only uncheck this box if Minecraft is changed."
        self.spawnProtectionLabel.tooltipText = self.spawnProtectionCheckBox.tooltipText = tooltipText

        row = Row((self.spawnProtectionCheckBox, self.spawnProtectionLabel))
        col = Column((Label("Spawn Point Options"), row, Button("OK", action=self.dismiss)))

        self.add(col)
        self.shrink_wrap()
Esempio n. 27
0
    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

        row = Row((self.autoPlaceCheckBox, self.autoPlaceLabel))
        col = Column((Label("Clone Options"), row, Button("OK", action=self.dismiss)))

        self.add(col)
        self.shrink_wrap()
Esempio n. 28
0
    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

        row = Row((self.autoPlaceCheckBox, self.autoPlaceLabel))
        col = Column((Label("Clone Options"), row, Button("OK", action=self.dismiss)))

        self.add(col)
        self.shrink_wrap()
Esempio n. 29
0
    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()
Esempio n. 30
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.player_UUID = {}
        self.level = tool.editor.level
        if hasattr(self.level, 'players'):
            players = self.level.players or ["[No players]"]
            if not self.level.oldPlayerFolderFormat:
                for player in players:
                    if player != "Player":
                        self.player_UUID[
                            version_compatability_utils.getPlayerNameFromUUID(
                                player)] = player
                self.player_UUID["Player"] = "Player"
                players = self.player_UUID.keys()

        else:
            players = ["Player"]
        self.players = players
        tableview = TableView(columns=[
            TableColumn("Player Name", 200),
        ])
        tableview.index = 0
        tableview.num_rows = lambda: len(players)
        tableview.row_data = lambda i: (players[i], )
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow
        self.table = tableview
        l = Label("Player: ")
        col = [l, tableview]

        gotoButton = Button("Goto Player", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto Player's View",
                                  action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move Player", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align Player to Camera",
                                    action=self.tool.movePlayerToCamera)
        col.extend(
            [gotoButton, gotoCameraButton, moveButton, moveToCameraButton])

        col = Column(col)
        self.add(col)
        self.shrink_wrap()
Esempio n. 31
0
    def __init__(self, tool):
        Panel.__init__(self, name='Panel.BrushPanel')
        self.tool = tool
        """
        presets, modeRow and styleRow are always created, no matter
        what brush is selected. styleRow can be disabled by putting disableStyleButton = True
        in the brush file.
        """
        presets = self.createPresetRow()

        self.brushModeButtonLabel = Label("Mode:")
        self.brushModeButton = ChoiceButton(sorted([mode for mode in tool.brushModes]),
                                       width=150,
                                       choose=self.brushModeChanged,
                                       doNotTranslate=True,
                                       )
        modeRow = Row([self.brushModeButtonLabel, self.brushModeButton])

        self.brushStyleButtonLabel = Label("Style:")
        self.brushStyleButton = ValueButton(ref=ItemRef(self.tool.options, "Style"),
                                            action=self.tool.swapBrushStyles,
                                            width=150)

        styleRow = Row([self.brushStyleButtonLabel, self.brushStyleButton])
        self.brushModeButton.selectedChoice = self.tool.selectedBrushMode
        optionsColumn = []
        optionsColumn.extend([presets, modeRow])
        if not getattr(tool.brushMode, 'disableStyleButton', False):
            optionsColumn.append(styleRow)
        """
        We're going over all options in the selected brush module, and making
        a field for all of them.
        """
        for r in tool.brushMode.inputs:
            row = []
            for key, value in r.iteritems():
                field = self.createField(key, value)
                row.append(field)
            row = Row(row)
            optionsColumn.append(row)
        if getattr(tool.brushMode, 'addPasteButton', False):
            importButton = Button("Import", action=tool.importPaste)
            importRow = Row([importButton])
            optionsColumn.append(importRow)
        optionsColumn = Column(optionsColumn, spacing=0)
        self.add(optionsColumn)
        self.shrink_wrap()
Esempio n. 32
0
    def __init__(self, editor):
        Panel.__init__(self, name='Panel.ControlPanel')
        self.editor = editor

        self.bg_color = (0, 0, 0, 0.8)

        header = self.getHeader()
        keysColumn = [Label("")]
        buttonsColumn = [header]

        hotkeys = ([
            (config.keys.newWorld.get(), "Create New World",
             editor.mcedit.createNewWorld),
            (config.keys.quickLoad.get(), "Quick Load", editor.askLoadWorld),
            (config.keys.open.get(), "Open...", editor.askOpenFile),
            (config.keys.save.get(), "Save", editor.saveFile),
            (config.keys.saveAs.get(), "Save As", editor.saveAs),
            (config.keys.reloadWorld.get(), "Reload", editor.reload),
            (config.keys.closeWorld.get(), "Close", editor.closeEditor),
            (config.keys.uploadWorld.get(), "Upload to FTP Server",
             editor.uploadChanges),
            (config.keys.gotoPanel.get(), "Waypoints/Goto",
             editor.showWaypointsDialog),
            (config.keys.worldInfo.get(), "World Info", editor.showWorldInfo),
            (config.keys.undo.get(), "Undo", editor.undo),
            (config.keys.redo.get(), "Redo", editor.redo),
            (config.keys.selectAll.get(), "Select All", editor.selectAll),
            (config.keys.deselect.get(), "Deselect", editor.deselect),
            (config.keys.viewDistance.get(),
             AttrRef(editor,
                     'viewDistanceLabelText'), editor.swapViewDistance),
            (config.keys.quit.get(), "Quit", editor.quit),
        ])

        buttons = HotkeyColumn(hotkeys,
                               keysColumn,
                               buttonsColumn,
                               item_spacing=2)

        sideColumn1 = editor.mcedit.makeSideColumn1()
        sideColumn2 = editor.mcedit.makeSideColumn2()
        spaceLabel = Label("")
        sideColumn = Column((sideColumn1, spaceLabel, sideColumn2))

        self.add(Row([buttons, sideColumn]))
        self.shrink_wrap()
Esempio n. 33
0
 def __init__(self, inventory, data):
     Panel.__init__(self)
     self.inventory = inventory
     slot, id, count, damage = data
     self.slot = slot
     self.id = TextFieldWrapped(text=id, doNotTranslate=True, width=300)
     self.count = IntField(text="%s"%count, min=-64, max=64)
     self.damage = IntField(text="%s"%damage, min=-32768, max=32767)
     header = Label(_("Inventory Slot #%s")%slot, doNotTranslate=True)
     row = Row([Label("id"), self.id,
                Label("Count"), self.count,
                Label("Damage"), self.damage,
                ])
     buttons = Row([Button("Save", action=self.dismiss), Button("Cancel", action=self.cancel)])
     col = Column([header, row, buttons], spacing=2)
     self.add(col)
     self.shrink_wrap()
Esempio n. 34
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.player_UUID = {}
        self.level = tool.editor.level
        if hasattr(self.level, 'players'):
            players = self.level.players or ["[No players]"]
            if not self.level.oldPlayerFolderFormat:
                for player in players:
                    if player != "Player":
                        self.player_UUID[version_utils.getPlayerNameFromUUID(player)] = player
                self.player_UUID["Player"] = "Player"
                players = self.player_UUID.keys()

        else:
            players = ["Player"]
        self.players = players
        tableview = TableView(columns=[
            TableColumn("Player Name", 200),
        ])
        tableview.index = 0
        tableview.num_rows = lambda: len(players)
        tableview.row_data = lambda i: (players[i],)
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow
        self.table = tableview
        l = Label("Player: ")
        col = [l, self.table]

        addButton = Button("Add Player", action=self.tool.addPlayer)
        removeButton = Button("Remove Player", action=self.tool.removePlayer)
        gotoButton = Button("Goto Player", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto Player's View", action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move Player", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align Player to Camera", action=self.tool.movePlayerToCamera)
        col.extend([addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton])

        col = Column(col)
        self.add(col)
        self.shrink_wrap()
Esempio n. 35
0
    def __init__(self, editor):
        Panel.__init__(self, name='Panel.ControlPanel')
        self.editor = editor

        self.bg_color = (0, 0, 0, 0.8)

        header = self.getHeader()
        keysColumn = [Label("")]
        buttonsColumn = [header]

        hotkeys = ([(config.keys.newWorld.get(), "Create New World",
                     editor.mcedit.createNewWorld),
                    (config.keys.quickLoad.get(), "Quick Load", editor.askLoadWorld),
                    (config.keys.open.get(), "Open...", editor.askOpenFile),
                    (config.keys.save.get(), "Save", editor.saveFile),
                    (config.keys.saveAs.get(), "Save As", editor.saveAs),
                    (config.keys.reloadWorld.get(), "Reload", editor.reload),
                    (config.keys.closeWorld.get(), "Close", editor.closeEditor),
                    (config.keys.uploadWorld.get(), "Upload to FTP Server", editor.uploadChanges),
                    (config.keys.gotoPanel.get(), "Goto", editor.showGotoPanel),
                    (config.keys.worldInfo.get(), "World Info", editor.showWorldInfo),
                    (config.keys.undo.get(), "Undo", editor.undo),
                    (config.keys.redo.get(), "Redo", editor.redo),
                    (config.keys.selectAll.get(), "Select All", editor.selectAll),
                    (config.keys.deselect.get(), "Deselect", editor.deselect),
                    (config.keys.viewDistance.get(),
                     AttrRef(editor, 'viewDistanceLabelText'), editor.swapViewDistance),
                    (config.keys.quit.get(), "Quit", editor.quit),
                   ])

        buttons = HotkeyColumn(hotkeys, keysColumn, buttonsColumn, item_spacing=2)

        sideColumn1 = editor.mcedit.makeSideColumn1()
        sideColumn2 = editor.mcedit.makeSideColumn2()
        spaceLabel = Label("")
        sideColumn = Column((sideColumn1, spaceLabel, sideColumn2))

        self.add(Row([buttons, sideColumn]))
        self.shrink_wrap()
Esempio n. 36
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        level = tool.editor.level
        if hasattr(level, 'players'):
            players = level.players or ["[No players]"]
        else:
            players = ["Player"]
        self.players = players
        tableview = TableView(columns=[
            TableColumn("Player Name", 200),
        ])
        tableview.index = 0
        tableview.num_rows = lambda: len(players)
        tableview.row_data = lambda i: (players[i], )
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow
        self.table = tableview
        l = Label("Player: ")
        col = [l, tableview]

        gotoButton = Button("Goto Player", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto Player's View",
                                  action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move Player", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align Player to Camera",
                                    action=self.tool.movePlayerToCamera)
        col.extend(
            [gotoButton, gotoCameraButton, moveButton, moveToCameraButton])

        col = Column(col)
        self.add(col)
        self.shrink_wrap()
Esempio n. 37
0
    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()
Esempio n. 38
0
    def __init__(self, tool):
        Panel.__init__(self, name='Panel.FilterToolPanel')
        self.macro_steps = []
        self.current_step = 0
        self._filter_json = None
        self.keys_panel = None
        self.filterOptionsPanel = None
        self.filterSelect = ChoiceButton([], choose=self.filterChanged, doNotTranslate=True)
        self.binding_button = Button("", action=self.bind_key,
                                     tooltipText="Click to bind this filter to a key")

        self.filterLabel = Label("Filter:", fg_color=(177, 177, 255, 255))
        self.filterLabel.mouse_down = lambda x: mcplatform.platform_open(directories.getFiltersDir())
        self.filterLabel.tooltipText = "Click to open filters folder"

        self.macro_button = Button("Record Macro", action=self.start_record_macro)
        self.filterSelectRow = Row((self.filterLabel, self.filterSelect,
                                    self.macro_button, self.binding_button))

        self.confirmButton = Button("Filter", action=self.confirm)

        self._recording = False
        self._save_macro = False
        self.tool = tool
        self.selectedName = self.filter_json.get("Last Filter Opened", "")
        
        
        utils = FilterUtils(
                            editor=tool.editor, 
                            materials=self.tool.editor.level.materials,
                            custom_widget=tool.editor.addExternalWidget,
                            resize_selection_box=tool.editor._resize_selection_box
                            )
        utils_module = imp.new_module("filter_utils")
        utils_module = utils
        sys.modules["filter_utils"] = utils_module
Esempio n. 39
0
    def __init__(self, editor):
        Panel.__init__(self)
        self.editor = editor

        self.bg_color = (0, 0, 0, 0.8)

        header = self.getHeader()
        keysColumn = [Label("")]
        buttonsColumn = [header]

        hotkeys = ([
            (config.keys.newWorld.get(), "Create New World",
             editor.mcedit.createNewWorld),
            (config.keys.quickLoad.get(), "Quick Load", editor.askLoadWorld),
            (config.keys.open.get(), "Open...", editor.askOpenFile),
            (config.keys.save.get(), "Save", editor.saveFile),
            (config.keys.reloadWorld.get(), "Reload", editor.reload),
            (config.keys.closeWorld.get(), "Close", editor.closeEditor),
            (config.keys.gotoPanel.get(), "Goto", editor.showGotoPanel),
            (config.keys.worldInfo.get(), "World Info", editor.showWorldInfo),
            (config.keys.undo.get(), "Undo", editor.undo),
            (config.keys.redo.get(), "Redo", editor.redo),
            (config.keys.selectAll.get(), "Select All", editor.selectAll),
            (config.keys.deselect.get(), "Deselect", editor.deselect),
            (config.keys.viewDistance.get(),
             AttrRef(editor,
                     'viewDistanceLabelText'), editor.swapViewDistance),
            (config.keys.quit.get(), "Quit", editor.quit),
        ])

        buttons = mceutils.HotkeyColumn(hotkeys, keysColumn, buttonsColumn)

        sideColumn = editor.mcedit.makeSideColumn()

        self.add(Row([buttons, sideColumn]))
        self.shrink_wrap()
Esempio n. 40
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.player_UUID = {}
        self.level = tool.editor.level
        if hasattr(self.level, 'players'):
            players = self.level.players or ["[No players]"]
            if not self.level.oldPlayerFolderFormat:
                for player in players:
                    if player != "Player" and player != "[No players]":
                        if player[4] == "-":
                            os.rename(os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player+".dat"), os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player.replace("-", "", 1)+".dat"))
                            player = player.replace("-", "", 1)
                        self.player_UUID[version_utils.playercache.getPlayerFromUUID(player)] = player
                if "Player" in players:
                    self.player_UUID["Player"] = "Player"
                if "[No players]" not in players:
                    players = sorted(self.player_UUID.keys(), key=lambda x: False if x == "Player" else x)

        else:
            players = ["Player"]
        self.players = players

        self.pages = TabPanel()
        tab_height = self.pages.tab_height

        max_height = tab_height + self.tool.editor.mainViewport.height - self.tool.editor.toolbar.height - self.tool.editor.subwidgets[0].height - self.pages.margin * 2
        #-# Uncomment the following line to have a maximum height for this panel.
        # max_height = min(max_height, 500)

        self.editNBTDataButton = Button("Edit NBT Data", action=self.editNBTData, tooltipText="Open the NBT Explorer to edit player's attributes and inventory")
        addButton = Button("Add Player", action=self.tool.addPlayer)
        removeButton = Button("Remove Player", action=self.tool.removePlayer)
        gotoButton = Button("Goto Player", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto Player's View", action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move Player", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align Player to Camera", action=self.tool.movePlayerToCamera)
        reloadSkin = Button("Reload Skins", action=self.tool.reloadSkins, tooltipText="This pulls skins from the online server, so this may take a while")

        btns = Column([self.editNBTDataButton, addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin], margin=0, spacing=2)
        h = max_height - btns.height - self.pages.margin * 2 - 2 - self.font.size(" ")[1] * 2

        tableview = TableView(nrows=(h - (self.font.size(" ")[1] * 2.5)) / self.font.size(" ")[1],
                              header_height=self.font.size(" ")[1],
                              columns=[TableColumn("Player Name(s):", 200),],
                              height=h,
                             )
        tableview.index = 0
        tableview.num_rows = lambda: len(players)
        tableview.row_data = lambda i: (players[i],)
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow

        def mouse_down(e):
            if e.button == 1 and e.num_clicks > 1:
                self.editNBTData()
            TableRowView.mouse_down(tableview.rows, e)

        tableview.rows.mouse_down = mouse_down

        tableview.rows.tooltipText = "Double-click or use the button below to edit the NBT Data."

        self.table = tableview
        col = Column([tableview, btns], spacing=2)
        self.col = col
        def close():
            self.pages.show_page(col)
        self.nbttree = NBTExplorerToolPanel(self.tool.editor, nbtObject={}, height=max_height, \
                                            close_text="Go Back", no_header=True, close_action=close,
                                            load_text=None)
        self.nbttree.shrink_wrap()
        
        
        self.pages.add_page("Players", col)
        self.nbtpage = Column([self.nbttree,])
        self.nbtpage.shrink_wrap()
        self.pages.add_page("NBT Data", self.nbtpage)
        self.pages.set_rect(self.nbttree._rect)
        self.pages.shrink_wrap()
        self.pages.show_page(col)
        self.add(self.pages)
        self.shrink_wrap()
        self.max_height = max_height
Esempio n. 41
0
    def __init__(self, tool, editor, _parent=None):
        Panel.__init__(self)
        self.tool = tool

        rotaterollRow = Row(
            (
                Label(config.keys.rotateClone.get()),
                Button("Rotate", width=80, action=tool.rotate, enable=self.transformEnable),
                Label(config.keys.rollClone.get()),
                Button("Roll", width=80, action=tool.roll, enable=self.transformEnable),
            )
        )

        flipmirrorRow = Row(
            (
                Label(config.keys.flip.get()),
                Button("Flip", width=80, action=tool.flip, enable=self.transformEnable),
                Label(config.keys.mirror.get()),
                Button("Mirror", width=80, action=tool.mirror, enable=self.transformEnable),
            )
        )

        self.alignCheckBox = CheckBox(ref=AttrRef(self.tool, "chunkAlign"))
        self.alignLabel = Label("Chunk Align")
        self.alignLabel.mouse_down = self.alignCheckBox.mouse_down

        alignRow = Row((self.alignCheckBox, self.alignLabel))

        # headerLabel = Label("Clone Offset")
        if self.useOffsetInput:
            self.offsetInput = CoordsInput(editor)
            self.offsetInput.coordsChanged = tool.offsetChanged
            self.offsetInput.nudgeButton.bg_color = tool.color
            self.offsetInput.nudge = tool.nudge
        else:
            self.nudgeButton = NudgeButton(editor)
            self.nudgeButton.bg_color = tool.color
            self.nudgeButton.nudge = tool.nudge

        repeatField = IntField(ref=AttrRef(tool, "repeatCount"))
        repeatField.min = 1
        repeatField.max = 1000

        repeatRow = Row((Label("Repeat"), repeatField))
        self.repeatField = repeatField

        scaleField = FloatField(ref=AttrRef(tool, "scaleFactor"))
        scaleField.min = 0.1
        scaleField.max = 8

        if self.transformEnable():
            scaleRow = Row((Label("Scale Factor"), scaleField))
        else:
            scaleRow = Row((Label("Scale Factor: 1.0"),))

        self.scaleField = scaleField

        self.copyAirCheckBox = CheckBox(ref=AttrRef(self.tool, "copyAir"))
        self.copyAirLabel = Label("Copy Air")
        self.copyAirLabel.mouse_down = self.copyAirCheckBox.mouse_down
        self.copyAirLabel.tooltipText = "Shortcut: Alt-1"
        self.copyAirCheckBox.tooltipText = self.copyAirLabel.tooltipText

        copyAirRow = Row((self.copyAirCheckBox, self.copyAirLabel))

        self.copyWaterCheckBox = CheckBox(ref=AttrRef(self.tool, "copyWater"))
        self.copyWaterLabel = Label("Copy Water")
        self.copyWaterLabel.mouse_down = self.copyWaterCheckBox.mouse_down
        self.copyWaterLabel.tooltipText = "Shortcut: Alt-2"
        self.copyWaterCheckBox.tooltipText = self.copyWaterLabel.tooltipText

        copyWaterRow = Row((self.copyWaterCheckBox, self.copyWaterLabel))

        self.copyBiomesCheckBox = CheckBox(ref=AttrRef(self.tool, "copyBiomes"))
        self.copyBiomesLabel = Label("Copy Biome(s)")
        self.copyBiomesLabel.mouse_down = self.copyBiomesCheckBox.mouse_down
        self.copyBiomesLabel.tooltipText = "Shortcut: Alt-3"
        self.copyBiomesCheckBox.tooltipText = self.copyBiomesLabel.tooltipText

        copyBiomesRow = Row((self.copyBiomesCheckBox, self.copyBiomesLabel))

        self.staticCommandsCheckBox = CheckBox(ref=AttrRef(self.tool, "staticCommands"))
        self.staticCommandsLabel = Label("Update Command Block Coords")
        self.staticCommandsLabel.mouse_down = self.staticCommandsCheckBox.mouse_down
        self.staticCommandsLabel.tooltipText = "When a command block is moved, and it contains a command, automatically update static coordinates (x y z) within that command.\nShortcut: Alt-4"
        self.staticCommandsCheckBox.tooltipText = self.staticCommandsLabel.tooltipText

        staticCommandsRow = Row((self.staticCommandsCheckBox, self.staticCommandsLabel))

        self.moveSpawnerPosCheckBox = CheckBox(ref=AttrRef(self.tool, "moveSpawnerPos"))
        self.moveSpawnerPosLabel = Label("Update Spawner Coords")
        self.moveSpawnerPosLabel.mouse_down = self.moveSpawnerPosCheckBox.mouse_down
        self.moveSpawnerPosLabel.tooltipText = (
            "When a spawner is moved, automatically update its spawning coordinates.\nShortcut: Alt-5"
        )
        self.moveSpawnerPosCheckBox.tooltipText = self.moveSpawnerPosLabel.tooltipText

        moveSpawnerPosRow = Row((self.moveSpawnerPosCheckBox, self.moveSpawnerPosLabel))

        self.regenerateUUIDCheckBox = CheckBox(ref=AttrRef(self.tool, "regenerateUUID"))
        self.regenerateUUIDLabel = Label("Regenerate Entity UUID")
        self.regenerateUUIDLabel.mouse_down = self.regenerateUUIDCheckBox.mouse_down
        self.regenerateUUIDLabel.tooltipText = (
            "Automatically generate new UUIDs for every entity copied. [RECOMMENDED]\nShortcut: Alt-6"
        )
        self.regenerateUUIDCheckBox.tooltipText = self.regenerateUUIDLabel.tooltipText

        regenerateUUIDRow = Row((self.regenerateUUIDCheckBox, self.regenerateUUIDLabel))

        self.performButton = Button("Clone", width=100, align="c")
        self.performButton.tooltipText = "Shortcut: Enter"
        self.performButton.action = tool.confirm
        self.performButton.enable = lambda: (tool.destPoint is not None)

        max_height = (
            self.tool.editor.mainViewport.height
            - self.tool.editor.toolbar.height
            - self.tool.editor.subwidgets[0].height
        )  # - self.performButton.height - 2

        def buildPage(*items):
            height = 0
            cls = []
            idx = 0
            for i, r in enumerate(items):
                r.margin = 0
                r.shrink_wrap()
                height += r.height
                if height > max_height:
                    cls.append(Column(items[idx:i], spacing=2, margin=0))
                    idx = i
                    height = 0
            cls.append(Column(items[idx:], spacing=2, margin=0))
            return cls

        if self.useOffsetInput:
            cols = buildPage(
                rotaterollRow,
                flipmirrorRow,
                alignRow,
                self.offsetInput,
                repeatRow,
                scaleRow,
                copyAirRow,
                copyWaterRow,
                copyBiomesRow,
                staticCommandsRow,
                moveSpawnerPosRow,
                regenerateUUIDRow,
            )
        else:
            cols = buildPage(
                rotaterollRow,
                flipmirrorRow,
                alignRow,
                self.nudgeButton,
                scaleRow,
                copyAirRow,
                copyWaterRow,
                copyBiomesRow,
                staticCommandsRow,
                moveSpawnerPosRow,
                regenerateUUIDRow,
            )

        row = Row(cols, spacing=0, margin=2)
        row.shrink_wrap()
        col = Column((row, self.performButton), spacing=2)
        self.add(col)
        self.anchor = "lwh"
        self.shrink_wrap()
Esempio n. 42
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.player_UUID = {}
        self.level = tool.editor.level
        if hasattr(self.level, 'players'):
            players = self.level.players or ["[No players]"]
            if not self.level.oldPlayerFolderFormat:
                for player in players:
                    if player != "Player" and player != "[No players]":
                        self.player_UUID[version_utils.playercache.
                                         getPlayerFromUUID(player)] = player
                if "Player" in players:
                    self.player_UUID["Player"] = "Player"
                if "[No players]" not in players:
                    players = sorted(self.player_UUID.keys(),
                                     key=lambda x: False
                                     if x == "Player" else x)

        else:
            players = ["Player"]
        self.players = players

        max_height = self.tool.editor.mainViewport.height - self.tool.editor.toolbar.height - self.tool.editor.subwidgets[
            0].height - self.margin - 2
        max_height = min(max_height, 500)

        addButton = Button("Add Player", action=self.tool.addPlayer)
        removeButton = Button("Remove Player", action=self.tool.removePlayer)
        gotoButton = Button("Goto Player", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto Player's View",
                                  action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move Player", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align Player to Camera",
                                    action=self.tool.movePlayerToCamera)
        reloadSkin = Button(
            "Reload Skins",
            action=self.tool.reloadSkins,
            tooltipText=
            "This pulls skins from the online server, so this may take a while"
        )

        # The Label("qb", doNotTranslate=True) is not nice, but is used to have a correct layout for the table.
        btns = (Label("qb", doNotTranslate=True), addButton, removeButton,
                gotoButton, gotoCameraButton, moveButton, moveToCameraButton,
                reloadSkin)
        max_height -= sum((a.height for a in btns)) - len(btns) * 2

        tableview = TableView(nrows=0,
                              row_height=self.font.size(" ")[1],
                              columns=[
                                  TableColumn("Player Name(s):", 200),
                              ],
                              height=max_height)
        tableview.index = 0
        tableview.num_rows = lambda: len(players)
        tableview.row_data = lambda i: (players[i], )
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow
        self.table = tableview
        col = [self.table]

        col.extend([
            addButton, removeButton, gotoButton, gotoCameraButton, moveButton,
            moveToCameraButton, reloadSkin
        ])

        col = Column(col, spacing=2)
        col.shrink_wrap()
        self.add(col)
        self.shrink_wrap()
Esempio n. 43
0
    def __init__(self, tool, editor, _parent=None):
        Panel.__init__(self)
        self.tool = tool

        rotaterollRow = Row((
            Label(config.keys.rotateClone.get()),
            Button("Rotate",
                   width=80,
                   action=tool.rotate,
                   enable=self.transformEnable),
            Label(config.keys.rollClone.get()),
            Button("Roll",
                   width=80,
                   action=tool.roll,
                   enable=self.transformEnable),
        ))

        flipmirrorRow = Row((
            Label(config.keys.flip.get()),
            Button("Flip",
                   width=80,
                   action=tool.flip,
                   enable=self.transformEnable),
            Label(config.keys.mirror.get()),
            Button("Mirror",
                   width=80,
                   action=tool.mirror,
                   enable=self.transformEnable),
        ))

        self.alignCheckBox = CheckBox(ref=AttrRef(self.tool, 'chunkAlign'))
        self.alignLabel = Label("Chunk Align")
        self.alignLabel.mouse_down = self.alignCheckBox.mouse_down

        alignRow = Row((self.alignCheckBox, self.alignLabel))

        # headerLabel = Label("Clone Offset")
        if self.useOffsetInput:
            self.offsetInput = CoordsInput(editor)
            self.offsetInput.coordsChanged = tool.offsetChanged
            self.offsetInput.nudgeButton.bg_color = tool.color
            self.offsetInput.nudge = tool.nudge
        else:
            self.nudgeButton = NudgeButton(editor)
            self.nudgeButton.bg_color = tool.color
            self.nudgeButton.nudge = tool.nudge

        repeatField = IntField(ref=AttrRef(tool, 'repeatCount'))
        repeatField.min = 1
        repeatField.max = 1000

        repeatRow = Row((Label("Repeat"), repeatField))
        self.repeatField = repeatField

        scaleField = FloatField(ref=AttrRef(tool, 'scaleFactor'))
        scaleField.min = 0.1
        scaleField.max = 8

        if self.transformEnable():
            scaleRow = Row((Label("Scale Factor"), scaleField))
        else:
            scaleRow = Row((Label("Scale Factor: 1.0"), ))

        self.scaleField = scaleField

        self.copyAirCheckBox = CheckBox(ref=AttrRef(self.tool, "copyAir"))
        self.copyAirLabel = Label("Copy Air")
        self.copyAirLabel.mouse_down = self.copyAirCheckBox.mouse_down
        self.copyAirLabel.tooltipText = "Shortcut: Alt-1"
        self.copyAirCheckBox.tooltipText = self.copyAirLabel.tooltipText

        copyAirRow = Row((self.copyAirCheckBox, self.copyAirLabel))

        self.copyWaterCheckBox = CheckBox(ref=AttrRef(self.tool, "copyWater"))
        self.copyWaterLabel = Label("Copy Water")
        self.copyWaterLabel.mouse_down = self.copyWaterCheckBox.mouse_down
        self.copyWaterLabel.tooltipText = "Shortcut: Alt-2"
        self.copyWaterCheckBox.tooltipText = self.copyWaterLabel.tooltipText

        copyWaterRow = Row((self.copyWaterCheckBox, self.copyWaterLabel))

        self.copyBiomesCheckBox = CheckBox(
            ref=AttrRef(self.tool, "copyBiomes"))
        self.copyBiomesLabel = Label("Copy Biomes")
        self.copyBiomesLabel.mouse_down = self.copyBiomesCheckBox.mouse_down
        self.copyBiomesLabel.tooltipText = "Shortcut: Alt-3"
        self.copyBiomesCheckBox.tooltipText = self.copyBiomesLabel.tooltipText

        copyBiomesRow = Row((self.copyBiomesCheckBox, self.copyBiomesLabel))

        self.staticCommandsCheckBox = CheckBox(
            ref=AttrRef(self.tool, "staticCommands"))
        self.staticCommandsLabel = Label("Change Coordinates")
        self.staticCommandsLabel.mouse_down = self.staticCommandsCheckBox.mouse_down
        self.staticCommandsLabel.tooltipText = "Check to automatically change command block static coordinates when moved.\nShortcut: Alt-4"
        self.staticCommandsCheckBox.tooltipText = self.staticCommandsLabel.tooltipText

        staticCommandsRow = Row(
            (self.staticCommandsCheckBox, self.staticCommandsLabel))

        self.moveSpawnerPosCheckBox = CheckBox(
            ref=AttrRef(self.tool, "moveSpawnerPos"))
        self.moveSpawnerPosLabel = Label("Change Spawners")
        self.moveSpawnerPosLabel.mouse_down = self.moveSpawnerPosCheckBox.mouse_down
        self.moveSpawnerPosLabel.tooltipText = "Check to automatically change the position of the mobs in spawners when moved.\nShortcut: Alt-5"
        self.moveSpawnerPosCheckBox.tooltipText = self.moveSpawnerPosLabel.tooltipText

        moveSpawnerPosRow = Row(
            (self.moveSpawnerPosCheckBox, self.moveSpawnerPosLabel))

        self.regenerateUUIDCheckBox = CheckBox(
            ref=AttrRef(self.tool, "regenerateUUID"))
        self.regenerateUUIDLabel = Label("Regenerate UUID")
        self.regenerateUUIDLabel.mouse_down = self.regenerateUUIDCheckBox.mouse_down
        self.regenerateUUIDLabel.tooltipText = "Check to automatically generate new UUIDs for entities.\nShortcut: Alt-6"
        self.regenerateUUIDCheckBox.tooltipText = self.regenerateUUIDLabel.tooltipText

        regenerateUUIDRow = Row(
            (self.regenerateUUIDCheckBox, self.regenerateUUIDLabel))

        self.performButton = Button("Clone", width=100, align="c")
        self.performButton.tooltipText = "Shortcut: Enter"
        self.performButton.action = tool.confirm
        self.performButton.enable = lambda: (tool.destPoint is not None)

        max_height = self.tool.editor.mainViewport.height - self.tool.editor.toolbar.height - self.tool.editor.subwidgets[
            0].height  # - self.performButton.height - 2

        def buildPage(*items):
            height = 0
            cls = []
            idx = 0
            for i, r in enumerate(items):
                r.margin = 0
                r.shrink_wrap()
                height += r.height
                if height > max_height:
                    cls.append(Column(items[idx:i], spacing=2, margin=0))
                    idx = i
                    height = 0
            cls.append(Column(items[idx:], spacing=2, margin=0))
            return cls

        if self.useOffsetInput:
            cols = buildPage(rotaterollRow, flipmirrorRow, alignRow,
                             self.offsetInput, repeatRow, scaleRow, copyAirRow,
                             copyWaterRow, copyBiomesRow, staticCommandsRow,
                             moveSpawnerPosRow, regenerateUUIDRow)
        else:
            cols = buildPage(rotaterollRow, flipmirrorRow, alignRow,
                             self.nudgeButton, scaleRow, copyAirRow,
                             copyWaterRow, copyBiomesRow, staticCommandsRow,
                             moveSpawnerPosRow, regenerateUUIDRow)

        row = Row(cols, spacing=0, margin=2)
        row.shrink_wrap()
        col = Column((row, self.performButton), spacing=2)
        self.add(col)
        self.anchor = "lwh"
        self.shrink_wrap()
Esempio n. 44
0
    def __init__(self,
                 editor,
                 nbtObject=None,
                 fileName=None,
                 dontSaveRootTag=False,
                 dataKeyName='Data',
                 **kwargs):
        """..."""
        Panel.__init__(self)
        self.editor = editor
        self.nbtObject = nbtObject
        self.fileName = fileName
        self.dontSaveRootTag = dontSaveRootTag
        self.displayed_item = None
        self.dataKeyName = dataKeyName
        self.init_data()
        btnRow = Row(
            [
                Button({
                    True: "Save",
                    False: "OK"
                }[fileName != None],
                       action=kwargs.get('ok_action', self.save_NBT),
                       tooltipText="Save your change in the NBT data."),
                Button("Reset",
                       action=self.reset,
                       tooltipText="Reset ALL your changes in the NBT data."),
                Button("Close", action=self.close),
            ],
            margin=1,
            spacing=4,
        )
        btnRow.shrink_wrap()

        if kwargs.get('no_header', False):
            self.max_height = max_height = kwargs.get(
                'height', editor.mainViewport.height - editor.toolbar.height -
                editor.subwidgets[0].height) - (self.margin *
                                                2) - btnRow.height - 2
        else:
            header = Label("NBT Explorer")
            self.max_height = max_height = kwargs.get(
                'height', editor.mainViewport.height - editor.toolbar.height -
                editor.subwidgets[0].height) - header.height - (
                    self.margin * 2) - btnRow.height - 2
        self.setCompounds()
        self.tree = NBTTree(height=max_height,
                            inner_width=250,
                            data=self.data,
                            compound_types=self.compounds,
                            draw_zebra=False,
                            _parent=self,
                            styles=bullet_styles)
        col = Column([self.tree, btnRow], margin=0, spacing=2)
        col.shrink_wrap()
        row = [
            col,
            Column([
                Label("", width=300),
            ],
                   height=max_height + btnRow.height + 2)
        ]
        self.displayRow = Row(row, height=max_height + btnRow.height + 2)
        if kwargs.get('no_header', False):
            self.add(
                Column([
                    self.displayRow,
                ],
                       height=max_height + btnRow.height + 2,
                       margin=0))
        else:
            self.add(Column([header, self.displayRow], margin=0))
        self.shrink_wrap()
        self.side_panel = None
Esempio n. 45
0
    def __init__(self, tool):
        Panel.__init__(self, name='Panel.PlayerPositionPanel')
        self.tool = tool
        self.player_UUID = {"UUID": [], "Name": []}
        self.level = tool.editor.level
        self.playercache = PlayerCache()
        # Add this instance to PlayerCache 'targets'. PlayerCache generated processes will call
        # this instance 'update_player' method when they have finished their execution.
        self.playercache.add_target(self.update_player)

        if hasattr(self.level, 'players'):
            players = self.level.players or ["[No players]"]
            if not self.level.oldPlayerFolderFormat:
                for player in players:
                    if player != "Player" and player != "[No players]":
                        if len(player) > 4 and player[4] == "-":
                            os.rename(
                                os.path.join(
                                    self.level.worldFolder.getFolderPath(
                                        "playerdata"), player + ".dat"),
                                os.path.join(
                                    self.level.worldFolder.getFolderPath(
                                        "playerdata"),
                                    player.replace("-", "", 1) + ".dat"))
                            player = player.replace("-", "", 1)


#                         print 5
                        data = self.playercache.getPlayerInfo(
                            player, use_old_data=True)
                        #self.player_UUID[data[0]] = data[1]
                        self.player_UUID["UUID"].append(data[0])
                        self.player_UUID["Name"].append(data[1])
                        #self.player_UUID[player] = data
                if "Player" in players:
                    #self.player_UUID["Player (Single Player)"] = "Player"
                    self.player_UUID["UUID"].append("Player")
                    self.player_UUID["Name"].append("Player (Single Player)")
                if "[No players]" not in players:
                    self.player_names = sorted(
                        self.player_UUID.values(),
                        key=lambda x: False
                        if x == "Player (Single Player)" else x)
                else:
                    self.player_UUID["UUID"].append("[No players]")
                    self.player_UUID["Name"].append("[No players]")

        else:
            players = ["Player (Single Player)"]
        self.players = players

        if 'Player' in self.player_UUID[
                'UUID'] and 'Player (Single Player)' in self.player_UUID[
                    'Name']:
            self.player_UUID['UUID'].insert(
                0, self.player_UUID['UUID'].pop(
                    self.player_UUID['UUID'].index('Player')))
            self.player_UUID['Name'].insert(
                0, self.player_UUID['Name'].pop(
                    self.player_UUID['Name'].index('Player (Single Player)')))

        self.pages = TabPanel()
        tab_height = self.pages.tab_height

        max_height = tab_height + self.tool.editor.mainViewport.height - self.tool.editor.toolbar.height - self.tool.editor.subwidgets[
            0].height - self.pages.margin * 2
        #-# Uncomment the following line to have a maximum height for this panel.
        # max_height = min(max_height, 500)

        self.editNBTDataButton = Button(
            "Edit NBT",
            action=self.editNBTData,
            tooltipText=
            "Open the NBT Explorer to edit player's attributes and inventory")
        addButton = Button("Add", action=self.tool.addPlayer)
        removeButton = Button("Remove", action=self.tool.removePlayer)
        gotoButton = Button("Goto", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto View",
                                  action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align to Camera",
                                    action=self.tool.movePlayerToCamera)
        reloadSkin = Button(
            "Reload Skins",
            action=self.tool.reloadSkins,
            tooltipText=
            "This pulls skins from the online server, so this may take a while"
        )

        btns = [self.editNBTDataButton]
        if not isinstance(self.level,
                          pymclevel.leveldbpocket.PocketLeveldbWorld):
            btns.extend([addButton, removeButton])
        btns.extend([
            gotoButton, gotoCameraButton, moveButton, moveToCameraButton,
            reloadSkin
        ])
        btns = Column(btns, margin=0, spacing=2)
        h = max_height - btns.height - self.pages.margin * 2 - 2 - self.font.get_linesize(
        ) * 2

        col = Label('')

        def close():
            self.pages.show_page(col)
        self.nbttree = NBTExplorerToolPanel(self.tool.editor, nbtObject={}, height=max_height, \
                                            close_text="Go Back", no_header=True, close_action=close,
                                            load_text=None)
        self.nbttree.shrink_wrap()

        self.nbtpage = Column([self.nbttree])
        self.nbtpage.shrink_wrap()
        self.pages.add_page("NBT Data", self.nbtpage)
        self.pages.set_rect(map(lambda x: x + self.margin, self.nbttree._rect))

        tableview = TableView(
            nrows=(h - (self.font.get_linesize() * 2.5)) /
            self.font.get_linesize(),
            header_height=self.font.get_linesize(),
            columns=[
                TableColumn("Player Name(s):",
                            (self.nbttree.width - (self.margin * 3)) / 3),
                TableColumn("Player UUID(s):",
                            (self.nbttree.width - (self.margin * 3)))
            ],
        )
        tableview.index = 0
        tableview.num_rows = lambda: len(self.player_UUID["UUID"])
        tableview.row_data = lambda i: (self.player_UUID["Name"][i], self.
                                        player_UUID["UUID"][i])
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow

        def mouse_down(e):
            if e.button == 1 and e.num_clicks > 1:
                self.editNBTData()
            TableRowView.mouse_down(tableview.rows, e)

        tableview.rows.mouse_down = mouse_down

        tableview.rows.tooltipText = "Double-click or use the button below to edit the NBT Data."

        self.table = tableview

        col.set_parent(None)
        self.col = col = Column([tableview, btns], spacing=2)

        self.pages.add_page("Players", col, 0)

        self.pages.shrink_wrap()
        self.pages.show_page(col)
        self.add(self.pages)
        self.shrink_wrap()
        self.max_height = max_height
Esempio n. 46
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.player_UUID = {}
        self.level = tool.editor.level
        if hasattr(self.level, 'players'):
            players = self.level.players or ["[No players]"]
            if not self.level.oldPlayerFolderFormat:
                for player in players:
                    if player != "Player" and player != "[No players]":
                        self.player_UUID[version_utils.getPlayerNameFromUUID(
                            player)] = player
                if "Player" in players:
                    self.player_UUID["Player"] = "Player"
                if "[No players]" not in players:
                    players = sorted(self.player_UUID.keys(),
                                     key=lambda x: False
                                     if x == "Player" else x.lower())

        else:
            players = ["Player"]
        self.players = players

        max_height = self.tool.editor.mainViewport.height - self.tool.editor.netherPanel.height - self.tool.editor.subwidgets[
            0].height - self.margin - 2

        addButton = Button("Add Player", action=self.tool.addPlayer)
        removeButton = Button("Remove Player", action=self.tool.removePlayer)
        gotoButton = Button("Goto Player", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto Player's View",
                                  action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move Player", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align Player to Camera",
                                    action=self.tool.movePlayerToCamera)
        reloadSkin = Button(
            "Reload Skins",
            action=self.tool.reloadSkins,
            tooltipText=
            "This pulls skins from the online server, so this may take a while"
        )

        max_height -= sum(
            (a.height
             for a in (addButton, removeButton, gotoButton, gotoCameraButton,
                       moveButton, moveToCameraButton, reloadSkin)))

        tableview = TableView(columns=[
            TableColumn("Player Name(s):", 200),
        ],
                              height=max_height)
        tableview.index = 0
        tableview.num_rows = lambda: len(players)
        tableview.row_data = lambda i: (players[i], )
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow
        self.table = tableview
        col = [self.table]

        col.extend([
            addButton, removeButton, gotoButton, gotoCameraButton, moveButton,
            moveToCameraButton, reloadSkin
        ])

        col = Column(col, margin=0, spacing=2)
        col.shrink_wrap()
        self.add(col)
        self.shrink_wrap()
Esempio n. 47
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool
        self.player_UUID = {}
        self.level = tool.editor.level
        if hasattr(self.level, 'players'):
            players = self.level.players or ["[No players]"]
            if not self.level.oldPlayerFolderFormat:
                for player in players:
                    if player != "Player" and player != "[No players]":
                        if len(player) > 4 and player[4] == "-":
                            os.rename(os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player+".dat"), os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player.replace("-", "", 1)+".dat"))
                            player = player.replace("-", "", 1)
                        data = version_utils.playercache.getPlayerInfo(player)
                        if isinstance(data, tuple):
                            self.player_UUID[data[1]] = data[0]
                        else:
                            self.player_UUID[player] = data
                if "Player" in players:
                    self.player_UUID["Player (Single Player)"] = "Player"
                if "[No players]" not in players:
                    players = sorted(self.player_UUID.keys(), key=lambda x: False if x == "Player (Single Player)" else x)

        else:
            players = ["Player (Single Player)"]
        self.players = players

        self.pages = TabPanel()
        tab_height = self.pages.tab_height

        max_height = tab_height + self.tool.editor.mainViewport.height - self.tool.editor.toolbar.height - self.tool.editor.subwidgets[0].height - self.pages.margin * 2
        #-# Uncomment the following line to have a maximum height for this panel.
        # max_height = min(max_height, 500)

        self.editNBTDataButton = Button("Edit NBT", action=self.editNBTData, tooltipText="Open the NBT Explorer to edit player's attributes and inventory")
        addButton = Button("Add", action=self.tool.addPlayer)
        removeButton = Button("Remove", action=self.tool.removePlayer)
        gotoButton = Button("Goto", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto View", action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align to Camera", action=self.tool.movePlayerToCamera)
        reloadSkin = Button("Reload Skins", action=self.tool.reloadSkins, tooltipText="This pulls skins from the online server, so this may take a while")

        btns = Column([self.editNBTDataButton, addButton, removeButton, gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin], margin=0, spacing=2)
        h = max_height - btns.height - self.pages.margin * 2 - 2 - self.font.get_linesize() * 2

        col = Label('')
        def close():
            self.pages.show_page(col)
        self.nbttree = NBTExplorerToolPanel(self.tool.editor, nbtObject={}, height=max_height, \
                                            close_text="Go Back", no_header=True, close_action=close,
                                            load_text=None)
        self.nbttree.shrink_wrap()

        self.nbtpage = Column([self.nbttree,])
        self.nbtpage.shrink_wrap()
        self.pages.add_page("NBT Data", self.nbtpage)
        self.pages.set_rect(map(lambda x:x+self.margin, self.nbttree._rect))

        tableview = TableView(nrows=(h - (self.font.get_linesize() * 2.5)) / self.font.get_linesize(),
                              header_height=self.font.get_linesize(),
                              columns=[TableColumn("Player Name(s):", self.nbttree.width - (self.margin * 3)),],
                             )
        tableview.index = 0
        tableview.num_rows = lambda: len(players)
        tableview.row_data = lambda i: (players[i],)
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow

        def mouse_down(e):
            if e.button == 1 and e.num_clicks > 1:
                self.editNBTData()
            TableRowView.mouse_down(tableview.rows, e)

        tableview.rows.mouse_down = mouse_down

        tableview.rows.tooltipText = "Double-click or use the button below to edit the NBT Data."

        self.table = tableview

        col.set_parent(None)
        self.col = col = Column([tableview, btns], spacing=2)

        self.pages.add_page("Players", col, 0)

        self.pages.shrink_wrap()
        self.pages.show_page(col)
        self.add(self.pages)
        self.shrink_wrap()
        self.max_height = max_height
Esempio n. 48
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool

        rotateRow = Row((
            Label(config.config.get("Keys", "Rotate").upper()),
            Button("Rotate",
                   width=80,
                   action=tool.rotate,
                   enable=self.transformEnable),
        ))

        rollRow = Row((
            Label(config.config.get("Keys", "Roll").upper()),
            Button("Roll",
                   width=80,
                   action=tool.roll,
                   enable=self.transformEnable),
        ))

        flipRow = Row((
            Label(config.config.get("Keys", "Flip").upper()),
            Button("Flip",
                   width=80,
                   action=tool.flip,
                   enable=self.transformEnable),
        ))

        mirrorRow = Row((
            Label(config.config.get("Keys", "Mirror").upper()),
            Button("Mirror",
                   width=80,
                   action=tool.mirror,
                   enable=self.transformEnable),
        ))

        alignRow = Row((CheckBox(ref=AttrRef(self.tool, 'chunkAlign')),
                        Label("Chunk Align")))

        # headerLabel = Label("Clone Offset")
        if self.useOffsetInput:
            self.offsetInput = CoordsInput()
            self.offsetInput.coordsChanged = tool.offsetChanged
            self.offsetInput.nudgeButton.bg_color = tool.color
            self.offsetInput.nudge = tool.nudge
        else:
            self.nudgeButton = NudgeButton()
            self.nudgeButton.bg_color = tool.color
            self.nudgeButton.nudge = tool.nudge

        repeatField = IntField(ref=AttrRef(tool, 'repeatCount'))
        repeatField.min = 1
        repeatField.max = 50

        repeatRow = Row((Label("Repeat"), repeatField))
        self.repeatField = repeatField

        scaleField = FloatField(ref=AttrRef(tool, 'scaleFactor'))
        scaleField.min = 0.125
        scaleField.max = 8
        dv = scaleField.decrease_value
        iv = scaleField.increase_value

        def scaleFieldDecrease():
            if scaleField.value > 1 / 8.0 and scaleField.value <= 1.0:
                scaleField.value *= 0.5
            else:
                dv()

        def scaleFieldIncrease():
            if scaleField.value < 1.0:
                scaleField.value *= 2.0
            else:
                iv()

        scaleField.decrease_value = scaleFieldDecrease
        scaleField.increase_value = scaleFieldIncrease

        scaleRow = Row((Label("Scale Factor"), scaleField))

        self.scaleField = scaleField

        self.copyAirCheckBox = CheckBox(ref=AttrRef(self.tool, "copyAir"))
        self.copyAirLabel = Label("Copy Air")
        self.copyAirLabel.mouse_down = self.copyAirCheckBox.mouse_down
        self.copyAirLabel.tooltipText = "Shortcut: ALT-1"
        self.copyAirCheckBox.tooltipText = self.copyAirLabel.tooltipText

        copyAirRow = Row((self.copyAirCheckBox, self.copyAirLabel))

        self.copyWaterCheckBox = CheckBox(ref=AttrRef(self.tool, "copyWater"))
        self.copyWaterLabel = Label("Copy Water")
        self.copyWaterLabel.mouse_down = self.copyWaterCheckBox.mouse_down
        self.copyWaterLabel.tooltipText = "Shortcut: ALT-2"
        self.copyWaterCheckBox.tooltipText = self.copyWaterLabel.tooltipText

        copyWaterRow = Row((self.copyWaterCheckBox, self.copyWaterLabel))

        self.copyBiomesCheckBox = CheckBox(
            ref=AttrRef(self.tool, "copyBiomes"))
        self.copyBiomesLabel = Label("Copy Biomes")
        self.copyBiomesLabel.mouse_down = self.copyBiomesCheckBox.mouse_down
        self.copyBiomesLabel.tooltipText = "Shortcut: ALT-3"
        self.copyBiomesCheckBox.tooltipText = self.copyBiomesLabel.tooltipText

        copyBiomesRow = Row((self.copyBiomesCheckBox, self.copyBiomesLabel))

        self.staticCommandsCheckBox = CheckBox(
            ref=AttrRef(self.tool, "staticCommands"))
        self.staticCommandsLabel = Label("Change Coordinates")
        self.staticCommandsLabel.mouse_down = self.staticCommandsCheckBox.mouse_down
        self.staticCommandsLabel.tooltipText = "Check to automatically change command block static coordinates when moved.\nShortcut: ALT-4"
        self.staticCommandsCheckBox.tooltipText = self.staticCommandsLabel.tooltipText

        staticCommandsRow = Row(
            (self.staticCommandsCheckBox, self.staticCommandsLabel))

        self.performButton = Button("Clone", width=100, align="c")
        self.performButton.tooltipText = "Shortcut: ENTER"
        self.performButton.action = tool.confirm
        self.performButton.enable = lambda: (tool.destPoint is not None)
        if self.useOffsetInput:
            col = Column((rotateRow, rollRow, flipRow, mirrorRow, alignRow,
                          self.offsetInput, repeatRow, scaleRow, copyAirRow,
                          copyWaterRow, copyBiomesRow, staticCommandsRow,
                          self.performButton))
        else:
            col = Column(
                (rotateRow, rollRow, flipRow, mirrorRow, alignRow,
                 self.nudgeButton, copyAirRow, copyWaterRow, copyBiomesRow,
                 staticCommandsRow, self.performButton))

        self.add(col)
        self.anchor = "lwh"

        self.shrink_wrap()
Esempio n. 49
0
    def __init__(self, tool):
        Panel.__init__(self, name='Panel.PlayerPositionPanel')
        self.tool = tool
        self.player_UUID = {"UUID": [], "Name": []}
        self.level = tool.editor.level
        self.playercache = PlayerCache()
        # Add this instance to PlayerCache 'targets'. PlayerCache generated processes will call
        # this instance 'update_player' method when they have finished their execution.
        self.playercache.add_target(self.update_player)
        
        if hasattr(self.level, 'players'):
            players = self.level.players or ["[No players]"]
            if not self.level.oldPlayerFolderFormat:
                for player in players:
                    if player != "Player" and player != "[No players]":
                        if len(player) > 4 and player[4] == "-":
                            os.rename(os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player+".dat"), os.path.join(self.level.worldFolder.getFolderPath("playerdata"), player.replace("-", "", 1)+".dat"))
                            player = player.replace("-", "", 1)
#                         print 5
                        data = self.playercache.getPlayerInfo(player, use_old_data=True)
                        #self.player_UUID[data[0]] = data[1]
                        self.player_UUID["UUID"].append(data[0])
                        self.player_UUID["Name"].append(data[1])
                        #self.player_UUID[player] = data
                if "Player" in players:
                    #self.player_UUID["Player (Single Player)"] = "Player"
                    self.player_UUID["UUID"].append("Player")
                    self.player_UUID["Name"].append("Player (Single Player)")
                if "[No players]" not in players:
                    self.player_names = sorted(self.player_UUID.values(), key=lambda x: False if x == "Player (Single Player)" else x)
                else:
                    self.player_UUID["UUID"].append("[No players]")
                    self.player_UUID["Name"].append("[No players]")

        else:
            players = ["Player (Single Player)"]
        self.players = players
        
        if 'Player' in self.player_UUID['UUID'] and 'Player (Single Player)' in self.player_UUID['Name']:
            self.player_UUID['UUID'].insert(0, self.player_UUID['UUID'].pop(self.player_UUID['UUID'].index('Player')))
            self.player_UUID['Name'].insert(0, self.player_UUID['Name'].pop(self.player_UUID['Name'].index('Player (Single Player)')))

        self.pages = TabPanel()
        tab_height = self.pages.tab_height

        max_height = tab_height + self.tool.editor.mainViewport.height - self.tool.editor.toolbar.height - self.tool.editor.subwidgets[0].height - self.pages.margin * 2
        #-# Uncomment the following line to have a maximum height for this panel.
        # max_height = min(max_height, 500)

        self.editNBTDataButton = Button("Edit NBT", action=self.editNBTData, tooltipText="Open the NBT Explorer to edit player's attributes and inventory")
        addButton = Button("Add", action=self.tool.addPlayer)
        removeButton = Button("Remove", action=self.tool.removePlayer)
        gotoButton = Button("Goto", action=self.tool.gotoPlayer)
        gotoCameraButton = Button("Goto View", action=self.tool.gotoPlayerCamera)
        moveButton = Button("Move", action=self.tool.movePlayer)
        moveToCameraButton = Button("Align to Camera", action=self.tool.movePlayerToCamera)
        reloadSkin = Button("Reload Skins", action=self.tool.reloadSkins, tooltipText="This pulls skins from the online server, so this may take a while")

        btns = [self.editNBTDataButton]
        if not isinstance(self.level, pymclevel.leveldbpocket.PocketLeveldbWorld):
            btns.extend([addButton, removeButton])
        btns.extend([gotoButton, gotoCameraButton, moveButton, moveToCameraButton, reloadSkin])
        btns = Column(btns, margin=0, spacing=2)
        h = max_height - btns.height - self.pages.margin * 2 - 2 - self.font.get_linesize() * 2

        col = Label('')

        def close():
            self.pages.show_page(col)
        self.nbttree = NBTExplorerToolPanel(self.tool.editor, nbtObject={}, height=max_height, \
                                            close_text="Go Back", no_header=True, close_action=close,
                                            load_text=None)
        self.nbttree.shrink_wrap()

        self.nbtpage = Column([self.nbttree])
        self.nbtpage.shrink_wrap()
        self.pages.add_page("NBT Data", self.nbtpage)
        self.pages.set_rect(map(lambda x:x+self.margin, self.nbttree._rect))

        tableview = TableView(nrows=(h - (self.font.get_linesize() * 2.5)) / self.font.get_linesize(),
                              header_height=self.font.get_linesize(),
                              columns=[TableColumn("Player Name(s):", (self.nbttree.width - (self.margin * 3)) / 3),
                                       TableColumn("Player UUID(s):", (self.nbttree.width - (self.margin * 3)))],
                              )
        tableview.index = 0
        tableview.num_rows = lambda: len(self.player_UUID["UUID"])
        tableview.row_data = lambda i: (self.player_UUID["Name"][i],self.player_UUID["UUID"][i])
        tableview.row_is_selected = lambda x: x == tableview.index
        tableview.zebra_color = (0, 0, 0, 48)

        def selectTableRow(i, evt):
            tableview.index = i

        tableview.click_row = selectTableRow

        def mouse_down(e):
            if e.button == 1 and e.num_clicks > 1:
                self.editNBTData()
            TableRowView.mouse_down(tableview.rows, e)

        tableview.rows.mouse_down = mouse_down

        tableview.rows.tooltipText = "Double-click or use the button below to edit the NBT Data."

        self.table = tableview

        col.set_parent(None)
        self.col = col = Column([tableview, btns], spacing=2)

        self.pages.add_page("Players", col, 0)

        self.pages.shrink_wrap()
        self.pages.show_page(col)
        self.add(self.pages)
        self.shrink_wrap()
        self.max_height = max_height
Esempio n. 50
0
    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.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.replaceLabel.tooltipText = _("Shortcut: {0}").format(_("Esc"))

            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()
Esempio n. 51
0
    def __init__(self, tool):
        Panel.__init__(self)
        self.tool = tool

        rotateRow = Row((
            Label(config.config.get("Keys", "Rotate").upper()),
            Button("Rotate", width=80, action=tool.rotate, enable=self.transformEnable),
        ))

        rollRow = Row((
            Label(config.config.get("Keys", "Roll").upper()),
            Button("Roll", width=80, action=tool.roll, enable=self.transformEnable),
        ))

        flipRow = Row((
            Label(config.config.get("Keys", "Flip").upper()),
            Button("Flip", width=80, action=tool.flip, enable=self.transformEnable),
        ))

        mirrorRow = Row((
            Label(config.config.get("Keys", "Mirror").upper()),
            Button("Mirror", width=80, action=tool.mirror, enable=self.transformEnable),
        ))

        alignRow = Row((
            CheckBox(ref=AttrRef(self.tool, 'chunkAlign')), Label("Chunk Align")
        ))

        # headerLabel = Label("Clone Offset")
        if self.useOffsetInput:
            self.offsetInput = CoordsInput()
            self.offsetInput.coordsChanged = tool.offsetChanged
            self.offsetInput.nudgeButton.bg_color = tool.color
            self.offsetInput.nudge = tool.nudge
        else:
            self.nudgeButton = NudgeButton()
            self.nudgeButton.bg_color = tool.color
            self.nudgeButton.nudge = tool.nudge

        repeatField = IntField(ref=AttrRef(tool, 'repeatCount'))
        repeatField.min = 1
        repeatField.max = 50

        repeatRow = Row((
            Label("Repeat"), repeatField
        ))
        self.repeatField = repeatField

        scaleField = FloatField(ref=AttrRef(tool, 'scaleFactor'))
        scaleField.min = 0.125
        scaleField.max = 8
        dv = scaleField.decrease_value
        iv = scaleField.increase_value

        def scaleFieldDecrease():
            if scaleField.value > 1 / 8.0 and scaleField.value <= 1.0:
                scaleField.value *= 0.5
            else:
                dv()

        def scaleFieldIncrease():
            if scaleField.value < 1.0:
                scaleField.value *= 2.0
            else:
                iv()

        scaleField.decrease_value = scaleFieldDecrease
        scaleField.increase_value = scaleFieldIncrease

        scaleRow = Row((
            Label("Scale Factor"), scaleField
        ))

        self.scaleField = scaleField

        self.copyAirCheckBox = CheckBox(ref=AttrRef(self.tool, "copyAir"))
        self.copyAirLabel = Label("Copy Air")
        self.copyAirLabel.mouse_down = self.copyAirCheckBox.mouse_down
        self.copyAirLabel.tooltipText = "Shortcut: ALT-1"
        self.copyAirCheckBox.tooltipText = self.copyAirLabel.tooltipText

        copyAirRow = Row((self.copyAirCheckBox, self.copyAirLabel))

        self.copyWaterCheckBox = CheckBox(ref=AttrRef(self.tool, "copyWater"))
        self.copyWaterLabel = Label("Copy Water")
        self.copyWaterLabel.mouse_down = self.copyWaterCheckBox.mouse_down
        self.copyWaterLabel.tooltipText = "Shortcut: ALT-2"
        self.copyWaterCheckBox.tooltipText = self.copyWaterLabel.tooltipText

        copyWaterRow = Row((self.copyWaterCheckBox, self.copyWaterLabel))

        self.copyBiomesCheckBox = CheckBox(ref=AttrRef(self.tool, "copyBiomes"))
        self.copyBiomesLabel = Label("Copy Biomes")
        self.copyBiomesLabel.mouse_down = self.copyBiomesCheckBox.mouse_down
        self.copyBiomesLabel.tooltipText = "Shortcut: ALT-3"
        self.copyBiomesCheckBox.tooltipText = self.copyBiomesLabel.tooltipText

        copyBiomesRow = Row((self.copyBiomesCheckBox, self.copyBiomesLabel))
        
        self.staticCommandsCheckBox = CheckBox(ref=AttrRef(self.tool, "staticCommands"))
        self.staticCommandsLabel = Label("Change Coordinates")
        self.staticCommandsLabel.mouse_down = self.staticCommandsCheckBox.mouse_down
        self.staticCommandsLabel.tooltipText = "Check to automatically change command block static coordinates when moved.\nShortcut: ALT-4"
        self.staticCommandsCheckBox.tooltipText = self.staticCommandsLabel.tooltipText

        staticCommandsRow = Row((self.staticCommandsCheckBox, self.staticCommandsLabel))

        self.performButton = Button("Clone", width=100, align="c")
        self.performButton.tooltipText = "Shortcut: ENTER"
        self.performButton.action = tool.confirm
        self.performButton.enable = lambda: (tool.destPoint is not None)
        if self.useOffsetInput:
            col = Column((
            rotateRow, rollRow, flipRow, mirrorRow, alignRow, self.offsetInput, repeatRow, scaleRow, copyAirRow,
            copyWaterRow, copyBiomesRow, staticCommandsRow, self.performButton))
        else:
            col = Column((
            rotateRow, rollRow, flipRow, mirrorRow, alignRow, self.nudgeButton, copyAirRow, copyWaterRow, copyBiomesRow,
            staticCommandsRow, self.performButton))

        self.add(col)
        self.anchor = "lwh"

        self.shrink_wrap()