Пример #1
0
class BetterButton(DebugObject):
  
    """ This is a wrapper around DirectButton, providing a simpler interface
    and better visuals """

    def __init__(self, parent, x, y, text, width=50, callback=None,
                 callbackArgs=None):

        DebugObject.__init__(self, "BetterButton")

        if callbackArgs is None:
            callbackArgs = []

        self._node = DirectButton(text=text, parent=parent, pressEffect=1,
                                  command=callback, extraArgs=callbackArgs,
                                  scale=1, pos=(x + width, 1, -y - 15),
                                  frameSize=(-width, width, -15, 15),
                                  text_fg=(1, 1, 1, 1),
                                  frameColor=(0.1, 0.1, 0.1, 1.0),
                                  text_font=Globals.font, text_pos=(0, -4),
                                  text_scale=14)

        # Add a hover effect
        self._node.bind(DGG.ENTER, self._onMouseOver)
        self._node.bind(DGG.EXIT, self._onMouseOut)

    def _onMouseOver(self, coords):
        self._node["frameColor"] = (0.0, 0.0, 0.0, 1.0)

    def _onMouseOut(self, coords):
        self._node["frameColor"] = (0.1, 0.1, 0.1, 1.0)
Пример #2
0
class CatalogRadioButton(NodePath):
    def __init__(self, parent, nodeName, clickEvent):
        NodePath.__init__(self, parent.attachNewNode(nodeName))

        self.radioButtons = []
        self.clickEvent = clickEvent

        self.normalNode = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'_UP').copyTo(self)
        self.clickedNode = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'_DN').copyTo(self)
        self.hoverNode = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'_OVR').copyTo(self)

        self.statusIndicator = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'Radio_ON').copyTo(self)
        self.statusIndicator.hide()

        self.radioButton = DirectButton(parent=self, relief=None, image=(self.normalNode, self.clickedNode, self.hoverNode), command=self.enable)

    def setOthers(self, radioButtons):
        self.radioButtons = radioButtons

    def enable(self):
        for radioButton in self.radioButtons:
            radioButton.disable()

        self.statusIndicator.show()
        self.clickEvent()

    def disable(self):
        self.statusIndicator.hide()

    def cleanup(self):
        self.radioButton.destroy()

        NodePath.removeNode(self)
Пример #3
0
    def __init__(self, rootParent=None):

        self.btnEndTurn = DirectButton(
            borderWidth=(0.0, 0.0),
            frameColor=(0.8, 0.8, 0.8, 0.0),
            frameSize=(-3.0, 3.0, -1.0, 1.0),
            hpr=LVecBase3f(0, 0, 0),
            image='./assets/Turn/EndTurn.png',
            pos=LPoint3f(0, 0, 0.1),
            relief=1,
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='End Turn',
            image_scale=LVecBase3f(3, 0, 1),
            image_pos=LPoint3f(0, 0, 0),
            text_align=TextNode.A_center,
            text_scale=(1.0, 1.0),
            text_pos=(0.0, -0.3),
            text_fg=LVecBase4f(1, 1, 1, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            parent=rootParent,
            command=base.messenger.send,
            extraArgs=["endTurn"],
            pressEffect=0,
        )
        self.btnEndTurn.setTransparency(1)
Пример #4
0
 def configureImportMenu(self):
     importBackground= OnscreenImage(parent=render2dp, 
     image='../textures/BGM_ORG.jpg') 
     newNameBox = DirectEntry(text = "" ,pos=(-0.4,0,0.5),scale=.08,
                                     frameColor=(1,1,1,0.3),initialText="", 
                                             numLines = 3,focus=1) 
     newPathBox = DirectEntry(text = "" ,pos=(-0.4,0,0.2),
                                         frameColor=(1,1,1,0.3),
             scale=.08,
             initialText="", numLines = 5,focus=1)
     confirmationButton=DirectButton(text='IMPORT',pos=(0, 0, -0.3),
                                scale=.1, pad=(.2, .2),
                                 frameColor=(0.058,.294,0.545,0.7),
                                 text_pos=(0,-0.3),text_scale=(0.8,0.8),
                                 text_fg=(0.88,0.98,1,1),
                                 frameSize=(-6.5,6.5,-0.8,0.8),
                                rolloverSound=None, clickSound=None,
                                command=self.importNewSong)
     backToOptionButton=DirectButton(text='<<BACK TO MUSIC LIST',
                                 pos=(-1,0,0.8),scale=.1,pad=(.2, .2),
                                 frameColor=(1,1,1,0),
                                 text_pos=(1.3,-0.3),text_scale=(0.8,0.8),
                                 text_fg=(0.88,0.98,1,1),
                                rolloverSound=None, clickSound=None,
                                command=lambda: self.switchPanel('import','mainMenu'))
     self.setPanel('import',Panel(importBackground, {'newName': newNameBox,
                     'newPath': newPathBox,'confirmButton': confirmationButton,
                     'back':backToOptionButton}))
 def load(self):
     btnGui = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_newsBtnGui')
     bookModel = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_shtickerBook')
     self.openNewNewsUp = btnGui.find('**/tt_t_gui_ign_new')
     self.openNewNewsUpBlink = btnGui.find('**/tt_t_gui_ign_newBlink')
     self.openNewNewsHover = btnGui.find('**/tt_t_gui_ign_newHover')
     self.openOldNewsUp = btnGui.find('**/tt_t_gui_ign_oldNews')
     self.openOldNewsHover = btnGui.find('**/tt_t_gui_ign_oldHover')
     self.closeNewsUp = bookModel.find('**/tt_t_gui_sbk_newsPage1')
     self.closeNewsHover = bookModel.find('**/tt_t_gui_sbk_newsPage2')
     btnGui.removeNode()
     bookModel.removeNode()
     oldScale = 0.5
     newScale = 0.9
     shtickerBookScale = 0.305
     newPos = VBase3(0.914, 0, 0.862)
     shtickerBookPos = VBase3(1.175, 0, -0.83)
     textScale = 0.06
     self.newIssueButton = DirectButton(relief=None, sortOrder=DGG.BACKGROUND_SORT_INDEX - 1, image=(self.openNewNewsUp, self.openNewNewsHover, self.openNewNewsHover), text=('', TTLocalizer.EventsPageNewsTabName, TTLocalizer.EventsPageNewsTabName), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=textScale, text_font=ToontownGlobals.getInterfaceFont(), pos=newPos, scale=newScale, command=self.__handleGotoNewsButton)
     self.gotoPrevPageButton = DirectButton(relief=None, image=(self.closeNewsUp, self.closeNewsHover, self.closeNewsHover), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=textScale, text_font=ToontownGlobals.getInterfaceFont(), pos=shtickerBookPos, scale=shtickerBookScale, command=self.__handleGotoPrevPageButton)
     self.goto3dWorldButton = DirectButton(relief=None, image=(self.closeNewsUp, self.closeNewsHover, self.closeNewsHover), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=textScale, text_font=ToontownGlobals.getInterfaceFont(), pos=shtickerBookPos, scale=shtickerBookScale, command=self.__handleGoto3dWorldButton)
     self.hideNewIssueButton()
     self.gotoPrevPageButton.hide()
     self.goto3dWorldButton.hide()
     self.accept('newIssueOut', self.handleNewIssueOut)
     bounce1Pos = VBase3(newPos.getX(), newPos.getY(), newPos.getZ() + 0.022)
     bounce2Pos = VBase3(newPos.getX(), newPos.getY(), newPos.getZ() + 0.015)
     bounceIval = Sequence(LerpPosInterval(self.newIssueButton, 0.1, bounce1Pos, blendType='easeOut'), LerpPosInterval(self.newIssueButton, 0.1, newPos, blendType='easeIn'), LerpPosInterval(self.newIssueButton, 0.07, bounce2Pos, blendType='easeOut'), LerpPosInterval(self.newIssueButton, 0.07, newPos, blendType='easeIn'))
     self.__blinkIval = Sequence(Func(self.__showOpenEyes), Wait(2), bounceIval, Wait(0.5), Func(self.__showClosedEyes), Wait(0.1), Func(self.__showOpenEyes), Wait(0.1), Func(self.__showClosedEyes), Wait(0.1))
     self.__blinkIval.loop()
     self.__blinkIval.pause()
     self.buttonsLoaded = True
     return
Пример #6
0
Файл: ui.py Проект: rdb/hexima
    def __init__(self,
                 parent,
                 number=1,
                 pos=(0, 0),
                 command=None,
                 extraArgs=[],
                 locked=False):
        text = '⚀⚁⚂⚃⚄⚅'[number - 1]
        self.path = DirectButton(parent=parent.path,
                                 text_fg=UI_COLOR,
                                 text_font=base.symbol_font,
                                 relief=None,
                                 text=text,
                                 scale=0.07,
                                 text_scale=2,
                                 pos=(pos[0], 0, pos[1]),
                                 command=command,
                                 extraArgs=extraArgs)

        #text = ''[number - 1]
        #self.path = DirectButton(parent=parent.path, text_fg=UI_COLOR, text_font=self.font, relief=None, text=text, scale=0.07, pos=(pos[0], 0, pos[1]))
        self.path.set_shader_off(1)
        self.path.set_color_scale_off(1)

        self.badge = None
        if locked:
            self.path.set_color_scale((1, 1, 1, 0.5))
            self.set_badge('')
Пример #7
0
    def __init__(self):

        ShowBase.__init__(self)

        #load background image
        self.__image = OnscreenImage(image='../../resources/images/main_menu.jpg', pos=(0, 0, 0), scale=1)
        self.__image.setSx(self.getAspectRatio())
        self.__image.setTransparency(TransparencyAttrib.MAlpha)

        #Three main opertaions
        self.__newGameButton = DirectButton(pos=(-0.9, 0, 0.5,), text=("新的游戏"), scale=0.1,
                                            command=self.new_game,frameColor=(0,0,0,0),
                                            image=("../../resources/images/main_menu.jpg","../../resources/images/main_menu.jpg",
                                                   "../../resources/images/main_menu.jpg"))
        self.__selectArchiveButton = DirectButton(pos=(-0.9, 0, 0.3,), text="选择存档", scale=0.1,text_fg=(1,1,1,1),
                                            command=self.select_archives, frameColor=(0, 0, 0, 0),
                                            image=("../../resources/images/main_menu.jpg", "../../resources/images/main_menu.jpg",
                                                   "../../resources/images/main_menu.jpg"))
        self.__exitGameButton = DirectButton(pos=(-0.9, 0, 0.1,), text="退出游戏", scale=0.1,text_fg=(1,1,1,1),
                                            command=self.exit_game, frameColor=(0, 0, 0, 0),
                                            image=("../../resources/images/main_menu.jpg", "../../resources/images/main_menu.jpg",
                                                   "../../resources/images/main_menu.jpg"))

        #add task to update background-image scale
        self.taskMgr.add(self.example_task, 'exampleTask')

        self.__rm=ResourcesManager()
Пример #8
0
 def build_page(self):
     self.frm = DirectFrame(frameSize=(-1.5, 1.5, -.9, .9),
                            frameColor=(.95, .95, .7, .85))
     txt = _("What do you want to do?\n\nNB Use 'p' for pausing the game.")
     menu_args = self.menu.gui.menu_args
     self.txt = OnscreenText(text=txt,
                             pos=(0, .64),
                             scale=.08,
                             wordwrap=32,
                             fg=menu_args.text_fg,
                             font=menu_args.font)
     on_back = lambda: self.on_end(True)
     on_end = lambda: self.on_end(False)
     menu_data = [('back to the game', _('back to the game'), on_back),
                  ('back to the main menu', _('back to the main menu'),
                   on_end)]
     btn_args = self.menu.gui.btn_args
     btn_visit = DirectButton(text=menu_data[0][1],
                              pos=(0, 1, 0),
                              command=menu_data[0][2],
                              text_scale=.8,
                              **btn_args)
     btn_dont_visit = DirectButton(text=menu_data[1][1],
                                   pos=(0, 1, -.5),
                                   command=menu_data[1][2],
                                   text_scale=.8,
                                   **btn_args)
     map(self.add_widget, [self.frm, self.txt, btn_visit, btn_dont_visit])
     PageGui.build_page(self, False)
     eng.hide_cursor()
     eng.show_standard_cursor()
     eng.do_later(.01, eng.toggle_pause, [False])
Пример #9
0
 def __init__(self):
     # create world
     self.world = cWorld()
     # setup controls
     self.setupControls()
     # display title information
     self.title = OnscreenText(text='BOIDS.PY - SEEK & ARRIVE',
                               fg=(1.0, 1.0, 1.0, 1.0),
                               pos=(-.98, .9),
                               scale=0.06)
     # display copright information
     self.copyRight = OnscreenText(text='Copyright (C) 2016 David Lettier.',
                                   fg=(1.0, 1.0, 1.0, 1.0),
                                   pos=(.98, -.98),
                                   scale=0.05)
     # display panda version text
     self.pandaVersion = OnscreenText(text='Panda Version 1.9.2',
                                      fg=(1.0, 1.0, 1.0, 1.0),
                                      pos=(-1.18, -.98),
                                      scale=0.04)
     # display print debug button
     # this button calls the prntDebug function
     self.prntDebugButton = DirectButton(text="Print Debug",
                                         relief=DGG.RAISED,
                                         scale=.1,
                                         pad=(.5, .5),
                                         pos=Vec3(-1.0, 0.0, -.8),
                                         command=self.prntDebug)
Пример #10
0
    def configureSetting(self):
        self.settingBackground = OnscreenImage(parent=render2dp, image='../textures/SET_ORG.jpg') 

        self.difficulty=OnscreenText(pos=(0.4,0.3),scale=0.08,fg=(0.88,0.98,1,1),
                                    text='Difficulty:')
        
        self.setDifficultyButton=DirectButton(pos=(0.6,0,0),scale=.1, pad=(.2, .2),
                                    frameColor=(0.058,0.294,0.545,0.7),
                                    frameSize=(-1.5,5,-0.8,0.8),
                                    text_pos=(1,-0.3),text_scale=(0.8,0.8),
                                    text_fg=(0.88,0.98,1,1),text=self.difficultyLevel,
                                    command=self.changeDifficulty)

        self.backToOptionButton3=DirectButton(text='<<BACK TO MENU',
                                    pos=(-1,0,0.8),scale=.1,pad=(.2, .2),
                                    frameColor=(1,1,1,0),
                                    text_pos=(1.3,-0.3),text_scale=(0.8,0.8),
                                    text_fg=(0.88,0.98,1,1),
                                   rolloverSound=None, clickSound=None,
                                   command=lambda: self.switchPanel('setting', 'options'))

        self.panels['setting'] = Panel(self.settingBackground,
                                        {'level': self.difficulty,
                                          'change': self.setDifficultyButton,
                                          'back': self.backToOptionButton3})
Пример #11
0
    def createHighScoreFrame(self):
        highScoreFrame=DirectScrolledFrame(frameColor=(0.5,0.5,1,0),
                                        canvasSize = (-0.3,0.2,-2,1), 
                            frameSize = (-0.3,1.1,-0.8,0.3),pos=(0.2,0,0.2))

        highScoreFrame['verticalScroll_thumb_frameColor']=(1,1,1,0.3)
        highScoreFrame['verticalScroll_incButton_frameColor']=(1,1,1,0)
        highScoreFrame['verticalScroll_decButton_frameColor']=(1,1,1,0)
        highScoreFrame['verticalScroll_frameColor']=(0.5,0.5,1,0)

        highScoreTitle1=DirectLabel(frameSize=(-0.6,0.6,-0.2,.2),pos=(0,0,0.9),
            text='Music',frameColor=(0,0,0,0),
            text_align=TextNode.ALeft,text_scale=0.08,text_fg=(1,1,1,1))
        highScoreTitle2=DirectLabel(frameSize=(-0.6,0.6,-0.6,.6),pos=(0.4,0,0.9),
            text='Highest Score',text_fg=(1,1,1,1),frameColor=(0,0,0,0),
            text_align=TextNode.ALeft,text_scale=0.08)

        highScoreTitle1.reparentTo(highScoreFrame.getCanvas())
        highScoreTitle2.reparentTo(highScoreFrame.getCanvas())

        for i in range(len(self.musicNames)):
            scoreLabel=DirectButton(frameSize=(-0.3,0.3,-0.2,.2),pos=(0,0,0.7-i*0.2),
            text='%s:  %d'%(self.musicNames[i],self.highestScores[self.musicNames[i]]),
            text_align=TextNode.ALeft,text_scale=0.08,frameColor=(0,0,0,0),
            text_fg=(1,1,1,1))
            scoreLabel.reparentTo(highScoreFrame.getCanvas())
        return highScoreFrame
Пример #12
0
    def introButtons(self):
        self.imageObject = OnscreenImage(image='stat_board.png', pos=(0, 0, 0))
        self.imageObject.setTransparency(TransparencyAttrib.MAlpha)

        buttonImage = loader.loadModel("phase_3/models/gui/quit_button.bam")
        self.testLoadingScreen = DirectButton(frameSize=None, text="Test Loading Game", image=(buttonImage.find('**/QuitBtn_UP'),
                                                                                buttonImage.find('**/QuitBtn_DN'),
                                                                                buttonImage.find('**/QuitBtn_RLVR')),
                                       relief=None, command=self.loadTest, text_pos=(0, -0.015),
                                       geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(0.00, 0.00, 0.60),
                                       text_scale=0.059999999999999998, borderWidth=(0.015, 0.01), scale=2.53)
        self.loadButton = DirectButton(frameSize=None, text="Load Game", image=(buttonImage.find('**/QuitBtn_UP'),
                                                                 buttonImage.find('**/QuitBtn_DN'),
                                                                 buttonImage.find('**/QuitBtn_RLVR')),
                               relief=None, command=self.loadGame, text_pos=(0, -0.015),
                               geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(0.00, 0.00, 0.30),
                               text_scale=0.059999999999999998, borderWidth=(0.015, 0.01), scale=2.53)
        self.customizeButton = DirectButton(frameSize=None, text="Customize", image=(buttonImage.find('**/QuitBtn_UP'),
                                                                 buttonImage.find('**/QuitBtn_DN'),
                                                                 buttonImage.find('**/QuitBtn_RLVR')),
                               relief=None, command=self.loadCustomize, text_pos=(0, -0.015),
                               geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(0.00, 0.00, -0.30),
                               text_scale=0.059999999999999998, borderWidth=(0.015, 0.01), scale=2.53)
        self.arenaButton = DirectButton(frameSize=None, text="Arena Game", image=(buttonImage.find('**/QuitBtn_UP'),
                                                                 buttonImage.find('**/QuitBtn_DN'),
                                                                 buttonImage.find('**/QuitBtn_RLVR')),
                               relief=None, command=self.loadArena, text_pos=(0, -0.015),
                               geom=None, pad=(0.01, 0.01), suppressKeys=0, pos=(0.00, 0.00, 0),
                               text_scale=0.059999999999999998, borderWidth=(0.015, 0.01), scale=2.53)
        buttonImage.removeNode()
Пример #13
0
    def __init__(self,
                 parent,
                 x,
                 y,
                 text,
                 width=50,
                 callback=None,
                 callbackArgs=None):

        DebugObject.__init__(self, "BetterButton")

        if callbackArgs is None:
            callbackArgs = []

        self._node = DirectButton(text=text,
                                  parent=parent,
                                  pressEffect=1,
                                  command=callback,
                                  extraArgs=callbackArgs,
                                  scale=1,
                                  pos=(x + width, 1, -y - 15),
                                  frameSize=(-width, width, -15, 15),
                                  text_fg=(1, 1, 1, 1),
                                  frameColor=(0.1, 0.1, 0.1, 1.0),
                                  text_font=Globals.font,
                                  text_pos=(0, -4),
                                  text_scale=14)

        # Add a hover effect
        self._node.bind(DGG.ENTER, self._onMouseOver)
        self._node.bind(DGG.EXIT, self._onMouseOut)
Пример #14
0
    def __init__(self):
        """ Initialization of the connect 4"""
        print('General > Initialization')
        super().__init__()

        # General settings
        # self.disable_mouse()

        # Load the background
        self.background = OnscreenImage(parent=self.render2dp,
                                        image="tex/bedroom.jpg")
        self.cam2dp.node().getDisplayRegion(0).setSort(-20)

        # Load the avatar
        self.arm = Actor("models/Tatsumi_models/Tatsumi_1",
                         {"anim1": "models/Tatsumi_models/Tatsumi_1_anim"})
        self.arm.setPos(0, 50, -36)
        self.arm.setScale(20, 20, 20)
        self.arm.reparentTo(self.render)
        self.arm.setPlayRate(4, "anim1")
        self.arm.play("anim1")

        # Load the buttons
        self.icon_connect4 = DirectButton(image="img/connect4.png",
                                          pos=(-1.5, 0, -0.8),
                                          scale=(0.2, 0.2, 0.2),
                                          relief=None,
                                          command=self.run_connect4)
        self.icon_connect4.setTransparency(TransparencyAttrib.MAlpha)

        self.games = []
Пример #15
0
 def doContinue(self):
   if(self.gameState == 'INIT'):
     self.gameState = 'MENU'
     self.menuMusic.play()
     self.text.hide()
     self.startBtn = DirectButton(text=("Play"), scale = 0.1, pos = (0.5,0,0),command=self.playGame)
     self.helpBtn = DirectButton(text=("Help"), scale = 0.1, pos = (0.5,0,-0.2),command=self.help)
     self.exitBtn = DirectButton(text=("Exit"), scale = 0.1,  pos = (0.5,0,-0.4), command = self.doExit)
     return
     
   if(self.gameState == 'RETRY'):
     self.retryScreen.show()
     self.retryBtn.show()
     
     self.loseSound.play()
     return
   
   if(self.gameState == 'LOSE'):
     self.loseScreen.show()
     self.menuBtn.show()
     return
   
   if(self.gameState == 'WIN'):
     if(self.gameLevel < 3):
       self.congratScreen.show()
       self.nextBtn.show()
     elif(self.gameLevel >= 3):
       self.winScreen.show()
       self.menuBtn.show()
     self.finalScoreText.setText('Your Score: '+str(int(self.score)))
     self.finalScoreText.show()
       
     self.winSound.play()
    def init_pawn_change_panel(self, side, move):
        self.pawn_change_panel = self.objMngr.load_plane_textured(
            "ChessRender/data/panel.png")
        self.pawn_change_panel.reparentTo(self.render_fsm_ref.aspect2d)
        self.pawn_change_panel.setPos((0, 0, -0.85))
        self.pawn_change_panel.setSx(1.8)
        self.pawn_change_panel.setSz(0.3)

        if side is Side.WHITE:
            swaped_figures = ["Q", "N", "B", "R"]
        else:
            swaped_figures = ["q", "n", "b", "r"]

        print('Side is ' + str(side))
        self.swaped_icons = []
        figure_num = 0
        for swaped_figure in swaped_figures:
            but = DirectButton(text="",
                               scale=0.13,
                               command=self.swap_pawn_command,
                               extraArgs=[swaped_figure, move],
                               frameColor=((0.8, 0.8, 0.8, 0.0)),
                               pos=(-0.5 + 0.35 * figure_num, 0, -0.85),
                               image=self.objMngr.textures[
                                   figure_as_render_object(swaped_figure)])
            but.setTransparency(TransparencyAttrib.MAlpha)
            self.swaped_icons.append(but)
            figure_num += 1
Пример #17
0
    def addWinIndicator(self, avId, card):
        if not avId or card is None:
            return

        trackId, cardTier = card

        index = len(self.roundResults[avId][trackId])
        if avId != base.localAvatar.doId:
            index += 5

        image = self.trackIcons[trackId].copyTo(NodePath())
        np = CARD_MODELS[cardTier].copyTo(NodePath())
        image.reparentTo(np)
        image.setScale(ICON_SCALE[trackId])
        image.setR(-90)
        card = DirectButton(parent=aspect2d,
                            relief=None,
                            geom=np,
                            geom_hpr=UNREVEALED_HPR,
                            geom_scale=0.3,
                            state=DGG.DISABLED,
                            command=self.doNothing,
                            scale=(0.2, 1, 0.2))

        pos = WON_CARD_POSITIONS[trackId][index]
        card.setPos(pos)
        self.winIndicators.append(card)
Пример #18
0
 def build_page(self):
     menu_args = self.menu.gui.menu_args
     self.frm = DirectFrame(frameSize=(-1.5, 1.5, -.9, .9),
                            frameColor=(.95, .95, .7, .85))
     txt = _(
         'Please, visit our site after exiting!\n\nIt helps us! Thank you!')
     self.txt = OnscreenText(text=txt,
                             pos=(0, .64),
                             scale=.08,
                             wordwrap=32,
                             fg=menu_args.text_fg,
                             font=menu_args.font)
     menu_data = [('visit our site after exiting',
                   _('visit our site after exiting'),
                   lambda: self.on_end(True)),
                  ("don't visit our site after exiting",
                   _("don't visit our site after exiting"),
                   lambda: self.on_end(False))]
     btn_args = self.menu.gui.btn_args
     btn_args['frameSize'] = (-12, 12, -.8, 1.2)
     btn_visit = DirectButton(text=menu_data[0][1],
                              pos=(0, 1, 0),
                              command=menu_data[0][2],
                              text_scale=.9,
                              **btn_args)
     btn_dont_visit = DirectButton(text=menu_data[1][1],
                                   pos=(0, 1, -.5),
                                   command=menu_data[1][2],
                                   text_scale=.7,
                                   **btn_args)
     widgets = [self.frm, self.txt, btn_visit, btn_dont_visit]
     map(self.add_widget, widgets)
     PageGui.build_page(self, False)
Пример #19
0
    def __init__(self):
        DirectButton.__init__(self,
                              parent=aspect2d,
                              frameColor=(1, 1, 1, 0),
                              relief=DGG.FLAT,
                              commandButtons=[])
        self.accept('window-event', self.windowResize)
        self.windowResize(None)
        #trick: make this re-throw mouse events
        self.bind(self.B1PRESS, self.rethrowEvent, ['mouse1'])
        self.bind(self.B2PRESS, self.rethrowEvent, ['mouse2'])
        self.bind(self.B3PRESS, self.rethrowEvent, ['mouse3'])
        self.bind(self.B4PRESS, self.rethrowEvent, ['mouse4'])
        self.bind(self.B5PRESS, self.rethrowEvent, ['mouse5'])

        self.bind(self.WHEELUP, self.rethrowEvent, ['wheel_up'])
        self.bind(self.WHEELDOWN, self.rethrowEvent, ['wheel_down'])
        self.bind(self.WHEELLEFT, self.rethrowEvent, ['wheel_left'])
        self.bind(self.WHEELRIGHT, self.rethrowEvent, ['wheel_right'])

        self.bind(self.B1RELEASE, self.rethrowEvent, ['mouse1-up'])
        self.bind(self.B2RELEASE, self.rethrowEvent, ['mouse2-up'])
        self.bind(self.B3RELEASE, self.rethrowEvent, ['mouse3-up'])
        self.bind(self.B4RELEASE, self.rethrowEvent, ['mouse4-up'])
        self.bind(self.B5RELEASE, self.rethrowEvent, ['mouse5-up'])
Пример #20
0
 def __init__(self, text, pos, parent=None, **kwargs):
     kwargs['text'] = text
     kwargs['pressEffect'] = 1  # Button appears to press when clicked
     kwargs['pos'] = pos
     kwargs['scale'] = .1
     kwargs['pad'] = (.5, .5)
     DirectButton.__init__(self, parent, **kwargs)
     self.initialiseoptions(BBButton)  # needed for subclassing DirectGui
Пример #21
0
    def __init__(self, rootParent=None):
        
        self.frmMain = DirectFrame(
            frameColor=(0.25, 0.25, 0.25, 1.0),
            frameSize=(0.0, 2.0, -0.1, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0, 0, 0),
            parent=rootParent,
        )
        self.frmMain.setTransparency(0)

        self.btnLeave = DirectButton(
            hpr=LVecBase3f(0, 0, 0),
            pad=(0.1, 0.1),
            pos=LPoint3f(0.115, 0, -0.075),
            relief=1,
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Leave',
            text_align=TextNode.A_center,
            text_scale=(0.75, 0.75),
            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=["leaveRoom"],
        )
        self.btnLeave.setTransparency(0)

        self.lblPlayerName = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.55, 0, -0.075),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Label',
            text_align=TextNode.A_left,
            text_scale=(0.75, 0.75),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0.8, 0.8, 0.8, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            parent=self.frmMain,
        )
        self.lblPlayerName.setTransparency(0)

        self.pg1983 = DirectLabel(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0.42, 0, -0.075),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Name:',
            text_align=TextNode.A_center,
            text_scale=(0.75, 0.75),
            text_pos=(0, 0),
            text_fg=LVecBase4f(0.6, 0.6, 0.6, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            parent=self.frmMain,
        )
        self.pg1983.setTransparency(0)
Пример #22
0
    def setting_menu(self):
        if self.__destroySetting==False:
            # 设置界面背景图
            self.__background = OnscreenImage(image='../../resources/images/settings/setting_frame.png', pos=(0, 0, 0),
                                              scale=(1.0, 0, 0.7))
            self.__background.setTransparency(TransparencyAttrib.MAlpha)

            ##滑动条
            self.__slider = DirectSlider(pos=(0.16, 0, 0.26), scale=0.5, value=0.5, command=self.__setMusicSliderVolume,
                                         frameSize=(-1.0, 0.9, -0.06, 0.06),
                                         image='../../resources/images/settings/slide_bar.png',
                                         image_pos=(-0.05, 0, 0.0), image_scale=(1.0, 0, 0.05),
                                         thumb_image='../../resources/images/settings/slide_btn.png',
                                         thumb_image_pos=(-0.0, 0, 0.0), thumb_image_scale=0.1,
                                         thumb_frameSize=(0.0, 0.0, 0.0, 0.0))
            self.__slider.setTransparency(TransparencyAttrib.MAlpha)

            # self.__musicButton = DirectButton(pos=(0.9, 0, 0.75), text="Close", scale=0.1, pad=(0.2, 0.2), rolloverSound=None,
            #                                   clickSound=None, command=self.toggleMusicBox,extraArgs=[base])

            # 继续按钮
            self.__continueButton = DirectButton(pos=(-0.25, 0, 0.0), text="", scale=(0.2, 0, 0.1),
                                                 command=self.__continue_game,
                                                 image=("../../resources/images/settings/btn_continue_0.png",
                                                        "../../resources/images/settings/btn_continue_0.png"
                                                        , "../../resources/images/settings/btn_continue_1.png"),
                                                 frameColor=(0, 0, 0, 0))
            self.__continueButton.setTransparency(TransparencyAttrib.MAlpha)

            # 存档按钮
            self.__saveButton = DirectButton(pos=(0.33, 0, 0.0), text="", scale=(0.2, 0, 0.1), command=self.__save_game,
                                             image=("../../resources/images/settings/btn_save_0.png",
                                                    "../../resources/images/settings/btn_save_0.png"
                                                    , "../../resources/images/settings/btn_save_1.png"),
                                             frameColor=(0, 0, 0, 0))
            self.__saveButton.setTransparency(TransparencyAttrib.MAlpha)

            # 帮助按钮
            self.__helpButton = DirectButton(pos=(-0.25, 0, -0.25), text="", scale=(0.2, 0, 0.1), command=self.__help,
                                             image=("../../resources/images/settings/btn_help_0.png",
                                                    "../../resources/images/settings/btn_help_0.png"
                                                    , "../../resources/images/settings/btn_help_1.png"),
                                             frameColor=(0, 0, 0, 0))
            self.__helpButton.setTransparency(TransparencyAttrib.MAlpha)

            # 回到主界面按钮
            self.__homeButton = DirectButton(pos=(0.33, 0, -0.25), text="", scale=(0.2, 0, 0.1), command=self.__return_home,
                                             image=("../../resources/images/settings/btn_home_0.png",
                                                    "../../resources/images/settings/btn_home_0.png"
                                                    , "../../resources/images/settings/btn_home_1.png"),
                                             frameColor=(0, 0, 0, 0))
            self.__homeButton.setTransparency(TransparencyAttrib.MAlpha)

            # 设置滑动条value
            self.__slider['value'] = self.__rm.get_volume()

            self.__destroySetting = True
Пример #23
0
 def load(self):
     buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui')
     upButton = buttonModels.find('**//InventoryButtonUp')
     downButton = buttonModels.find('**/InventoryButtonDown')
     rolloverButton = buttonModels.find('**/InventoryButtonRollover')
     self.exitButton = DirectButton(
         relief=None,
         text=TTLocalizer.PartyTeamActivityExitButton,
         text_fg=(1, 1, 0.65, 1),
         text_pos=(0, -0.15),
         text_scale=0.5,
         image=(upButton, downButton, rolloverButton),
         image_color=(1, 0, 0, 1),
         image_scale=(14.5, 1, 9),
         pos=(0, 0, 0.8),
         scale=0.15,
         command=self.handleExitButtonClick)
     self.exitButton.hide()
     if self.activity.toonsCanSwitchTeams():
         self.switchButton = DirectButton(
             relief=None,
             text=TTLocalizer.PartyTeamActivitySwitchTeamsButton,
             text_fg=(1, 1, 1, 1),
             text_pos=(0, 0.1),
             text_scale=0.5,
             image=(upButton, downButton, rolloverButton),
             image_color=(0, 1, 0, 1),
             image_scale=(15, 1, 15),
             pos=(0, 0, 0.5),
             scale=0.15,
             command=self.handleSwitchButtonClick)
         self.switchButton.hide()
     else:
         self.switchButton = None
     buttonModels.removeNode()
     self.countdownText = OnscreenText(
         text='',
         pos=(0.0, -0.2),
         scale=PartyGlobals.TeamActivityTextScale * 1.2,
         fg=(1.0, 1.0, 0.65, 1.0),
         align=TextNode.ACenter,
         font=ToontownGlobals.getSignFont(),
         mayChange=True)
     self.countdownText.hide()
     self.statusText = OnscreenText(
         text='',
         pos=(0.0, 0.0),
         scale=PartyGlobals.TeamActivityTextScale,
         fg=PartyGlobals.TeamActivityStatusColor,
         align=TextNode.ACenter,
         font=ToontownGlobals.getSignFont(),
         mayChange=True)
     self.statusText.hide()
     self.timer = PartyUtils.getNewToontownTimer()
     self.timer.hide()
     return
    def __init__(self, phone, doneEvent=None):
        NodePath.__init__(self, aspect2d.attachNewNode('CatalogGUI'))
        DirectObject.__init__(self)

        CatalogGlobals.CatalogNodePath.find('**/CATALOG_GUI_BKGD').copyTo(self)
        self.setScale(CatalogGlobals.CatalogBKGDScale)

        self.phone = phone
        self.doneEvent = doneEvent

        self.arrowButtons = {}
        self.createArrowButtons()

        self.currentTab = None
        self.tabButtons = {}
        self.createTabButtons()

        self.radioButtons = []
        # self.createRadioButtons()

        self.activePage = 0
        self.gifting = -1

        guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui')
        hangupGui = guiItems.find('**/hangup')
        hangupRolloverGui = guiItems.find('**/hangup_rollover')
        self.hangup = DirectButton(
            self,
            relief=None,
            pos=(2.28, 0, -1.3),
            image=[hangupGui, hangupRolloverGui, hangupRolloverGui, hangupGui],
            text=['', TTLocalizer.CatalogHangUp, TTLocalizer.CatalogHangUp],
            text_fg=Vec4(1),
            text_scale=0.07,
            text_pos=(0.0, 0.14),
            command=self.hangUp)
        guiItems.removeNode()

        jarGui = loader.loadModel('phase_3.5/models/gui/jar_gui')
        self.moneyDisplay = DirectLabel(
            parent=self,
            relief=None,
            pos=(2.28, 0, -0.9),
            scale=0.8,
            text=str(base.localAvatar.getMoney()),
            text_scale=0.18,
            text_fg=(0.95, 0.95, 0, 1),
            text_shadow=(0, 0, 0, 1),
            text_pos=(0, -0.1, 0),
            image=jarGui.find('**/Jar'),
            text_font=ToontownGlobals.getSignFont())

        jarGui.removeNode()
        return
Пример #25
0
 def show(self):
     OnscreenText(text='Pong',
                  scale=0.2,
                  pos=(0, 0.5, 0),
                  bg=(0, 0, 0, 0),
                  fg=(1, 1, 1, 1))
     DirectButton(text='Start', scale=0.12, command=self.start_cb)
     DirectButton(text='Quit',
                  scale=0.12,
                  pos=(0, 0, -0.2),
                  command=sys.exit)
Пример #26
0
 def showGagButton(self):
     geom = CIGlobals.getDefaultBtnGeom()
     self.gagThrowBtn = DirectButton(geom=geom,
                                     geom_scale=(0.75, 1, 1),
                                     text="Throw Gag",
                                     text_scale=0.05,
                                     text_pos=(0, -0.01),
                                     relief=None,
                                     parent=base.a2dTopCenter,
                                     pos=(0, 0, -0.1))
     self.gagThrowBtn.setBin('gui-popup', 60)
     self.gagThrowBtn.hide()
Пример #27
0
Файл: ui.py Проект: rdb/hexima
    def __init__(self,
                 parent,
                 text="",
                 pos=(0, 0),
                 size=(0.4, 0.2),
                 command=None,
                 extraArgs=[],
                 icon=None,
                 icon_style='solid',
                 disabled=False,
                 anchor=None):
        parent_path = parent.path if anchor is None else parent.anchors[anchor]

        #frame = (-size[0] * 0.5, size[0] * 0.5, -size[1] * 0.5, size[1] * 0.5)
        frame = (-0.15, 0.25 if icon else 0.15, -0.03, 0.08)
        self.path = DirectButton(parent=parent_path,
                                 text_fg=UI_COLOR,
                                 relief=None,
                                 frameSize=frame,
                                 text=text,
                                 text_scale=0.09,
                                 pos=(pos[0], 0, pos[1]),
                                 command=command,
                                 extraArgs=extraArgs)
        #generate_border(self.path, frame)

        if disabled:
            self.path['state'] = DGG.DISABLED

        if icon is not None:
            self.icon_pivot = self.path.attach_new_node('pivot')
            self.icon_pivot.set_pos(-0.1, 0, 0.025)
            font = base.icon_fonts[icon_style]
            text = OnscreenText(parent=self.icon_pivot,
                                text=icon,
                                fg=(1, 1, 1, 1),
                                font=font,
                                align=core.TextNode.A_center,
                                scale=0.07,
                                pos=(-0.002, -0.025))
        else:
            self.icon_pivot = None

        self.path.bind('enter-', self.on_focus)
        self.path.bind('exit-', self.on_blur)
        self.path.bind('fin-', self.on_focus)
        self.path.bind('fout-', self.on_blur)

        self.path.set_shader_off(1)

        self.path.set_color_scale((1, 1, 1, 0.6))

        parent._child_item_added(self.path)
Пример #28
0
 def initGameScore(self):
     score,miss,good,perfect = self.game.getScoreReport()
     self.setGameScoreBackground(score)
     self.highScoreTuple=self.updateHighestScore(score)
     self.gameScoreText=OnscreenText(
                     text='Total: '+str(score),pos=(-0.8,0.7),
                                 scale = 0.2,fg=(1,0.78,0.18,1),mayChange=1)
     self.newHigh=OnscreenText(
                     text='New High!',pos=(-0.7,0.5),
                                 scale = 0.15,fg=(1,1,1,1),mayChange=1)
     self.scoreFrame=DirectFrame(pos=(0.6,0,-0.6),
                 frameSize = (-0.2,0.6,-0.2,0.2),frameColor=(0,0.1,0.3,1))
     self.perfectLabel=DirectLabel(
                                 text='Perfect: '+str(perfect),
                                 pos=(0,0,.1),text_align=TextNode.ALeft,
                                 scale = 0.1,text_fg=(0.28,0.65,858,1),
                                 frameColor=(1,1,1,0),text_scale=(0.9,0.9))
     self.goodLabel=DirectLabel(
                                 text='Good: '+str(good),
                                 pos=(0,0,0),
                                 scale = 0.1,text_fg=(0.52,0.67,0.52,1),
                                 text_align=TextNode.ALeft,
                                 frameColor=(1,1,1,0),text_scale=(0.9,0.9))
     self.missLabel=DirectLabel(
                                 text='Miss: '+str(miss),
                                 pos=(0,0,-.1),
                                 scale = 0.1,text_fg=(0.72,0.67,0.67,1),
                                 text_align=TextNode.ALeft,
                                 frameColor=(1,1,1,0),text_scale=(0.9,0.9))
     self.perfectLabel.reparentTo(self.scoreFrame)
     self.goodLabel.reparentTo(self.scoreFrame)
     self.missLabel.reparentTo(self.scoreFrame)
     self.retryButton=DirectButton(frameColor=(0,0.1,0.3,1),
                                 pos=(-1,0,-0.5), text="Retry",
                                 text_fg=(1,1,1,1),text_scale=(1,1),
                                 text_align=TextNode.ALeft,
                                scale=.1, pad=(.2, .2),frameSize=(-1,6.6,-0.6,1),
                                rolloverSound=None, clickSound=None,
                                command=self.retry)
     self.mainMenuButton=DirectButton(frameColor=(0,0.1,0.3,1),
                                 pos=(-1,0,-0.7), text="Back To Menu",
                                 text_fg=(1,1,1,1),text_scale=(1,1),text_align=TextNode.ALeft,
                                 text_pos=(-0.5,-0.1),
                                scale=.1, pad=(.2, .2),frameSize=(-1,6.6,-0.8,0.8),
                                rolloverSound=None, clickSound=None,
                                command=lambda: self.switchPanel('gameScore','mainMenu'))
     self.setPanel('gameScore',Panel(self.gameScoreBackground,{'scoreText':self.gameScoreText, 'newHigh':self.newHigh,
         'scoreFrame':self.scoreFrame,'retry':self.retryButton,'mainMenu':self.mainMenuButton}))
     self.switchPanel('dance','gameScore')
     if self.highScoreTuple[1]:
         self.newHigh.show()
     else:
         self.newHigh.hide()
Пример #29
0
class GUI:
    def __init__(self, rootParent=None):

        self.frmMain = DirectFrame(
            frameColor=(0.0, 0.0, 0.0, 0.75),
            frameSize=(-1, 1, -1, 1),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0, 0, 0),
            parent=rootParent,
        )
        self.frmMain.setTransparency(1)

        self.btnQuit = DirectButton(
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0, 0, -0.75),
            scale=LVecBase3f(0.1, 0.1, 0.1),
            text='Quit',
            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=["quitRoom"],
            pressEffect=1,
        )
        self.btnQuit.setTransparency(0)

        self.lblMessage = DirectLabel(
            frameColor=(0.0, 0.0, 0.0, 0.0),
            frameSize=(-2.981, 3.106, -0.325, 0.725),
            hpr=LVecBase3f(0, 0, 0),
            pos=LPoint3f(0, 0, 0),
            scale=LVecBase3f(0.2, 0.2, 0.2),
            text='Player A Won',
            text_align=TextNode.A_center,
            text_scale=(1.0, 1.0),
            text_pos=(0, 0),
            text_fg=LVecBase4f(1, 1, 1, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            parent=self.frmMain,
        )
        self.lblMessage.setTransparency(0)

    def show(self):
        self.frmMain.show()

    def hide(self):
        self.frmMain.hide()

    def destroy(self):
        self.frmMain.destroy()
Пример #30
0
 def __init__(self, key, image, action, pos, rootParent):
     self.key = key
     self.btn = DirectButton(frameSize=(-0.1, 0.1, -0.1, 0.1),
                             frameColor=(0, 0, 0, 0),
                             text="",
                             image=image,
                             image_scale=0.1,
                             command=base.messenger.send,
                             extraArgs=[action],
                             pos=pos,
                             parent=rootParent)
     self.btn.setTransparency(1)
Пример #31
0
 def helpScreen(self):
     self.easyAI.hide()
     self.hardAI.hide()
     self.help.hide()
     self.fram["image"] = self.path + "/help.jpg"
     self.fram.updateFrameStyle()
     self.back = DirectButton(text="",
                              command=self.helpScreen,
                              pos=(0, 0, -0.4),
                              scale=0.1,
                              text_bg=(0, 0, 0, 1),
                              text_fg=(255, 255, 255, 1))
Пример #32
0
    def __init__(self):
        DirectObject.__init__(self)
        self.backpack = base.localAvatar.backpack

        if not self.backpack:
            return
        self.backpack.loadoutGUI = self

        self.oneSlotPos = [(0, 0, 0)]
        self.twoSlotsPos = [(0, 0, 0.30), (0, 0, -0.2)]
        self.threeSlotsPos = [(0, 0, 0.5), (0, 0, 0), (0, 0, -0.5)]
        self.fourSlotPos = [(0, 0, 0.5), (0, 0, 0.15), (0, 0, -0.2),
                            (0, 0, -0.55)]
        self.availableSlot = 0
        self.slots = []
        self.activeSlot = None
        self.defaultSlots = 3
        self.prevSlot = None
        self.ammoLabel = None

        self.inventoryFrame = DirectFrame(parent=base.a2dRightCenter,
                                          pos=(-0.1725, 0, 0))

        self.visibilityBtn = DirectButton(text="",
                                          relief=None,
                                          text_bg=(1, 1, 1, 0),
                                          parent=base.a2dRightCenter,
                                          pos=(-0.1725, 0, 0),
                                          frameSize=(-0.2, 0.2, -0.725, 0.7),
                                          clickSound=None,
                                          rolloverSound=None)
        self.visibilityBtn.bind(DGG.WITHIN, self.__handleVisEnter)
        self.visibilityBtn.bind(DGG.WITHOUT, self.__handleVisExit)
        self.visibilityBtn.setBin('background', 10)

        self.visibilityBtn = None
        self.visibilityBtnStatus = 0
        self.switchSound = True
        self.switchSoundSfx = base.loadSfx(
            "phase_3/audio/sfx/GUI_balloon_popup.ogg")

        self.visibilityFSM = ClassicFSM('InventoryGui-VisibilityFSM', [
            State('off', self.enterOff, self.exitOff),
            State('hidden', self.enterHidden, self.exitHidden),
            State('hidden2visible', self.enterHidden2Visible,
                  self.exitHidden2Visible),
            State('visible', self.enterVisible, self.exitVisible),
            State('visible2hidden', self.enterVisible2Hidden,
                  self.exitVisible2Hidden)
        ], 'off', 'off')
        self.visibilityFSM.enterInitialState()
        self.visibilityFSM.request('hidden')
Пример #33
0
class cApplication( DirectObject ):
    def __init__( self ):
        # create world
        self.world = cWorld( )
        # setup controls
        self.setupControls( )
        # display title information
        self.title = OnscreenText( text = 'BOIDS.PY - SEEK & ARRIVE', fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -.98, .9 ), scale = 0.06 )
        # display copright information
        self.copyRight = OnscreenText( text = 'Copyright (C) 2016 David Lettier.', fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( .98, -.98 ), scale = 0.05 )
        # display panda version text
        self.pandaVersion = OnscreenText( text = 'Panda Version 1.9.2', fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -1.18, -.98 ), scale = 0.04 )
        # display print debug button
        # this button calls the prntDebug function
        self.prntDebugButton = DirectButton( text = "Print Debug", relief = DGG.RAISED, scale = .1, pad = ( .5, .5 ), pos = Vec3( -1.0, 0.0, -.8 ), command = self.prntDebug )
    def setupControls( self ):
        # accept the esc key to exit application
        self.accept( 'escape', sys.exit )
    def prntDebug( self ):
        # destory debug button
        self.prntDebugButton.destroy( )
        # create new clear debug button
        # this button calls the clearDebug function
        self.clearDebugButton = DirectButton( text = "Clear Debug", relief = DGG.RAISED, scale = .1, pad = ( .5, .5 ), pos = Vec3( -1.0, 0.0, -.8 ), command = self.clearDebug )
        # create green target position text
        self.greenPos = OnscreenText( text = 'Green Target Pos: ' + str( int( self.world.target.getX( ) ) ) + ", " + str( int( self.world.target.getY( ) ) ) + ", " + str( int( self.world.target.getZ( ) ) ), fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -.8, .8 ), scale = 0.05, mayChange = True )
        # create blue boid position text
        self.bluePos = OnscreenText( text = 'Blue Boid (Arrive) Pos: ' + str( int( self.world.blueBoid.boidModel.getX( ) ) ) + ", " + str( int( self.world.blueBoid.boidModel.getY( ) ) ) + ", " + str( int( self.world.blueBoid.boidModel.getZ( ) ) ), fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -.8, .7 ), scale = 0.05, mayChange = True )
        # create green boid position text
        self.redPos = OnscreenText( text = 'Red Boid (Seek) Pos: ' + str( int( self.world.redBoid.boidModel.getX( ) ) ) + ", " + str( int( self.world.redBoid.boidModel.getY( ) ) ) + ", " + str( int( self.world.redBoid.boidModel.getZ( ) ) ), fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -.8, .6 ), scale = 0.05, mayChange = True )
        # add the update on screen text task
        taskMgr.add( self.updateOSTxt, 'updateOSTxt' )
    def updateOSTxt( self, Task ):
        # update green target position text
        self.greenPos.setText( 'Green Target Pos: ' + str( int( self.world.target.getX( ) ) ) + ", " + str( int( self.world.target.getY( ) ) ) + ", " + str( int( self.world.target.getZ( ) ) ) )
        # update blue boid position text
        self.bluePos.setText( 'Blue Boid (Arrive) Pos: ' + str( int( self.world.blueBoid.boidModel.getX( ) ) ) + ", " + str( int( self.world.blueBoid.boidModel.getY( ) ) ) + ", " + str( int( self.world.blueBoid.boidModel.getZ( ) ) ) )
        # update red boid position text
        self.redPos.setText( 'Red Boid (Seek) Pos: ' + str( int( self.world.redBoid.boidModel.getX( ) ) ) + ", " + str( int( self.world.redBoid.boidModel.getY( ) ) ) + ", " + str( int( self.world.redBoid.boidModel.getZ( ) ) ) )
        # call task next frame
        return Task.cont
    def clearDebug( self ):
        # destory button
        self.clearDebugButton.destroy( )
        # destory all debug on screen text
        self.greenPos.destroy( )
        self.bluePos.destroy( )
        self.redPos.destroy( )
        # remove task
        taskMgr.remove( 'updateOSTxt' )
        # create again the print debug button to start the cycle all over again
        self.prntDebugButton = DirectButton( text = "Print Debug", relief = DGG.RAISED, scale = .1, pad = ( .5, .5 ), pos = Vec3( -1.0, 0.0, -.8 ), command = self.prntDebug )
Пример #34
0
 def __init__(self, *args, **kwargs):
     DirectButton.__init__(self, *args, **kwargs)
     self['frameSize'] = (-1, 1, -1, 1)
     self['relief'] = FLAT
     shader = Shader.load(Shader.SL_GLSL,
                          'yyagl/assets/shaders/filter.vert',
                          'yyagl/assets/shaders/imgbtn.frag')
     self.setShader(shader)
     self.setShaderInput('col_offset', 0)
     self.setShaderInput('enable', 1)
     self.setTransparency(True)
     self.bind(ENTER, self._on_enter)
     self.bind(EXIT, self._on_exit)
     self.initialiseoptions(self.__class__)
Пример #35
0
class GUI:
    def __init__(self, rootParent=None):

        self.btnRollDice = DirectButton(
            frameColor=(0.8, 0.8, 0.8, 0.0),
            frameSize=(-0.25, 0.25, -0.25, 0.25),
            hpr=LVecBase3f(0, 0, 0),
            image='./assets/Dice/DiceButton.png',
            pos=LPoint3f(0.25, 0, 0.25),
            relief=1,
            scale=LVecBase3f(1, 1, 1),
            text='',
            image_scale=LVecBase3f(0.25, 0.25, 0.25),
            image_pos=LPoint3f(0, 0, 0),
            text_align=TextNode.A_center,
            text_scale=(0.15, 0.15),
            text_pos=(-0.08, -0.09),
            text_fg=LVecBase4f(1, 1, 1, 1),
            text_bg=LVecBase4f(0, 0, 0, 0),
            parent=rootParent,
            command=base.messenger.send,
            extraArgs=["rollDice"],
            pressEffect=0,
        )
        self.btnRollDice.setTransparency(1)

    def show(self):
        self.btnRollDice.show()

    def hide(self):
        self.btnRollDice.hide()

    def destroy(self):
        self.btnRollDice.destroy()
Пример #36
0
def __createFolder(self, entry, xPos, zPos):
    name = entry.name

    btn = DirectButton(
        parent=self.container.getCanvas(),
        image=loader.load_texture(f"{self.iconDir}/Folder.png", loaderOptions=self.imageOpts),
        image_scale=16,
        image_pos=(16,0,0),
        relief=1,
        frameColor = self.theme.folder_background,
        frameSize=(0, self.screenWidthPxHalf*2, -16, 16),
        pos=LPoint3f(xPos, 0, zPos),
        text = name,
        text_scale=12,
        text_align=TextNode.ALeft,
        text_pos=(32,-4),
        text_fg=self.theme.default_text_color,
        command=self.folderMoveIn,
        extraArgs=[entry.path]
    )

    lblInfo = __createMIMEInfo(self, btn, entry, True)
    #lblSize = __createSizeInfo(self, btn, entry)

    btn.bind(DGG.MWDOWN, self.scroll, [0.01])
    btn.bind(DGG.MWUP, self.scroll, [-0.01])
    btn.setTransparency(TransparencyAttrib.M_multisample)
Пример #37
0
def __createFolder(self, entry, xPos, zPos):
    name = entry.name
    if len(entry.name) > 10:
        name = ""
        for i in range(max(math.ceil(len(entry.name) / 10), 4)):
            name += entry.name[i * 10:i * 10 + 10] + "\n"
        name = name[:-1]
        if math.ceil(len(entry.name) / 10) > 4:
            name += "..."
    btn = DirectButton(parent=self.container.getCanvas(),
                       image=loader.load_texture(f"{self.iconDir}/Folder.png",
                                                 loaderOptions=self.imageOpts),
                       image_scale=35,
                       relief=1,
                       frameColor=self.theme.folder_background,
                       frameSize=(-40, 40, -40, 40),
                       pos=LPoint3f(xPos, 0, zPos),
                       text=name,
                       text_scale=12,
                       text_pos=(0, -40),
                       text_fg=self.theme.default_text_color,
                       command=self.folderMoveIn,
                       extraArgs=[entry.path])
    btn.bind(DGG.MWDOWN, self.scroll, [0.01])
    btn.bind(DGG.MWUP, self.scroll, [-0.01])
    btn.setTransparency(TransparencyAttrib.M_multisample)
 def __createFile(self, filename, xPos, zPos):
     name = filename
     if len(filename) > 10:
         name = ""
         for i in range(min(math.ceil(len(filename)/10), 4)):
             name += filename[i*10:i*10+10]+"\n"
         name = name[:-1]
         if math.ceil(len(filename)/10) > 4:
             name += "..."
     btn = DirectButton(
         parent=self.container.getCanvas(),
         image="icons/File.png",
         image_scale=35,
         relief=1,
         frameColor = (
             (0.9, 0.9, 0.9, 0), # Normal
             (0.95, 0.95, 1, 1), # Click
             (0.9, 0.9, 1, 1), # Hover
             (0.5, 0.5, 0.5, 1)), # Disabled
         frameSize=(-40, 40, -40, 40),
         pos=LPoint3f(xPos, 0, zPos),
         text = name,
         text_scale=12,
         text_pos=(0,-40),
         command=self.txtFileName.set,
         extraArgs=[filename]
     )
     btn.bind(DGG.MWDOWN, self.scroll, [0.01])
     btn.bind(DGG.MWUP, self.scroll, [-0.01])
     btn.setTransparency(TransparencyAttrib.M_multisample)
Пример #39
0
    def __init__(self, phone, doneEvent=None):
        NodePath.__init__(self, aspect2d.attachNewNode('CatalogGUI'))
        DirectObject.__init__(self)

        CatalogGlobals.CatalogNodePath.find('**/CATALOG_GUI_BKGD').copyTo(self)
        self.setScale(CatalogGlobals.CatalogBKGDScale)

        self.phone = phone
        self.doneEvent = doneEvent

        self.arrowButtons = {}
        self.createArrowButtons()

        self.currentTab = None
        self.tabButtons = {}
        self.createTabButtons()

        self.radioButtons = []
        # self.createRadioButtons()

        self.activePage = 0
        self.gifting = -1

        guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui')
        hangupGui = guiItems.find('**/hangup')
        hangupRolloverGui = guiItems.find('**/hangup_rollover')
        self.hangup = DirectButton(self, relief=None, pos=(2.28, 0, -1.3),
                                   image=[hangupGui, hangupRolloverGui, hangupRolloverGui, hangupGui],
                                   text=['', TTLocalizer.CatalogHangUp, TTLocalizer.CatalogHangUp],
                                   text_fg=Vec4(1), text_scale=0.07, text_pos=(0.0, 0.14),
                                   command=self.hangUp)
        guiItems.removeNode()
Пример #40
0
class CatalogArrowButton(NodePath):
    def __init__(self, parent, nodeName, clickEvent):
        NodePath.__init__(self, parent.attachNewNode(nodeName))

        self.clickEvent = clickEvent

        self.normalNode = CatalogGlobals.CatalogNodePath.find('**/arrow_UP_'+nodeName).copyTo(self)
        self.clickedNode = CatalogGlobals.CatalogNodePath.find('**/arrow_DN_'+nodeName).copyTo(self)
        self.hoverNode = CatalogGlobals.CatalogNodePath.find('**/arrow_OVR_'+nodeName).copyTo(self)

        self.arrowButton = DirectButton(parent=self, relief=None, image=(self.normalNode, self.clickedNode, self.hoverNode), command=self.clickEvent)

    def cleanup(self):
        self.arrowButton.destroy()

        NodePath.removeNode(self)
Пример #41
0
    def _create_components(self):
        """ Creates the window components """
        self._node = self._parent.attach_new_node("Window")
        self._node.set_pos(self._pos.x, 1, -self._pos.y)
        border_px = 1
        self._border_frame = DirectFrame(
            pos=(0, 1, 0), frameSize=(-border_px, self._width + border_px,
            border_px, -self._height - border_px),
            frameColor=(24 / 255.0, 131 / 255.0, 215 / 255.0, 1),
            parent=self._node, state=DGG.NORMAL)
        self._background = DirectFrame(
            pos=(0, 1, 0), frameSize=(0, self._width, 0, -self._height),
            frameColor=(0.1, 0.1, 0.1, 1.0), parent=self._node)
        self._title_bar = DirectFrame(
            pos=(0, 1, 0), frameSize=(0, self._width, 0, -25),
            # frameColor=(0.058, 0.058, 0.058, 1),
            frameColor=(1, 1, 1, 1),
            parent=self._node,
            state=DGG.NORMAL)
        self._window_title = Text(
            parent=self._node, x=8, y=17, text=self._title, size=13,
            color=Vec3(0.15), may_change=True)
        self._btn_close = DirectButton(
            relief=DGG.FLAT, pressEffect=1, pos=(self._width - 22, 1, -12),
            frameColor=(1.0, 0.2, 0.2, 0.5), parent=self._node,
            scale=(45 / 2, 1, 24 / 2),
            image="/$$rp/data/gui/close_window.png")

        # Init bindings
        self._btn_close.set_transparency(TransparencyAttrib.M_alpha)
        self._btn_close.bind(DGG.B1CLICK, self._request_close)
        self._btn_close.bind(DGG.WITHIN, self._on_close_btn_hover)
        self._btn_close.bind(DGG.WITHOUT, self._on_close_btn_out)
        self._title_bar.bind(DGG.B1PRESS, self._start_drag)
        self._title_bar.bind(DGG.B1RELEASE, self._stop_drag)
Пример #42
0
 def showBookButton(self, inBook = 0):
     self.book_gui = loader.loadModel('phase_3.5/models/gui/sticker_open_close_gui.bam')
     self.book_btn = DirectButton(geom=(self.book_gui.find('**/BookIcon_CLSD'), self.book_gui.find('**/BookIcon_OPEN'), self.book_gui.find('**/BookIcon_RLVR')), relief=None, pos=(-0.175, 0, 0.163), command=self.bookButtonClicked, scale=(0.7, 0.8, 0.8), parent=base.a2dBottomRight)
     self.book_btn.setBin('gui-popup', 60)
     if inBook:
         self.book_btn['geom'] = (self.book_gui.find('**/BookIcon_OPEN'), self.book_gui.find('**/BookIcon_CLSD'), self.book_gui.find('**/BookIcon_RLVR2'))
         self.book_btn['command'] = self.bookButtonClicked
         self.book_btn['extraArgs'] = [0]
     return
 def doContinue(self):
   if(self.gameState == 'INIT'):
     self.gameState = 'MENU'
     self.text.clearText()
     self.musicLoop.setLoop(True)
     self.musicLoop.setVolume(0.5)
     self.musicLoop.play()
     self.startBtn = DirectButton(text=("Play"), scale = 0.1, pos = (0,0,0),command=self.playGame)
     self.helpBtn = DirectButton(text=("Help"), scale = 0.1, pos = (0,0,-0.2),command=self.help)
     self.exitBtn = DirectButton(text=("Exit"), scale = 0.1,  pos = (0,0,-0.4), command = self.doExit)
     return
   
   if self.gameState == 'NEXT':
     self.nextLevelSound.play()
     self.fire = True
     self.gameLevel += 1
     self.score += (self.attempts * 100)
     self.doReset()
     self.gameState = 'PLAY'
     return
   
   if self.gameState == 'LOSE':
     self.loseSound.play()
     self.arrow.removeNode()
     self.loseScreen.show()
     self.levelText.hide()
     self.attemptText.hide()
     self.scoreText.hide()
     self.text.hide()
     self.pauseText.hide()
     self.retryBtn.show()
     return
   
   if self.gameState == 'WIN':
     self.levelText.hide()
     self.attemptText.hide()
     self.scoreText.clearText()
     self.scoreText.setPos(0,0.6)
     self.scoreText.setText("%s"%self.score)
     self.winScreen.show()
     self.winSound.play()
     self.menuBtn.show()
     self.pauseText.hide()
     return
Пример #44
0
 def load(self):
     buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui')
     upButton = buttonModels.find('**//InventoryButtonUp')
     downButton = buttonModels.find('**/InventoryButtonDown')
     rolloverButton = buttonModels.find('**/InventoryButtonRollover')
     self.exitButton = DirectButton(relief=None, text=TTLocalizer.PartyTeamActivityExitButton, text_fg=(1, 1, 0.65, 1), text_pos=(0, -0.15), text_scale=0.5, image=(upButton, downButton, rolloverButton), image_color=(1, 0, 0, 1), image_scale=(14.5, 1, 9), pos=(0, 0, 0.8), scale=0.15, command=self.handleExitButtonClick)
     self.exitButton.hide()
     if self.activity.toonsCanSwitchTeams():
         self.switchButton = DirectButton(relief=None, text=TTLocalizer.PartyTeamActivitySwitchTeamsButton, text_fg=(1, 1, 1, 1), text_pos=(0, 0.1), text_scale=0.5, image=(upButton, downButton, rolloverButton), image_color=(0, 1, 0, 1), image_scale=(15, 1, 15), pos=(0, 0, 0.5), scale=0.15, command=self.handleSwitchButtonClick)
         self.switchButton.hide()
     else:
         self.switchButton = None
     buttonModels.removeNode()
     self.countdownText = OnscreenText(text='', pos=(0.0, -0.2), scale=PartyGlobals.TeamActivityTextScale * 1.2, fg=(1.0, 1.0, 0.65, 1.0), align=TextNode.ACenter, font=ToontownGlobals.getSignFont(), mayChange=True)
     self.countdownText.hide()
     self.statusText = OnscreenText(text='', pos=(0.0, 0.0), scale=PartyGlobals.TeamActivityTextScale, fg=PartyGlobals.TeamActivityStatusColor, align=TextNode.ACenter, font=ToontownGlobals.getSignFont(), mayChange=True)
     self.statusText.hide()
     self.timer = PartyUtils.getNewToontownTimer()
     self.timer.hide()
     return
 def __init__(self):
     self.resetImages()
     imageFrame = PDialog(parent = aspect2dp, pos = (0, 0, 0.10000000000000001), image_scale = (1.3 * 4 / 3.0, 1, 1.3), fadeScreen = 0.84999999999999998, scale = 1.1000000000000001)
     imageFrame.hide()
     imX = 0.84999999999999998
     imY = imX * 3 / 4.0
     self.imageObj = OnscreenImage(parent = imageFrame, image = self.screens[0], scale = (imX, 1, imY), pos = (0, 0, -0.025000000000000001))
     self.imageLabel = DirectLabel(parent = imageFrame, relief = None, state = DGG.DISABLED, pos = (0, 0, -0.75), textMayChange = 1, text_fg = (0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 1), text_scale = 0.040000000000000001)
     self.imageLabel.hide()
     topGui = loader.loadModel('models/gui/toplevel_gui')
     arrow = topGui.find('**/generic_arrow')
     buttons = loader.loadModel('models/gui/lookout_gui')
     closeButton = (buttons.find('**/lookout_close_window'), buttons.find('**/lookout_close_window_down'), buttons.find('**/lookout_close_window_over'))
     xs = 1.2
     self.nextButton = DirectButton(parent = imageFrame, relief = None, command = self.next, pos = (0.69999999999999996, 0, 0), image = arrow, image_scale = (-xs, xs, xs), sortOrder = -5)
     self.prevButton = DirectButton(parent = imageFrame, relief = None, command = self.prev, pos = (-0.69999999999999996, 0, 0), image = arrow, image_scale = xs, sortOrder = -5)
     self.closeButton = DirectButton(parent = imageFrame, relief = None, command = self.close, pos = (0.78000000000000003, 0, -0.5), image = closeButton, image_scale = 0.29999999999999999, text = PLocalizer.lClose, text_fg = PiratesGuiGlobals.TextFG1, text_scale = 0.050000000000000003, text_pos = (0, -0.10000000000000001), sortOrder = -5)
     self.showIval = Sequence(Func(imageFrame.show), Wait(1), Parallel(LerpPosInterval(self.closeButton, 0.20000000000000001, Vec3(0.78000000000000003, 0, -0.80000000000000004), Vec3(0.78000000000000003, 0, -0.5)), LerpPosInterval(self.nextButton, 0.20000000000000001, Vec3(1, 0, 0), Vec3(0.69999999999999996, 0, 0)), LerpPosInterval(self.prevButton, 0.20000000000000001, Vec3(-1, 0, 0), Vec3(-0.69999999999999996, 0, 0))), Func(self.imageLabel.show))
     self.imageFrame = imageFrame
     base.transitions.fadeScreen(0.84999999999999998)
Пример #46
0
 def clearDebug( self ):
     # destory button
     self.clearDebugButton.destroy( )
     # destory all debug on screen text
     self.greenPos.destroy( )
     self.bluePos.destroy( )
     self.redPos.destroy( )
     # remove task
     taskMgr.remove( 'updateOSTxt' )
     # create again the print debug button to start the cycle all over again
     self.prntDebugButton = DirectButton( text = "Print Debug", relief = DGG.RAISED, scale = .1, pad = ( .5, .5 ), pos = Vec3( -1.0, 0.0, -.8 ), command = self.prntDebug )
Пример #47
0
def load(args):
    """Sets up the GUI for the main menu.
    Arguments:
        This takes no arguments.
    """

    global backFrame
    global menuFrame
    global pauseText
    global backButton

    font_digital = loader.loadFont('digital.egg')

    backFrame = DirectFrame()
    backFrame['frameColor'] = (0, 0, 0, .5)
    backFrame['frameSize'] = (2, -2, 2, -2)
    backFrame.setPos(0, 0, 0)

    menuFrame = DirectFrame()
    menuFrame.reparentTo(backFrame)
    menuFrame['frameColor'] = (1, 1, 1, .5)
    menuFrame['frameSize'] = (.5, -.5, .5, -.5)
    menuFrame.setPos(0, 0, 0)

    pauseText = OnscreenText()
    pauseText['text'] = ('PAUSED')
    pauseText['scale'] = (.1)
    pauseText['font'] = (font_digital)
    pauseText['fg'] = (1, 1, 1, 1)
    pauseText.setPos(0, .9)

    backButton = DirectButton()
    backButton.reparentTo(menuFrame)
    backButton['text'] = ('Back')
    backButton['text_scale'] = (.1)
    backButton['text_pos'] = (0, -0.03)
    backButton['frameVisibleScale'] = (2, 0.5, 0)
    backButton['frameColor'] = (1, 1, 1, 0)
    backButton['command'] = (messenger.send)
    backButton['extraArgs'] = ("switch_gui", [gui.menu.pause_options, gui.menu.pause])
    backButton.setPos(0, 0, 0)
Пример #48
0
 def __init__(self):
     DirectButton.__init__(self,parent = aspect2d, frameColor =(1,1,1,0), relief = DGG.FLAT,commandButtons = [])
     self.accept('window-event', self.windowResize)
     self.windowResize(None)
     #trick: make this re-throw mouse events
     self.bind(self.B1PRESS, self.rethrowEvent,['mouse1'])
     self.bind(self.B2PRESS, self.rethrowEvent,['mouse2'])
     self.bind(self.B3PRESS, self.rethrowEvent,['mouse3'])
     self.bind(self.B4PRESS, self.rethrowEvent,['mouse4'])
     self.bind(self.B5PRESS, self.rethrowEvent,['mouse5'])
     
     self.bind(self.WHEELUP, self.rethrowEvent, ['wheel_up'])
     self.bind(self.WHEELDOWN, self.rethrowEvent, ['wheel_down'])
     self.bind(self.WHEELLEFT, self.rethrowEvent, ['wheel_left'])
     self.bind(self.WHEELRIGHT, self.rethrowEvent, ['wheel_right'])
     
     self.bind(self.B1RELEASE, self.rethrowEvent,['mouse1-up'])
     self.bind(self.B2RELEASE, self.rethrowEvent,['mouse2-up'])
     self.bind(self.B3RELEASE, self.rethrowEvent,['mouse3-up'])
     self.bind(self.B4RELEASE, self.rethrowEvent,['mouse4-up'])
     self.bind(self.B5RELEASE, self.rethrowEvent,['mouse5-up'])
Пример #49
0
    def __init__(self, parent = None, **kw):

        optiondefs = (
            # Define type of DirectGuiWidget
            ('pgFunc',         PGButton,   None),
            ('numStates',      4,          None),
            ('state',          DGG.NORMAL, None),
            ('relief',         None,       None),
            ('invertedFrames', (1,),       None),
            ('frameSize',      (-1,1,-1,1),None),
            ('scale',          0.05,       None),
            # Command to be called on button click
            ('command',        None,       None),
            ('extraArgs',      [],         None),
            # Which mouse buttons can be used to click the button
            ('commandButtons', (DGG.LMB,),     self.setCommandButtons),
            # Sounds to be used for button events
            ('rolloverSound', DGG.getDefaultRolloverSound(), self.setRolloverSound),
            ('clickSound',    DGG.getDefaultClickSound(),    self.setClickSound),
            # Can only be specified at time of widget contruction
            # Do the text/graphics appear to move when the button is clicked
            ('pressEffect',     1,         DGG.INITOPT),
            ('uncheckedImage',  'ui/default/checkbox_unchecked.png',      self.setUncheckedImage),
            ('checkedImage',    'ui/default/checkbox_checked.png',      self.setCheckedImage),
            ('uncheckedGeom',  None,      None),
            ('checkedGeom',    None,      None),
            ('isChecked',       False,     self.renewgeom),
            )
        
        # Merge keyword options with default options
        self.defineoptions(kw, optiondefs)

        DirectButton.__init__(self,parent)
        
        
        self.__checkstatedumpnp = NodePath('checkstatenp')
        
        
        self.initialiseoptions(SDirectCheckBox)
Пример #50
0
    def __init__(self, cr):
        try:
            self.LocalToon_initialized
            return
        except:
            self.LocalToon_initialized = 1

        DistributedToon.__init__(self, cr)
        self.avatarChoice = cr.localAvChoice
        self.smartCamera = SmartCamera()
        self.chatInput = ChatInput()
        self.moneyGui = MoneyGui()
        self.laffMeter = LaffOMeter()
        self.positionExaminer = PositionExaminer()
        self.friendRequestManager = FriendRequestManager()
        self.friendsList = FriendsList()
        self.panel = ToonPanel()
        friendsgui = loader.loadModel('phase_3.5/models/gui/friendslist_gui.bam')
        self.friendButton = DirectButton(geom=(friendsgui.find('**/FriendsBox_Closed'), friendsgui.find('**/FriendsBox_Rollover'), friendsgui.find('**/FriendsBox_Rollover')), text=('', 'Friends', 'Friends', ''), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.065, text_pos=(0, -0.2), relief=None, parent=base.a2dTopRight, pos=(-0.18, 0.0, -0.17), command=self.friendsButtonClicked, scale=0.75)
        friendsgui.removeNode()
        del friendsgui
        self.hideFriendButton()
        self.runSfx = base.loadSfx('phase_3.5/audio/sfx/AV_footstep_runloop.wav')
        self.runSfx.setLoop(True)
        self.walkSfx = base.loadSfx('phase_3.5/audio/sfx/AV_footstep_walkloop.wav')
        self.walkSfx.setLoop(True)
        self.controlManager = ControlManager.ControlManager(True, False)
        self.offset = 3.2375
        self.movementKeymap = {'forward': 0,
         'backward': 0,
         'left': 0,
         'right': 0,
         'jump': 0}
        self.avatarMovementEnabled = False
        self.isMoving_forward = False
        self.isMoving_side = False
        self.isMoving_back = False
        self.isMoving_jump = False
        self.pieThrowBtn = None
        self.myBattle = None
        self.invGui = None
        self.pickerTrav = None
        self.pickerRay = None
        self.pickerRayNode = None
        self.pickerHandler = None
        self.rolledOverTag = None
        self.inTutorial = False
        self.hasDoneJump = False
        self.lastState = None
        self.lastAction = None
        return
Пример #51
0
 def __init__( self ):
     # create world
     self.world = cWorld( )
     # setup controls
     self.setupControls( )
     # display title information
     self.title = OnscreenText( text = 'BOIDS.PY - SEEK & ARRIVE', fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -.98, .9 ), scale = 0.06 )
     # display copright information
     self.copyRight = OnscreenText( text = 'Copyright (C) 2016 David Lettier.', fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( .98, -.98 ), scale = 0.05 )
     # display panda version text
     self.pandaVersion = OnscreenText( text = 'Panda Version 1.9.2', fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -1.18, -.98 ), scale = 0.04 )
     # display print debug button
     # this button calls the prntDebug function
     self.prntDebugButton = DirectButton( text = "Print Debug", relief = DGG.RAISED, scale = .1, pad = ( .5, .5 ), pos = Vec3( -1.0, 0.0, -.8 ), command = self.prntDebug )
Пример #52
0
    def __init__(self, catalogGui, nodeName, clickEvent):
        NodePath.__init__(self, catalogGui.attachNewNode(nodeName))

        self.active = False
        self.activePage = 0
        self.catalogGui = catalogGui
        self.catalogItemPages = []
        self.otherTabs = []
        self.clickEvent = clickEvent

        self.clickedNode = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'_DN').copyTo(self)
        self.hoverNode = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'_OVR').copyTo(self)

        self.tabButton = DirectButton(parent=self, relief=None, image=(self.clickedNode, self.clickedNode, self.hoverNode), command=self.tabClicked)
Пример #53
0
    def __init__(self, parent, nodeName, clickEvent):
        NodePath.__init__(self, parent.attachNewNode(nodeName))

        self.radioButtons = []
        self.clickEvent = clickEvent

        self.normalNode = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'_UP').copyTo(self)
        self.clickedNode = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'_DN').copyTo(self)
        self.hoverNode = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'_OVR').copyTo(self)

        self.statusIndicator = CatalogGlobals.CatalogNodePath.find('**/'+nodeName+'Radio_ON').copyTo(self)
        self.statusIndicator.hide()

        self.radioButton = DirectButton(parent=self, relief=None, image=(self.normalNode, self.clickedNode, self.hoverNode), command=self.enable)
Пример #54
0
 def prntDebug( self ):
     # destory debug button
     self.prntDebugButton.destroy( )
     # create new clear debug button
     # this button calls the clearDebug function
     self.clearDebugButton = DirectButton( text = "Clear Debug", relief = DGG.RAISED, scale = .1, pad = ( .5, .5 ), pos = Vec3( -1.0, 0.0, -.8 ), command = self.clearDebug )
     # create green target position text
     self.greenPos = OnscreenText( text = 'Green Target Pos: ' + str( int( self.world.target.getX( ) ) ) + ", " + str( int( self.world.target.getY( ) ) ) + ", " + str( int( self.world.target.getZ( ) ) ), fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -.8, .8 ), scale = 0.05, mayChange = True )
     # create blue boid position text
     self.bluePos = OnscreenText( text = 'Blue Boid (Arrive) Pos: ' + str( int( self.world.blueBoid.boidModel.getX( ) ) ) + ", " + str( int( self.world.blueBoid.boidModel.getY( ) ) ) + ", " + str( int( self.world.blueBoid.boidModel.getZ( ) ) ), fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -.8, .7 ), scale = 0.05, mayChange = True )
     # create green boid position text
     self.redPos = OnscreenText( text = 'Red Boid (Seek) Pos: ' + str( int( self.world.redBoid.boidModel.getX( ) ) ) + ", " + str( int( self.world.redBoid.boidModel.getY( ) ) ) + ", " + str( int( self.world.redBoid.boidModel.getZ( ) ) ), fg = ( 1.0, 1.0, 1.0, 1.0), pos = ( -.8, .6 ), scale = 0.05, mayChange = True )
     # add the update on screen text task
     taskMgr.add( self.updateOSTxt, 'updateOSTxt' )
Пример #55
0
    def _create_components(self):
        """ Creates the window components """
        self._node = self._parent.attach_new_node("Window")
        self._node.set_pos(self._pos.x, 1, -self._pos.y)
        border_px = 1
        self._border_frame = DirectFrame(
            pos=(0, 1, 0),
            frameSize=(-border_px, self._width + border_px, border_px, -self._height - border_px),
            frameColor=(0.0, 0.0, 0.0, 1),
            parent=self._node,
            state=DGG.NORMAL,
        )
        # self._border_frame.hide()
        self._background = DirectFrame(
            pos=(0, 1, 0),
            frameSize=(0, self._width, 0, -self._height),
            frameColor=(0.098, 0.098, 0.098, 1),
            parent=self._node,
        )
        self._title_bar = DirectFrame(
            pos=(0, 1, 0),
            frameSize=(0, self._width, 0, -45),
            frameColor=(0.058, 0.058, 0.058, 1),
            parent=self._node,
            state=DGG.NORMAL,
        )
        self._window_title = BetterOnscreenText(
            parent=self._node, x=12, y=29, text=self._title, size=19, color=Vec3(0.7), may_change=True
        )
        self._btn_close = DirectButton(
            relief=DGG.FLAT,
            pressEffect=1,
            pos=(self._width - 22, 1, -22),
            frameColor=(0, 0, 0, 0),
            scale=(20, 1, 20),
            parent=self._node,
            image="Data/GUI/CloseWindow.png",
        )

        # Init bindings
        self._btn_close.set_transparency(TransparencyAttrib.M_alpha)
        self._btn_close.bind(DGG.B1CLICK, self._request_close)
        self._btn_close.bind(DGG.WITHIN, self._on_close_btn_hover)
        self._btn_close.bind(DGG.WITHOUT, self._on_close_btn_out)
        self._title_bar.bind(DGG.B1PRESS, self._start_drag)
        self._title_bar.bind(DGG.B1RELEASE, self._stop_drag)
Пример #56
0
    def __init__(self, parent, x, y, text, width=50, callback=None,
                 callbackArgs=None):

        DebugObject.__init__(self, "BetterButton")

        if callbackArgs is None:
            callbackArgs = []

        self._node = DirectButton(text=text, parent=parent, pressEffect=1,
                                  command=callback, extraArgs=callbackArgs,
                                  scale=1, pos=(x + width, 1, -y - 15),
                                  frameSize=(-width, width, -15, 15),
                                  text_fg=(1, 1, 1, 1),
                                  frameColor=(0.1, 0.1, 0.1, 1.0),
                                  text_font=Globals.font, text_pos=(0, -4),
                                  text_scale=14)

        # Add a hover effect
        self._node.bind(DGG.ENTER, self._onMouseOver)
        self._node.bind(DGG.EXIT, self._onMouseOut)
Пример #57
0
 def __init__(self, command = None, always_enable = False, fileName = None, head = '',extraArgs = None,style = color_themes.ilia_button):
     self.__exists = False
     self.__command = command
     self.__always_enable = always_enable
     self.__fileName = fileName
     self.__head = head
     if not extraArgs: self.__extraArgs = []
     else: self.__extraArgs = extraArgs
     NodePath.__init__(self,'SaveLoadLabel')
     
     self.__button = DirectButton(parent = self, command = command,  extraArgs = self.__extraArgs, frameSize = (0,1.2,-0.33,0), **style) 
     #In case of interfering with mouse wheel input
     self.__button.bind(WHEELUP, self.__rethrowEvent, ['wheel_up'])
     self.__button.bind(WHEELDOWN, self.__rethrowEvent, ['wheel_down'])
     self.__button.bind(WHEELLEFT, self.__rethrowEvent, ['wheel_left'])
     self.__button.bind(WHEELRIGHT, self.__rethrowEvent, ['wheel_right'])
     self.__button.bind(DGG.B2PRESS, self.__rethrowEvent, ['mouse2'])
     self.__button.bind(DGG.B3PRESS, self.__rethrowEvent, ['mouse3'])
     
     self.__text = OnscreenText(parent = self, pos = (0.05, -0.10), align = TextNode.ALeft, **color_themes.system_text) # @UndefinedVariable
     
     self.reload()
Пример #58
0
    def __init__(self, phone, doneEvent=None):
        NodePath.__init__(self, aspect2d.attachNewNode('CatalogGUI'))
        DirectObject.__init__(self)

        CatalogGlobals.CatalogNodePath.find('**/CATALOG_GUI_BKGD').copyTo(self)
        self.setScale(CatalogGlobals.CatalogBKGDScale)

        self.phone = phone
        self.doneEvent = doneEvent

        self.arrowButtons = {}
        self.createArrowButtons()

        self.currentTab = None
        self.tabButtons = {}
        self.createTabButtons()

        self.radioButtons = []
        # self.createRadioButtons()

        self.activePage = 0
        self.gifting = -1

        guiItems = loader.loadModel('phase_5.5/models/gui/catalog_gui')
        hangupGui = guiItems.find('**/hangup')
        hangupRolloverGui = guiItems.find('**/hangup_rollover')
        self.hangup = DirectButton(self, relief=None, pos=(2.28, 0, -1.3),
                                   image=[hangupGui, hangupRolloverGui, hangupRolloverGui, hangupGui],
                                   text=['', TTLocalizer.CatalogHangUp, TTLocalizer.CatalogHangUp],
                                   text_fg=Vec4(1), text_scale=0.07, text_pos=(0.0, 0.14),
                                   command=self.hangUp)
        guiItems.removeNode()
        
        jarGui = loader.loadModel('phase_3.5/models/gui/jar_gui')
        self.moneyDisplay = DirectLabel(parent=self, relief=None, pos=(2.28, 0, -0.9), scale=0.8, text=str(base.localAvatar.getMoney()), text_scale=0.18, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_pos=(0, -0.1, 0), image=jarGui.find('**/Jar'), text_font=ToontownGlobals.getSignFont())
        
        jarGui.removeNode()
        return
class NewsPageButtonManager(FSM.FSM):
    notify = DirectNotifyGlobal.directNotify.newCategory('NewsPageButtonManager')

    def __init__(self):
        FSM.FSM.__init__(self, 'NewsPageButtonManager')
        self.buttonsLoaded = False
        self.clearGoingToNewsInfo()
        self.__blinkIval = None
        self.load()
        return

    def load(self):
        btnGui = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_newsBtnGui')
        bookModel = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_shtickerBook')
        self.openNewNewsUp = btnGui.find('**/tt_t_gui_ign_new')
        self.openNewNewsUpBlink = btnGui.find('**/tt_t_gui_ign_newBlink')
        self.openNewNewsHover = btnGui.find('**/tt_t_gui_ign_newHover')
        self.openOldNewsUp = btnGui.find('**/tt_t_gui_ign_oldNews')
        self.openOldNewsHover = btnGui.find('**/tt_t_gui_ign_oldHover')
        self.closeNewsUp = bookModel.find('**/tt_t_gui_sbk_newsPage1')
        self.closeNewsHover = bookModel.find('**/tt_t_gui_sbk_newsPage2')
        btnGui.removeNode()
        bookModel.removeNode()
        oldScale = 0.5
        newScale = 0.9
        shtickerBookScale = 0.305
        newPos = VBase3(0.914, 0, 0.862)
        shtickerBookPos = VBase3(1.175, 0, -0.83)
        textScale = 0.06
        self.newIssueButton = DirectButton(relief=None, sortOrder=DGG.BACKGROUND_SORT_INDEX - 1, image=(self.openNewNewsUp, self.openNewNewsHover, self.openNewNewsHover), text=('', TTLocalizer.EventsPageNewsTabName, TTLocalizer.EventsPageNewsTabName), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=textScale, text_font=ToontownGlobals.getInterfaceFont(), pos=newPos, scale=newScale, command=self.__handleGotoNewsButton)
        self.gotoPrevPageButton = DirectButton(relief=None, image=(self.closeNewsUp, self.closeNewsHover, self.closeNewsHover), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=textScale, text_font=ToontownGlobals.getInterfaceFont(), pos=shtickerBookPos, scale=shtickerBookScale, command=self.__handleGotoPrevPageButton)
        self.goto3dWorldButton = DirectButton(relief=None, image=(self.closeNewsUp, self.closeNewsHover, self.closeNewsHover), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=textScale, text_font=ToontownGlobals.getInterfaceFont(), pos=shtickerBookPos, scale=shtickerBookScale, command=self.__handleGoto3dWorldButton)
        self.hideNewIssueButton()
        self.gotoPrevPageButton.hide()
        self.goto3dWorldButton.hide()
        self.accept('newIssueOut', self.handleNewIssueOut)
        bounce1Pos = VBase3(newPos.getX(), newPos.getY(), newPos.getZ() + 0.022)
        bounce2Pos = VBase3(newPos.getX(), newPos.getY(), newPos.getZ() + 0.015)
        bounceIval = Sequence(LerpPosInterval(self.newIssueButton, 0.1, bounce1Pos, blendType='easeOut'), LerpPosInterval(self.newIssueButton, 0.1, newPos, blendType='easeIn'), LerpPosInterval(self.newIssueButton, 0.07, bounce2Pos, blendType='easeOut'), LerpPosInterval(self.newIssueButton, 0.07, newPos, blendType='easeIn'))
        self.__blinkIval = Sequence(Func(self.__showOpenEyes), Wait(2), bounceIval, Wait(0.5), Func(self.__showClosedEyes), Wait(0.1), Func(self.__showOpenEyes), Wait(0.1), Func(self.__showClosedEyes), Wait(0.1))
        self.__blinkIval.loop()
        self.__blinkIval.pause()
        self.buttonsLoaded = True
        return

    def __showOpenEyes(self):
        self.newIssueButton['image'] = (self.openNewNewsUp, self.openNewNewsHover, self.openNewNewsHover)

    def __showClosedEyes(self):
        self.newIssueButton['image'] = (self.openNewNewsUpBlink, self.openNewNewsHover, self.openNewNewsHover)

    def clearGoingToNewsInfo(self):
        self.goingToNewsPageFrom3dWorld = False
        self.setGoingToNewsPageFromStickerBook(False)

    def __handleGotoNewsButton(self):
        currentState = base.localAvatar.animFSM.getCurrentState().getName()
        if currentState == 'jumpAirborne':
            return
        from toontown.toon import LocalToon
        if not LocalToon.WantNewsPage:
            return
        if base.cr and base.cr.playGame and base.cr.playGame.getPlace() and base.cr.playGame.getPlace().fsm:
            fsm = base.cr.playGame.getPlace().fsm
            curState = fsm.getCurrentState().getName()
            if curState == 'walk':
                if hasattr(localAvatar, 'newsPage'):
                    base.cr.centralLogger.writeClientEvent('news gotoNewsButton clicked')
                    localAvatar.book.setPage(localAvatar.newsPage)
                    fsm.request('stickerBook')
                    self.goingToNewsPageFrom3dWorld = True
            elif curState == 'stickerBook':
                if hasattr(localAvatar, 'newsPage'):
                    base.cr.centralLogger.writeClientEvent('news gotoNewsButton clicked')
                    fsm.request('stickerBook')
                    if hasattr(localAvatar, 'newsPage') and localAvatar.newsPage:
                        localAvatar.book.goToNewsPage(localAvatar.newsPage)

    def __handleGotoPrevPageButton(self):
        self.clearGoingToNewsInfo()
        localAvatar.book.setPageBeforeNews()
        self.showAppropriateButton()
        self.ignoreEscapeKeyPress()

    def __handleGoto3dWorldButton(self):
        localAvatar.book.closeBook()

    def hideNewIssueButton(self):
        if hasattr(self, 'newIssueButton') and self.newIssueButton:
            self.newIssueButton.hide()
            localAvatar.clarabelleNewsPageCollision(False)

    def __showNewIssueButton(self):
        self.newIssueButton.show()
        localAvatar.clarabelleNewsPageCollision(True)

    def hideAllButtons(self):
        if not self.buttonsLoaded:
            return
        self.gotoPrevPageButton.hide()
        self.goto3dWorldButton.hide()
        self.hideNewIssueButton()
        self.__blinkIval.pause()

    def isNewIssueButtonShown(self):
        if not base.cr.inGameNewsMgr:
            return False
            
        if localAvatar.getLastTimeReadNews() < base.cr.inGameNewsMgr.getLatestIssue():
            return True
            
        return False

    def enterHidden(self):
        self.hideAllButtons()

    def exitHidden(self):
        pass

    def enterNormalWalk(self):
        if not self.buttonsLoaded:
            return
            
        if not base.cr.inGameNewsMgr:
            return
            
        if localAvatar.getLastTimeReadNews() < base.cr.inGameNewsMgr.getLatestIssue():
            self.__showNewIssueButton()
            self.__blinkIval.resume()
            
        else:
            self.hideNewIssueButton()
            
        self.gotoPrevPageButton.hide()
        self.goto3dWorldButton.hide()

    def exitNormalWalk(self):
        if not self.buttonsLoaded:
            return
        self.hideAllButtons()

    def enterGotoWorld(self):
        if not self.buttonsLoaded:
            return
        self.hideAllButtons()
        self.goto3dWorldButton.show()

    def exitGotoWorld(self):
        if not self.buttonsLoaded:
            return
        self.hideAllButtons()
        localAvatar.book.setPageBeforeNews(enterPage=False)
        self.clearGoingToNewsInfo()

    def enterPrevPage(self):
        if not self.buttonsLoaded:
            return
        self.hideAllButtons()
        self.gotoPrevPageButton.show()

    def exitPrevPage(self):
        if not self.buttonsLoaded:
            return
        self.hideAllButtons()

    def showAppropriateButton(self):
        self.notify.debugStateCall(self)
        from toontown.toon import LocalToon
        if not LocalToon.WantNewsPage:
            return
        if not self.buttonsLoaded:
            return
        if base.cr and base.cr.playGame and base.cr.playGame.getPlace() and hasattr(base.cr.playGame.getPlace(), 'fsm') and base.cr.playGame.getPlace().fsm:
            fsm = base.cr.playGame.getPlace().fsm
            curState = fsm.getCurrentState().getName()
            book = localAvatar.book
            if curState == 'walk':
                if localAvatar.tutorialAck and not localAvatar.isDisguised and not isinstance(base.cr.playGame.getPlace(), CogHQBossBattle.CogHQBossBattle):
                    self.request('NormalWalk')
                else:
                    self.request('Hidden')
            elif curState == 'stickerBook':
                if self.goingToNewsPageFrom3dWorld:
                    if localAvatar.tutorialAck:
                        self.request('GotoWorld')
                    else:
                        self.request('Hidden')
                elif self.goingToNewsPageFromStickerBook or hasattr(localAvatar, 'newsPage') and localAvatar.book.isOnPage(localAvatar.newsPage):
                    if localAvatar.tutorialAck:
                        self.request('PrevPage')
                    else:
                        self.request('Hidden')
                elif localAvatar.tutorialAck:
                    self.request('NormalWalk')
                else:
                    self.request('Hidden')

    def setGoingToNewsPageFromStickerBook(self, newVal):
        self.goingToNewsPageFromStickerBook = newVal

    def enterOff(self):
        self.ignoreAll()
        if not self.buttonsLoaded:
            return
        if self.__blinkIval:
            self.__blinkIval.finish()
            self.__blinkIval = None
        self.newIssueButton.destroy()
        self.gotoPrevPageButton.destroy()
        self.goto3dWorldButton.destroy()
        del self.openNewNewsUp
        del self.openNewNewsUpBlink
        del self.openNewNewsHover
        del self.openOldNewsUp
        del self.openOldNewsHover
        del self.closeNewsUp
        del self.closeNewsHover
        return

    def exitOff(self):
        self.notify.warning('Should not get here. NewsPageButtonManager.exitOff')

    def simulateEscapeKeyPress(self):
        if self.goingToNewsPageFrom3dWorld:
            self.__handleGoto3dWorldButton()
        if self.goingToNewsPageFromStickerBook:
            self.__handleGotoPrevPageButton()

    def handleNewIssueOut(self):
        if localAvatar.isReadingNews():
            pass
        else:
            self.showAppropriateButton()

    def acceptEscapeKeyPress(self):
        self.accept(ToontownGlobals.StickerBookHotkey, self.simulateEscapeKeyPress)
        self.accept(ToontownGlobals.OptionsPageHotkey, self.simulateEscapeKeyPress)

    def ignoreEscapeKeyPress(self):
        self.ignore(ToontownGlobals.StickerBookHotkey)
        self.ignore(ToontownGlobals.OptionsPageHotkey)
class ScreenshotViewer:
    notify = DirectNotifyGlobal.directNotify.newCategory('ScreenshotViewer')

    def __init__(self):
        self.resetImages()
        imageFrame = PDialog(parent = aspect2dp, pos = (0, 0, 0.10000000000000001), image_scale = (1.3 * 4 / 3.0, 1, 1.3), fadeScreen = 0.84999999999999998, scale = 1.1000000000000001)
        imageFrame.hide()
        imX = 0.84999999999999998
        imY = imX * 3 / 4.0
        self.imageObj = OnscreenImage(parent = imageFrame, image = self.screens[0], scale = (imX, 1, imY), pos = (0, 0, -0.025000000000000001))
        self.imageLabel = DirectLabel(parent = imageFrame, relief = None, state = DGG.DISABLED, pos = (0, 0, -0.75), textMayChange = 1, text_fg = (0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 1), text_scale = 0.040000000000000001)
        self.imageLabel.hide()
        topGui = loader.loadModel('models/gui/toplevel_gui')
        arrow = topGui.find('**/generic_arrow')
        buttons = loader.loadModel('models/gui/lookout_gui')
        closeButton = (buttons.find('**/lookout_close_window'), buttons.find('**/lookout_close_window_down'), buttons.find('**/lookout_close_window_over'))
        xs = 1.2
        self.nextButton = DirectButton(parent = imageFrame, relief = None, command = self.next, pos = (0.69999999999999996, 0, 0), image = arrow, image_scale = (-xs, xs, xs), sortOrder = -5)
        self.prevButton = DirectButton(parent = imageFrame, relief = None, command = self.prev, pos = (-0.69999999999999996, 0, 0), image = arrow, image_scale = xs, sortOrder = -5)
        self.closeButton = DirectButton(parent = imageFrame, relief = None, command = self.close, pos = (0.78000000000000003, 0, -0.5), image = closeButton, image_scale = 0.29999999999999999, text = PLocalizer.lClose, text_fg = PiratesGuiGlobals.TextFG1, text_scale = 0.050000000000000003, text_pos = (0, -0.10000000000000001), sortOrder = -5)
        self.showIval = Sequence(Func(imageFrame.show), Wait(1), Parallel(LerpPosInterval(self.closeButton, 0.20000000000000001, Vec3(0.78000000000000003, 0, -0.80000000000000004), Vec3(0.78000000000000003, 0, -0.5)), LerpPosInterval(self.nextButton, 0.20000000000000001, Vec3(1, 0, 0), Vec3(0.69999999999999996, 0, 0)), LerpPosInterval(self.prevButton, 0.20000000000000001, Vec3(-1, 0, 0), Vec3(-0.69999999999999996, 0, 0))), Func(self.imageLabel.show))
        self.imageFrame = imageFrame
        base.transitions.fadeScreen(0.84999999999999998)


    def destroy(self):
        self.imageFrame.destroy()


    def resetImages(self):
        filenames = os.listdir(os.curdir + '/' + PLocalizer.ScreenshotDir)
        self.screens = _[1]
        self.currentIndex = 0


    def resetButtons(self):
        self.closeButton.setPos(Vec3(0.78000000000000003, 0, -0.5))
        self.nextButton.setPos(Vec3(0.69999999999999996, 0, 0))
        self.prevButton.setPos(Vec3(-0.69999999999999996, 0, 0))


    def showImage(self, index):
        if index >= 0 and index < len(self.screens):
            self.imageFrame.show()
            self.imageObj.setImage(self.screens[index])
            pandafile = Filename(str(ExecutionEnvironment.getCwd()))
            winfile = pandafile.toOsSpecific()
            self.imageLabel['text'] = '%s:\n%s\n%s\n[%s/%s]' % (PLocalizer.ScreenshotLocation, winfile, self.screens[index], index + 1, len(self.screens))
            self.imageLabel['text_fg'] = (0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 1)
            self.imageLabel['text_scale'] = 0.040000000000000001

        if len(self.screens) == 1:
            self.prevButton['state'] = DGG.DISABLED
            self.nextButton['state'] = DGG.DISABLED
        else:
            self.prevButton['state'] = DGG.NORMAL
            self.nextButton['state'] = DGG.NORMAL


    def next(self):
        self.currentIndex = (self.currentIndex + 1) % len(self.screens)

        try:
            self.showImage(self.currentIndex)
        except:
            self.notify.error('Bad image')



    def prev(self):
        self.currentIndex = (self.currentIndex - 1) % len(self.screens)

        try:
            self.showImage(self.currentIndex)
        except:
            self.notify.error('Bad Image')



    def close(self):
        self.imageFrame.hide()


    def show(self):
        self.resetImages()
        self.resetButtons()
        self.showImage(0)
        self.showIval.start()


    def toggleShow(self):
        if self.imageFrame.isHidden():
            self.show()
        else:
            self.close()