def __init__(self, render_fsm): ScreenState.__init__(self) self.button_sizes = (-3, 3, -0.4, 0.8) self.render_fsm_ref = render_fsm self.screen_atributes.screen_texts["screen_text:Title"] = ScreenTextFsm("Windows params:", (0, 0.2)) self.screen_atributes.radio_buttons["rb:WinSize 16:9"] = RadioButtonFsm("16:9", (-0.2, 0, 0), self.confirm_command) self.screen_atributes.radio_buttons["rb:WinSize 4:3"] = RadioButtonFsm("4:3", (0.2, 0, 0), self.confirm_command) self.screen_atributes.buttons["but:Confirm"] = ButtonFsm("Confirm", (0, 0, -0.5)) self.screen_atributes.buttons["but:Back"] = ButtonFsm("Back", (0, 0, -0.8)) self.initialize_button_links() # sound bar self.sound_value = int(render_fsm.sound.get_volume() * 100) self.screen_atributes.screen_texts["screen_text:sound"] = ScreenTextFsm("Sound volume:", (0, 0.7)) self.sound_bar = DirectScrollBar(range=(0, 100), value=self.sound_value, pageSize=3, command=self.on_sound_change) self.menu_music_box = DirectCheckButton(text="MenuMusic", scale=.07, command=self.update_menu_music) self.menu_music_box["indicatorValue"] = self.render_fsm_ref.sound.can_play(SoundTypes.MAIN) self.menu_music_box.setIndicatorValue() self.menu_music_box.setPos(0.0, 0.0, 0.3) self.sound_bar.setPos(0.0, 0.0, 0.5) self.screen_atributes.screen_texts["screen_text:sound_volume"] = ScreenTextFsm(str(self.sound_value), (0, 0.4))
def __init__(self, node, name): SocketBase.__init__(self, node, name) self.type = INSOCKET self.frame = DirectFrame( frameColor=(0.25, 0.25, 0.25, 1), frameSize=(-1, 0, -self.height, 0), parent=node.frame, ) SocketBase.createPlug(self, self.frame) ''' self.text = DirectLabel( frameColor=(0, 0, 0, 0), frameSize=(0, 1, -self.height, 0), scale=(1, 1, 1), text=self.name, text_align=TextNode.A_left, text_scale=(0.1, 0.1), text_pos=(0.1, -0.02), text_fg=(1, 1, 1, 1), text_bg=(0, 0, 0, 0), parent=self.frame, )''' self.checkbox = DirectCheckButton(text=name, pos=(0.5, 0, 0), scale=.1, command=self.updateConnectedNodes, parent=self.frame) self.resize(1)
class BoolSocket(SocketBase): def __init__(self, node, name): SocketBase.__init__(self, node, name) self.type = INSOCKET self.frame = DirectFrame( frameColor=(0.25, 0.25, 0.25, 1), frameSize=(-1, 0, -self.height, 0), parent=node.frame, ) SocketBase.createPlug(self, self.frame) ''' self.text = DirectLabel( frameColor=(0, 0, 0, 0), frameSize=(0, 1, -self.height, 0), scale=(1, 1, 1), text=self.name, text_align=TextNode.A_left, text_scale=(0.1, 0.1), text_pos=(0.1, -0.02), text_fg=(1, 1, 1, 1), text_bg=(0, 0, 0, 0), parent=self.frame, )''' self.checkbox = DirectCheckButton(text=name, pos=(0.5, 0, 0), scale=.1, command=self.updateConnectedNodes, parent=self.frame) self.resize(1) def setValue(self, value): self.checkbox["indicatorValue"] = value self.checkbox.setIndicatorValue() def getValue(self): return self.checkbox["indicatorValue"] def show(self, z, left): self.frame.setZ(z) self.frame.setX(left) def resize(self, newWidth): self.frame["frameSize"] = (0, newWidth, -self.height / 2, self.height / 2) #self.text["frameSize"] = (0, newWidth, -self.height/2, self.height/2) def setConnected(self, connected): if connected: self.checkbox["state"] = DGG.DISABLED else: self.checkbox["state"] = DGG.NORMAL self.connected = connected
def __init__(self, rootParent=None): self.volume = DirectSlider( pos=LPoint3f(0.2, 0, 0.325), text='Volume', text_pos=(-1.05, -0.02), text_fg=(1, 1, 1, 1), text_scale=0.1, text_align=TextNode.ARight, parent=rootParent, command=base.messenger.send, extraArgs=["volumeChange"], ) self.volume.setTransparency(0) self.audioMute = DirectCheckButton( frameSize=(-2.925000047683716, 3.024999713897705, -0.225, 0.8250000238418579), pos=LPoint3f(0, 0, 0), scale=LVecBase3f(0.1, 0.1, 0.1), text='Mute', parent=rootParent, command=self.toggleMute, ) self.audioMute.setTransparency(0) self.btnBack = DirectButton( frameSize=(-1.5249999523162843, 1.6499999523162843, -0.21250001192092896, 0.8250000238418579), pos=LPoint3f(0, 0, -0.575), scale=LVecBase3f(0.1, 0.1, 0.1), text='Back', parent=rootParent, command=base.messenger.send, extraArgs=["optionBack"], pressEffect=1, ) self.btnBack.setTransparency(0) self.fullscreen = DirectCheckButton( frameSize=(-3.35, 2.6, -0.213, 0.825), pos=LPoint3f(0.045, 0, -0.175), scale=LVecBase3f(0.1, 0.1, 0.1), text='Fullscreen', parent=rootParent, command=self.toggleFullscreen, ) self.fullscreen.setTransparency(0)
def _construir_hud(self): # boton crear mesh btn_crear_mesh = DirectButton(text="crear mesh", scale=0.075, pos=Vec3(0.95, 0.9), command=self._crear_mesh) btn_crear_mesh.reparentTo(self.aspect2d) # check smooth chk_smooth = DirectCheckButton(text="smooth", scale=0.075, pos=Vec3(0.95, 0.8), command=self._establecer_smooth) chk_smooth.reparentTo(self.aspect2d) # boton eliminar mesh btn_eliminar_mesh = DirectButton(text="eliminar mesh", scale=0.075, pos=Vec3(0.95, 0.7), command=self._eliminar_mesh) btn_eliminar_mesh.reparentTo(self.aspect2d)
def bld_page(self): menu_args = self.menu_args self.pagewidgets = [] self.buttons = [] joypad_lab = DirectLabel(text=_('Use the joypad when present'), pos=(-.1, 1, .8), text_align=TextNode.ARight, **menu_args.label_args) PageGui.transl_text(joypad_lab, 'Use the joypad when present', _('Use the joypad when present')) self._joypad_cb = DirectCheckButton( pos=(.09, 1, .82), text='', indicatorValue=self.joystick, indicator_frameColor=menu_args.text_fg, **menu_args.checkbtn_args) if not has_pygame(): self._joypad_cb['state'] = DISABLED def add_lab(text, pos_z): self.pagewidgets += [ DirectLabel(text=text, pos=(-.1, 1, pos_z), text_align=TextNode.ARight, **menu_args.label_args) ] def add_btn(text, pos_z): btn = DirectButton(pos=(.46, 1, pos_z), text=text, command=self.start_rec, **menu_args.btn_args) btn['extraArgs'] = [btn] self.pagewidgets += [btn] self.buttons += [btn] buttons_data = [(_('Accelerate'), 'forward', .6), (_('Brake/Reverse'), 'rear', .4), (_('Left'), 'left', .2), (_('Right'), 'right', 0), (_('Weapon'), 'button', -.2), (_('Respawn'), 'respawn', -.4)] for btn_data in buttons_data: add_lab(btn_data[0], btn_data[2]) add_btn(self.keys[btn_data[1]], btn_data[2]) l_a = menu_args.label_args.copy() l_a['scale'] = .065 self.hint_lab = DirectLabel(text=_('Press the key to record it'), pos=(0, 1, -.6), **l_a) self.hint_lab.hide() self.pagewidgets += [joypad_lab, self._joypad_cb, self.hint_lab] map(self.add_widget, self.pagewidgets) ThanksPageGui.bld_page(self)
def createDirectCheckButton(self, parent=None): parent = self.getEditorRootCanvas() if parent is None else parent pos = self.editorCenter if parent == self.getEditorRootCanvas() else (0,0,0) if self.visEditorInAspect2D: element = DirectCheckButton( text="Checkbutton", parent=parent, scale=0.1) else: element = DirectCheckButton( pos=pos, text_scale=24, borderWidth=(2, 2), text="Checkbutton", indicator_text_scale=24, indicator_borderWidth=(2, 2), parent=parent, scale=1) elementInfo = ElementInfo(element, "DirectCheckButton") self.setupBind(elementInfo) return elementInfo
def load(self): cmdMap = { 'Toggle Music': [2.65, self.toggleMusic, options['want-music']], 'Toggle Sound Effects': [1.27, self.toggleSFX, options['want-sfx']], 'Toggle Rank Visibility': [1.27, self.toggleRankView, options['show-player-ranks']], 'Toggle Player Names': [1.3, self.togglePlayerNames, options['show-player-names']] } startZ = 0.25 for bText, bOptions in cmdMap.items(): border, callback, configVal = bOptions checkbox = DirectCheckButton(parent=self, relief=None, text=bText, text_font=FONT, command=callback, text_scale=0.8, boxPlacement='right', boxBorder=border, scale=0.1, pos=(-0.1, 0, startZ), indicatorValue=configVal) startZ -= 0.17 self._optionButtons.append(checkbox) buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui') upButton = buttonModels.find('**//InventoryButtonUp') downButton = buttonModels.find('**/InventoryButtonDown') rolloverButton = buttonModels.find('**/InventoryButtonRollover') self.saveButton = DirectButton(parent=self, text_font=FONT, text='Save', text_pos=(0, -.17), scale=0.2, text_scale=0.68, command=self.unload, image=(upButton, downButton, rolloverButton), relief=None, text_fg=(0, 0, 0, 1), pos=(0, 0, -0.39), image_color=(1, 0.94, 0, 1), image_scale=(17, 1, 7), sortOrder=DGG.GEOM_SORT_INDEX) buttonModels.removeNode()
def create_bool_entry(self, frame, param): btn = DirectCheckButton( parent=frame, text="", text_scale=self.text_scale, text_align=TextNode.A_left, boxPlacement="left", #borderWidth=(2, 2), indicator_text_scale=self.text_scale, indicator_text='A', indicator_text_pos=(0, 4), indicator_borderWidth=(2, 2), #boxBorder=1 pressEffect=False, suppressKeys=1, command=self.do_update, extraArgs=[None, param], ) btn['indicatorValue'] = param.get_param() widget = SizerWidget(btn) return widget
class FsmStateWindowSettings(ScreenState): def __init__(self, render_fsm): ScreenState.__init__(self) self.button_sizes = (-3, 3, -0.4, 0.8) self.render_fsm_ref = render_fsm self.screen_atributes.screen_texts["screen_text:Title"] = ScreenTextFsm("Windows params:", (0, 0.2)) self.screen_atributes.radio_buttons["rb:WinSize 16:9"] = RadioButtonFsm("16:9", (-0.2, 0, 0), self.confirm_command) self.screen_atributes.radio_buttons["rb:WinSize 4:3"] = RadioButtonFsm("4:3", (0.2, 0, 0), self.confirm_command) self.screen_atributes.buttons["but:Confirm"] = ButtonFsm("Confirm", (0, 0, -0.5)) self.screen_atributes.buttons["but:Back"] = ButtonFsm("Back", (0, 0, -0.8)) self.initialize_button_links() # sound bar self.sound_value = int(render_fsm.sound.get_volume() * 100) self.screen_atributes.screen_texts["screen_text:sound"] = ScreenTextFsm("Sound volume:", (0, 0.7)) self.sound_bar = DirectScrollBar(range=(0, 100), value=self.sound_value, pageSize=3, command=self.on_sound_change) self.menu_music_box = DirectCheckButton(text="MenuMusic", scale=.07, command=self.update_menu_music) self.menu_music_box["indicatorValue"] = self.render_fsm_ref.sound.can_play(SoundTypes.MAIN) self.menu_music_box.setIndicatorValue() self.menu_music_box.setPos(0.0, 0.0, 0.3) self.sound_bar.setPos(0.0, 0.0, 0.5) self.screen_atributes.screen_texts["screen_text:sound_volume"] = ScreenTextFsm(str(self.sound_value), (0, 0.4)) def on_sound_change(self): self.sound_value = int(self.sound_bar.getValue()) self.render_fsm_ref.sound.set_volume(self.sound_value / 100.0) # sound bar self.screen_atributes.screen_texts["screen_text:sound_volume"] = ScreenTextFsm(str(self.sound_value), (0, 0.4)) self.clear_nodes() self.render(self.render_fsm_ref) def update_menu_music(self, status): menu_music_play = True if status == 1 else False self.render_fsm_ref.sound.turn(SoundTypes.MAIN, menu_music_play) self.render_fsm_ref.sound.play(SoundTypes.MAIN, is_looped=True) def initialize_button_links(self): self.screen_atributes.buttons["but:Confirm"].add_link("fsm:MainMenu") self.screen_atributes.buttons["but:Confirm"].add_command(self.confirm_command) self.screen_atributes.buttons["but:Back"].add_link("fsm:MainMenu") def confirm_command(self): # 16:9 if self.radio_button_var[0] == 0: props = WindowProperties() props.clearSize() props.setTitle('Chess Classic') props.setSize(DEFAULT16x9SCREEN_W, DEFAULT16x9SCREEN_H) #props.setFixedSize(True) self.render_fsm_ref.win.requestProperties(props) # 4:3 if self.radio_button_var[0] == 1: props = WindowProperties() props.clearSize() props.setTitle('Chess Classic') props.setSize(DEFAULT4x3SCREEN_W, DEFAULT4x3SCREEN_H) #props.setFixedSize(True) self.render_fsm_ref.win.requestProperties(props) def clear(self): for node in self.screen_atributes.scene_nodes: node.removeNode() for key in self.gui_text_fields.keys(): self.gui_text_fields[key].removeNode() self.sound_bar.destroy() self.menu_music_box.destroy() def clear_nodes(self): for node in self.screen_atributes.scene_nodes: node.removeNode() for key in self.gui_text_fields.keys(): self.gui_text_fields[key].removeNode()
def __init__(self, rootParent=None): self.frmMain = DirectFrame( borderWidth=(2, 2), frameColor=(1, 1, 1, 1), frameSize=(-300.0, 300.0, -250.0, 250.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(0, 0, 0), parent=rootParent, ) self.frmMain.setTransparency(0) self.frmHeader = DirectFrame( borderWidth=(2, 2), frameColor=(0.25, 0.25, 0.25, 1.0), frameSize=(-300.0, 300.0, -20.0, 20.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(0, 0, 230), parent=self.frmMain, ) self.frmHeader.setTransparency(0) self.lblHeader = DirectLabel( borderWidth=(2, 2), frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-295, 0, -5), scale=LVecBase3f(1, 1, 1), text='Settings', text_align=TextNode.A_left, text_scale=(16.0, 16.0), text_pos=(0, 0), text_fg=LVecBase4f(1, 1, 1, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmHeader, ) self.lblHeader.setTransparency(0) self.btnOk = DirectButton( borderWidth=(2, 2), frameSize=(-45.0, 45.0, -6.0, 14.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(120, 0, -220), relief=1, scale=LVecBase3f(1, 1, 1), text='OK', text_align=TextNode.A_center, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, command=messenger.send, extraArgs=["Settings_OK"], ) self.btnOk.setTransparency(0) self.btnCancel = DirectButton( borderWidth=(2, 2), frameSize=(-45.0, 45.0, -6.0, 14.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(230, 0, -220), relief=1, scale=LVecBase3f(1, 1, 1), text='Cancel', text_align=TextNode.A_center, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, command=messenger.send, extraArgs=["Settings_CANCEL"], ) self.btnCancel.setTransparency(0) self.lblCustomWidgets = DirectLabel( borderWidth=(2, 2), frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-260, 0, 5), scale=LVecBase3f(1, 1, 1), text='Custom widgets path:', text_align=TextNode.A_left, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblCustomWidgets.setTransparency(0) self.txtCustomWidgetsPath = DirectEntry( borderWidth=(0.167, 0.167), hpr=LVecBase3f(0, 0, 0), overflow=1, pos=LPoint3f(-50, 0, 5), scale=LVecBase3f(12, 1, 12), width=18.0, text_align=TextNode.A_left, text_scale=(1.0, 1.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.txtCustomWidgetsPath.setTransparency(0) self.lblAskForQuit = DirectLabel( borderWidth=(2, 2), frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-260, 0, 140), scale=LVecBase3f(1, 1, 1), text='Ask before quit:', text_align=TextNode.A_left, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblAskForQuit.setTransparency(0) self.cbAskForQuit = DirectCheckButton( borderWidth=(2, 2), frameColor=(1.0, 1.0, 1.0, 1.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(110, 0, 145), scale=LVecBase3f(1, 1, 1), text='', indicator_borderWidth=(2, 2), indicator_hpr=LVecBase3f(0, 0, 0), indicator_pos=LPoint3f(-11, 0, -7.2), indicator_relief='sunken', indicator_text_align=TextNode.A_center, indicator_text_scale=(24, 24), indicator_text_pos=(0, -0.2), indicator_text_fg=LVecBase4f(0, 0, 0, 1), indicator_text_bg=LVecBase4f(0, 0, 0, 0), text_align=TextNode.A_left, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.cbAskForQuit.setTransparency(0) self.lblExecutableScripts = DirectLabel( borderWidth=(2, 2), frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-260, 0, 95), scale=LVecBase3f(1, 1, 1), text='Create executable Scripts:', text_align=TextNode.A_left, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblExecutableScripts.setTransparency(0) self.cbExecutableScripts = DirectCheckButton( borderWidth=(2, 2), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(110, 0, 100), scale=LVecBase3f(1, 1, 1), text='', indicator_borderWidth=(2, 2), indicator_hpr=LVecBase3f(0, 0, 0), indicator_pos=LPoint3f(-11, 0, -7.2), indicator_relief='sunken', indicator_text_align=TextNode.A_center, indicator_text_scale=(24, 24), indicator_text_pos=(0, -0.2), indicator_text_fg=LVecBase4f(0, 0, 0, 1), indicator_text_bg=LVecBase4f(0, 0, 0, 0), text_align=TextNode.A_center, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.cbExecutableScripts.setTransparency(0) self.btnBrowseWidgetPath = DirectButton( borderWidth=(2, 2), frameSize=(-45.25, 45.25, -6.0, 14.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(230, 0, 5), relief=1, scale=LVecBase3f(1, 1, 1), text='Browse', text_align=TextNode.A_center, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.btnBrowseWidgetPath.setTransparency(0) self.lblShowToolbar = DirectLabel( borderWidth=(2, 2), frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-260, 0, 50), scale=LVecBase3f(1, 1, 1), text='Show toolbar', text_align=TextNode.A_left, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblShowToolbar.setTransparency(0) self.cbShowToolbar = DirectCheckButton( borderWidth=(2, 2), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(110, 0, 55), scale=LVecBase3f(1, 1, 1), text='', indicator_borderWidth=(2, 2), indicator_hpr=LVecBase3f(0, 0, 0), indicator_pos=LPoint3f(-11, 0, -7.2), indicator_relief='sunken', indicator_text_align=TextNode.A_center, indicator_text_scale=(24, 24), indicator_text_pos=(0, -0.2), indicator_text_fg=LVecBase4f(0, 0, 0, 1), indicator_text_bg=LVecBase4f(0, 0, 0, 0), text_align=TextNode.A_center, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.cbShowToolbar.setTransparency(0) self.lblSearchPath = DirectLabel( borderWidth=(2, 2), frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-260, 0, -45), scale=LVecBase3f(1, 1, 1), text='Search paths', text_align=TextNode.A_left, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblSearchPath.setTransparency(0) self.txtSearchPaths = DirectEntry( borderWidth=(0.167, 0.167), frameSize=(-0.167, 18.167, -0.463, 1.155), hpr=LVecBase3f(0, 0, 0), overflow=1, pos=LPoint3f(-50, 0, -45), scale=LVecBase3f(12, 1, 12), width=18.0, text_align=TextNode.A_left, text_scale=(1, 1), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.txtSearchPaths.setTransparency(0) self.btnBrowseSearchPaths = DirectButton( borderWidth=(2, 2), frameSize=(-45.25, 45.25, -6.0, 14.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(230, 0, -45), relief=1, scale=LVecBase3f(1, 1, 1), text='Browse', text_align=TextNode.A_center, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.btnBrowseSearchPaths.setTransparency(0) self.lblWorkDir = DirectLabel( borderWidth=(2, 2), frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-260, 0, -95), scale=LVecBase3f(1, 1, 1), text='Default work directory', text_align=TextNode.A_left, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblWorkDir.setTransparency(0) self.txtWorkDir = DirectEntry( borderWidth=(0.08333333333333333, 0.08333333333333333), hpr=LVecBase3f(0, 0, 0), overflow=1, pos=LPoint3f(-50, 0, -95), scale=LVecBase3f(12, 1, 12), width=18.0, text_align=TextNode.A_left, text_scale=(1, 1), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.txtWorkDir.setTransparency(0) self.btnBrowseWorkDir = DirectButton( borderWidth=(2, 2), frameSize=(-45.25, 45.25, -6.0, 14.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(230, 0, -95), relief=1, scale=LVecBase3f(1, 1, 1), text='Browse', text_align=TextNode.A_center, text_scale=(12.0, 12.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, pressEffect=1, ) self.btnBrowseWorkDir.setTransparency(0) self.spinAutosaveDealy = DirectSpinBox( frameSize=(-2.1, 1.0, -0.742, 0.742), hpr=LVecBase3f(0, 0, 0), maxValue=3600, minValue=10, pos=LPoint3f(105, 0, -140), value=60, scale=LVecBase3f(12, 1, 12), decButton_hpr=LVecBase3f(0, 0, 0), decButton_pos=LPoint3f(0.583333, 0, -0.533333), decButton_text='6', decButton_text0_align=TextNode.A_center, decButton_text0_scale=(1, 1), decButton_text0_pos=(0, 0), decButton_text0_fg=LVecBase4f(0, 0, 0, 1), decButton_text0_bg=LVecBase4f(0, 0, 0, 0), decButton_text0_wordwrap=None, decButton_text1_align=TextNode.A_center, decButton_text1_scale=(1, 1), decButton_text1_pos=(0, 0), decButton_text1_fg=LVecBase4f(0, 0, 0, 1), decButton_text1_bg=LVecBase4f(0, 0, 0, 0), decButton_text1_wordwrap=None, decButton_text2_align=TextNode.A_center, decButton_text2_scale=(1, 1), decButton_text2_pos=(0, 0), decButton_text2_fg=LVecBase4f(0, 0, 0, 1), decButton_text2_bg=LVecBase4f(0, 0, 0, 0), decButton_text2_wordwrap=None, decButton_text3_align=TextNode.A_center, decButton_text3_scale=(1, 1), decButton_text3_pos=(0, 0), decButton_text3_fg=LVecBase4f(0, 0, 0, 1), decButton_text3_bg=LVecBase4f(0, 0, 0, 0), decButton_text3_wordwrap=None, incButton_hpr=LVecBase3f(0, 0, 0), incButton_pos=LPoint3f(0.583333, 0, -0.016667), incButton_text='5', incButton_text0_align=TextNode.A_center, incButton_text0_scale=(1, 1), incButton_text0_pos=(0, 0), incButton_text0_fg=LVecBase4f(0, 0, 0, 1), incButton_text0_bg=LVecBase4f(0, 0, 0, 0), incButton_text0_wordwrap=None, incButton_text1_align=TextNode.A_center, incButton_text1_scale=(1, 1), incButton_text1_pos=(0, 0), incButton_text1_fg=LVecBase4f(0, 0, 0, 1), incButton_text1_bg=LVecBase4f(0, 0, 0, 0), incButton_text1_wordwrap=None, incButton_text2_align=TextNode.A_center, incButton_text2_scale=(1, 1), incButton_text2_pos=(0, 0), incButton_text2_fg=LVecBase4f(0, 0, 0, 1), incButton_text2_bg=LVecBase4f(0, 0, 0, 0), incButton_text2_wordwrap=None, incButton_text3_align=TextNode.A_center, incButton_text3_scale=(1, 1), incButton_text3_pos=(0, 0), incButton_text3_fg=LVecBase4f(0, 0, 0, 1), incButton_text3_bg=LVecBase4f(0, 0, 0, 0), incButton_text3_wordwrap=None, valueEntry_hpr=LVecBase3f(0, 0, 0), valueEntry_initialText='60', valueEntry_pos=LPoint3f(0, 0, -0.345625), valueEntry_text_align=TextNode.A_right, valueEntry_text_scale=(1, 1), valueEntry_text_pos=(0, 0), valueEntry_text_fg=LVecBase4f(0, 0, 0, 1), valueEntry_text_bg=LVecBase4f(0, 0, 0, 0), valueEntry_text_wordwrap=None, parent=self.frmMain, ) self.spinAutosaveDealy.setTransparency(0) self.lblAutosaveDelay = DirectLabel( borderWidth=(2, 2), frameColor=(0.8, 0.8, 0.8, 0.0), frameSize=LVecBase4f(0.3, 84.45, -3.9, 8.7), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-260, 0, -140), scale=LVecBase3f(1, 1, 1), text='Autosave delay in seconds', text0_align=TextNode.A_left, text0_scale=(12.0, 12.0), text0_pos=(0, 0), text0_fg=LVecBase4f(0, 0, 0, 1), text0_bg=LVecBase4f(0, 0, 0, 0), text0_wordwrap=None, parent=self.frmMain, ) self.lblAutosaveDelay.setTransparency(0)
def __init__(self, rootParent=None): self.frmMain = DirectFrame( frameColor=(1, 1, 1, 1), frameSize=(-1.777, 1.777, -1.0, 1.0), hpr=LVecBase3f(0, 0, 0), image='assets/menu/Background.png', pos=LPoint3f(0, 0, 0), image_scale=LVecBase3f(1.77778, 0, 1.1638), image_pos=LPoint3f(0, 0, 0), parent=rootParent, ) self.frmMain.setTransparency(0) self.lblptions = DirectLabel( frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(0, 0, 0.8), scale=LVecBase3f(0.1, 0.1, 0.1), text='Options', text_align=TextNode.A_center, text_scale=(1, 1), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblptions.setTransparency(0) self.lblServer = DirectLabel( frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-0.75, 0, 0.175), scale=LVecBase3f(1, 1, 1), text='Game Server URL:', text_align=TextNode.A_left, text_scale=(0.05, 0.05), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblServer.setTransparency(0) self.btnOk = DirectButton( hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-0.375, 0, -0.775), relief=1, scale=LVecBase3f(0.1, 0.1, 0.1), text='Ok', text_align=TextNode.A_center, text_scale=(1, 1), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, command=base.messenger.send, extraArgs=["options_ok"], pressEffect=1, ) self.btnOk.setTransparency(0) self.btnCancel = DirectButton( hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(0.275, 0, -0.775), relief=1, scale=LVecBase3f(0.1, 0.1, 0.1), text='Cancel', text_align=TextNode.A_center, text_scale=(1, 1), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, command=base.messenger.send, extraArgs=["options_cancel"], pressEffect=1, ) self.btnCancel.setTransparency(0) self.txtServer = DirectEntry( borderWidth=(0.01, 0.01), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(-0.15, 0, 0.17), scale=LVecBase3f(1, 1, 1), width=25.0, text_align=TextNode.A_left, text_scale=(0.05, 0.05), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.txtServer.setTransparency(0) self.cbMusic = DirectCheckButton( frameSize=(-3.0, 2.0, -0.3, 1.0), hpr=LVecBase3f(0, 0, 0), indicatorValue=1, pos=LPoint3f(0, 0, -0.21), scale=LVecBase3f(0.05, 0.1, 0.05), text='Music', indicator_hpr=LVecBase3f(0, 0, 0), indicator_pos=LPoint3f(-2.625, 0, 0.05), indicator_relief='sunken', indicator_text_align=TextNode.A_center, indicator_text_scale=(1, 1), indicator_text_pos=(0, -0.2), indicator_text_fg=LVecBase4f(0, 0, 0, 1), indicator_text_bg=LVecBase4f(0, 0, 0, 0), text_align=TextNode.A_center, text_scale=(1.0, 1.0), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.cbMusic.setTransparency(0) self.cbSFX = DirectCheckButton( frameSize=(-3.0, 2.0, -0.3, 1.0), hpr=LVecBase3f(0, 0, 0), indicatorValue=1, pos=LPoint3f(0, 0, -0.315), scale=LVecBase3f(0.05, 0.1, 0.05), text='SFX', indicator_hpr=LVecBase3f(0, 0, 0), indicator_pos=LPoint3f(-2.625, 0, 0.05), indicator_relief='sunken', indicator_text_align=TextNode.A_center, indicator_text_scale=(1, 1), indicator_text_pos=(0, -0.2), indicator_text_fg=LVecBase4f(0, 0, 0, 1), indicator_text_bg=LVecBase4f(0, 0, 0, 0), text_align=TextNode.A_center, text_scale=(1, 1), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.cbSFX.setTransparency(0) self.lblAudio = DirectLabel( frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(0, 0, -0.1), scale=LVecBase3f(0.1, 0.1, 0.1), text='Audio', text_align=TextNode.A_center, text_scale=(1, 1), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblAudio.setTransparency(0) self.lblConnection = DirectLabel( frameColor=(0.8, 0.8, 0.8, 0.0), hpr=LVecBase3f(0, 0, 0), pos=LPoint3f(0, 0, 0.3), scale=LVecBase3f(0.1, 0.1, 0.1), text='Connection', text_align=TextNode.A_center, text_scale=(1, 1), text_pos=(0, 0), text_fg=LVecBase4f(0, 0, 0, 1), text_bg=LVecBase4f(0, 0, 0, 0), parent=self.frmMain, ) self.lblConnection.setTransparency(0)
def bld_page(self): menu_args = self.menu_args self.pagewidgets = [] def add_lab(txt, txt_tr, pos_z): lab = DirectLabel(text='', pos=(-.1, 1, pos_z), text_align=TextNode.ARight, **menu_args.label_args) PageGui.transl_text(lab, txt, txt_tr) self.pagewidgets += [lab] return lab add_lab('Language', _('Language'), .7) self._lang_opt = DirectOptionMenu(text='', items=eng.languages, pos=(.49, 1, .7), initialitem=self.props.lang, command=self.__change_lang, **menu_args.option_args) add_lab('Volume', _('Volume'), .5) self._vol_slider = DirectSlider(pos=(.52, 0, .53), scale=.49, value=self.props.volume, frameColor=menu_args.btn_color, thumb_frameColor=menu_args.text_fg, command=self.__on_volume) add_lab('Fullscreen', _('Fullscreen'), .3) self._fullscreen_cb = DirectCheckButton( pos=(.12, 1, .32), text='', indicatorValue=self.props.fullscreen, indicator_frameColor=menu_args.text_fg, command=lambda val: eng.toggle_fullscreen(), **menu_args.checkbtn_args) add_lab('Resolution', _('Resolution'), .1) res2vec = lambda res: LVector2i(*[int(val) for val in res.split('x')]) self._res_opt = DirectOptionMenu( text='', items=[ 'x'.join([str(el_res) for el_res in res]) for res in eng.resolutions ], pos=(.49, 1, .1), initialitem='x'.join(str(res) for res in eng.closest_res), command=lambda res: eng.set_resolution(res2vec(res)), **menu_args.option_args) add_lab('Antialiasing', _('Antialiasing'), -.1) aa_next_lab = DirectLabel(text='', pos=(.2, 1, -.1), text_align=TextNode.ALeft, **menu_args.label_args) PageGui.transl_text(aa_next_lab, '(from the next execution)', _('(from the next execution)')) self._aa_cb = DirectCheckButton(pos=(.12, 1, -.07), text='', indicatorValue=self.props.aa, indicator_frameColor=menu_args.text_fg, **menu_args.checkbtn_args) add_lab('Shaders', _('Shaders'), -.3) self._shaders_cb = DirectCheckButton( pos=(.12, 1, -.27), text='', indicatorValue=self.props.shaders, indicator_frameColor=menu_args.text_fg, **menu_args.checkbtn_args) # bld_in = lambda: self.menu.logic.push_page( # InputPage(self.menu, self.props.joystick, self.props.keys)) # it doesn't work if we go forward and back between options and input: # we should update keys input_btn = DirectButton(text='', pos=(0, 1, -.5), command=self.on_input_btn, **menu_args.btn_args) PageGui.transl_text(input_btn, 'Configure input', _('Configure input')) self.pagewidgets += [ self._lang_opt, self._vol_slider, self._fullscreen_cb, self._res_opt, self._aa_cb, aa_next_lab, input_btn, self._shaders_cb ] map(self.add_widget, self.pagewidgets) idx = LangMgr().lang_codes.index(self.props.lang) self.__change_lang(eng.languages[idx]) ThanksPageGui.bld_page(self)