Ejemplo n.º 1
0
def createButton(text, btnGeom, xPos, yPos, args):
    buttonSize = (-2, 2, 1, -1)
    btn = DirectButton(
        scale=0.25,
        geom=btnGeom,
        # some temp text
        text=text,
        text_scale=0.4,
        # set the alignment to right
        text_align=TextNode.ACenter,
        # set the text color to black
        text_fg=(1, 1, 1, 1),
        # set the buttons images
        relief=1,
        frameColor=(0,0,0,0),
        frameSize=buttonSize,
        pressEffect=False,
        pos=(xPos, 0, yPos),
        command=base.messenger.send,
        extraArgs=args,
        rolloverSound=None,
        clickSound=None)
    # check if the text is to long and resize the frame if necessary
    if btn.getBounds()[0] < buttonSize[0] or \
            btn.getBounds()[1] > buttonSize[1]:
        btn["frameSize"] = (
            btn.getBounds()[0]-0.2, btn.getBounds()[1]+0.2,
            buttonSize[2], buttonSize[3])
        btn.resetFrameSize()
    btn.setTransparency(True)
    return btn
Ejemplo n.º 2
0
    def load(self):
        BookPage.load(self)
        # Let's load up the clouds.
        for pos, scale, hpr in self.cloudPos:
            cloud = loader.loadModel('phase_3.5/models/gui/cloud.bam')
            cloud.reparentTo(self)
            cloud.setPos(pos)
            cloud.setScale(scale)
            cloud.setHpr(hpr)
            self.clouds.append(cloud)

        for pos, scale, hpr, hood in self.hoodClouds:
            if not base.localAvatar.hasDiscoveredHood(
                    ZoneUtil.getZoneId(hood)):
                cloud = loader.loadModel('phase_3.5/models/gui/cloud.bam')
                cloud.reparentTo(self)
                cloud.setPos(pos)
                cloud.setScale(scale)
                cloud.setHpr(hpr)
                self.clouds.append(cloud)

        for pos, name in self.labelData:
            if base.localAvatar.hasDiscoveredHood(ZoneUtil.getZoneId(name)):
                text = name
                if base.localAvatar.hasTeleportAccess(
                        ZoneUtil.getZoneId(name)):
                    text = 'Go To\n' + text
                label = DirectButton(
                    parent=self,
                    relief=None,
                    pos=pos,
                    pad=(0.2, 0.16),
                    text=('', text, text, ''),
                    text_bg=Vec4(1, 1, 1, 0.4),
                    text_scale=0.055,
                    text_wordwrap=8,
                    rolloverSound=CIGlobals.getRolloverSound(),
                    clickSound=None,
                    pressEffect=0,
                    sortOrder=1,
                    text_font=CIGlobals.getToonFont())
                if base.localAvatar.hasTeleportAccess(
                        ZoneUtil.getZoneId(name)):
                    label['command'] = self.book.finished
                    label['extraArgs'] = [ZoneUtil.getZoneId(name)]
                label.resetFrameSize()
                self.labels.append(label)

        currHoodName = base.cr.playGame.hood.id
        currLocation = ''
        if base.localAvatar.zoneId == ZoneUtil.MinigameAreaId or base.localAvatar.getBattleZone(
        ) is not None:
            currLocation = ''
        elif ZoneUtil.getWhereName(base.localAvatar.zoneId) == 'playground':
            currLocation = 'Playground'
        elif ZoneUtil.getWhereName(
                base.localAvatar.zoneId) in ['street', 'interior']:
            currLocation = ZoneUtil.BranchZone2StreetName[
                ZoneUtil.getBranchZone(base.localAvatar.zoneId)]
        self.infoLabel = DirectLabel(relief=None,
                                     text='You are in: {0}\n{1}'.format(
                                         currHoodName, currLocation),
                                     scale=0.06,
                                     pos=(-0.4, 0, -0.74),
                                     parent=self,
                                     text_align=TextNode.ACenter)

        if currHoodName in [ZoneUtil.MinigameArea, ZoneUtil.BattleTTC]:
            currHoodName = base.cr.playGame.lastHood
        btpText = 'Back to Playground'
        btpEA = [ZoneUtil.getZoneId(currHoodName)]
        self.BTPButton = DirectButton(relief=None,
                                      text=btpText,
                                      geom=CIGlobals.getDefaultBtnGeom(),
                                      text_pos=(0, -0.018),
                                      geom_scale=(1.3, 1.11, 1.11),
                                      text_scale=0.06,
                                      parent=self,
                                      text_font=CIGlobals.getToonFont(),
                                      pos=(0.25, 0, -0.75),
                                      command=self.book.finished,
                                      extraArgs=btpEA,
                                      scale=0.7)

        icons = loader.loadModel('phase_3.5/models/gui/sos_textures.bam')
        self.icon = icons.find('**/teleportIcon')
        icons.detachNode()