Esempio n. 1
0
    def __init__(self):
        self.game = None
        ShowBase.__init__(self)
        # FSM.__init__(self, "battle-tank-fsm")

        if settings.DISABLE_SFX:
            self.disableAllAudio()

        # Enhance font readability
        DGG.getDefaultFont().setPixelsPerUnit(100)
        # get the displays width and height for later usage
        self.dispWidth = self.pipe.getDisplayWidth()
        self.dispHeight = self.pipe.getDisplayHeight()

        self.musicManager.setConcurrentSoundLimit(3)
        self.render.setAntialias(AntialiasAttrib.MMultisample)

        self.menu = MainMenu(self)
        self.hud = Hud(self)
        self.accept("escape", self.__escape)

        self.state = settings.IN_MENU_STATE
        self.menu.show()

        # accept msg inputs
        self.accept(settings.QUIT_GAME_DRIVER, self.exit_game)
        self.accept(settings.START_GAME_DRIVER, self.start_game)

        # collision
        self.cTrav = CollisionTraverser()
        self.cTrav.setRespectPrevTransform(True)
        self.pusher = CollisionHandlerPusher()
        self.cHandler = CollisionHandlerEvent()
 def __init__(self):
     render.setAntialias(AntialiasAttrib.MAuto)
     # render.setRenderModeWireframe()
     DGG.getDefaultFont().setPixelsPerUnit(100)
     self.setShaders()
     self.initLights()
     self.initTransitions()
     self.setFPS()
     self.setCam()
Esempio n. 3
0
    def __init__(self, offset, h_size, v_size, numLines, hugpos):
        self.numLines = numLines
        #if hugpos == "statusbar":
        #    color = (0,0,0,1)
        #else:
        #    color = (0.2, 0.2, 0.2, 0.8)
        color = (0.2, 0.2, 0.2, 0.9)
        self.frame = DirectFrame(   relief = DGG.FLAT
                                  , frameColor = color
                                  , scale = 1
                                  , frameSize = (0, h_size, 0, -v_size) )
        self.v_size = v_size
        self.hugpos = hugpos
        self.offset = offset
        
        if hugpos == "top":
            self.frame.reparentTo(base.a2dTopLeft)#@UndefinedVariable
            self.frame.setPos(self.offset.getX(), 0, self.offset.getZ() - GUI_TOP_OFFSET)
        elif hugpos == "bottom":
            self.frame.reparentTo(base.a2dBottomLeft)#@UndefinedVariable
            self.frame.setPos(self.offset.getX(), 0, self.offset.getZ() + GUI_BOTTOM_OFFSET -0.085)
        elif hugpos == "statusbar":
            self.frame.reparentTo(base.a2dTopLeft)#@UndefinedVariable
            self.frame.setPos(self.offset.getX(), 0, self.offset.getZ())

        fixedWidthFont = loader.loadFont(GUI_FONT)#@UndefinedVariable
        if not fixedWidthFont.isValid():
            print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
            fixedWidthFont = DGG.getDefaultFont()
        
        if numLines == 1:
            self.lineHeight = 0.05
        else:
            self.lineHeight = v_size*0.9 / numLines
            
        # output lines
        self.frameOutputList = list()
        for i in xrange( self.numLines ):
            label = OnscreenText( parent = self.frame
                              , text = ""
                              , pos = (0.005, -(i+1)*self.lineHeight)
                              , align=TextNode.ALeft
                              , mayChange=1
                              , scale=0.04
                              , fg = (1,1,1,1)
                              , shadow = (0, 0, 0, 1))
                              #, frame = (200,0,0,1) )
            label.setFont( fixedWidthFont )
            self.frameOutputList.append( label )
Esempio n. 4
0
    def __init__(self, numPlayers, avIdList, votes, directions, namesList,
                 disconnectedList, directionToGo, directionReason,
                 directionTotals, *args, **kwargs):
        opts = {
            'relief': None,
            'geom': DGG.getDefaultDialogGeom(),
            'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.8, ),
            'geom_scale': (1.75, 1, 0.75),
            'pos': (0, 0, 0.525)
        }
        opts.update(kwargs)
        DirectFrame.__init__(self, *args, **opts)
        self.initialiseoptions(VoteResultsPanel)
        listMultiplier = 1
        if TravelGameGlobals.SpoofFour:
            listMultiplier = 4
        self.avIdList = avIdList * listMultiplier
        self.numPlayers = numPlayers * listMultiplier
        self.votes = votes * listMultiplier
        self.directions = directions * listMultiplier
        self.namesList = namesList * listMultiplier
        self.disconnectedList = disconnectedList * listMultiplier
        self.directionToGo = directionToGo
        self.directionReason = directionReason
        self.directionTotals = directionTotals
        self.entryList = []
        self.rowFrame = []
        self.upDownFrame = DirectFrame(parent=self,
                                       relief=None,
                                       pos=self.getRowPos(-1))
        self.upLabel = DirectLabel(parent=self.upDownFrame,
                                   relief=None,
                                   pos=(1.2, 0, 0.0),
                                   text=TTLocalizer.TravelGameDirections[0],
                                   text_fg=(0.0, 0.0, 1.0, 1.0),
                                   text_scale=0.05,
                                   text_align=TextNode.ARight)
        self.downLabel = DirectLabel(parent=self.upDownFrame,
                                     relief=None,
                                     pos=(1.43, 0, 0.0),
                                     text=TTLocalizer.TravelGameDirections[1],
                                     text_fg=(1.0, 0.0, 0.0, 1.0),
                                     text_scale=0.05,
                                     text_align=TextNode.ARight)
        self.totalFrame = DirectFrame(parent=self,
                                      relief=None,
                                      pos=self.getRowPos(self.numPlayers))
        self.totalText = DirectLabel(parent=self.totalFrame,
                                     relief=None,
                                     pos=(1.0, 0, 0.0),
                                     text='Total',
                                     text_fg=(0.0, 0.0, 0.0, 1.0),
                                     text_scale=0.05,
                                     text_align=TextNode.ARight)
        self.totalVotesUpLabel = DirectLabel(parent=self.totalFrame,
                                             relief=None,
                                             pos=(1.2, 0, 0.0),
                                             text='',
                                             text_fg=(0.0, 0.0, 1.0, 1.0),
                                             text_scale=0.05,
                                             text_align=TextNode.ARight)
        self.totalVotesDownLabel = DirectLabel(parent=self.totalFrame,
                                               relief=None,
                                               pos=(1.43, 0, 0.0),
                                               text='',
                                               text_fg=(1.0, 0.0, 0.0, 1.0),
                                               text_scale=0.05,
                                               text_align=TextNode.ARight)
        self.totalVotesLabels = [
            self.totalVotesUpLabel, self.totalVotesDownLabel
        ]
        self.resultFrame = DirectFrame(parent=self,
                                       relief=None,
                                       pos=self.getRowPos(5))
        self.resultLabel = DirectLabel(parent=self.resultFrame,
                                       text='',
                                       text_scale=0.06,
                                       pos=(0.7, 0, 0.0),
                                       text_align=TextNode.ACenter)
        self.setupResultLabel()
        for index in xrange(self.numPlayers):
            frame = DirectFrame(parent=self,
                                relief=None,
                                pos=self.getRowPos(index))
            self.rowFrame.append(frame)
            nameLabel = DirectFrame(parent=frame,
                                    relief=None,
                                    pos=(0.46, 0.0, 0.0),
                                    text=self.namesList[index],
                                    text_fg=(0.0, 0.0, 0.0, 1.0),
                                    text_scale=0.05,
                                    text_align=TextNode.ACenter,
                                    text_font=DGG.getDefaultFont())
            votesUpLabel = DirectLabel(parent=frame,
                                       relief=None,
                                       pos=(1.2, 0.0, 0.0),
                                       text='',
                                       text_fg=(0, 0, 1, 1),
                                       text_scale=0.05,
                                       text_align=TextNode.ARight,
                                       text_font=DGG.getDefaultFont())
            votesDownLabel = DirectLabel(parent=frame,
                                         relief=None,
                                         pos=(1.43, 0.0, 0.0),
                                         text='',
                                         text_fg=(1, 0, 0, 1),
                                         text_scale=0.05,
                                         text_align=TextNode.ARight,
                                         text_font=DGG.getDefaultFont())
            nameLabel.hide()
            self.entryList.append((nameLabel, votesUpLabel, votesDownLabel))

        return
Esempio n. 5
0
    def __init__(self, class_parent, parent, h_size, v_size, aspect, hugpos):
        self.h_size = h_size
        self.v_size = v_size
        self.scale = 0.04
        self.parent = class_parent
        self.numlines = int(v_size / self.scale - 2)

        self.pos_min_x = 0
        self.pos_min_y = 0
        self.pos_max_x = self.h_size
        self.pos_max_y = 0.7

        if aspect > 0:
            self.pos_max_x /= aspect
        else:
            self.pos_max_y *= aspect

        self.consoleFrame = DirectFrame(relief=DGG.RIDGE,
                                        frameColor=(0, 0, 0, 0),
                                        scale=self.scale,
                                        frameSize=(0, self.h_size / self.scale,
                                                   0,
                                                   self.v_size / self.scale))

        if parent == base.a2dBottomLeft:  #@UndefinedVariable
            self.pos_min_x -= 1
            self.pos_min_y -= 1
            self.pos_max_x -= 1
            self.pos_max_y -= 1

        if hugpos == "bottom":
            self.consoleFrame.setPos(0, 0, GUI_BOTTOM_OFFSET - 0.085)
            self.pos_min_x = 0
            self.pos_min_y = GUI_BOTTOM_OFFSET - 0.085 - 0.07
            self.pos_max_x = self.h_size
            self.pos_max_y = GUI_BOTTOM_OFFSET - 0.085

        fixedWidthFont = loader.loadFont(GUI_FONT)  #@UndefinedVariable
        #fixedWidthFont.setPixelsPerUnit(60)
        #fixedWidthFont.setRenderMode(fixedWidthFont.RMSolid)
        if not fixedWidthFont.isValid():
            print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(
                self.font)
            fixedWidthFont = DGG.getDefaultFont()

        #fixedWidthFont.setPageSize(512,512)
        #fixedWidthFont.setPixelsPerUnit(60)

        self.consoleEntry = DirectEntry(
            self.consoleFrame,
            text="",
            command=self.onEnterPress
            #, width       = self.h_size/self.scale -2
            ,
            pos=(0.01, 0, 0.02),
            initialText="Enter text...",
            numLines=1,
            focus=0,
            entryFont=fixedWidthFont,
            scale=1,
            frameColor=(0, 0, 0, 0.2),
            text_fg=(0, 1, 0, 1),
            text_shadow=(0, 0, 0, 1))

        #self.consoleEntry = DirectEntry(self.consoleFrame)

        self.consoleEntry["frameSize"] = (0, self.h_size / self.scale, 0, 1)
        self.consoleEntry["width"] = self.h_size / self.scale
        self.consoleEntry["focusInCommand"] = self.focusInCallback
        self.consoleEntry["focusOutCommand"] = self.focusOutCallback

        self.consoleFrame.reparentTo(parent)

        self.textBuffer = list()
        self.textBufferLength = 100
        for i in xrange(self.textBufferLength):
            self.textBuffer.append(['', (100, 100, 100, 1)])
        self.textBufferPos = self.textBufferLength - self.numlines

        # output lines
        self.consoleOutputList = list()
        for i in xrange(self.numlines):
            label = OnscreenText(parent=self.consoleFrame,
                                 text="",
                                 pos=(0, i + 1.5),
                                 align=TextNode.ALeft,
                                 mayChange=1,
                                 scale=1.0,
                                 fg=(100, 100, 100, 1),
                                 shadow=(0, 0, 0, 1))
            # , frame = (200,0,0,1) )
            label.setFont(fixedWidthFont)
            self.consoleOutputList.append(label)

        self.linelength = 57
        self.linewrap = textwrap.TextWrapper()
        self.linewrap.width = self.linelength
        self.toggleConsole()
    def __init__(self, numPlayers, avIdList, votes, directions, namesList, disconnectedList, directionToGo, directionReason, directionTotals, *args, **kwargs):
        opts = {'relief': None,
         'geom': DGG.getDefaultDialogGeom(),
         'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.8,),
         'geom_scale': (1.75, 1, 0.25),
         'pos': (0, 0, 0.825)}
        opts.update(kwargs)
        DirectFrame.__init__(self, *args, **opts)
        self.initialiseoptions(VoteResultsTrolleyPanel)
        listMultiplier = 1
        if TravelGameGlobals.SpoofFour:
            listMultiplier = 4
        self.avIdList = avIdList * listMultiplier
        self.numPlayers = numPlayers * listMultiplier
        self.votes = votes * listMultiplier
        self.directions = directions * listMultiplier
        self.namesList = namesList * listMultiplier
        self.disconnectedList = disconnectedList * listMultiplier
        self.directionToGo = directionToGo
        self.directionReason = directionReason
        self.directionTotals = directionTotals
        self.entryList = []
        self.rowFrame = []
        self.upDownFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(-1))
        self.upLabel = DirectLabel(parent=self, relief=None, pos=(-0.5, 0, 0.06), text=TTLocalizer.TravelGameDirections[0] + ':', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight)
        self.downLabel = DirectLabel(parent=self, relief=None, pos=(0.5, 0, 0.06), text=TTLocalizer.TravelGameDirections[1] + ':', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight)
        self.totalVotesUpLabel = DirectLabel(parent=self.upLabel, relief=None, pos=(0.2, 0, 0.0), text='0', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight)
        self.totalVotesDownLabel = DirectLabel(parent=self.downLabel, relief=None, pos=(0.2, 0, 0.0), text='0', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight)
        self.totalFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(self.numPlayers))
        self.totalVotesLabels = [self.totalVotesUpLabel, self.totalVotesDownLabel]
        self.resultFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(0.5))
        self.resultLabel = DirectLabel(parent=self.resultFrame, text='', text_scale=0.06, pos=(0.7, 0, 0.0), text_align=TextNode.ACenter)
        self.setupResultLabel()
        for index in range(self.numPlayers):
            frame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(index))
            self.rowFrame.append(frame)
            nameLabel = DirectFrame(parent=frame, relief=None, pos=(0.46, 0.0, 0.0), text=self.namesList[index], text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ACenter, text_font=DGG.getDefaultFont())
            votesUpLabel = DirectLabel(parent=frame, relief=None, pos=(1.2, 0.0, 0.0), text='', text_fg=(0, 0, 1, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont())
            votesDownLabel = DirectLabel(parent=frame, relief=None, pos=(1.43, 0.0, 0.0), text='', text_fg=(1, 0, 0, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont())
            nameLabel.hide()
            self.entryList.append((nameLabel, votesUpLabel, votesDownLabel))

        self.avVotesLabel = {}
        self.avArrows = {}
        matchingGameGui = loader.loadModel('phase_3.5/models/gui/matching_game_gui')
        minnieArrow = matchingGameGui.find('**/minnieArrow')
        from toontown.minigame.DistributedTravelGame import map3dToAspect2d
        for index in range(self.numPlayers):
            avId = self.avIdList[index]
            av = base.cr.doId2do.get(avId)
            if av:
                height = av.getHeight()
                avPos = av.getPos(render)
                avPos.setZ(av.getZ() + 5)
                labelPos = map3dToAspect2d(render, avPos)
                if not labelPos:
                    continue
                labelPos.setZ(labelPos.getZ() + 0.3)
                arrow = None
                if self.votes[index] > 0:
                    arrow = aspect2d.attachNewNode('avArrow')
                    minnieArrow.copyTo(arrow)
                    arrow.setScale(1.1, 1, 1.15)
                    arrow.setPos(labelPos)
                    if self.directions[index] == 0:
                        arrow.setR(-90)
                        arrow.setColorScale(0, 0, 1, 1)
                    else:
                        arrow.setR(90)
                        arrow.setColorScale(1, 0, 0, 1)
                    arrow.wrtReparentTo(self.resultFrame)
                    arrow.hide()
                    self.avArrows[index] = arrow
                fgColor = Vec4(0, 0, 0, 1)
                if self.votes[index] > 0:
                    if self.directions[index] == 0:
                        fgColor = Vec4(0, 0, 1, 1)
                    else:
                        fgColor = Vec4(1, 0, 0, 1)
                if self.votes[index] > 0:
                    newLabel = DirectLabel(parent=aspect2d, relief=None, pos=labelPos, text='test', text_fg=(1, 1, 1, 1), text_scale=0.1, text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont(), text_pos=(0, -0.01, 0))
                else:
                    newLabel = DirectLabel(parent=aspect2d, geom=DGG.getDefaultDialogGeom(), geom_scale=(0.2, 1, 0.2), relief=None, pos=labelPos, text='test', text_fg=(0.5, 0.5, 0.5, 1), text_scale=0.1, text_align=TextNode.ACenter, text_font=ToontownGlobals.getSignFont(), text_pos=(0, -0.035, 0))
                newLabel.wrtReparentTo(self.resultFrame)
                newLabel.hide()
                self.avVotesLabel[index] = newLabel

        matchingGameGui.removeNode()
        self.curArrowSfxIndex = 0
        self.upArrowSfx = []
        self.downArrowSfx = []
        for i in range(5):
            self.upArrowSfx.append(base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.mp3'))
            self.downArrowSfx.append(base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_red_arrow.mp3'))

        self.winVoteSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_win_vote.mp3')
        self.noVoteSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_square_no_vote_1.mp3')
        self.loseVoteSfx = base.loadSfx('phase_4/audio/sfx/MG_sfx_travel_game_lose_vote.mp3')
        self.localAvatarWon = False
        self.localAvatarLost = False
        localIndex = self.avIdList.index(base.localAvatar.doId)
        localDirection = self.directions[localIndex]
        localVotes = self.votes[localIndex]
        if localVotes:
            if localDirection == self.directionToGo:
                if not TravelGameGlobals.ReverseWin:
                    self.localAvatarWon = True
                else:
                    self.localAvatarLost = True
            elif not TravelGameGlobals.ReverseWin:
                self.localAvatarLost = True
            else:
                self.localAvatarWon = True
        return
Esempio n. 7
0
 def __init__( self, parent ):
   self.parent = parent
   
   # line wrapper
   self.linewrap = textwrap.TextWrapper()
   self.linewrap.width = self.linelength
   
   # calculate window size
   left   = (self.h_pos) / self.scale
   right  = (self.h_pos + self.h_size) / self.scale
   bottom = (self.v_pos) / self.scale
   top    = (self.v_pos + self.v_size) /self.scale
   
   # panda3d interface
   self.consoleFrame = DirectFrame ( relief = DGG.GROOVE
                                   , frameColor = (200, 200, 200, 0.5)
                                   , scale=self.scale
                                   , frameSize = (0, self.h_size / self.scale, 0, self.v_size / self.scale) )
   
   # vardis 27-02-2009: Added special cull bin in order to render on top of everything
   CullBinManager.getGlobalPtr().addBin(PanoConstants.CONSOLE_CULL_BIN_NAME, CullBinManager.BTUnsorted, PanoConstants.CONSOLE_CULL_BIN_VAL)
   self.consoleFrame.setBin("fixed", PanoConstants.RENDER_ORDER_CONSOLE)
   
   self.windowEvent( base.win )
   
   # try to load the defined font
   fixedWidthFont = loader.loadFont(parent.game.getResources().getResourceFullPath(PanoConstants.RES_TYPE_FONTS, self.font))
   # if font is not valid use default font
   if not fixedWidthFont.isValid():
     if self.font is None:
       print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
     fixedWidthFont = DGG.getDefaultFont()
   
   # text entry line
   self.consoleEntry = DirectEntry ( self.consoleFrame
                                   , text        = ""
                                   , command     = self.onEnterPress
                                   , width       = self.h_size/self.scale - 2
                                   , pos         = (1, 0, 1.5)
                                   , initialText = ""
                                   , numLines    = 1
                                   , focus       = 1
                                   , entryFont   = fixedWidthFont)
   
   # output lines
   self.consoleOutputList = list()
   for i in xrange( self.numlines ):
     label = OnscreenText( parent = self.consoleFrame
                         , text = ""
                         , pos = (1, -i+3+self.numlines)
                         , align=TextNode.ALeft
                         , mayChange=1
                         , scale=1.0
                         , fg = self.defaultTextColor )
     label.setFont( fixedWidthFont )
     self.consoleOutputList.append( label )
   
   # list of the last commands of the user
   self.userCommandList = list()
   self.userCommandListLength = 100
   for i in xrange(self.userCommandListLength):
     self.userCommandList.append('')
   self.userCommandPos = 0
   
   # buffer for data
   self.textBuffer = list()
   self.textBufferLength = 1000
   for i in xrange(self.textBufferLength):
     self.textBuffer.append(['', DEFAULT_COLOR])
   self.textBufferPos = self.textBufferLength-self.numlines
   
   # toggle the window at least once to activate the events
   self.toggleConsole()
   self.toggleConsole()
   
   self.help()
Esempio n. 8
0
    def __init__(self):
        """initialise the engine"""
        ShowBase.__init__(self)
        FSM.__init__(self, "FSM-Game")

        #
        # BASIC APPLICATION CONFIGURATIONS
        #
        # disable pandas default camera driver
        self.disableMouse()
        # set background color to black
        self.setBackgroundColor(0, 0, 0)
        # set antialias for the complete sceen to automatic
        self.render.setAntialias(AntialiasAttrib.MAuto)
        # shader generator
        render.setShaderAuto()
        # Enhance font readability
        DGG.getDefaultFont().setPixelsPerUnit(100)

        #
        # CONFIGURATION LOADING
        #
        # load given variables or set defaults
        # check if audio should be muted
        mute = ConfigVariableBool("audio-mute", False).getValue()
        if mute:
            self.disableAllAudio()
        else:
            self.enableAllAudio()
        # check if particles should be enabled
        particles = ConfigVariableBool("particles-enabled", True).getValue()
        if particles:
            self.enableParticles()
        # check if the config file hasn't been created
        if not os.path.exists(prcFile):
            # get the displays width and height
            w = self.pipe.getDisplayWidth()
            h = self.pipe.getDisplayHeight()
            # set window properties
            # clear all properties not previously set
            base.win.clearRejectedProperties()
            # setup new window properties
            props = WindowProperties()
            # Fullscreen
            props.setFullscreen(True)
            # set the window size to the screen resolution
            props.setSize(w, h)
            # request the new properties
            base.win.requestProperties(props)
        elif base.appRunner:
            # As when the application is started as appRunner instance
            # it doesn't respect our loadPrcFile configurations specific
            # to the window, hence we need to manually set them here.
            for dec in range(mainConfig.getNumDeclarations()):
                #TODO: Check for all window specific variables like
                #      fullscreen, screen size, title and window
                #      decoration that you have in your configuration
                #      and set them by your own.
                if mainConfig.getVariableName(dec) == "fullscreen":
                    if not mainConfig.getDeclaration(dec).getBoolWord(0): break
                    # get the displays width and height
                    w = self.pipe.getDisplayWidth()
                    h = self.pipe.getDisplayHeight()
                    # set window properties
                    # clear all properties not previously set
                    base.win.clearRejectedProperties()
                    # setup new window properties
                    props = WindowProperties()
                    # Fullscreen
                    props.setFullscreen(True)
                    # set the window size to the screen resolution
                    props.setSize(w, h)
                    # request the new properties
                    base.win.requestProperties(props)
                    break

        # automatically safe configuration at application exit
        base.exitFunc = self.__writeConfig

        # due to the delayed window resizing and switch to fullscreen
        # we wait some time until everything is set so we can savely
        # proceed with other setups like the menus
        if base.appRunner:
            # this behaviour only happens if run from p3d files and
            # hence the appRunner is enabled
            taskMgr.doMethodLater(0.5,
                                  self.postInit,
                                  "post initialization",
                                  extraArgs=[])
        else:
            self.postInit()
Esempio n. 9
0
    def __init__(self, numPlayers, avIdList, votes, directions, namesList,
                 disconnectedList, directionToGo, directionReason,
                 directionTotals, *args, **kwargs):
        opts = {
            'relief': None,
            'geom': DGG.getDefaultDialogGeom(),
            'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.8, ),
            'geom_scale': (1.75, 1, 0.25),
            'pos': (0, 0, 0.825)
        }
        opts.update(kwargs)
        DirectFrame.__init__(self, *args, **opts)
        self.initialiseoptions(VoteResultsTrolleyPanel)
        listMultiplier = 1
        if TravelGameGlobals.SpoofFour:
            listMultiplier = 4
        self.avIdList = avIdList * listMultiplier
        self.numPlayers = numPlayers * listMultiplier
        self.votes = votes * listMultiplier
        self.directions = directions * listMultiplier
        self.namesList = namesList * listMultiplier
        self.disconnectedList = disconnectedList * listMultiplier
        self.directionToGo = directionToGo
        self.directionReason = directionReason
        self.directionTotals = directionTotals
        self.entryList = []
        self.rowFrame = []
        self.upDownFrame = DirectFrame(parent=self,
                                       relief=None,
                                       pos=self.getRowPos(-1))
        self.upLabel = DirectLabel(parent=self,
                                   relief=None,
                                   pos=(-0.5, 0, 0.06),
                                   text=TTLocalizer.TravelGameDirections[0] +
                                   ':',
                                   text_fg=(0.0, 0.0, 1.0, 1.0),
                                   text_scale=0.05,
                                   text_align=TextNode.ARight)
        self.downLabel = DirectLabel(parent=self,
                                     relief=None,
                                     pos=(0.5, 0, 0.06),
                                     text=TTLocalizer.TravelGameDirections[1] +
                                     ':',
                                     text_fg=(1.0, 0.0, 0.0, 1.0),
                                     text_scale=0.05,
                                     text_align=TextNode.ARight)
        self.totalVotesUpLabel = DirectLabel(parent=self.upLabel,
                                             relief=None,
                                             pos=(0.2, 0, 0.0),
                                             text='0',
                                             text_fg=(0.0, 0.0, 1.0, 1.0),
                                             text_scale=0.05,
                                             text_align=TextNode.ARight)
        self.totalVotesDownLabel = DirectLabel(parent=self.downLabel,
                                               relief=None,
                                               pos=(0.2, 0, 0.0),
                                               text='0',
                                               text_fg=(1.0, 0.0, 0.0, 1.0),
                                               text_scale=0.05,
                                               text_align=TextNode.ARight)
        self.totalFrame = DirectFrame(parent=self,
                                      relief=None,
                                      pos=self.getRowPos(self.numPlayers))
        self.totalVotesLabels = [
            self.totalVotesUpLabel, self.totalVotesDownLabel
        ]
        self.resultFrame = DirectFrame(parent=self,
                                       relief=None,
                                       pos=self.getRowPos(0.5))
        self.resultLabel = DirectLabel(parent=self.resultFrame,
                                       text='',
                                       text_scale=0.06,
                                       pos=(0.7, 0, 0.0),
                                       text_align=TextNode.ACenter)
        self.setupResultLabel()
        for index in xrange(self.numPlayers):
            frame = DirectFrame(parent=self,
                                relief=None,
                                pos=self.getRowPos(index))
            self.rowFrame.append(frame)
            nameLabel = DirectFrame(parent=frame,
                                    relief=None,
                                    pos=(0.46, 0.0, 0.0),
                                    text=self.namesList[index],
                                    text_fg=(0.0, 0.0, 0.0, 1.0),
                                    text_scale=0.05,
                                    text_align=TextNode.ACenter,
                                    text_font=DGG.getDefaultFont())
            votesUpLabel = DirectLabel(parent=frame,
                                       relief=None,
                                       pos=(1.2, 0.0, 0.0),
                                       text='',
                                       text_fg=(0, 0, 1, 1),
                                       text_scale=0.05,
                                       text_align=TextNode.ARight,
                                       text_font=DGG.getDefaultFont())
            votesDownLabel = DirectLabel(parent=frame,
                                         relief=None,
                                         pos=(1.43, 0.0, 0.0),
                                         text='',
                                         text_fg=(1, 0, 0, 1),
                                         text_scale=0.05,
                                         text_align=TextNode.ARight,
                                         text_font=DGG.getDefaultFont())
            nameLabel.hide()
            self.entryList.append((nameLabel, votesUpLabel, votesDownLabel))

        self.avVotesLabel = {}
        self.avArrows = {}
        matchingGameGui = loader.loadModel(
            'phase_3.5/models/gui/matching_game_gui')
        minnieArrow = matchingGameGui.find('**/minnieArrow')
        from toontown.minigame.DistributedTravelGame import map3dToAspect2d
        for index in xrange(self.numPlayers):
            avId = self.avIdList[index]
            av = base.cr.doId2do.get(avId)
            if av:
                height = av.getHeight()
                avPos = av.getPos(render)
                avPos.setZ(av.getZ() + 5)
                labelPos = map3dToAspect2d(render, avPos)
                if not labelPos:
                    continue
                labelPos.setZ(labelPos.getZ() + 0.3)
                arrow = None
                if self.votes[index] > 0:
                    arrow = aspect2d.attachNewNode('avArrow')
                    minnieArrow.copyTo(arrow)
                    arrow.setScale(1.1, 1, 1.15)
                    arrow.setPos(labelPos)
                    if self.directions[index] == 0:
                        arrow.setR(-90)
                        arrow.setColorScale(0, 0, 1, 1)
                    else:
                        arrow.setR(90)
                        arrow.setColorScale(1, 0, 0, 1)
                    arrow.wrtReparentTo(self.resultFrame)
                    arrow.hide()
                    self.avArrows[index] = arrow
                fgColor = Vec4(0, 0, 0, 1)
                if self.votes[index] > 0:
                    if self.directions[index] == 0:
                        fgColor = Vec4(0, 0, 1, 1)
                    else:
                        fgColor = Vec4(1, 0, 0, 1)
                if self.votes[index] > 0:
                    newLabel = DirectLabel(
                        parent=aspect2d,
                        relief=None,
                        pos=labelPos,
                        text='test',
                        text_fg=(1, 1, 1, 1),
                        text_scale=0.1,
                        text_align=TextNode.ACenter,
                        text_font=ToontownGlobals.getSignFont(),
                        text_pos=(0, -0.01, 0))
                else:
                    newLabel = DirectLabel(
                        parent=aspect2d,
                        geom=DGG.getDefaultDialogGeom(),
                        geom_scale=(0.2, 1, 0.2),
                        relief=None,
                        pos=labelPos,
                        text='test',
                        text_fg=(0.5, 0.5, 0.5, 1),
                        text_scale=0.1,
                        text_align=TextNode.ACenter,
                        text_font=ToontownGlobals.getSignFont(),
                        text_pos=(0, -0.035, 0))
                newLabel.wrtReparentTo(self.resultFrame)
                newLabel.hide()
                self.avVotesLabel[index] = newLabel

        matchingGameGui.removeNode()
        self.curArrowSfxIndex = 0
        self.upArrowSfx = []
        self.downArrowSfx = []
        for i in xrange(5):
            self.upArrowSfx.append(
                base.loader.loadSfx(
                    'phase_4/audio/sfx/MG_sfx_travel_game_blue_arrow.ogg'))
            self.downArrowSfx.append(
                base.loader.loadSfx(
                    'phase_4/audio/sfx/MG_sfx_travel_game_red_arrow.ogg'))

        self.winVoteSfx = base.loader.loadSfx(
            'phase_4/audio/sfx/MG_sfx_travel_game_win_vote.ogg')
        self.noVoteSfx = base.loader.loadSfx(
            'phase_4/audio/sfx/MG_sfx_travel_game_square_no_vote_1.ogg')
        self.loseVoteSfx = base.loader.loadSfx(
            'phase_4/audio/sfx/MG_sfx_travel_game_lose_vote.ogg')
        self.localAvatarWon = False
        self.localAvatarLost = False
        localIndex = self.avIdList.index(base.localAvatar.doId)
        localDirection = self.directions[localIndex]
        localVotes = self.votes[localIndex]
        if localVotes:
            if localDirection == self.directionToGo:
                if not TravelGameGlobals.ReverseWin:
                    self.localAvatarWon = True
                else:
                    self.localAvatarLost = True
            elif not TravelGameGlobals.ReverseWin:
                self.localAvatarLost = True
            else:
                self.localAvatarWon = True
        return
Esempio n. 10
0
    def __init__(self, parent):
        global base
        if not logger.isEnabledFor(logging.DEBUG):
            global CONSOLE_MESSAGE
            CONSOLE_MESSAGE = '''
----------------- Ship's Interface version 3.0.9_749 -------------------
Direct Ship Interface Enabled.
Please use caution.  Irresponsible use of this console may result in the ship's AI refusing access to this interface.

type 'help' for basic commands.
-------------------------------------------------------------------------'''

        # change up from parent/IC
        self.parent = parent
        localenv = globals()
        localenv['gameroot'] = self.parent
        self._iconsole = customConsoleClass(localsEnv=localenv)

        # line wrapper
        self.linewrap = textwrap.TextWrapper()
        self.linewrap.width = self.linelength

        # calculate window size
        # left   = (self.h_pos) / self.scale
        # right  = (self.h_pos + self.h_size) / self.scale
        # bottom = (self.v_pos) / self.scale
        # top    = (self.v_pos + self.v_size) /self.scale

        # panda3d interface
        self.consoleFrame = DirectFrame(relief=DGG.GROOVE,
                                        frameColor=(200, 200, 200, 0.5),
                                        scale=self.scale,
                                        frameSize=(0, self.h_size / self.scale,
                                                   0,
                                                   self.v_size / self.scale))

        self.windowEvent(base.win)
        fixedWidthFont = None
        try:
            # try to load the defined font
            fixedWidthFont = parent.loader.loadFont(self.font)
        except Exception:
            traceback.print_exc()
            # if font is not valid use default font
            logger.warn('could not load the defined font %s" % str(self.font')
            fixedWidthFont = DGG.getDefaultFont()

        # text lines
        self._visibleLines = list(
            OnscreenText(parent=self.consoleFrame,
                         text="",
                         pos=(1, -i + 3 + self.numlines),
                         align=TextNode.ALeft,
                         mayChange=1,
                         scale=1.0,
                         fg=self.defaultTextColor)
            for i in range(self.numlines))
        map(lambda x: x.setFont(fixedWidthFont), self._visibleLines)

        # text entry line
        self.consoleEntry = DirectEntry(self.consoleFrame,
                                        text="",
                                        command=self.submitTrigger,
                                        width=self.h_size / self.scale - 2,
                                        pos=(1, 0, 1.5),
                                        initialText="",
                                        numLines=1,
                                        focus=1,
                                        entryFont=fixedWidthFont)

        # self.console_output = ConsoleOutput(testme=True)
        self.echo(CONSOLE_MESSAGE)
        self.clipboard = pyperclip
Esempio n. 11
0
    def __init__(self, offset, parent, unit_type, default_hp, hp, default_ap, ap):
            
        self.offset = offset
        self.frame = DirectFrame(   relief = DGG.FLAT
                                  , scale = 1
                                  , frameSize = (-0.5, 0.5, 0, -0.5)
                                  , parent = parent )
        self.frame.setBillboardPointEye()
        self.frame.setLightOff()
        self.frame.setBin("fixed", 40)
        self.frame.setDepthTest(False)
        self.frame.setDepthWrite(False)
        
        fixedWidthFont = loader.loadFont(GUI_FONT)#@UndefinedVariable        
        #fixedWidthFont.setPixelsPerUnit(60)
        #fixedWidthFont.setRenderMode(fontt.RMSolid)
        if not fixedWidthFont.isValid():
            print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
            fixedWidthFont = DGG.getDefaultFont()
        
        self.label = OnscreenText( parent = self.frame
                              , text = ""
                              , pos = (offset.getX(),offset.getZ()+0.1)
                              , align=TextNode.ACenter
                              , mayChange=True
                              , scale=0.1
                              , fg = (1,0,0,1)
                              #, shadow = (0, 0, 0, 1)
                              #, frame = (200,0,0,1) 
                              )
        self.label.setFont( fixedWidthFont )
        #self.label.setLightOff()

        self.all_icons = {}
        self.visible_icons = {}
        self.addIcon("overwatch")
        self.addIcon("set_up")
        
        self.ap_bar = DirectWaitBar(parent = self.frame
                                  , text = ""
                                  , range = default_ap
                                  , value = ap
                                  , pos = (offset.getX()+0.08,0,offset.getZ()-0.27)
                                  , barColor = (0,0,1,1)
                                  , frameColor = (0,0,0.5,0.2)
                                  , scale = (0.3,0.5,0.3))
        
        self.hp_bar = DirectWaitBar(parent = self.frame
                                  , text = ""
                                  , range = default_hp
                                  , value = hp
                                  , pos = (offset.getX()+0.08,0,offset.getZ()-0.2)
                                  , barColor = (0,1,0,1)
                                  , frameColor = (1,0,0,0.9)
                                  , scale = (0.3,0.5,0.3))
        
        self.insignia = OnscreenImage(parent = self.frame
                                            ,image = "unit_" + unit_type + "_big_transparent_32.png"
                                            #,pos = (offset.getX(),0,offset.getZ()+0.14)
                                            , pos = (offset.getX() - 0.31,0,offset.getZ()-0.23)
                                            ,scale = 0.09)
        self.insignia.setTransparency(TransparencyAttrib.MAlpha)
Esempio n. 12
0
    def __init__(self):
        ShowBase.__init__(self)

        self.setBackgroundColor(0, 0, 0)
        # make the font look nice at a big scale
        DGG.getDefaultFont().setPixelsPerUnit(100)

        # Store our mapping, with some sensible defaults.  In a real game, you
        # will want to load these from a configuration file.
        self.mapping = InputMapping()
        self.mapping.mapAxis("Move forward", InputDevice.Axis.left_y)
        self.mapping.mapAxis("Move backward", InputDevice.Axis.left_y)
        self.mapping.mapAxis("Move left", InputDevice.Axis.left_x)
        self.mapping.mapAxis("Move right", InputDevice.Axis.left_x)
        self.mapping.mapButton("Jump", GamepadButton.face_a())
        self.mapping.mapButton("Use", GamepadButton.face_b())
        self.mapping.mapButton("Break", GamepadButton.face_x())
        self.mapping.mapButton("Fix", GamepadButton.face_y())

        # The geometry for our basic buttons
        maps = loader.loadModel("models/button_map")
        self.buttonGeom = (maps.find("**/ready"), maps.find("**/click"),
                           maps.find("**/hover"), maps.find("**/disabled"))

        # Change the default dialog skin.
        DGG.setDefaultDialogGeom("models/dialog.png")

        # create a sample title
        self.textscale = 0.1
        self.title = DirectLabel(scale=self.textscale,
                                 pos=(base.a2dLeft + 0.05, 0.0,
                                      base.a2dTop - (self.textscale + 0.05)),
                                 frameColor=VBase4(0, 0, 0, 0),
                                 text="Button Mapping",
                                 text_align=TextNode.ALeft,
                                 text_fg=VBase4(1, 1, 1, 1),
                                 text_shadow=VBase4(0, 0, 0, 0.75),
                                 text_shadowOffset=Vec2(0.05, 0.05))
        self.title.setTransparency(1)

        # Set up the list of actions that we can map keys to
        # create a frame that will create the scrollbars for us
        # Load the models for the scrollbar elements
        thumbMaps = loader.loadModel("models/thumb_map")
        thumbGeom = (thumbMaps.find("**/thumb_ready"),
                     thumbMaps.find("**/thumb_click"),
                     thumbMaps.find("**/thumb_hover"),
                     thumbMaps.find("**/thumb_disabled"))
        incMaps = loader.loadModel("models/inc_map")
        incGeom = (incMaps.find("**/inc_ready"), incMaps.find("**/inc_click"),
                   incMaps.find("**/inc_hover"),
                   incMaps.find("**/inc_disabled"))
        decMaps = loader.loadModel("models/dec_map")
        decGeom = (decMaps.find("**/dec_ready"), decMaps.find("**/dec_click"),
                   decMaps.find("**/dec_hover"),
                   decMaps.find("**/dec_disabled"))

        # create the scrolled frame that will hold our list
        self.lstActionMap = DirectScrolledFrame(
            # make the frame occupy the whole window
            frameSize=VBase4(base.a2dLeft, base.a2dRight, 0.0, 1.55),
            # make the canvas as big as the frame
            canvasSize=VBase4(base.a2dLeft, base.a2dRight, 0.0, 0.0),
            # set the frames color to white
            frameColor=VBase4(0, 0, 0.25, 0.75),
            pos=(0, 0, -0.8),
            verticalScroll_scrollSize=0.2,
            verticalScroll_frameColor=VBase4(0.02, 0.02, 0.02, 1),
            verticalScroll_thumb_relief=1,
            verticalScroll_thumb_geom=thumbGeom,
            verticalScroll_thumb_pressEffect=False,
            verticalScroll_thumb_frameColor=VBase4(0, 0, 0, 0),
            verticalScroll_incButton_relief=1,
            verticalScroll_incButton_geom=incGeom,
            verticalScroll_incButton_pressEffect=False,
            verticalScroll_incButton_frameColor=VBase4(0, 0, 0, 0),
            verticalScroll_decButton_relief=1,
            verticalScroll_decButton_geom=decGeom,
            verticalScroll_decButton_pressEffect=False,
            verticalScroll_decButton_frameColor=VBase4(0, 0, 0, 0),
        )

        # creat the list items
        idx = 0
        self.listBGEven = base.loader.loadModel("models/list_item_even")
        self.listBGOdd = base.loader.loadModel("models/list_item_odd")
        self.actionLabels = {}
        for action in self.mapping.actions:
            mapped = self.mapping.formatMapping(action)
            item = self.__makeListItem(action, mapped, idx)
            item.reparentTo(self.lstActionMap.getCanvas())
            idx += 1

        # recalculate the canvas size to set scrollbars if necesary
        self.lstActionMap["canvasSize"] = (base.a2dLeft + 0.05,
                                           base.a2dRight - 0.05,
                                           -(len(self.mapping.actions) * 0.1),
                                           0.09)
        self.lstActionMap.setCanvasSize()
Esempio n. 13
0
    def __init__(self):
        """initialise the engine"""
        ShowBase.__init__(self)
        FSM.__init__(self, "FSM-Game")

        #
        # BASIC APPLICATION CONFIGURATIONS
        #
        # disable pandas default camera driver
        self.disableMouse()
        # set background color to black
        self.setBackgroundColor(0, 0, 0)
        # set antialias for the complete sceen to automatic
        self.render.setAntialias(AntialiasAttrib.MAuto)
        # shader generator
        render.setShaderAuto()
        # Enhance font readability
        DGG.getDefaultFont().setPixelsPerUnit(100)

        #
        # CONFIGURATION LOADING
        #
        # load given variables or set defaults
        # check if audio should be muted
        mute = ConfigVariableBool("audio-mute", False).getValue()
        if mute:
            self.disableAllAudio()
        else:
            self.enableAllAudio()
        # check if particles should be enabled
        particles = ConfigVariableBool("particles-enabled", True).getValue()
        if particles:
            self.enableParticles()
        # check if the config file hasn't been created
        if not os.path.exists(prcFile):
            # get the displays width and height
            w = self.pipe.getDisplayWidth()
            h = self.pipe.getDisplayHeight()
            # set window properties
            # clear all properties not previously set
            base.win.clearRejectedProperties()
            # setup new window properties
            props = WindowProperties()
            # Fullscreen
            props.setFullscreen(True)
            # set the window size to the screen resolution
            props.setSize(w, h)
            # request the new properties
            base.win.requestProperties(props)
        elif base.appRunner:
            # As when the application is started as appRunner instance
            # it doesn't respect our loadPrcFile configurations specific
            # to the window, hence we need to manually set them here.
            for dec in range(mainConfig.getNumDeclarations()):
                #TODO: Check for all window specific variables like
                #      fullscreen, screen size, title and window
                #      decoration that you have in your configuration
                #      and set them by your own.
                if mainConfig.getVariableName(dec) == "fullscreen":
                    if not mainConfig.getDeclaration(dec).getBoolWord(0): break
                    # get the displays width and height
                    w = self.pipe.getDisplayWidth()
                    h = self.pipe.getDisplayHeight()
                    # set window properties
                    # clear all properties not previously set
                    base.win.clearRejectedProperties()
                    # setup new window properties
                    props = WindowProperties()
                    # Fullscreen
                    props.setFullscreen(True)
                    # set the window size to the screen resolution
                    props.setSize(w, h)
                    # request the new properties
                    base.win.requestProperties(props)
                    break

        # automatically safe configuration at application exit
        base.exitFunc = self.__writeConfig

        # due to the delayed window resizing and switch to fullscreen
        # we wait some time until everything is set so we can savely
        # proceed with other setups like the menus
        if base.appRunner:
            # this behaviour only happens if run from p3d files and
            # hence the appRunner is enabled
            taskMgr.doMethodLater(0.5, self.postInit,
                "post initialization", extraArgs=[])
        else:
            self.postInit()
Esempio n. 14
0
 def __init__( self, parent ):
   self.parent = parent
   
   # line wrapper
   self.linewrap = textwrap.TextWrapper()
   self.linewrap.width = self.linelength
   
   # calculate window size
   left   = (self.h_pos) / self.scale
   right  = (self.h_pos + self.h_size) / self.scale
   bottom = (self.v_pos) / self.scale
   top    = (self.v_pos + self.v_size) /self.scale
   
   # panda3d interface
   self.consoleFrame = DirectFrame ( relief = DGG.GROOVE
                                   , frameColor = (200, 200, 200, 0.5)
                                   , scale=self.scale
                                   , frameSize = (0, self.h_size / self.scale, 0, self.v_size / self.scale) )
   self.windowEvent( base.win )
   
   # try to load the defined font
   try:
     fixedWidthFont = loader.loadFont(self.font)
   except:
     print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
     fixedWidthFont = DGG.getDefaultFont()
   # if font is not valid use default font
   if not fixedWidthFont.isValid():
     if self.font is None:
       print "pandaInteractiveConsole.py :: could not load the defined font %s" % str(self.font)
     fixedWidthFont = DGG.getDefaultFont()
   
   # text entry line
   self.consoleEntry = DirectEntry ( self.consoleFrame
                                   , text        = ""
                                   , command     = self.onEnterPress
                                   , width       = self.h_size/self.scale - 2
                                   , pos         = (1, 0, 1.5)
                                   , initialText = ""
                                   , numLines    = 1
                                   , focus       = 1
                                   , entryFont   = fixedWidthFont)
   
   # output lines
   self.consoleOutputList = list()
   for i in xrange( self.numlines ):
     label = OnscreenText( parent = self.consoleFrame
                         , text = ""
                         , pos = (1, -i+3+self.numlines)
                         , align=TextNode.ALeft
                         , mayChange=1
                         , scale=1.0
                         , fg = self.defaultTextColor )
     label.setFont( fixedWidthFont )
     self.consoleOutputList.append( label )
   
   # list of the last commands of the user
   self.userCommandList = list()
   self.userCommandListLength = 100
   for i in xrange(self.userCommandListLength):
     self.userCommandList.append('')
   self.userCommandPos = 0
   
   # buffer for data
   self.textBuffer = list()
   self.textBufferLength = 1000
   for i in xrange(self.textBufferLength):
     self.textBuffer.append(['', DEFAULT_COLOR])
   self.textBufferPos = self.textBufferLength-self.numlines
   
   # toggle the window at least once to activate the events
   self.toggleConsole()
   self.toggleConsole()
   
   # call the help-command on start
   self.onEnterPress("help")
Esempio n. 15
0
    def __init__(self):
        """initialise the engine"""
        ShowBase.__init__(self)
        base.notify.info("Version {}".format(versionstring))
        FSM.__init__(self, "FSM-Game")

        #
        # BASIC APPLICATION CONFIGURATIONS
        #
        # disable pandas default camera driver
        self.disableMouse()
        # set antialias for the complete sceen to automatic
        self.render.setAntialias(AntialiasAttrib.MAuto)
        # shader generator
        render.setShaderAuto()
        # Enhance font readability
        DGG.getDefaultFont().setPixelsPerUnit(100)
        # get the displays width and height for later usage
        self.dispWidth = self.pipe.getDisplayWidth()
        self.dispHeight = self.pipe.getDisplayHeight()

        #
        # CONFIGURATION LOADING
        #
        # load given variables or set defaults
        # check if particles should be enabled
        # NOTE: If you use the internal physics engine, this always has
        #       to be enabled!
        particles = ConfigVariableBool("particles-enabled", True).getValue()
        if particles:
            self.enableParticles()

        def setFullscreen():
            """Helper function to set the window fullscreen
            with width and height set to the screens size"""
            # set window properties
            # clear all properties not previously set
            base.win.clearRejectedProperties()
            # setup new window properties
            props = WindowProperties()
            # Fullscreen
            props.setFullscreen(True)
            # set the window size to the screen resolution
            props.setSize(self.dispWidth, self.dispHeight)
            # request the new properties
            base.win.requestProperties(props)
            # Set the config variables so we correctly store the
            # new size and fullscreen setting later
            winSize = ConfigVariableString("win-size")
            winSize.setValue("{} {}".format(self.dispWidth, self.dispHeight))
            fullscreen = ConfigVariableBool("fullscreen")
            fullscreen.setValue(True)
            # Render a frame to make sure the fullscreen is applied
            # before we do anything else
            self.taskMgr.step()
            # make sure to propagate the new aspect ratio properly so
            # the GUI and other things will be scaled appropriately
            aspectRatio = self.dispWidth / self.dispHeight
            self.adjustWindowAspectRatio(aspectRatio)

        # check if the config file hasn't been created
        if not os.path.exists(prcFile):
            setFullscreen()
        # automatically safe configuration at application exit
        #base.exitFunc = self.__writeConfig

        #
        # INITIALIZE GAME CONTENT
        #
        base.cTrav = CollisionTraverser("base collision traverser")
        base.pusher = CollisionHandlerPusher()
        self.menu = Menu()
        self.credits = Credits()
        self.charSelection = CharacterSelection()
        self.levelSelection = LevelSelection()
        self.koScreen = KoScreen()
        self.hud = Hud()
        self.menuMusic = loader.loadMusic("assets/audio/menuMusic.ogg")
        self.menuMusic.setLoop(True)
        self.fightMusic = loader.loadMusic("assets/audio/fightMusic.ogg")
        self.fightMusic.setLoop(True)
        base.audio3d = Audio3DManager(base.sfxManagerList[0], camera)

        #
        # EVENT HANDLING
        #
        # By default we accept the escape key
        self.accept("escape", self.__escape)

        #
        # ENTER GAMES INITIAL FSM STATE
        #
        self.request("Menu")
    def __init__(self, numPlayers, avIdList, votes, directions, namesList, disconnectedList, directionToGo, directionReason, directionTotals, *args, **kwargs):
        opts = {'relief': None,
         'geom': DGG.getDefaultDialogGeom(),
         'geom_color': ToontownGlobals.GlobalDialogColor[:3] + (0.8,),
         'geom_scale': (1.75, 1, 0.75),
         'pos': (0, 0, 0.525)}
        opts.update(kwargs)
        DirectFrame.__init__(self, *args, **opts)
        self.initialiseoptions(VoteResultsPanel)
        listMultiplier = 1
        if TravelGameGlobals.SpoofFour:
            listMultiplier = 4
        self.avIdList = avIdList * listMultiplier
        self.numPlayers = numPlayers * listMultiplier
        self.votes = votes * listMultiplier
        self.directions = directions * listMultiplier
        self.namesList = namesList * listMultiplier
        self.disconnectedList = disconnectedList * listMultiplier
        self.directionToGo = directionToGo
        self.directionReason = directionReason
        self.directionTotals = directionTotals
        self.entryList = []
        self.rowFrame = []
        self.upDownFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(-1))
        self.upLabel = DirectLabel(parent=self.upDownFrame, relief=None, pos=(1.2, 0, 0.0), text=TTLocalizer.TravelGameDirections[0], text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight)
        self.downLabel = DirectLabel(parent=self.upDownFrame, relief=None, pos=(1.43, 0, 0.0), text=TTLocalizer.TravelGameDirections[1], text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight)
        self.totalFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(self.numPlayers))
        self.totalText = DirectLabel(parent=self.totalFrame, relief=None, pos=(1.0, 0, 0.0), text='Total', text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight)
        self.totalVotesUpLabel = DirectLabel(parent=self.totalFrame, relief=None, pos=(1.2, 0, 0.0), text='', text_fg=(0.0, 0.0, 1.0, 1.0), text_scale=0.05, text_align=TextNode.ARight)
        self.totalVotesDownLabel = DirectLabel(parent=self.totalFrame, relief=None, pos=(1.43, 0, 0.0), text='', text_fg=(1.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ARight)
        self.totalVotesLabels = [self.totalVotesUpLabel, self.totalVotesDownLabel]
        self.resultFrame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(5))
        self.resultLabel = DirectLabel(parent=self.resultFrame, text='', text_scale=0.06, pos=(0.7, 0, 0.0), text_align=TextNode.ACenter)
        self.setupResultLabel()
        for index in range(self.numPlayers):
            frame = DirectFrame(parent=self, relief=None, pos=self.getRowPos(index))
            self.rowFrame.append(frame)
            nameLabel = DirectFrame(parent=frame, relief=None, pos=(0.46, 0.0, 0.0), text=self.namesList[index], text_fg=(0.0, 0.0, 0.0, 1.0), text_scale=0.05, text_align=TextNode.ACenter, text_font=DGG.getDefaultFont())
            votesUpLabel = DirectLabel(parent=frame, relief=None, pos=(1.2, 0.0, 0.0), text='', text_fg=(0, 0, 1, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont())
            votesDownLabel = DirectLabel(parent=frame, relief=None, pos=(1.43, 0.0, 0.0), text='', text_fg=(1, 0, 0, 1), text_scale=0.05, text_align=TextNode.ARight, text_font=DGG.getDefaultFont())
            nameLabel.hide()
            self.entryList.append((nameLabel, votesUpLabel, votesDownLabel))

        return
Esempio n. 17
0
    def __init__(self):
        ShowBase.__init__(self)
        FSM.__init__(self, "mainStateMachine")

        # some basic enhancements
        # window background color
        self.setBackgroundColor(0, 0, 0)
        # set antialias for the complete sceen to automatic
        self.render.setAntialias(AntialiasAttrib.MAuto)
        # shader generator
        render.setShaderAuto()
        # Enhance font readability
        DGG.getDefaultFont().setPixelsPerUnit(100)
        # hide the mouse cursor
        hide_cursor()

        #
        # CONFIGURATION LOADING
        #
        # load given variables or set defaults
        # check if audio should be muted
        mute = ConfigVariableBool("audio-mute", False).getValue()
        if mute:
            self.disableAllAudio()
        else:
            self.enableAllAudio()

        base.sfxManagerList[0].setVolume(
            ConfigVariableDouble("audio-volume-sfx", 1.0).getValue())
        base.difficulty = ConfigVariableInt("difficulty", 0).getValue()

        def setFullscreen():
            """Helper function to set the window fullscreen
            with width and height set to the screens size"""
            # get the displays width and height
            w = self.pipe.getDisplayWidth()
            h = self.pipe.getDisplayHeight()
            # set window properties
            # clear all properties not previously set
            base.win.clearRejectedProperties()
            # setup new window properties
            props = WindowProperties()
            # Fullscreen
            props.setFullscreen(True)
            # set the window size to the screen resolution
            props.setSize(w, h)
            # request the new properties
            base.win.requestProperties(props)

        # check if the config file hasn't been created
        if not os.path.exists(prcFile):
            setFullscreen()
        elif base.appRunner:
            # When the application is started as appRunner instance, it
            # doesn't respect our loadPrcFiles configurations specific
            # to the window as the window is already created, hence we
            # need to manually set them here.
            for dec in range(mainConfig.getNumDeclarations()):
                # check if we have the fullscreen variable
                if mainConfig.getVariableName(dec) == "fullscreen":
                    setFullscreen()
        # automatically safe configuration at application exit
        base.exitFunc = self.__writeConfig

        # due to the delayed window resizing and switch to fullscreen
        # we wait some time until everything is set so we can savely
        # proceed with other setups like the menus
        if base.appRunner:
            # this behaviour only happens if run from p3d files and
            # hence the appRunner is enabled
            taskMgr.doMethodLater(0.5,
                                  self.postInit,
                                  "post initialization",
                                  extraArgs=[])
        else:
            self.postInit()
Esempio n. 18
0
    def __init__(self):
        #
        # BASIC APPLICATION CONFIGURATIONS
        #
        # disable pandas default camera driver
        self.disableMouse()
        # set antialias for the complete sceen to automatic
        self.render.setAntialias(AntialiasAttrib.MAuto)
        # shader generator
        #render.setShaderAuto()
        # Enhance font readability
        font = loader.loadFont("assets/fonts/OldaniaADFStd-Regular.otf")
        DGG.setDefaultFont(font)
        DGG.getDefaultFont().setPixelsPerUnit(100)
        # get the displays width and height for later usage
        self.dispWidth = self.pipe.getDisplayWidth()
        self.dispHeight = self.pipe.getDisplayHeight()

        base.serverHost = ConfigVariableString("server-host", "127.0.0.1:4400")

        #
        # CONFIGURATION LOADING
        #
        # load given variables or set defaults
        # check if particles should be enabled
        # NOTE: If you use the internal physics engine, this always has
        #       to be enabled!
        particles = ConfigVariableBool("particles-enabled", True).getValue()
        if particles:
            self.enableParticles()

        def setFullscreen():
            """Helper function to set the window fullscreen
            with width and height set to the screens size"""
            # set window properties
            # clear all properties not previously set
            base.win.clearRejectedProperties()
            # setup new window properties
            props = WindowProperties()
            # Fullscreen
            props.setFullscreen(True)
            # set the window size to the screen resolution
            props.setSize(self.dispWidth, self.dispHeight)
            # request the new properties
            base.win.requestProperties(props)
            # Set the config variables so we correctly store the
            # new size and fullscreen setting later
            winSize = ConfigVariableString("win-size")
            winSize.setValue("{} {}".format(self.dispWidth, self.dispHeight))
            fullscreen = ConfigVariableBool("fullscreen")
            fullscreen.setValue(True)
            # Render a frame to make sure the fullscreen is applied
            # before we do anything else
            self.taskMgr.step()
            # make sure to propagate the new aspect ratio properly so
            # the GUI and other things will be scaled appropriately
            aspectRatio = self.dispWidth / self.dispHeight
            self.adjustWindowAspectRatio(aspectRatio)

        # check if the config file hasn't been created
        if not os.path.exists(prcFile):
            setFullscreen()

        # automatically safe configuration at application exit
        base.exitFunc = self.writeConfig
Esempio n. 19
0
    def __init__(self):
        ShowBase.__init__(self)

        self.setBackgroundColor(0, 0, 0)
        # make the font look nice at a big scale
        DGG.getDefaultFont().setPixelsPerUnit(100)

        # Store our mapping, with some sensible defaults.  In a real game, you
        # will want to load these from a configuration file.
        self.mapping = InputMapping()
        self.mapping.mapAxis("Move forward", InputDevice.Axis.left_y)
        self.mapping.mapAxis("Move backward", InputDevice.Axis.left_y)
        self.mapping.mapAxis("Move left", InputDevice.Axis.left_x)
        self.mapping.mapAxis("Move right", InputDevice.Axis.left_x)
        self.mapping.mapButton("Jump", GamepadButton.face_a())
        self.mapping.mapButton("Use", GamepadButton.face_b())
        self.mapping.mapButton("Break", GamepadButton.face_x())
        self.mapping.mapButton("Fix", GamepadButton.face_y())

        # The geometry for our basic buttons
        maps = loader.loadModel("models/button_map")
        self.buttonGeom = (
            maps.find("**/ready"),
            maps.find("**/click"),
            maps.find("**/hover"),
            maps.find("**/disabled"))

        # Change the default dialog skin.
        DGG.setDefaultDialogGeom("models/dialog.png")

        # create a sample title
        self.textscale = 0.1
        self.title = DirectLabel(
            scale=self.textscale,
            pos=(base.a2dLeft + 0.05, 0.0, base.a2dTop - (self.textscale + 0.05)),
            frameColor=VBase4(0, 0, 0, 0),
            text="Button Mapping",
            text_align=TextNode.ALeft,
            text_fg=VBase4(1, 1, 1, 1),
            text_shadow=VBase4(0, 0, 0, 0.75),
            text_shadowOffset=Vec2(0.05, 0.05))
        self.title.setTransparency(1)

        # Set up the list of actions that we can map keys to
        # create a frame that will create the scrollbars for us
        # Load the models for the scrollbar elements
        thumbMaps = loader.loadModel("models/thumb_map")
        thumbGeom = (
            thumbMaps.find("**/thumb_ready"),
            thumbMaps.find("**/thumb_click"),
            thumbMaps.find("**/thumb_hover"),
            thumbMaps.find("**/thumb_disabled"))
        incMaps = loader.loadModel("models/inc_map")
        incGeom = (
            incMaps.find("**/inc_ready"),
            incMaps.find("**/inc_click"),
            incMaps.find("**/inc_hover"),
            incMaps.find("**/inc_disabled"))
        decMaps = loader.loadModel("models/dec_map")
        decGeom = (
            decMaps.find("**/dec_ready"),
            decMaps.find("**/dec_click"),
            decMaps.find("**/dec_hover"),
            decMaps.find("**/dec_disabled"))

        # create the scrolled frame that will hold our list
        self.lstActionMap = DirectScrolledFrame(
            # make the frame occupy the whole window
            frameSize=VBase4(base.a2dLeft, base.a2dRight, 0.0, 1.55),
            # make the canvas as big as the frame
            canvasSize=VBase4(base.a2dLeft, base.a2dRight, 0.0, 0.0),
            # set the frames color to white
            frameColor=VBase4(0, 0, 0.25, 0.75),
            pos=(0, 0, -0.8),

            verticalScroll_scrollSize=0.2,
            verticalScroll_frameColor=VBase4(0.02, 0.02, 0.02, 1),

            verticalScroll_thumb_relief=1,
            verticalScroll_thumb_geom=thumbGeom,
            verticalScroll_thumb_pressEffect=False,
            verticalScroll_thumb_frameColor=VBase4(0, 0, 0, 0),

            verticalScroll_incButton_relief=1,
            verticalScroll_incButton_geom=incGeom,
            verticalScroll_incButton_pressEffect=False,
            verticalScroll_incButton_frameColor=VBase4(0, 0, 0, 0),

            verticalScroll_decButton_relief=1,
            verticalScroll_decButton_geom=decGeom,
            verticalScroll_decButton_pressEffect=False,
            verticalScroll_decButton_frameColor=VBase4(0, 0, 0, 0),)

        # creat the list items
        idx = 0
        self.listBGEven = base.loader.loadModel("models/list_item_even")
        self.listBGOdd = base.loader.loadModel("models/list_item_odd")
        self.actionLabels = {}
        for action in self.mapping.actions:
            mapped = self.mapping.formatMapping(action)
            item = self.__makeListItem(action, mapped, idx)
            item.reparentTo(self.lstActionMap.getCanvas())
            idx += 1

        # recalculate the canvas size to set scrollbars if necesary
        self.lstActionMap["canvasSize"] = (
            base.a2dLeft+0.05, base.a2dRight-0.05,
            -(len(self.mapping.actions)*0.1), 0.09)
        self.lstActionMap.setCanvasSize()