Beispiel #1
0
    def makeSideColumn(self):
        def showLicense():
            platform_open(os.path.join(directories.getDataDir(),
                                       "LICENSE.txt"))

        def showCacheDir():
            platform_open(directories.getCacheDir())

        def showScreenshotsDir():
            platform_open(os.path.join(directories.parentDir, "screenshots"))

        def refresh():
            version_utils.playercache.force_refresh()

        hotkeys = ([
            ("", "Controls", self.showKeyConfig),
            ("", "Graphics", self.showGraphicOptions),
            ("", "Options", self.showOptions),
            ("", "Homepage",
             lambda: platform_open("http://www.mcedit-unified.net"),
             "http://www.mcedit-unified.net"),
            ("", "About MCEdit",
             lambda: platform_open("http://www.mcedit-unified.net/about.html"),
             "http://www.mcedit-unified.net/about.html"),
            ("", "License", showLicense,
             os.path.join(directories.getDataDir(), "LICENSE.txt")),
            ("", "Config Files", showCacheDir, directories.getCacheDir()),
            ("", "Screenshots", showScreenshotsDir,
             os.path.join(directories.parentDir, "screenshots")),
            ("", "Refresh Player Names", refresh)
        ])

        c = mceutils.HotkeyColumn(hotkeys)

        return c
Beispiel #2
0
    def makeSideColumn(self):
        def showLicense():
            platform_open(os.path.join(directories.getDataDir(),
                                       "LICENSE.txt"))

        def showCacheDir():
            platform_open(directories.getCacheDir())

        readmePath = os.path.join(directories.getDataDir(), "README.html")

        hotkeys = ([
            ("", "Controls", self.showKeyConfig),
            ("", "Graphics", self.showGraphicOptions),
            ("", "Options", self.showOptions),
            ("", "Homepage",
             lambda: platform_open("http://khroki.github.io/MCEdit-Unified")),
            ("", "About MCEdit", lambda: platform_open(
                "http://khroki.github.io/MCEdit-Unified/about.html")),
            ("", "Recent Changes",
             lambda: platform_open("http://khroki.github.io/MCEdit-Unified")),
            ("", "License", showLicense),
            ("", "Config Files Folder", showCacheDir),
        ])

        c = mceutils.HotkeyColumn(hotkeys)

        return c
Beispiel #3
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.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 = mceutils.HotkeyColumn(hotkeys,
                                        keysColumn,
                                        buttonsColumn,
                                        item_spacing=2)

        sideColumn = editor.mcedit.makeSideColumn()

        self.add(Row([buttons, sideColumn]))
        self.shrink_wrap()
Beispiel #4
0
class FileOpener(albow.Widget):
    is_gl_container = True

    def __init__(self, mcedit, *args, **kwargs):
        kwargs['rect'] = mcedit.rect
        albow.Widget.__init__(self, *args, **kwargs)
        self.anchor = 'tlbr'
        self.mcedit = mcedit
        self.root = self.get_root()

        helpColumn = []

        label = albow.Label(
            _("{0}/{1}/{2}/{3}/{4}/{5} to move").format(
                config.keys.forward.get(),
                config.keys.left.get(),
                config.keys.back.get(),
                config.keys.right.get(),
                config.keys.up.get(),
                config.keys.down.get(),
            ))
        label.anchor = 'whrt'
        label.align = 'r'
        helpColumn.append(label)

        def addHelp(text):
            label = albow.Label(text)
            label.anchor = 'whrt'
            label.align = "r"
            helpColumn.append(label)

        addHelp(_("{0} to slow down").format(config.keys.brake.get()))
        addHelp("Right-click to toggle camera control")
        addHelp("Mousewheel to control tool distance")
        addHelp(
            _("Hold {0} for details").format(config.keys.showBlockInfo.get()))

        helpColumn = albow.Column(helpColumn, align="r")
        helpColumn.topright = self.topright
        helpColumn.anchor = "whrt"
        # helpColumn.is_gl_container = True
        self.add(helpColumn)

        keysColumn = [albow.Label("")]
        buttonsColumn = [panels.ControlPanel.getHeader()]

        shortnames = []
        for world in self.mcedit.recentWorlds():
            shortname = os.path.basename(world)
            try:
                if pymclevel.MCInfdevOldLevel.isLevel(world):
                    lev = pymclevel.MCInfdevOldLevel(world, readonly=True)
                    shortname = lev.LevelName
                    if lev.LevelName != lev.displayName:
                        shortname = u"{0} ({1})".format(
                            lev.LevelName, lev.displayName)
            except Exception, e:
                logging.warning(
                    'Couldn\'t get name from recent world: {0!r}'.format(e))

            if shortname == "level.dat":
                shortname = os.path.basename(os.path.dirname(world))

            if len(shortname) > 40:
                shortname = shortname[:37] + "..."
            shortnames.append(shortname)

        hotkeys = (
            [(config.keys.newWorld.get(), 'Create New World',
              self.createNewWorld),
             (config.keys.quickLoad.get(), 'Quick Load',
              self.mcedit.editor.askLoadWorld),
             (config.keys.open.get(), 'Open...', self.promptOpenAndLoad)] +
            [('F{0}'.format(i + 1), shortnames[i],
              self.createLoadButtonHandler(world))
             for i, world in enumerate(self.mcedit.recentWorlds())])

        commandRow = mceutils.HotkeyColumn(hotkeys, keysColumn, buttonsColumn)
        commandRow.anchor = 'lrh'

        sideColumn = mcedit.makeSideColumn()
        sideColumn.anchor = 'wh'

        contentRow = albow.Row((commandRow, sideColumn))
        contentRow.center = self.center
        contentRow.anchor = "rh"
        self.add(contentRow)
        self.sideColumn = sideColumn