def button(self, text, onClick, scale=1.0, parent=None, textAlign=TextNode.A_left, **alignArgs): if parent is None: parent = self.mainMenuNode colours = self.app.theme.colours result = DirectButton( text=text, text_fg=colours.mainMenuColour, text1_fg=colours.mainMenuClicked, text2_fg=colours.mainMenuHighlight, text3_fg=colours.disabledButton, scale=scale * 0.08, command=onClick, parent=parent, relief=None, textMayChange=True, text_align=textAlign, ) align(result, **alignArgs) self.addDirect(result) return result
def _checkBox(self, parent, text, y): colours = self.app.theme.colours label = DirectLabel( parent=parent, text=text, text_scale=0.04, text_fg=colours.listboxButtons, relief=None, ) align(label, left=0.38, midZ=y) result = DirectCheckButton( parent=parent, scale=0.04, pos=(0.35, 0, y), command=self.checkBoxChanged, ) return result
def show(self): self.archivist.refresh() self.selectedGameButton = None while self.archivesGamesList['items']: self.archivesGamesList.removeItem( self.archivesGamesList['items'][0]) colours = self.app.theme.colours games = self.archivist.getGames() for game in games: gameName = os.path.splitext(os.path.basename(game.filename))[0] button = DirectButton( text=gameName, text_fg=colours.listboxButtons, text1_fg=colours.listboxSelectedButtons, text_align=TextNode.ALeft, scale=0.04, command=self.selectArchiveGame, relief=None, ) button['extraArgs'] = [button] align(button, left=0) button.gameFile = game self.archivesGamesList.addItem(button) if games: self.selectArchiveGame(self.archivesGamesList['items'][0]) else: self.archivesGamesList.addItem( DirectLabel( text='No compatible game files found', text_scale=0.04, text_fg=colours.noGamesColour, text_align=TextNode.ALeft, relief=None, ))
def setup(self, archivesNode): button = DirectButton( text='Load replay from file...', scale=0.04, command=self.showLoadReplayFileDialog, parent=archivesNode, pad=(1, 0.3), ) align(button, midX=0, top=0.45) label = DirectLabel( text='- or -', text_scale=0.06, text_align=TextNode.ACenter, relief=None, parent=archivesNode, ) align(label, midX=0, top=0.33) colours = self.app.theme.colours self.archivesGamesList = DirectScrolledList( decButton_pos=(0.4, 0, 0.17), decButton_text='up', decButton_text_scale=0.04, decButton_borderWidth=(0.005, 0.005), decButton_pad=(0.03, 0.01), decButton_text3_fg=colours.disabledButton, incButton_pos=(0.4, 0, -0.51), incButton_text='down', incButton_text_scale=0.04, incButton_borderWidth=(0.005, 0.005), incButton_pad=(0.03, 0.01), incButton_text3_fg=colours.disabledButton, frameSize=(0.0, 0.8, -0.55, 0.22), frameColor=colours.replayMenu, pos=(-0.85, 0, 0), numItemsVisible=13, forceHeight=0.045, itemFrame_pos=(0.02, 0, 0.1), parent=archivesNode, ) DirectButton( text='refresh', text_align=TextNode.ACenter, scale=0.04, command=self.show, parent=archivesNode, pad=(0.9, 0.3), pos=(-0.175, 0, 0.162), ) frame = DirectFrame( parent=archivesNode, pos=(0.45, 0, 0.07), frameSize=(-0.4, 0.4, -0.09, 0.15), frameColor=colours.replayMenu, ) self.archiveNameLabel = DirectLabel( parent=frame, text='', pos=(0, 0, 0.1), text_scale=0.04, text_fg=colours.listboxButtons, text_align=TextNode.ACenter, relief=None, ) self.archiveTimeLabel = DirectLabel( parent=frame, text='No game selected', pos=(0, 0, 0.05), text_scale=0.04, text_fg=colours.listboxButtons, text_align=TextNode.ACenter, relief=None, ) self.archiveDurationLabel = DirectLabel( parent=frame, text='', pos=(0, 0, -0.05), text_scale=0.04, text_fg=colours.listboxButtons, text_align=TextNode.ACenter, relief=None, ) self.archiveReplayButton = DirectButton( text='Watch replay', text_align=TextNode.ACenter, scale=0.04, parent=archivesNode, pad=(0.9, 0.3), pos=(0.45, 0, -0.1), text3_fg=colours.disabledButton, command=self.watchSelectedReplay, ) self.archiveStatsButton = DirectButton( text='View game statistics', text_align=TextNode.ACenter, scale=0.04, parent=archivesNode, pad=(0.9, 0.3), pos=(0.45, 0, -0.2), text3_fg=colours.disabledButton, command=self.viewSelectedGameStats, ) self.scene.button( 'back', self.scene.showMainMenu, right=0.87, z=-0.67, parent=archivesNode, )
def setup(self, node): self.node = node colours = self.app.theme.colours DirectFrame( parent=self.node, pos=(0, 0, 0), frameSize=(-0.9, 0.9, -0.55, 0.37), frameColor=colours.playMenu, relief=DGG.GROOVE, borderWidth=(0.02, 0.02), ) self.mainNode = self.scene.reparent( NodePath('settingsMain'), self.node) self.mainNode.hide() self.displayNode = self.scene.reparent( NodePath('displaySettings'), self.node) self.displayNode.hide() self.displaySettingsScreen.setup(self.displayNode) self.audioNode = self.scene.reparent( NodePath('audioSettings'), self.node) self.audioNode.hide() self.audioSettingsScreen.setup(self.audioNode) self.controlNode = self.scene.reparent( NodePath('controlSettings'), self.node) self.controlNode.hide() self.controlSettingsScreen.setup(self.controlNode) BUTTON_PROPERTIES = { 'scale': 0.04, 'frameSize': (-7.0, 7.0, -1.0, 1.5), 'parent': self.mainNode, } button = DirectButton( text='Display', command=self.showDisplaySettings, **BUTTON_PROPERTIES ) align(button, midX=0, midZ=2.5*0.04) button = DirectButton( text='Audio', command=self.showAudioSettings, **BUTTON_PROPERTIES ) align(button, midX=0, midZ=0) button = DirectButton( text='Controls', command=self.showControlSettings, **BUTTON_PROPERTIES ) align(button, midX=0, midZ=-2.5*0.04) button = DirectButton( text='Back', command=self.close, **BUTTON_PROPERTIES ) align(button, midX=0, midZ=-6*0.04)
def setup(self, node): colours = self.app.theme.colours TEXT_PROPERTIES = { 'parent': node, 'text_scale': 0.038, 'text_fg': colours.listboxButtons, 'text_align': TextNode.A_right, 'relief': None, } KEY_PROPERTIES = { 'parent': node, 'scale': 0.038, 'frameColor': self.COLOUR_VALID, 'frameSize': (-3.0, 3.0, -0.7, 0.7), 'text_align': TextNode.A_center, 'text_scale': 0.9, 'text_pos': (0, -0.18), 'relief': DGG.FLAT, 'textMayChange': True, 'command': self.actionSelected, } movement = [ACTION_JUMP, ACTION_DOWN, ACTION_LEFT, ACTION_RIGHT] menus = [ACTION_MAIN_MENU, ACTION_MORE_MENU] actions = [ ACTION_UPGRADE_MENU, ACTION_USE_UPGRADE, ACTION_ABANDON_UPGRADE, ACTION_EDIT_PLAYER_INFO, ACTION_READY, ACTION_PAUSE_GAME, ACTION_EMOTE, ] misc = [ACTION_CHAT, ACTION_FOLLOW] upgrades = [ upgradeClass.action for upgradeClass in sorted( allUpgrades, key=lambda upgradeClass: upgradeClass.order)] upgrades.append(ACTION_CLEAR_UPGRADE) display = [ ACTION_LEADERBOARD_TOGGLE, ACTION_HUD_TOGGLE, ACTION_TERMINAL_TOGGLE] actionNames = { ACTION_ABANDON_UPGRADE: 'Abandon upgrade', ACTION_UPGRADE_MENU: 'Select upgrade', ACTION_USE_UPGRADE: 'Activate upgrade', ACTION_EDIT_PLAYER_INFO: 'Change nick / hat', ACTION_CHAT: 'Chat', ACTION_DOWN: 'Drop down', ACTION_EMOTE: 'Emote', ACTION_FOLLOW: 'Auto pan (replay)', ACTION_JUMP: 'Jump', ACTION_LEADERBOARD_TOGGLE: 'Show leaderboard', ACTION_LEFT: 'Move left', ACTION_MAIN_MENU: 'Main menu', ACTION_MORE_MENU: 'Advanced', ACTION_CLEAR_UPGRADE: 'Deselect upgrade', ACTION_READY: 'Toggle ready', ACTION_PAUSE_GAME: 'Pause/resume', ACTION_RIGHT: 'Move right', ACTION_HUD_TOGGLE: 'Toggle HUD', ACTION_TERMINAL_TOGGLE: 'Toggle terminal', } actionNames.update((upgradeClass.action, upgradeClass.name) for upgradeClass in allUpgrades) # Organise the categories by column self.layout = [ [movement, menus], [actions, display], [upgrades, misc], ] xPos = -0.68 for column in self.layout: # Each column yPos = 0.30 for category in column: # Each category for action in category: # Each action # Draw action name (eg. Respawn) label = DirectLabel( text=actionNames[action], **TEXT_PROPERTIES ) align(label, right=xPos, midZ=yPos) # Create input box box = DirectButton( text='', extraArgs=[action], **KEY_PROPERTIES ) align(box, left=xPos + 0.03, midZ=yPos) self.inputLookup[action] = box yPos -= 0.07 # Between items yPos -= 0.08 # Between categories xPos += 0.65 # Between columns BUTTON_PROPERTIES = { 'scale': 0.04, 'frameSize': (-5.0, 5.0, -1.0, 1.5), 'parent': node, } self.restoreDefaultButton = DirectButton( text='Restore defaults', # scale=0.04, # parent=node, command=self.restoreDefaults, # text_align=TextNode.A_left, # pad=(0.5, 0.2) **BUTTON_PROPERTIES ) align(self.restoreDefaultButton, midX=0, z=-0.63) self.saveButton = DirectButton( text='Save', command=self.save, **BUTTON_PROPERTIES ) align(self.saveButton, left=-0.87, z=-0.63) self.saveButton.hide() self.finishButton = DirectButton( text='Back', command=self.cancelPressed, **BUTTON_PROPERTIES ) align(self.finishButton, right=0.87, z=-0.63)
def setup(self, node): colours = self.app.theme.colours SLIDER_PROPERTIES = { 'range': (0, 100), 'pageSize': 100, 'scrollSize': 0, 'parent': node, 'scale': 0.5, 'frameSize': (-0.85, 0.85, -0.08, 0.08), 'thumb_relief': DGG.RIDGE, } TEXT_PROPERTIES = { 'parent': node, 'text_scale': 0.08, 'text_fg': colours.listboxButtons, 'text_align': TextNode.A_left, 'relief': None, 'textMayChange': True, } label = DirectLabel( text='Music volume', **TEXT_PROPERTIES ) align(label, left=-0.85, midZ=0.25) self.musicSlider = DirectSlider(**SLIDER_PROPERTIES) align(self.musicSlider, left=-0.2, midZ=0.25) self.musicLabel = DirectLabel( text='100', **TEXT_PROPERTIES ) align(self.musicLabel, left=0.70, midZ=0.25) label = DirectLabel( text='Enable music', **TEXT_PROPERTIES ) align(label, left=-0.85, midZ=0.10) self.musicCheckbox = DirectCheckButton( scale=0.06, parent=node, command=self.applySettings, ) align(self.musicCheckbox, left=-0.2, midZ=0.10) label = DirectLabel( text='Sound volume', **TEXT_PROPERTIES ) align(label, left=-0.85, midZ=-0.05) self.soundSlider = DirectSlider(**SLIDER_PROPERTIES) align(self.soundSlider, left=-0.2, midZ=-0.05) self.soundLabel = DirectLabel( text='100', **TEXT_PROPERTIES ) align(self.soundLabel, left=0.70, midZ=-0.05) label = DirectLabel( text='Enable sound', **TEXT_PROPERTIES ) align(label, left=-0.85, midZ=-0.20) self.soundCheckbox = DirectCheckButton( scale=0.06, parent=node, command=self.applySettings, ) align(self.soundCheckbox, left=-0.2, midZ=-0.20) BUTTON_PROPERTIES = { 'scale': 0.04, 'frameSize': (-5.0, 5.0, -1.0, 1.5), 'parent': node, } button = DirectButton( text='Back', command=self.parent.showMainButtons, **BUTTON_PROPERTIES ) align(button, right=0.87, z=-0.63)
def setup(self, node): colours = self.app.theme.colours TEXT_PROPERTIES = { 'parent': node, 'text_scale': 0.08, 'text_fg': colours.listboxButtons, 'text_align': TextNode.A_left, 'relief': None, } DROPDOWN_PROPERTIES = { 'parent': node, 'scale': 0.06, 'textMayChange': True, 'frameSize': (-0.5, 12, -0.7, 1.05), 'command': self.optionChanged, } label = DirectLabel( text='Screen resolution', **TEXT_PROPERTIES ) align(label, left=-0.85, midZ=0.25) self.resolutionMenu = DirectOptionMenu( # If there isn't at least one item by default, the text alignment # will be all messed up when adding the resolutions. items=[''], **DROPDOWN_PROPERTIES ) align(self.resolutionMenu, left=0, midZ=0.25) label = DirectLabel( text='Display mode', **TEXT_PROPERTIES ) align(label, left=-0.85, midZ=0.10) self.displayModeMenu = DirectOptionMenu( items=self.DISPLAY_MODE_OPTIONS, **DROPDOWN_PROPERTIES ) align(self.displayModeMenu, left=0, midZ=0.10) label = DirectLabel( text='Detail level', **TEXT_PROPERTIES ) align(label, left=-0.85, midZ=-0.05) self.detailMenu = DirectOptionMenu( items=list(self.DETAIL_LEVEL_OPTIONS.keys()), **DROPDOWN_PROPERTIES ) align(self.detailMenu, left=0, midZ=-0.05) label = DirectLabel( text='Show FPS', **TEXT_PROPERTIES ) align(label, left=-0.85, midZ=-0.20) self.showFPS = DirectCheckButton( scale=0.06, parent=node, pos=(0, 0, -0.20), command=self.optionChanged ) align(self.showFPS, left=0, midZ=-0.20) BUTTON_PROPERTIES = { 'scale': 0.04, 'frameSize': (-5.0, 5.0, -1.0, 1.5), 'parent': node, } self.saveButton = DirectButton( text='Save', command=self.saveSettings, **BUTTON_PROPERTIES ) align(self.saveButton, left=-0.87, z=-0.63) self.saveButton.hide() self.finishButton = DirectButton( text='Back', command=self.cancelPressed, **BUTTON_PROPERTIES ) align(self.finishButton, right=0.87, z=-0.63)