def buildWidgets(self): for w in self.subwidgets: w.set_parent(None) helpColumn = [] self.root.movementLabel = 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()), ), doNotTranslate=True) label.anchor = 'whrt' label.align = 'r' helpColumn.append(label) def addHelp(text, dnt=False): label = albow.Label(text, doNotTranslate=dnt) label.anchor = 'whrt' label.align = "r" helpColumn.append(label) return label self.root.slowDownLabel = addHelp(_("{0} to slow down").format(_(config.keys.brake.get())), dnt=True) self.camCont = addHelp("Right-click to toggle camera control") self.toolDist = addHelp("Mousewheel to control tool distance") self.root.detailsLabel = addHelp(_("Hold {0} for details").format(_(config.keys.showBlockInfo.get())), dnt=True) self.helpColumn = 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)
def addHelp(text, dnt=False): label = albow.Label(text, self.root.surface.get_width(), doNotTranslate=dnt) label.anchor = 'whrt' label.align = "r" helpColumn.append(label) return label
def __init__(self, mcedit): Dialog.__init__(self) #.# spacing = 0 keyConfigTable = albow.TableView( nrows=30, columns=[ albow.TableColumn("Command", 200, "l"), albow.TableColumn("Assigned Key", 150, "r") ]) keyConfigTable.num_rows = lambda: len(self.keyConfigKeys) keyConfigTable.row_data = self.getRowData keyConfigTable.row_is_selected = lambda x: x == self.selectedKeyIndex keyConfigTable.click_row = self.selectTableRow keyConfigTable.key_down = self.key_down keyConfigTable.key_up = self.key_up #.# self.changes = {} self.changesNum = False self.enter = 0 self.root = None self.editor = None tableWidget = albow.Widget() tableWidget.add(keyConfigTable) tableWidget.shrink_wrap() self.keyConfigTable = keyConfigTable buttonRow = (albow.Button("Assign Key...", action=self.askAssignSelectedKey), albow.Button("Done", action=self.done), albow.Button("Cancel", action=self.cancel)) buttonRow = albow.Row(buttonRow) resetToDefaultRow = albow.Row( (albow.Button("Reset to default", action=self.resetDefault), )) choiceButton = mceutils.ChoiceButton( ["WASD", "Arrows", "Numpad", "WASD Old"], choose=self.choosePreset) if config.keys.forward.get() == "Up": choiceButton.selectedChoice = "Arrows" elif config.keys.forward.get() == "[8]": choiceButton.selectedChoice = "Numpad" elif config.keys.brake.get() == "Space": choiceButton.selectedChoice = "WASD Old" self.oldChoice = choiceButton.selectedChoice choiceRow = albow.Row((albow.Label("Presets: "), choiceButton)) self.choiceButton = choiceButton col = albow.Column( (tableWidget, choiceRow, buttonRow, resetToDefaultRow), spacing=spacing, margin=0) self.add(col) self.shrink_wrap()
def __init__(self, mcedit): Dialog.__init__(self) self.mcedit = mcedit fieldOfViewRow = mceutils.FloatInputRow("Field of View: ", ref=config.settings.fov, width=100, min=25, max=120) targetFPSRow = mceutils.IntInputRow("Target FPS: ", ref=config.settings.targetFPS, width=100, min=1, max=60) bufferLimitRow = mceutils.IntInputRow("Vertex Buffer Limit (MB): ", ref=config.settings.vertexBufferLimit, width=100, min=0) fastLeavesRow = mceutils.CheckBoxLabel("Fast Leaves", ref=config.settings.fastLeaves, tooltipText="Leaves are solid, like Minecraft's 'Fast' graphics") roughGraphicsRow = mceutils.CheckBoxLabel("Rough Graphics", ref=config.settings.roughGraphics, tooltipText="All blocks are drawn the same way (overrides 'Fast Leaves')") enableMouseLagRow = mceutils.CheckBoxLabel("Enable Mouse Lag", ref=config.settings.enableMouseLag, tooltipText="Enable choppy mouse movement for faster loading.") packs = resource_packs.packs.get_available_resource_packs() packs.remove('Default') packs.sort() packs.insert(0, 'Default') self.resourcePackButton = mceutils.ChoiceButton(packs, choose=self.change_texture) self.resourcePackButton.selectedChoice = resource_packs.packs.get_selected_resource_pack_name() settingsColumn = albow.Column((fastLeavesRow, roughGraphicsRow, enableMouseLagRow, # texturePackRow, fieldOfViewRow, targetFPSRow, bufferLimitRow, self.resourcePackButton, ), align='r') settingsColumn = albow.Column((albow.Label("Settings"), settingsColumn)) settingsRow = albow.Row((settingsColumn,)) optionsColumn = albow.Column((settingsRow, albow.Button("OK", action=self.dismiss))) self.add(optionsColumn) self.shrink_wrap()
def __init__(self, mcedit): Dialog.__init__(self) self.mcedit = mcedit self.saveOldConfig = { config.settings.fov: config.settings.fov.get(), config.settings.targetFPS: config.settings.targetFPS.get(), config.settings.vertexBufferLimit: config.settings.vertexBufferLimit.get(), config.settings.fastLeaves: config.settings.fastLeaves.get(), config.settings.roughGraphics: config.settings.roughGraphics.get(), config.settings.enableMouseLag: config.settings.enableMouseLag.get(), config.settings.maxViewDistance: config.settings.maxViewDistance.get() } self.saveOldResourcePack = ResourcePackHandler.Instance( ).get_selected_resource_pack_name() self.fieldOfViewRow = albow.FloatInputRow("Field of View: ", ref=config.settings.fov, width=100, min=25, max=120) self.targetFPSRow = albow.IntInputRow("Target FPS: ", ref=config.settings.targetFPS, width=100, min=1, max=60) self.bufferLimitRow = albow.IntInputRow( "Vertex Buffer Limit (MB): ", ref=config.settings.vertexBufferLimit, width=100, min=0) fastLeavesRow = albow.CheckBoxLabel( "Fast Leaves", ref=config.settings.fastLeaves, tooltipText="Leaves are solid, like Minecraft's 'Fast' graphics") roughGraphicsRow = albow.CheckBoxLabel( "Rough Graphics", ref=config.settings.roughGraphics, tooltipText= "All blocks are drawn the same way (overrides 'Fast Leaves')") enableMouseLagRow = albow.CheckBoxLabel( "Enable Mouse Lag", ref=config.settings.enableMouseLag, tooltipText="Enable choppy mouse movement for faster loading.") playerSkins = albow.CheckBoxLabel( "Show Player Skins", ref=config.settings.downloadPlayerSkins, tooltipText="Show player skins while editing the world") self.maxView = albow.IntInputRow( "Max View Distance", ref=config.settings.maxViewDistance, tooltipText= "Sets the maximum view distance for the renderer. Values over 32 can possibly be unstable, so use it at your own risk" ) self.maxView.subwidgets[1]._increment = 2 packs = ResourcePackHandler.Instance().get_available_resource_packs() packs.remove('Default Resource Pack') packs.sort() packs.insert(0, 'Default Resource Pack') self.resourcePackButton = albow.ChoiceButton( packs, choose=self.change_texture, doNotTranslate=True) self.resourcePackButton.selectedChoice = self.saveOldResourcePack settingsColumn = albow.Column( ( fastLeavesRow, roughGraphicsRow, enableMouseLagRow, # texturePackRow, self.fieldOfViewRow, self.targetFPSRow, self.bufferLimitRow, self.maxView, playerSkins, self.resourcePackButton, ), align='r') settingsColumn = albow.Column( (albow.Label("Graphics Settings"), settingsColumn)) settingsRow = albow.Row((settingsColumn, )) buttonsRow = albow.Row((albow.Button("OK", action=self.dismiss), albow.Button("Cancel", action=self.cancel))) resetToDefaultRow = albow.Row( (albow.Button("Reset to default", action=self.resetDefault), )) optionsColumn = albow.Column( (settingsRow, buttonsRow, resetToDefaultRow)) self.add(optionsColumn) self.shrink_wrap()
def addHelp(text, dnt=False): label = albow.Label(text, doNotTranslate=dnt) label.anchor = 'whrt' label.align = "r" helpColumn.append(label) return label
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() #-# Translation live update self.buildWidgets() def buildWidgets(self): for w in self.subwidgets: w.set_parent(None) helpColumn = [] self.root.movementLabel = 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()), ), doNotTranslate=True) label.anchor = 'whrt' label.align = 'r' helpColumn.append(label) def addHelp(text, dnt=False): label = albow.Label(text, doNotTranslate=dnt) label.anchor = 'whrt' label.align = "r" helpColumn.append(label) return label self.root.slowDownLabel = addHelp(_("{0} to slow down").format(_(config.keys.brake.get())), dnt=True) self.camCont = addHelp("Right-click to toggle camera control") self.toolDist = addHelp("Mousewheel to control tool distance") self.root.detailsLabel = addHelp(_("Hold {0} for details").format(_(config.keys.showBlockInfo.get())), dnt=True) self.helpColumn = 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())]) self.root.commandRow = commandRow = albow.HotkeyColumn(hotkeys, keysColumn, buttonsColumn) commandRow.anchor = 'lrh' sideColumn1 = self.mcedit.makeSideColumn1() sideColumn1.anchor = 'wh' spaceLabel = albow.Label("") spaceLabel.anchor = 'wh' sideColumn2 = self.mcedit.makeSideColumn2() sideColumn2.anchor = 'wh' contentRow = albow.Row((commandRow, albow.Column((sideColumn1, spaceLabel, sideColumn2)))) contentRow.center = self.center contentRow.anchor = "rh" self.contentRow = contentRow self.add(contentRow) self.invalidate()
def askAssignKey(self, configKey, labelString=None): if not self.isConfigKey(configKey): self.enter = 0 return panel = Panel() panel.bg_color = (0.5, 0.5, 0.6, 1.0) if labelString is None and configKey != "Fast Nudge": labelString = _( "Press a key to assign to the action \"{0}\"\n\nPress ESC to cancel." ).format(_(configKey)) elif labelString is None: labelString = _( "Press a key to assign to the action \"{0}\"\nNo key means right click to fast nudge.\nPress ESC to cancel." ).format(_(configKey)) label = albow.Label(labelString) unbind_button = Button("Press to unbind", action=self.unbind) column = Column((label, unbind_button)) panel.add(column) panel.shrink_wrap() def panelKeyUp(evt): keyname = self.root.getKey(evt) panel.dismiss(keyname) def panelMouseUp(evt): button = remapMouseButton(evt.button) if button == 3: keyname = "Button 3" elif button == 4: keyname = "Scroll Up" elif button == 5: keyname = "Scroll Down" elif button == 6: keyname = "Button 4" elif button == 7: keyname = "Button 5" if button > 2: panel.dismiss(keyname) panel.key_up = panelKeyUp panel.mouse_up = panelMouseUp self.panel = panel keyname = panel.present() if type(keyname) is bool: return True if keyname == "Return" and self.enter == 1: self.enter = 0 self.askAssignKey(configKey) return True self.enter = 0 _keyname = _(keyname) if keyname != "Escape" and keyname not in [ "Alt-F4", "F1", "F2", "F3", "F4", "F5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "Ctrl-Alt-F9", "Ctrl-Alt-F10" ]: if "Modifier" in configKey and keyname != "Ctrl" and keyname != "Alt" and keyname != "Shift": self.askAssignKey( configKey, _("{0} is not a modifier. Press a new key.\n\nPress ESC to cancel." ).format(_keyname)) return True if configKey in [ 'Down', 'Up', 'Back', 'Forward', 'Left', 'Right', 'Pan Down', 'Pan Up', 'Pan Left', 'Pan Right' ]: if 'Ctrl' in keyname or '-' in keyname: self.askAssignKey( configKey, "Movement keys can't use Ctrl or be with modifiers. Press a new key.\n\nPress ESC to cancel." ) return True filter_keys = [ i for (i, j) in config.config._sections["Filter Keys"].items() if j == _keyname ] if filter_keys: self.askAssignKey( configKey, _("Can't bind. {0} is already used by the \"{1}\" filter.\n Press a new key.\n\nPress ESC to cancel." ).format(_keyname, filter_keys[0])) return True oldkey = config.keys[config.convert(configKey)].get() config.keys[config.convert(configKey)].set(keyname) if oldkey != keyname and configKey not in self.changes: self.changes[configKey] = oldkey self.changesNum = True elif keyname != "Escape": self.askAssignKey( configKey, _("You can't use the key {0}. Press a new key.\n\nPress ESC to cancel." ).format(_keyname)) return True else: return True
def bind_key(self, message=None): panel = Panel() panel.bg_color = (0.5, 0.5, 0.6, 1.0) if not message: message = _("Press a key to assign to the filter \"{0}\"\n\n" "Press ESC to cancel.").format(self.selectedName) label = albow.Label(message) unbind_button = Button("Press to unbind", action=self.unbind_key) column = Column((label, unbind_button)) panel.add(column) panel.shrink_wrap() def panelKeyUp(evt): _key_name = self.root.getKey(evt) panel.dismiss(_key_name) def panelMouseUp(evt): button = keys.remapMouseButton(evt.button) _key_name = None if button == 3: _key_name = "Button 3" elif button == 4: _key_name = "Scroll Up" elif button == 5: _key_name = "Scroll Down" elif button == 6: _key_name = "Button 4" elif button == 7: _key_name = "Button 5" if 2 < button < 8: panel.dismiss(_key_name) panel.key_up = panelKeyUp panel.mouse_up = panelMouseUp self.keys_panel = panel key_name = panel.present() if type(key_name) is bool: return True if key_name != "Escape": if key_name in [ "Alt-F4", "F1", "F2", "F3", "F4", "F5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "Ctrl-Alt-F9", "Ctrl-Alt-F10" ]: self.bind_key( _("You can't use the key {0}.\n" "Press a key to assign to the filter \"{1}\"\n\n" "" "Press ESC to cancel.").format(_(key_name), self.selectedName)) return True keysUsed = [(j, i) for (j, i) in config.config.items("Keys") if i == key_name] if keysUsed: self.bind_key( _("Can't bind. {0} is already used by {1}.\n" "Press a key to assign to the filter \"{2}\"\n\n" "" "Press ESC to cancel.").format(_(key_name), keysUsed[0][0], self.selectedName)) return True filter_keys = [ i for (i, j) in config.config.items("Filter Keys") if j == key_name ] if filter_keys: self.bind_key( _("Can't bind. {0} is already used by the \"{1}\" filter.\n" "Press a new key.\n\n" "" "Press ESC to cancel.").format(_(key_name), filter_keys[0])) return True config.config.set("Filter Keys", self.selectedName.lower(), key_name) config.save() self.reload()
def addHelp(text): label = albow.Label(text) label.anchor = 'whrt' label.align = "r" helpColumn.append(label)
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)
def initComponents(self): """Initilize the window components. Call this after translation hs been loaded.""" autoBrakeRow = albow.CheckBoxLabel( "Autobrake", ref=config.controls.autobrake, tooltipText="Apply brake when not pressing movement keys") swapAxesRow = albow.CheckBoxLabel( "Swap Axes Looking Down", ref=config.controls.swapAxes, tooltipText= "Change the direction of the Forward and Backward keys when looking down" ) cameraAccelRow = albow.FloatInputRow("Camera Acceleration: ", ref=config.controls.cameraAccel, width=100, min=5.0) cameraDragRow = albow.FloatInputRow("Camera Drag: ", ref=config.controls.cameraDrag, width=100, min=1.0) cameraMaxSpeedRow = albow.FloatInputRow( "Camera Max Speed: ", ref=config.controls.cameraMaxSpeed, width=100, min=1.0) cameraBrakeSpeedRow = albow.FloatInputRow( "Camera Braking Speed: ", ref=config.controls.cameraBrakingSpeed, width=100, min=1.0) mouseSpeedRow = albow.FloatInputRow("Mouse Speed: ", ref=config.controls.mouseSpeed, width=100, min=0.1, max=20.0) undoLimitRow = albow.IntInputRow("Undo Limit: ", ref=config.settings.undoLimit, width=100, min=0) maxCopiesRow = albow.IntInputRow( "Copy Stack Size: ", ref=config.settings.maxCopies, width=100, min=0, tooltipText="Maximum number of copied objects.") compassSizeRow = albow.IntInputRow("Compass Size (%): ", ref=config.settings.compassSize, width=100, min=0, max=100) fontProportion = albow.IntInputRow( "Fonts Proportion (%): ", ref=config.settings.fontProportion, width=100, min=0, tooltipText= "Fonts sizing proportion. The number is a percentage.\nRestart needed!" ) albow.resource.font_proportion = config.settings.fontProportion.get() fogIntensityRow = albow.IntInputRow("Fog Intensity (%): ", ref=config.settings.fogIntensity, width=100, min=0, max=100) invertRow = albow.CheckBoxLabel( "Invert Mouse", ref=config.controls.invertMousePitch, tooltipText="Reverse the up and down motion of the mouse.") spaceHeightRow = albow.IntInputRow( "Low Detail Height", ref=config.settings.spaceHeight, tooltipText= "When you are this far above the top of the world, move fast and use low-detail mode." ) blockBufferRow = albow.IntInputRow( "Block Buffer (MB):", ref=albow.AttrRef(self, 'blockBuffer'), min=1, tooltipText= "Amount of memory used for temporary storage. When more than this is needed, the disk is used instead." ) setWindowPlacementRow = albow.CheckBoxLabel( "Set Window Placement", ref=config.settings.setWindowPlacement, tooltipText="Try to save and restore the window position.") rotateBlockBrushRow = albow.CheckBoxLabel( "Rotate block with brush", ref=config.settings.rotateBlockBrush, tooltipText= "When rotating your brush, also rotate the orientation of the block your brushing with" ) compassToggleRow = albow.CheckBoxLabel( "Toggle compass", ref=config.settings.compassToggle) windowSizeRow = albow.CheckBoxLabel( "Window Resize Alert", ref=config.settings.shouldResizeAlert, tooltipText= "Reminds you that the cursor won't work correctly after resizing the window." ) superSecretSettingsRow = albow.CheckBoxLabel( "Super Secret Settings", ref=config.settings.superSecretSettings, tooltipText="Weird stuff happen!") longDistanceRow = albow.CheckBoxLabel( "Long-Distance Mode", ref=config.settings.longDistanceMode, tooltipText= "Always target the farthest block under the cursor, even in mouselook mode." ) flyModeRow = albow.CheckBoxLabel( "Fly Mode", ref=config.settings.flyMode, tooltipText= "Moving forward and Backward will not change your altitude in Fly Mode." ) showCommandsRow = albow.CheckBoxLabel( "Show Commands", ref=config.settings.showCommands, tooltipText= "Show the command in a Command Block when hovering over it.") cancelCommandBlockOffset = albow.CheckBoxLabel( "Cancel Command Block Offset", ref=config.schematicCopying.cancelCommandBlockOffset, tooltipText="Cancels the command blocks coords changed when copied." ) lng = config.settings.langCode.get() langs = sorted(self.getLanguageChoices().items()) langNames = [k for k, v in langs] self.languageButton = albow.ChoiceButton(langNames, choose=self.changeLanguage, doNotTranslate=True) if self.sgnal[lng] in self.languageButton.choices: self.languageButton.selectedChoice = self.sgnal[lng] langButtonRow = albow.Row( (albow.Label("Language", tooltipText="Choose your language."), self.languageButton)) portableList = ["Portable", "Fixed"] self.goPortableButton = goPortableButton = albow.ChoiceButton( portableList, choose=self.togglePortable) goPortableButton.selectedChoice = self.saveOldPortable goPortableButton.tooltipText = self.portableButtonTooltip() goPortableRow = albow.Row( (albow.Label("Install Mode"), goPortableButton)) # Disabled Crash Reporting Option # reportRow = albow.CheckBoxLabel("Report Errors", # ref=config.settings.reportCrashes, # tooltipText="Automatically report errors to the developer.") self.inputs = ( spaceHeightRow, cameraAccelRow, cameraDragRow, cameraMaxSpeedRow, cameraBrakeSpeedRow, blockBufferRow, mouseSpeedRow, undoLimitRow, maxCopiesRow, compassSizeRow, fontProportion, fogIntensityRow, ) options = ( longDistanceRow, flyModeRow, autoBrakeRow, swapAxesRow, invertRow, superSecretSettingsRow, rotateBlockBrushRow, compassToggleRow, showCommandsRow, cancelCommandBlockOffset, langButtonRow, ) + (((sys.platform == "win32" and pygame.version.vernum == (1, 9, 1)) and (windowSizeRow, ) or ())) + ((sys.platform == "win32") and (setWindowPlacementRow, ) or ()) + ((not sys.platform == "darwin") and (goPortableRow, ) or ()) rightcol = albow.Column(options, align='r') leftcol = albow.Column(self.inputs, align='r') optionsColumn = albow.Column( (albow.Label("Options"), albow.Row((leftcol, rightcol), align="t"))) settingsRow = albow.Row((optionsColumn, )) buttonsRow = albow.Row((albow.Button("OK", action=self.dismiss), albow.Button("Cancel", action=self.cancel))) resetToDefaultRow = albow.Row( (albow.Button("Reset to default", action=self.resetDefault), )) optionsColumn = albow.Column( (settingsRow, buttonsRow, resetToDefaultRow)) optionsColumn.key_down = self.key_down self.add(optionsColumn) self.shrink_wrap()
def askAssignKey(self, configKey, labelString=None): if not self.isConfigKey(configKey): self.enter = 0 return panel = Panel() panel.bg_color = (0.5, 0.5, 0.6, 1.0) if labelString is None: labelString = _( "Press a key to assign to the action \"{0}\"\n\nPress ESC to cancel. Press Shift-ESC to unbind." ).format(configKey) label = albow.Label(labelString) panel.add(label) panel.shrink_wrap() def panelKeyUp(evt): keyname = self.root.getKey(evt) panel.dismiss(keyname) def panelMouseUp(evt): button = remapMouseButton(evt.button) if button == 3: keyname = "Button 3" elif button == 4: keyname = "Scroll Up" elif button == 5: keyname = "Scroll Down" elif button == 6: keyname = "Button 4" elif button == 7: keyname = "Button 5" if button > 2: panel.dismiss(keyname) panel.key_up = panelKeyUp panel.mouse_up = panelMouseUp keyname = panel.present() if keyname == "Return" and self.enter == 1: self.enter = 0 self.askAssignKey( configKey, _("Press a key to assign to the action \"{0}\"\n\nPress ESC to cancel. Press Shift-ESC to unbind." ).format(configKey)) return True self.enter = 0 if keyname != "Escape" and keyname != "Shift-Escape" and keyname not in [ "Alt-F4", "F1", "F2", "F3", "F4", "F5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "Ctrl-Alt-F9", "Ctrl-Alt-F10" ]: if "Modifier" in configKey and keyname != "Ctrl" and keyname != "Alt" and keyname != "Shift": self.askAssignKey( configKey, _("{0} is not a modifier. " "Press a new key.\n\n" "Press ESC to cancel. Press Shift-ESC to unbind."). format(keyname)) return True if configKey in [ 'Down', 'Up', 'Back', 'Forward', 'Left', 'Right', 'Pan Down', 'Pan Up', 'Pan Left', 'Pan Right' ]: if 'Ctrl' in keyname: self.askAssignKey( configKey, _("Movement keys can't use Ctrl. " "Press a new key.\n\n" "Press ESC to cancel. Press Shift-ESC to unbind.")) return True oldkey = config.keys[config.convert(configKey)].get() config.keys[config.convert(configKey)].set(keyname) if configKey not in self.changes: self.changes[configKey] = oldkey self.changesNum = True elif keyname == "Shift-Escape": config.keys[config.convert(configKey)].set("None") elif keyname != "Escape": self.askAssignKey( configKey, _("You can't use the key {0}. " "Press a new key.\n\n" "Press ESC to cancel. Press Shift-ESC to unbind.").format( keyname)) return True else: return True