示例#1
0
 def __init__(self, parent = None, **kw):
     
     optiondefs = (
                   ('itemcontent',        [],          None),
                   ('relief',             DGG.FLAT,    None),
                   ('popupMarker_relief', None,        None),
                   ('frameColor',         (0,0,0,0.5), None),
                   ('text_fg',            (1,1,1,1),   None),
                   ('item_relief',        DGG.FLAT,    None),
                   ('popupMenu_relief',   None,        None),
                  )
     self.defineoptions(kw, optiondefs)
     DirectOptionMenu.__init__(self)
     self.initialiseoptions(SDirectOptionMenu)
     self.resetFrameSize()
示例#2
0
    def __init__(self, parent=None, **kw):

        optiondefs = (
            ('itemcontent', [], None),
            ('relief', DGG.FLAT, None),
            ('popupMarker_relief', None, None),
            ('frameColor', (0, 0, 0, 0.5), None),
            ('text_fg', (1, 1, 1, 1), None),
            ('item_relief', DGG.FLAT, None),
            ('popupMenu_relief', None, None),
        )
        self.defineoptions(kw, optiondefs)
        DirectOptionMenu.__init__(self)
        self.initialiseoptions(SDirectOptionMenu)
        self.resetFrameSize()
示例#3
0
def test_showPopupMenu():
    menu = DirectOptionMenu()

    # Showing an option menu without items will raise an exception
    with pytest.raises(Exception):
        menu.showPopupMenu()

    menu["items"] = ["item1", "item2"]
    menu.showPopupMenu()
    assert not menu.popupMenu.isHidden()
    assert not menu.cancelFrame.isHidden()

    menu.hidePopupMenu()
    assert menu.popupMenu.isHidden()
    assert menu.cancelFrame.isHidden()
示例#4
0
    def render_option_lists(self):
        for option_list_key in self.screen_atributes.option_lists.keys():
            option_list = self.screen_atributes.option_lists[option_list_key]
            pos = option_list.position

            command = lambda str_res_, option_list_: (option_list_.command(
                str_res_))
            gui_option_list = DirectOptionMenu(text=option_list.text,
                                               scale=0.1,
                                               pos=(pos[0], pos[1], pos[2]),
                                               items=option_list.items,
                                               command=command,
                                               extraArgs=[option_list])

            self.screen_atributes.scene_nodes.append(gui_option_list)
示例#5
0
    def __init__(self, parent, **kw):
        self._parent = parent
        buttonModels = loader.loadModel('phase_3/models/gui/quit_button')
        self.upButton = buttonModels.find('**/QuitBtn_UP')
        self.downButton = buttonModels.find('**/QuitBtn_DN')
        self.rolloverButton = buttonModels.find('**/QuitBtn_RLVR')
        buttonModels.removeNode()

        self.image_scale = kw.get('bimg_scale', (9, 1, 15))
        self.btext_scale = kw.get('btext_scale', 0.75)
        self.btext_pos = kw.get('btext_pos', (0.65, -0.05))
        self.button_scale = kw.get('button_scale', 1)
        self.button_pos = kw.get('button_pos', (0.8, 0, 0.0))

        for key in ['btext_scale', 'btext_pos', 'button_scale', 'button_pos', 'bimg_scale']:
            if key in kw:
                del kw[key]

        geom_pos = kw.get('image_pos', (1.5, 0, 0.15))
        text_pos = kw.get('text_pos', (0.34, -.1))
        optiondefs = (
            ('relief', None, None),
            ('popupMarker_relief', None, None),
            ('scale', 0.07, None),
            ('highlightColor', (0.65, 0.65, 0.65, 1), None),
            ('highlightScale', (self.btext_scale + 0.07,)*2, None),
            ('text_font', FONT, None),
            ('text_pos', text_pos, None),
            ('text_scale', self.btext_scale, None),
            ('geom', (self.upButton, self.downButton, self.rolloverButton), None),
            ('geom_scale', self.image_scale, None),
            ('geom_pos', geom_pos, None)
        )
        self.defineoptions(kw, optiondefs)
        DirectOptionMenu.__init__(self, parent=parent)
        self.initialiseoptions(CustomizeOption)
示例#6
0
def test_initialitem():
    # initialitem by string
    menuByStr = DirectOptionMenu(items=["item1", "item2"], initialitem="item2")
    assert menuByStr.get() == "item2"
    assert menuByStr["text"] == "item2"

    # initialitem by Index
    menuByIdx = DirectOptionMenu(items=["item1", "item2"], initialitem=1)
    assert menuByIdx.get() == "item2"
    assert menuByIdx["text"] == "item2"
示例#7
0
def test_item_text_scale():
    highlightScale = (2, 2)
    unhighlightScale = (0.5, 0.5)
    menu = DirectOptionMenu(
        items=["item1", "item2"],
        item_text_scale=unhighlightScale,
        highlightScale=highlightScale)

    # initial scale
    item = menu.component("item0")

    item_text_scale = 0.8
    assert item["text_scale"] == unhighlightScale

    # highlight scale
    menu._highlightItem(item, 0)
    assert item["text_scale"] == highlightScale

    # back to initial scale
    menu._unhighlightItem(item, item["frameColor"])
    assert item["text_scale"] == unhighlightScale
示例#8
0
def test_menu_destroy():
    menu = DirectOptionMenu(items=["item1", "item2"])
    menu.destroy()
示例#9
0
def test_set_get():
    menu = DirectOptionMenu(items=["item1", "item2"])
    menu.set(1, False)
    assert menu.selectedIndex == 1
    assert menu.get() == "item2"
    assert menu["text"] == "item2"
示例#10
0
def test_index():
    menu = DirectOptionMenu(items=["item1", "item2"])
    assert menu.index("item1") == 0
    assert menu.index("item2") == 1
示例#11
0
    def __init__(self, rootParent=None):

        self.frmMain = DirectFrame(
            frameColor=(1, 1, 1, 1),
            frameSize=(-1.777778, 1.77777778, -1.1638, 1.1638),
            hpr=LVecBase3f(0, 0, 0),
            image='assets/menu/Background.png',
            pos=LPoint3f(0, 0, 0),
            image_scale=LVecBase3f(1.77778, 1, 1.1638),
            image_pos=LPoint3f(0, 0, 0),
            parent=rootParent,
        )
        self.frmMain.setTransparency(0)

        self.frmSinglePlayerCreateGame = DirectFrame(
            borderWidth=(0.01, 0.01),
            frameColor=(1, 1, 1, 1),
            frameSize=(-0.65, 0.65, -0.55, 0.55),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.425, 0, 0),
            relief=5,
            parent=self.frmMain,
        )
        self.frmSinglePlayerCreateGame.setTransparency(0)

        self.lblHeader = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0, 0, 0.425),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Singleplayer Game',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
        )
        self.lblHeader.setTransparency(0)

        self.lblGameType = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.6, 0, 0.225),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Game Type',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
        )
        self.lblGameType.setTransparency(0)

        self.lblNumNPCs = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.6, 0, -0.125),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Number of NPCs ',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
        )
        self.lblNumNPCs.setTransparency(0)

        self.optionNumNPCs = DirectOptionMenu(
            items=['item1'],
            frameSize=(0.07500000298023224, 3.012500149011612,
                       -0.11250001192092896, 0.75),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.2, 0, -0.115),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='item1',
            cancelframe_frameSize=(-1, 1, -1, 1),
            cancelframe_hpr=LVecBase3f(0, 0, 0),
            cancelframe_pos=LPoint3f(0, 0, 0),
            cancelframe_relief=None,
            item_frameSize=(0.07500000298023224, 2.4125001430511475,
                            -0.11250001192092896, 0.75),
            item_hpr=LVecBase3f(0, 0, 0),
            item_pos=LPoint3f(-0.075, 0, -0.75),
            item_text='item1',
            item0_text_align=TextNode.A_left,
            item0_text_scale=(1, 1),
            item0_text_pos=(0, 0),
            item0_text_fg=LVecBase4f(0, 0, 0, 1),
            item0_text_bg=LVecBase4f(0, 0, 0, 0),
            item0_text_wordwrap=None,
            popupMarker_frameSize=(-0.5, 0.5, -0.2, 0.2),
            popupMarker_hpr=LVecBase3f(0, 0, 0),
            popupMarker_pos=LPoint3f(2.7125, 0, 0.31875),
            popupMarker_relief=2,
            popupMarker_scale=LVecBase3f(0.4, 0.4, 0.4),
            popupMenu_frameSize=(0, 2.3375001400709152, -0.862500011920929, 0),
            popupMenu_hpr=LVecBase3f(0, 0, 0),
            popupMenu_pos=LPoint3f(0, 0, 0),
            popupMenu_relief='raised',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
        )
        self.optionNumNPCs.setTransparency(0)

        self.optionGameType = DirectOptionMenu(
            items=['item1'],
            frameSize=(0.07500000298023224, 3.012500149011612,
                       -0.11250001192092896, 0.75),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.2, 0, 0.22),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='item1',
            cancelframe_frameSize=(-1, 1, -1, 1),
            cancelframe_hpr=LVecBase3f(0, 0, 0),
            cancelframe_pos=LPoint3f(0, 0, 0),
            cancelframe_relief=None,
            item_frameSize=(0.07500000298023224, 2.4125001430511475,
                            -0.11250001192092896, 0.75),
            item_hpr=LVecBase3f(0, 0, 0),
            item_pos=LPoint3f(-0.075, 0, -0.75),
            item_text='item1',
            item0_text_align=TextNode.A_left,
            item0_text_scale=(1, 1),
            item0_text_pos=(0, 0),
            item0_text_fg=LVecBase4f(0, 0, 0, 1),
            item0_text_bg=LVecBase4f(0, 0, 0, 0),
            item0_text_wordwrap=None,
            popupMarker_frameSize=(-0.5, 0.5, -0.2, 0.2),
            popupMarker_hpr=LVecBase3f(0, 0, 0),
            popupMarker_pos=LPoint3f(2.7125, 0, 0.31875),
            popupMarker_relief=2,
            popupMarker_scale=LVecBase3f(0.4, 0.4, 0.4),
            popupMenu_frameSize=(0, 2.3375001400709152, -0.862500011920929, 0),
            popupMenu_hpr=LVecBase3f(0, 0, 0),
            popupMenu_pos=LPoint3f(0, 0, 0),
            popupMenu_relief='raised',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
        )
        self.optionGameType.setTransparency(0)

        self.btnStart = DirectButton(
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.35, 0, -0.45),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Start',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
            command=base.messenger.send,
            extraArgs=["singlePlayerCreateGame_start"],
        )
        self.btnStart.setTransparency(0)

        self.lblPlayerClass = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.6, 0, 0.05),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Player Class',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
        )
        self.lblPlayerClass.setTransparency(0)

        self.optionPlayerClass = DirectOptionMenu(
            items=['item1'],
            frameSize=(0.07500000298023224, 3.012500149011612,
                       -0.11250001192092896, 0.75),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.2, 0, 0.055),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='item1',
            cancelframe_frameSize=(-1, 1, -1, 1),
            cancelframe_hpr=LVecBase3f(0, 0, 0),
            cancelframe_pos=LPoint3f(0, 0, 0),
            cancelframe_relief=None,
            item_frameSize=(0.07500000298023224, 2.4125001430511475,
                            -0.11250001192092896, 0.75),
            item_hpr=LVecBase3f(0, 0, 0),
            item_pos=LPoint3f(-0.075, 0, -0.75),
            item_text='item1',
            item0_text_align=TextNode.A_left,
            item0_text_scale=(1, 1),
            item0_text_pos=(0, 0),
            item0_text_fg=LVecBase4f(0, 0, 0, 1),
            item0_text_bg=LVecBase4f(0, 0, 0, 0),
            item0_text_wordwrap=None,
            popupMarker_frameSize=(-0.5, 0.5, -0.2, 0.2),
            popupMarker_hpr=LVecBase3f(0, 0, 0),
            popupMarker_pos=LPoint3f(2.7125, 0, 0.31875),
            popupMarker_relief=2,
            popupMarker_scale=LVecBase3f(0.4, 0.4, 0.4),
            popupMenu_frameSize=(0, 2.3375001400709152, -0.862500011920929, 0),
            popupMenu_hpr=LVecBase3f(0, 0, 0),
            popupMenu_pos=LPoint3f(0, 0, 0),
            popupMenu_relief='raised',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
        )
        self.optionPlayerClass.setTransparency(0)

        self.btnCancel = DirectButton(
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.325, 0, -0.45),
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
            command=base.messenger.send,
            extraArgs=["singlePlayerCreateGame_back"],
        )
        self.btnCancel.setTransparency(0)

        self.lblDifficulty = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.6, 0, -0.29),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Difficulty',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
        )
        self.lblDifficulty.setTransparency(0)

        self.optionDifficulty = DirectOptionMenu(
            items=['item1'],
            frameSize=(0.07500000298023224, 3.012500149011612,
                       -0.11250001192092896, 0.75),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.2, 0, -0.29),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='item1',
            cancelframe_frameSize=(-1, 1, -1, 1),
            cancelframe_hpr=LVecBase3f(0, 0, 0),
            cancelframe_pos=LPoint3f(0, 0, 0),
            cancelframe_relief=None,
            item_frameSize=(0.07500000298023224, 2.4125001430511475,
                            -0.11250001192092896, 0.75),
            item_hpr=LVecBase3f(0, 0, 0),
            item_pos=LPoint3f(-0.075, 0, -0.75),
            item_text='item1',
            item0_text_align=TextNode.A_left,
            item0_text_scale=(1, 1),
            item0_text_pos=(0, 0),
            item0_text_fg=LVecBase4f(0, 0, 0, 1),
            item0_text_bg=LVecBase4f(0, 0, 0, 0),
            item0_text_wordwrap=None,
            popupMarker_frameSize=(-0.5, 0.5, -0.2, 0.2),
            popupMarker_hpr=LVecBase3f(0, 0, 0),
            popupMarker_pos=LPoint3f(2.7125, 0, 0.31875),
            popupMarker_relief=2,
            popupMarker_scale=LVecBase3f(0.4, 0.4, 0.4),
            popupMenu_frameSize=(0, 2.3375001400709152, -0.862500011920929, 0),
            popupMenu_hpr=LVecBase3f(0, 0, 0),
            popupMenu_pos=LPoint3f(0, 0, 0),
            popupMenu_relief='raised',
            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),
            text_wordwrap=None,
            parent=self.frmSinglePlayerCreateGame,
        )
        self.optionDifficulty.setTransparency(0)

        self.frmPlayerInfo = DirectFrame(
            borderWidth=(0.01, 0.01),
            frameColor=(1, 1, 1, 1),
            frameSize=(-0.5, 0.5, -0.55, 0.55),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.765, 0, 0),
            relief=3,
            parent=self.frmMain,
        )
        self.frmPlayerInfo.setTransparency(0)

        self.lblInfoHeader = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0, 0, 0.45),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Info',
            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),
            text_wordwrap=None,
            parent=self.frmPlayerInfo,
        )
        self.lblInfoHeader.setTransparency(0)

        self.frmImageHero = DirectFrame(
            frameColor=(1, 1, 1, 1),
            frameSize=(-0.15, 0.15, -0.2, 0.2),
            hpr=LVecBase3f(0, 0, 0),
            image=
            '/home/fireclaw/workspace/Ankandora/AnkandoraLight/design/guiGraphics/heroArcher.png',
            pos=LPoint3f(-0.275, 0, 0.195),
            image_scale=LVecBase3f(0.15, 1, 0.2),
            image_pos=LPoint3f(0, 0, 0),
            parent=self.frmPlayerInfo,
        )
        self.frmImageHero.setTransparency(1)

        self.lblClassDescription = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.12, 0, 0.31),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='The archer shoots from afar and gains the first-strike',
            text_align=TextNode.A_left,
            text_scale=(0.6, 0.6),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0, 0, 0, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            text_wordwrap=10.0,
            parent=self.frmPlayerInfo,
        )
        self.lblClassDescription.setTransparency(0)

        self.lblHealth = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.28, 0, -0.1),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Health',
            text_align=TextNode.A_center,
            text_scale=(0.7, 0.7),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0, 0, 0, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            text_wordwrap=None,
            parent=self.frmPlayerInfo,
        )
        self.lblHealth.setTransparency(0)

        self.lblAttack = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.275, 0, -0.285),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Attack',
            text_align=TextNode.A_center,
            text_scale=(0.7, 0.7),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0, 0, 0, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            text_wordwrap=None,
            parent=self.frmPlayerInfo,
        )
        self.lblAttack.setTransparency(0)

        self.lblHealthValue = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.275, 0, -0.17),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='7',
            text_align=TextNode.A_center,
            text_scale=(0.6, 0.6),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0, 0, 0, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            text_wordwrap=None,
            parent=self.frmPlayerInfo,
        )
        self.lblHealthValue.setTransparency(0)

        self.lblAttackValue = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.275, 0, -0.36),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='4',
            text_align=TextNode.A_center,
            text_scale=(0.6, 0.6),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0, 0, 0, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            text_wordwrap=None,
            parent=self.frmPlayerInfo,
        )
        self.lblAttackValue.setTransparency(0)
示例#12
0
    def __init__(self, rootParent=None):
        
        self.frmCreateRoom = DirectFrame(
            borderWidth=(0.01, 0.01),
            frameColor=(1, 1, 1, 1),
            frameSize=(-0.65, 0.65, -0.55, 0.55),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0, 0, 0),
            relief=5,
            parent=rootParent,
        )
        self.frmCreateRoom.setTransparency(0)

        self.btnOk = DirectButton(
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.425, 0, -0.45),
            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.frmCreateRoom,
            command=base.messenger.send,
            extraArgs=["createRoom_Ok"],
        )
        self.btnOk.setTransparency(0)

        self.btnCancel = DirectButton(
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.4, 0, -0.45),
            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.frmCreateRoom,
            command=base.messenger.send,
            extraArgs=["createRoom_Cancel"],
        )
        self.btnCancel.setTransparency(0)

        self.pg1640 = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0, 0, 0.425),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Create New Room',
            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.frmCreateRoom,
        )
        self.pg1640.setTransparency(0)

        self.pg2148 = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.05, 0, 0.24),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Room Name',
            text_align=TextNode.A_right,
            text_scale=(1, 1),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0, 0, 0, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            parent=self.frmCreateRoom,
        )
        self.pg2148.setTransparency(0)

        self.pg2173 = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.05, 0, 0.065),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='# of Players',
            text_align=TextNode.A_right,
            text_scale=(1, 1),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0, 0, 0, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            parent=self.frmCreateRoom,
        )
        self.pg2173.setTransparency(0)

        self.pg2201 = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.05, 0, -0.115),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Game Type',
            text_align=TextNode.A_right,
            text_scale=(1, 1),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0, 0, 0, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            parent=self.frmCreateRoom,
        )
        self.pg2201.setTransparency(0)

        self.entryRoomName = DirectEntry(
            hpr=LVecBase3f(0, 0, 0),
            overflow=1,
            pos=LPoint3f(0.08, 0, 0.25),
            scale=LVecBase3f(0.05, 0.1, 0.05),
            width=8.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.frmCreateRoom,
        )
        self.entryRoomName.setTransparency(0)

        self.optionNumPlayers = DirectOptionMenu(
            items=['item1'],
            frameSize=(0.07500000298023224, 3.012500149011612, -0.11250001192092896, 0.75),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.175, 0, 0.06),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='item1',
            cancelframe_frameSize=(-1, 1, -1, 1),
            cancelframe_hpr=LVecBase3f(0, 0, 0),
            cancelframe_pos=LPoint3f(0, 0, 0),
            cancelframe_relief=None,
            item_frameSize=(0.07500000298023224, 2.4125001430511475, -0.11250001192092896, 0.75),
            item_hpr=LVecBase3f(0, 0, 0),
            item_pos=LPoint3f(-0.075, 0, -0.75),
            item_text='item1',
            item0_text_align=TextNode.A_left,
            item0_text_scale=(1, 1),
            item0_text_pos=(0, 0),
            item0_text_fg=LVecBase4f(0, 0, 0, 1),
            item0_text_bg=LVecBase4f(0, 0, 0, 0),
            popupMarker_frameSize=(-0.5, 0.5, -0.2, 0.2),
            popupMarker_hpr=LVecBase3f(0, 0, 0),
            popupMarker_pos=LPoint3f(2.7125, 0, 0.31875),
            popupMarker_relief=2,
            popupMarker_scale=LVecBase3f(0.4, 0.4, 0.4),
            popupMenu_frameSize=(0, 2.3375001400709152, -0.862500011920929, 0),
            popupMenu_hpr=LVecBase3f(0, 0, 0),
            popupMenu_pos=LPoint3f(0, 0, 0),
            popupMenu_relief='raised',
            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.frmCreateRoom,
        )
        self.optionNumPlayers.setTransparency(0)

        self.optionGameType = DirectOptionMenu(
            items=['item1'],
            frameSize=(0.07500000298023224, 3.012500149011612, -0.11250001192092896, 0.75),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.175, 0, -0.125),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='item1',
            cancelframe_frameSize=(-1, 1, -1, 1),
            cancelframe_hpr=LVecBase3f(0, 0, 0),
            cancelframe_pos=LPoint3f(0, 0, 0),
            cancelframe_relief=None,
            item_frameSize=(0.07500000298023224, 2.4125001430511475, -0.11250001192092896, 0.75),
            item_hpr=LVecBase3f(0, 0, 0),
            item_pos=LPoint3f(-0.075, 0, -0.75),
            item_text='item1',
            item0_text_align=TextNode.A_left,
            item0_text_scale=(1, 1),
            item0_text_pos=(0, 0),
            item0_text_fg=LVecBase4f(0, 0, 0, 1),
            item0_text_bg=LVecBase4f(0, 0, 0, 0),
            popupMarker_frameSize=(-0.5, 0.5, -0.2, 0.2),
            popupMarker_hpr=LVecBase3f(0, 0, 0),
            popupMarker_pos=LPoint3f(2.7125, 0, 0.31875),
            popupMarker_relief=2,
            popupMarker_scale=LVecBase3f(0.4, 0.4, 0.4),
            popupMenu_frameSize=(0, 2.3375001400709152, -0.862500011920929, 0),
            popupMenu_hpr=LVecBase3f(0, 0, 0),
            popupMenu_pos=LPoint3f(0, 0, 0),
            popupMenu_relief='raised',
            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.frmCreateRoom,
        )
        self.optionGameType.setTransparency(0)

        self.pg629 = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            frameSize=(-1.15, 1.25, -0.113, 0.725),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(-0.055, 0, -0.3),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Difficulty',
            text_align=TextNode.A_right,
            text_scale=(1, 1),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0, 0, 0, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            parent=self.frmCreateRoom,
        )
        self.pg629.setTransparency(0)

        self.optionDifficulty = DirectOptionMenu(
            items=['item1'],
            frameSize=(0.1, 3.013, -0.113, 0.75),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.175, 0, -0.305),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='item1',
            cancelframe_frameSize=(-1, 1, -1, 1),
            cancelframe_hpr=LVecBase3f(0, 0, 0),
            cancelframe_pos=LPoint3f(0, 0, 0),
            cancelframe_relief=None,
            item_frameSize=(0.07500000298023224, 2.4125001430511475, -0.11250001192092896, 0.75),
            item_hpr=LVecBase3f(0, 0, 0),
            item_pos=LPoint3f(-0.075, 0, -0.75),
            item_text='item1',
            item0_text_align=TextNode.A_left,
            item0_text_scale=(1, 1),
            item0_text_pos=(0, 0),
            item0_text_fg=LVecBase4f(0, 0, 0, 1),
            item0_text_bg=LVecBase4f(0, 0, 0, 0),
            popupMarker_frameSize=(-0.5, 0.5, -0.2, 0.2),
            popupMarker_hpr=LVecBase3f(0, 0, 0),
            popupMarker_pos=LPoint3f(2.7125, 0, 0.31875),
            popupMarker_relief=2,
            popupMarker_scale=LVecBase3f(0.4, 0.4, 0.4),
            popupMenu_frameSize=(0, 2.3375001400709152, -0.862500011920929, 0),
            popupMenu_hpr=LVecBase3f(0, 0, 0),
            popupMenu_pos=LPoint3f(0, 0, 0),
            popupMenu_relief='raised',
            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.frmCreateRoom,
        )
        self.optionDifficulty.setTransparency(0)
示例#13
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)
示例#14
0
class OptionPageGui(ThanksPageGui):
    def __init__(self, mdt, menu, option_props):
        self._vol_slider = None
        self._fullscreen_cb = None
        self._lang_opt = None
        self._aa_cb = None
        self._res_opt = None
        self._browser_cb = None
        self.props = option_props
        ThanksPageGui.__init__(self, mdt, menu)

    def build_page(self):
        menu_gui = self.menu.gui
        menu_args = self.menu.gui.menu_args
        self.pagewidgets = []

        def add_lab(txt, txt_tr, z):
            lab = DirectLabel(text='',
                              pos=(-.1, 1, z),
                              text_align=TextNode.ARight,
                              **menu_gui.label_args)
            PageGui.transl_text(lab, txt, txt_tr)
            self.pagewidgets += [lab]
            return lab

        add_lab('Language', _('Language'), .5)
        self._lang_opt = DirectOptionMenu(text='',
                                          items=eng.languages,
                                          pos=(.49, 1, .5),
                                          initialitem=self.props.lang,
                                          command=self.__change_lang,
                                          **menu_gui.option_args)
        add_lab('Volume', _('Volume'), .3)
        self._vol_slider = DirectSlider(pos=(.52, 0, .33),
                                        scale=.49,
                                        value=self.props.volume,
                                        frameColor=menu_args.btn_color,
                                        thumb_frameColor=menu_args.text_fg,
                                        command=self.__on_volume)
        fullscreen_lab = add_lab('Fullscreen', _('Fullscreen'), .1)
        self._fullscreen_cb = DirectCheckButton(
            pos=(.12, 1, .12),
            text='',
            indicatorValue=self.props.fullscreen,
            indicator_frameColor=menu_args.text_fg,
            command=lambda val: eng.toggle_fullscreen(),
            **menu_gui.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_gui.option_args)
        add_lab('Antialiasing', _('Antialiasing'), -.3)
        aa_next_lab = DirectLabel(text='',
                                  pos=(.2, 1, -.3),
                                  text_align=TextNode.ALeft,
                                  **menu_gui.label_args)
        PageGui.transl_text(aa_next_lab, '(from the next execution)',
                            _('(from the next execution)'))
        self._aa_cb = DirectCheckButton(pos=(.12, 1, -.27),
                                        text='',
                                        indicatorValue=self.props.aa,
                                        indicator_frameColor=menu_args.text_fg,
                                        **menu_gui.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
        bld_in = lambda: self.menu.logic.push_page(
            InputPage(self.menu, self.props.joystick, self.props.opt_file[
                'settings']['keys']))
        input_btn = DirectButton(text='',
                                 pos=(0, 1, -.5),
                                 command=bld_in,
                                 **menu_gui.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
        ]
        map(self.add_widget, self.pagewidgets)
        idx = LangMgr().lang_codes.index(self.props.lang)
        self.__change_lang(eng.languages[idx])
        ThanksPageGui.build_page(self)

    def update_texts(self):
        PageGui.update_texts(self)
        curr_lang = LangMgr().curr_lang
        self._lang_opt.set({'en': 0, 'it': 1}[curr_lang], fCommand=0)

    def __on_volume(self):
        eng.set_volume(self._vol_slider['value'])

    def __change_lang(self, arg):
        lang_dict = {'English': 'en', 'Italiano': 'it'}
        LangMgr().set_lang(lang_dict[arg])
        self.update_texts()