Пример #1
0
 def __createToonModels(self, avId):
     toon = self.getAvatar(avId)
     self.toonScaleDict[avId] = toon.getScale()
     toon.useLOD(1000)
     toonParent = render.attachNewNode('toonOriginChange')
     toon.reparentTo(toonParent)
     toon.setPosHpr(0, 0, -(toon.getHeight() / 2.0), 0, 0, 0)
     self.toonModelDict[avId] = toonParent
     head = ToonHead.ToonHead()
     head.setupHead(self.getAvatar(avId).style)
     head.reparentTo(hidden)
     self.toonHeadDict[avId] = head
     toon = self.getAvatar(avId)
     tag = NametagFloat3d()
     tag.hideNametag()
     tag.update()
     tag.setBillboardOffset(0)
     tag.setAvatar(head)
     toon.nametag.add(tag)
     tagPath = head.attachNewNode(tag)
     tagPath.setPos(0, 0, 1)
     head.tag = tag
     self.__loadToonInCannon(avId)
     self.getAvatar(avId).dropShadow.hide()
     self.dropShadowDict[avId] = self.dropShadow.copyTo(hidden)
Пример #2
0
    def __init__(self, dna, **kw):
        self.dna = dna

        # Create an avatar head for the panel
        head = hidden.attachNewNode('head', 20)
        self.headModel = ToonHead.ToonHead()
        self.headModel.setupHead(self.dna, forGui = 1)
        self.headModel.fitAndCenterHead(1.0, forGui = 1)
        self.headModel.reparentTo(head)
        self.headModel.setName('headModel')

        # Start blinking, but don't look around--the avatar's looking
        # at you!
        self.headModel.startBlink()

        optiondefs = (
            ('dialogName',    'ToonHeadDialog',        None),
            ('style',         TTDialog.NoButtons,None),
            ('geom',          head,                    None),
            ('geom_scale',    0.35,                    None),
            ('geom_pos',      (-0.25,0,0),             None),
            ('text_wordwrap', 9,                       None),
            ('fadeScreen',    0,                       None),
            )
        # Merge keyword options with default options
        self.defineoptions(kw, optiondefs)

        # initialize our base class.  Need to pass style
        TTDialog.TTDialog.__init__(self, style = self['style'])

        self.initialiseoptions(ToonHeadDialog)

        # Replace copy of head in dialog with blinking version
        self.postInitialiseFuncList.append(self.replaceHead)
 def _createWelcomePage(self):
     self.nametagGroup = None
     page = DirectFrame(self.frame)
     page.setName('PartyPlannerWelcomePage')
     self.welcomeTitleLabel = DirectLabel(
         parent=page,
         relief=None,
         text=TTLocalizer.PartyPlannerWelcomeTitle,
         pos=self.gui.find('**/title_locator').getPos(),
         scale=self.titleScale)
     self.partyPlannerHead = ToonHead.ToonHead()
     partyPlannerStyle = base.cr.partyManager.getPartyPlannerStyle()
     self.partyPlannerHead.setupHead(partyPlannerStyle, forGui=True)
     self.partyPlannerHead.setPos(
         self.gui.find('**/step_01_partymanPete_locator').getPos())
     animal = partyPlannerStyle.getAnimal()
     if animal == 'cat' or animal == 'pig':
         headScale = 0.4
     elif animal == 'dog' or animal == 'bear':
         headScale = 0.45
     elif animal == 'rabbit':
         headScale = 0.35
     else:
         headScale = 0.3
     self.partyPlannerHead.setScale(headScale)
     self.partyPlannerHead.setH(180.0)
     self.partyPlannerHead.reparentTo(page)
     self.__createNametag(page)
     return page
Пример #4
0
 def setAv(self, av):
     self.head = self.stateNodePath[0].attachNewNode('head', 20)
     self.head.setPosHprScale(0, -0.5, -0.09, 180.0, 0.0, 0.0, 0.2, 0.2,
                              0.2)
     self.headModel = ToonHead.ToonHead()
     self.headModel.setupHead(av.style, forGui=1)
     self.headModel.reparentTo(self.head)
Пример #5
0
 def buildFrame(self, name, dnaTuple):
     frame = loader.loadModel('phase_3.5/models/modules/trophy_frame')
     dna = ToonDNA.ToonDNA()
     apply(dna.newToonFromProperties, dnaTuple)
     head = ToonHead.ToonHead()
     head.setupHead(dna)
     head.setPosHprScale(0, -0.05, -0.05, 180, 0, 0, 0.55, 0.02, 0.55)
     if dna.head[0] == 'r':
         head.setZ(-0.15)
     elif dna.head[0] == 'h':
         head.setZ(0.05)
     elif dna.head[0] == 'm':
         head.setScale(0.45, 0.02, 0.45)
     head.reparentTo(frame)
     nameText = TextNode('trophy')
     nameText.setFont(ToontownGlobals.getToonFont())
     nameText.setAlign(TextNode.ACenter)
     nameText.setTextColor(0, 0, 0, 1)
     nameText.setWordwrap(5.36 * FrameScale)
     nameText.setText(name)
     namePath = frame.attachNewNode(nameText.generate())
     namePath.setPos(0, -0.03, -.6)
     namePath.setScale(0.186 / FrameScale)
     frame.setScale(FrameScale, 1.0, FrameScale)
     return frame
 def getPicture(self, avatar):
     from toontown.toon import Toon
     from toontown.toon import ToonHead
     from toontown.toon import TTEmote
     from otp.avatar import Emote
     self.hasPicture = True
     if self.emoteIndex in Emote.globalEmote.getHeadEmotes():
         toon = ToonHead.ToonHead()
         toon.setupHead(avatar.style, forGui=1)
     else:
         toon = Toon.Toon()
         toon.setDNA(avatar.style)
         toon.loop('neutral')
     toon.setH(180)
     model, ival = self.makeFrameModel(toon, 0)
     track, duration = Emote.globalEmote.doEmote(toon,
                                                 self.emoteIndex,
                                                 volume=self.volume)
     if duration == None:
         duration = 0
     name = 'emote-item-%s' % self.sequenceNumber
     CatalogEmoteItem.sequenceNumber += 1
     if track != None:
         track = Sequence(Sequence(track, duration=0),
                          Wait(duration + 2),
                          name=name)
     else:
         track = Sequence(Func(Emote.globalEmote.doEmote, toon,
                               self.emoteIndex),
                          Wait(duration + 4),
                          name=name)
     self.pictureToon = toon
     return (model, track)
Пример #7
0
 def __init__(self, av, purchaseModels):
     DirectFrame.__init__(self,
                          relief=None,
                          image=purchaseModels.find('**/Char_Pnl'))
     self.initialiseoptions(PurchaseHeadFrame)
     self.statusLabel = DirectLabel(parent=self,
                                    relief=None,
                                    text='',
                                    text_scale=TTLocalizer.PstatusLabel,
                                    text_wordwrap=7.5,
                                    text_fg=(0.05, 0.14, 0.4, 1),
                                    text_pos=(0.1, 0, 0))
     self.av = av
     self.avKeep = DelayDelete.DelayDelete(av, 'PurchaseHeadFrame.av')
     self.accept('clientCleanup', self._handleClientCleanup)
     self.head = self.stateNodePath[0].attachNewNode('head', 20)
     self.head.setPosHprScale(-0.22, 10.0, -0.1, 180.0, 0.0, 0.0, 0.1, 0.1,
                              0.1)
     self.headModel = ToonHead.ToonHead()
     self.headModel.setupHead(self.av.style, forGui=1)
     self.headModel.reparentTo(self.head)
     self.tag2Node = NametagFloat2d()
     self.tag2Node.setContents(Nametag.CName)
     self.av.nametag.addNametag(self.tag2Node)
     self.tag2 = self.attachNewNode(self.tag2Node.upcastToPandaNode())
     self.tag2.setPosHprScale(-0.22, 10.0, 0.12, 0, 0, 0, 0.046, 0.046,
                              0.046)
     self.tag1Node = NametagFloat2d()
     self.tag1Node.setContents(Nametag.CSpeech | Nametag.CThought)
     self.av.nametag.addNametag(self.tag1Node)
     self.tag1 = self.attachNewNode(self.tag1Node.upcastToPandaNode())
     self.tag1.setPosHprScale(-0.15, 0, -0.1, 0, 0, 0, 0.046, 0.046, 0.046)
     self.hide()
     return
Пример #8
0
 def createNPCToonHead(self, NPCID, dimension=0.5):
     NPCInfo = NPCToons.NPCToonDict[NPCID]
     dnaList = NPCInfo[2]
     gender = NPCInfo[3]
     if dnaList == 'r':
         dnaList = NPCToons.getRandomDNA(NPCID, gender)
     dna = ToonDNA.ToonDNA()
     dna.newToonFromProperties(*dnaList)
     head = ToonHead.ToonHead()
     head.setupHead(dna, forGui=1)
     self.fitGeometry(head, fFlip=1, dimension=dimension)
     return head
Пример #9
0
 def createNpcToonHead(self, toNpcId):
     npcInfo = NPCToons.NPCToonDict[toNpcId]
     dnaList = npcInfo[2]
     gender = npcInfo[3]
     if dnaList == 'r':
         dnaList = NPCToons.getRandomDNA(toNpcId, gender)
     dna = ToonDNA.ToonDNA()
     dna.newToonFromProperties(*dnaList)
     head = ToonHead.ToonHead()
     head.setupHead(dna, forGui=1)
     self.fitGeometry(head, fFlip=1)
     return head
Пример #10
0
 def __createToonHead(self, toon):
     self.toonHead = ToonHead.ToonHead()
     self.toonHead.setupHead(toon.style)
     self.toonHead.reparentTo(hidden)
     tag = NametagFloat3d()
     tag.setContents(Nametag.CSpeech | Nametag.CThought)
     tag.setBillboardOffset(0)
     tag.setAvatar(self.toonHead)
     toon.nametag.addNametag(tag)
     tagPath = self.toonHead.attachNewNode(tag.upcastToPandaNode())
     tagPath.setPos(0, 0, 1)
     self.toonHead.tag = tag
 def __createToonModels(self):
     self.model_Created = 1
     self.jurorToon = NPCToons.createLocalNPC(ToontownGlobals.LawbotBossBaseJurorNpcId + self.index)
     self.toonScale = self.jurorToon.getScale()
     jurorToonParent = render.attachNewNode('toonOriginChange')
     self.jurorToon.wrtReparentTo(jurorToonParent)
     self.jurorToon.setPosHpr(0, 0, -(self.jurorToon.getHeight() / 2.0), 0, -90, 0)
     self.toonModel = jurorToonParent
     self.toonHead = ToonHead.ToonHead()
     self.toonHead.setupHead(self.jurorToon.style)
     self.toonHead.reparentTo(hidden)
     self.__loadToonInCannon()
Пример #12
0
    def __init__(self, av, purchaseModels):
        DirectFrame.__init__(
            self,
            relief=None,
            image=purchaseModels.find("**/Char_Pnl"),
        )
        self.initialiseoptions(PurchaseHeadFrame)

        self.statusLabel = DirectLabel(
            parent=self,
            relief=None,
            text="",
            text_scale=TTLocalizer.PstatusLabel,
            text_wordwrap=7.5,
            text_fg=(0.05, 0.14, 0.4, 1),
            text_pos=(0.1, 0, 0),
        )

        self.av = av
        # Do not allow the avatar to be deleted now
        # because we made a chat bubble and nametag on him
        # and try to delete them when we exit
        self.avKeep = DelayDelete.DelayDelete(av, 'PurchaseHeadFrame.av')
        self.accept('clientCleanup', self._handleClientCleanup)

        self.head = self.stateNodePath[0].attachNewNode('head', 20)
        self.head.setPosHprScale(-0.22, 10.0, -0.1, 180., 0., 0., 0.1, 0.1,
                                 0.1)

        self.headModel = ToonHead.ToonHead()
        self.headModel.setupHead(self.av.style, forGui=1)
        self.headModel.reparentTo(self.head)

        # Make a nametag to display just the name.
        self.tag2Node = NametagFloat2d()
        self.tag2Node.setContents(Nametag.CName)
        self.av.nametag.addNametag(self.tag2Node)

        self.tag2 = self.attachNewNode(self.tag2Node.upcastToPandaNode())
        self.tag2.setPosHprScale(-0.22, 10.0, 0.12, 0, 0, 0, 0.046, 0.046,
                                 0.046)

        # And another nametag for the chat balloon.  This gets
        # parented in after the above nametag, so the chat balloon
        # will be on top of the name if it needs to be.
        self.tag1Node = NametagFloat2d()
        self.tag1Node.setContents(Nametag.CSpeech | Nametag.CThought)
        self.av.nametag.addNametag(self.tag1Node)

        self.tag1 = self.attachNewNode(self.tag1Node.upcastToPandaNode())
        self.tag1.setPosHprScale(-0.15, 0, -0.1, 0, 0, 0, 0.046, 0.046, 0.046)

        self.hide()
Пример #13
0
 def createNpcToonHead(self, toNpcId, questId=0):
     npcInfo = NPCToons.NPCToonDict[toNpcId]
     dnaList = npcInfo[2]
     if dnaList == 'r':
         seed = base.localAvatar.doId + questId
         gender = 'm' if seed % 2 == 0 else 'f'
         dnaList = NPCToons.getRandomDNA(seed, gender)
     dna = ToonDNA.ToonDNA()
     dna.newToonFromProperties(*dnaList)
     head = ToonHead.ToonHead()
     head.setupHead(dna, forGui=1)
     self.fitGeometry(head, fFlip=1)
     return head
Пример #14
0
 def __createToonHead(self, toon):
     self.toonHead = ToonHead.ToonHead()
     self.toonHead.setupHead(toon.style)
     self.toonHead.reparentTo(hidden)
     tag = NametagFloat3d()
     tag.hideNametag()
     tag.update()
     tag.setBillboardOffset(0)
     tag.setAvatar(self.toonHead)
     toon.nametag.add(tag)
     tagPath = self.toonHead.attachNewNode(tag)
     tagPath.setPos(0, 0, 1)
     self.toonHead.tag = tag
Пример #15
0
 def createNPCToonHead(self, NPCID, dimension=0.5):
     NPCInfo = NPCToons.NPCToonDict[NPCID]
     dnaList = NPCInfo[2]
     gender = NPCInfo[3]
     if dnaList == 'r':
         dnaList = NPCToons.getRandomDNA(NPCID, gender)
     dna = ToonDNA.ToonDNA()
     dna.newToonFromProperties(*dnaList)
     head = ToonHead.ToonHead()
     head.setupHead(dna, forGui=1)
     self.fitGeometry(head, fFlip=1, dimension=dimension)
     '''if NPCID == 91917:
         LaughingManGlobals.addHeadEffect(head, book=True)'''
     return head
Пример #16
0
 def __init__(self, dna, **kw):
     self.dna = dna
     head = hidden.attachNewNode('head', 20)
     self.headModel = ToonHead.ToonHead()
     self.headModel.setupHead(self.dna, forGui = 1)
     self.headModel.fitAndCenterHead(1.0, forGui = 1)
     self.headModel.reparentTo(head)
     self.headModel.setName('headModel')
     self.headModel.startBlink()
     optiondefs = (('dialogName', 'ToonHeadDialog', None), ('style', TTDialog.NoButtons, None), ('geom', head, None), ('geom_scale', 0.34999999999999998, None), ('geom_pos', (-0.25, 0, 0), None), ('text_wordwrap', 9, None), ('fadeScreen', 0, None))
     self.defineoptions(kw, optiondefs)
     TTDialog.TTDialog.__init__(self, style = self['style'])
     self.initialiseoptions(ToonHeadDialog)
     self.postInitialiseFuncList.append(self.replaceHead)
Пример #17
0
    def getPicture(self, avatar):
        # Returns a (DirectWidget, Interval) pair to draw and animate a
        # little representation of the item, or (None, None) if the
        # item has no representation.  This method is only called on
        # the client.

        # Don't import this at the top of the file, since this code
        # must run on the AI.
        from toontown.toon import Toon
        from toontown.toon import ToonHead
        from toontown.toon import TTEmote
        from otp.avatar import Emote

        assert (not self.hasPicture)
        self.hasPicture = True

        if self.emoteIndex in Emote.globalEmote.getHeadEmotes():
            toon = ToonHead.ToonHead()
            toon.setupHead(avatar.style, forGui=1)
        else:
            toon = Toon.Toon()
            toon.setDNA(avatar.style)
            toon.loop('neutral')

        toon.setH(180)
        model, ival = self.makeFrameModel(toon, 0)

        # Discard the ival from makeFrameModel, since we don't want to
        # spin.

        track, duration = Emote.globalEmote.doEmote(toon,
                                                    self.emoteIndex,
                                                    volume=self.volume)

        if duration == None:
            duration = 0
        name = "emote-item-%s" % (self.sequenceNumber)
        CatalogEmoteItem.sequenceNumber += 1
        if track != None:
            track = Sequence(Sequence(track, duration=0),
                             Wait(duration + 2),
                             name=name)
        else:
            track = Sequence(Func(Emote.globalEmote.doEmote, toon,
                                  self.emoteIndex),
                             Wait(duration + 4),
                             name=name)
        self.pictureToon = toon
        return (model, track)
Пример #18
0
 def setupButtons(self, av=None, position=0):
     deleteButton = None
     button = DirectButton(text=('', '', ''),
                           text_scale=TTLocalizer.ACplayThisToon,
                           text_fg=(1, 0.9, 0.1, 1),
                           relief=None,
                           text_font=ToontownGlobals.getSignFont(),
                           command=self.selectToon,
                           extraArgs=[position],
                           image=self.buttonBgs[position])
     button.reparentTo(self.patNode2d)
     button.setPos(BUTTONPOSITIONS[position])
     button.setScale(.5)
     # Delete Toon button
     trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui.bam')
     if av:
         self.hasToons[position] = True
         headmod = ToonHead.ToonHead()
         headmod.setupHead(ToonDNA.ToonDNA(av.dna), forGui=1)
         headmod.setPosHprScale(0, -0.5, -0.1, 180, 0, 0, 0.24, 0.24, 0.24)
         headmod.startBlink()
         headmod.startLookAround()
         button['text_pos'] = (0, 0, 2)
         headmod.reparentTo(button)
         deleteButton = DirectButton(
             parent=button,
             geom=(trashcanGui.find('**/TrashCan_CLSD'),
                   trashcanGui.find('**/TrashCan_OPEN'),
                   trashcanGui.find('**/TrashCan_RLVR')),
             text=('', TTLocalizer.AvatarChoiceDelete,
                   TTLocalizer.AvatarChoiceDelete, ''),
             text_fg=(1, 1, 1, 1),
             text_shadow=(0, 0, 0, 1),
             text_scale=0.15,
             text_pos=(0, -0.1),
             relief=None,
             scale=.5,
             command=self.__handleDelete,
             extraArgs=[position],
             pos=(.2, 0, -.2))
     else:
         button['text'] = (TTLocalizer.AvatarChoiceMakeAToon, )
         self.hasToons[position] = False
     self.buttonList.append(button)
     if deleteButton:
         self.deleteButtons.append(deleteButton)
Пример #19
0
    def setupButtons(self, av=None, position=0):
        button = DirectButton(text=' ',
                              relief=None,
                              command=self.selectToon,
                              extraArgs=[position],
                              image=self.buttonBgs[position])
        button.reparentTo(self.patNode2d)
        button.setPos(BUTTONPOSITIONS[position])
        button.setScale(.5)

        if av:
            head = hidden.attachNewNode('head')
            head.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24, 0.24)
            head.reparentTo(button)
            headmod = ToonHead.ToonHead()
            headmod.setupHead(ToonDNA.ToonDNA(av.dna), forGui=1)
            headmod.reparentTo(head)
        self.buttonList.append(button)
 def __init__(self,
              av,
              color=ToontownGlobals.GlobalDialogColor,
              g=DGG.getDefaultDialogGeom()):
     DirectFrame.__init__(self,
                          relief=None,
                          geom=g,
                          geom_color=color,
                          geom_scale=(1, 1, 0.5),
                          pos=(0, 0, 0))
     self.initialiseoptions(ToonHeadFrame)
     self.av = av
     self.avKeep = DelayDelete.DelayDelete(av, 'ToonHeadFrame.avKeep')
     self.head = self.stateNodePath[0].attachNewNode('head', 20)
     self.head.setPosHprScale(-0.27, 10.0, -0.09, 180.0, 0.0, 0.0, 0.2, 0.2,
                              0.2)
     self.headModel = ToonHead.ToonHead()
     self.headModel.startBlink()
     self.headModel.setupHead(self.av.style, forGui=1)
     self.headModel.reparentTo(self.head)
     self.tag1Node = NametagFloat2d()
     self.tag1Node.hideNametag()
     self.tag1Node.showThought()
     self.av.nametag.add(self.tag1Node)
     self.tag1 = self.attachNewNode(self.tag1Node)
     self.tag1.setPosHprScale(-0.16, 0, -0.09, 0, 0, 0, 0.055, 0.055, 0.055)
     self.tag2Node = NametagFloat2d()
     self.tag2Node.hideChat()
     self.av.nametag.add(self.tag2Node)
     self.tag2 = self.attachNewNode(self.tag2Node)
     self.tag2.setPosHprScale(-0.27, 10.0, 0.16, 0, 0, 0, 0.05, 0.05, 0.05)
     self.extraData = DirectLabel(parent=self,
                                  relief=None,
                                  pos=(0.0, 0.0, 0.06),
                                  scale=1.0,
                                  text='',
                                  text0_fg=(0.3, 0.2, 1, 1),
                                  text_scale=(0.14, 0.06),
                                  text_pos=(0, -0.01))
     self.extraData.hide()
Пример #21
0
 def begin(self, range, label, gui, tipCategory, zoneId):
     self.waitBar['range'] = range
     self.tip['text'] = self.getTip(tipCategory)
     self.title['text'] = label
     self.__count = 0
     self.__expectedCount = range
     if gui:
         base.setBackgroundColor(Vec4(0.952, 0.796, 0.317, 1))
         if base.localAvatarStyle:
             from toontown.toon import ToonHead
             self.toon['text'] = base.localAvatarName
             self.starring['text'] = TTLocalizer.StarringIn
             self.head = ToonHead.ToonHead()
             self.head.setupHead(base.localAvatarStyle, forGui=1)
             self.head.reparentTo(self.gui)
             self.head.fitAndCenterHead(1, forGui=1)
         self.gui.reparentTo(aspect2dp, NO_FADE_SORT_INDEX)
     else:
         self.waitBar.reparentTo(aspect2dp, NO_FADE_SORT_INDEX)
         self.title.reparentTo(aspect2dp, NO_FADE_SORT_INDEX)
         self.gui.reparentTo(hidden)
     self.waitBar.update(self.__count)
 def _DistributedCannon__createToonModels(self):
     self.model_Created = 1
     toon = self.av
     self.toonScale = toon.getScale()
     toon.useLOD(1000)
     toonParent = render.attachNewNode('toonOriginChange')
     toon.wrtReparentTo(toonParent)
     toon.setPosHpr(0, 0, -(toon.getHeight() / 2.0), 0, -90, 0)
     self.toonModel = toonParent
     self.toonHead = ToonHead.ToonHead()
     self.toonHead.setupHead(self.av.style)
     self.toonHead.reparentTo(hidden)
     tag = NametagFloat3d()
     tag.setContents(Nametag.CSpeech | Nametag.CThought)
     tag.setBillboardOffset(0)
     tag.setAvatar(self.toonHead)
     toon.nametag.addNametag(tag)
     tagPath = self.toonHead.attachNewNode(tag.upcastToPandaNode())
     tagPath.setPos(0, 0, 1)
     self.toonHead.tag = tag
     self._DistributedCannon__loadToonInCannon()
     self.av.dropShadow.hide()
     self.dropShadow = self.shadowNode.copyTo(hidden)
Пример #23
0
    def buildFrame(self, name, dnaTuple):
        assert self.notify.debugStateCall(self)
        frame = loader.loadModel('phase_3.5/models/modules/trophy_frame')

        dna = ToonDNA.ToonDNA()
        dna.newToonFromProperties(*dnaTuple)

        head = ToonHead.ToonHead()
        head.setupHead(dna)

        head.setPosHprScale(0, -0.05, -0.05, 180, 0, 0, 0.55, 0.02, 0.55)
        if dna.head[0] == 'r':
            # Give rabbits a bit more space above the head.
            head.setZ(-0.15)
        elif dna.head[0] == 'h':
            # Give horses a bit more space below the head.
            head.setZ(0.05)
        elif dna.head[0] == 'm':
            # Mice should be a bit smaller to fit the ears.
            head.setScale(0.45, 0.02, 0.45)

        head.reparentTo(frame)

        nameText = TextNode("trophy")
        nameText.setFont(ToontownGlobals.getToonFont())
        nameText.setAlign(TextNode.ACenter)
        nameText.setTextColor(0, 0, 0, 1)
        nameText.setWordwrap(5.36 * FrameScale)
        nameText.setText(name)

        namePath = frame.attachNewNode(nameText.generate())
        namePath.setPos(0, -0.03, -.6)
        namePath.setScale(0.186 / FrameScale)

        frame.setScale(FrameScale, 1.0, FrameScale)
        return frame
Пример #24
0
    def begin(self, range, label, gui, tipCategory):
        self.waitBar['range'] = range
        self.tip['text'] = self.getTip(tipCategory)
        self.title['text'] = label
        if hasattr(base, 'cr') and base.cr.currentEpisode == 'short_work':
            self.title['text_fg'] = (0, 0, 0, 1)
            self.title['text_scale'] = 0.1169
        self.__count = 0
        self.__expectedCount = range
        if gui:
            base.setBackgroundColor(Vec4(0.952, 0.796, 0.317, 1))
            if base.localAvatarStyle:
                self.toon['text'] = base.localAvatarName
                self.starring['text'] = TTLocalizer.StarringIn
                if base.cr.oranges:
                    from toontown.suit import Suit, SuitDNA
                    avatar = Suit.Suit()
                    avatar.dna = SuitDNA.SuitDNA()
                    suitIndex = base.localAvatarStyle.armColor % 8 + SuitDNA.suitsPerDept * (base.localAvatarStyle.sleeveTex % 5)
                    avatar.dna.newSuit(SuitDNA.suitHeadTypes[suitIndex])
                    avatar.setDNA(avatar.dna)
                    self.head = self.gui.attachNewNode('head')
                    for part in avatar.headParts:
                        copyPart = part.copyTo(self.head)
                        copyPart.setDepthTest(1)
                        copyPart.setDepthWrite(1)

                    p1 = Point3()
                    p2 = Point3()
                    self.head.calcTightBounds(p1, p2)
                    d = p2 - p1
                    biggest = max(d[0], d[1], d[2])
                    s = 0.5 / biggest
                    self.head.setPosHprScale(0, 0, -0.2, 180, 0, 0, s, s, s)
                    avatar.cleanup()
                    avatar.delete()
                elif base.cr.currentEpisode == 'short_work':
                    from toontown.suit import Suit, SuitDNA
                    avatar = Suit.Suit()
                    avatar.dna = SuitDNA.SuitDNA()
                    suitIndex = SuitDNA.suitHeadTypes.index('sc')
                    avatar.dna.newSuit(SuitDNA.suitHeadTypes[suitIndex])
                    avatar.setDNA(avatar.dna)
                    self.head = self.gui.attachNewNode('head')
                    for part in avatar.headParts:
                        copyPart = part.copyTo(self.head)
                        copyPart.setDepthTest(1)
                        copyPart.setDepthWrite(1)

                    p1 = Point3()
                    p2 = Point3()
                    self.head.calcTightBounds(p1, p2)
                    d = p2 - p1
                    biggest = max(d[0], d[1], d[2])
                    s = 0.5 / biggest
                    self.head.setPosHprScale(0, 0, -0.2, 180, 0, 0, s, s, s)
                    avatar.cleanup()
                    avatar.delete()
                else:
                    from toontown.toon import ToonHead
                    self.head = ToonHead.ToonHead()
                    self.head.setupHead(base.localAvatarStyle, forGui=1)
                    self.head.reparentTo(self.gui)
                    self.head.fitAndCenterHead(1, forGui=1)
            self.gui.reparentTo(aspect2dp, DGG.NO_FADE_SORT_INDEX)
        else:
            self.waitBar.reparentTo(aspect2dp, DGG.NO_FADE_SORT_INDEX)
            self.title.reparentTo(aspect2dp, DGG.NO_FADE_SORT_INDEX)
            self.gui.reparentTo(hidden)
        self.waitBar.update(self.__count)
        self.firstInit = 0
Пример #25
0
 def __init__(self, av=None, position=0, paid=0, okToLockout=1):
     DirectButton.__init__(self, relief=None, text='', text_font=ToontownGlobals.getSignFont())
     self.initialiseoptions(AvatarChoice)
     self.hasPaid = paid
     self.mode = None
     if base.restrictTrialers and okToLockout:
         if position not in AvatarChoice.NEW_TRIALER_OPEN_POS:
             if not self.hasPaid:
                 self.mode = AvatarChoice.MODE_LOCKED
                 self.name = ''
                 self.dna = None
     if self.mode is not AvatarChoice.MODE_LOCKED:
         if not av:
             self.mode = AvatarChoice.MODE_CREATE
             self.name = ''
             self.dna = None
         else:
             self.mode = AvatarChoice.MODE_CHOOSE
             self.name = av.name
             self.dna = ToonDNA.ToonDNA(av.dna)
             self.wantName = av.wantName
             self.approvedName = av.approvedName
             self.rejectedName = av.rejectedName
             self.allowedName = av.allowedName
     self.position = position
     self.doneEvent = 'avChoicePanel-' + str(self.position)
     self.deleteWithPasswordFrame = None
     if base.classicVisuals == 2:
         self.pickAToonGui = loader.loadModel('phase_3/models/gui/pick_a_toon_gui')
     else:
         self.pickAToonGui = loader.loadModel('phase_3/models/gui/tt_m_gui_pat_mainGui')
     self.buttonBgs = []
     if base.classicVisuals == 2:
         self['image'] = self.pickAToonGui.find('**/av-chooser_Square_UP')
     else:
         num = 0
         bgNodesNames = ['default', 'halloween', 'holiday', 'aprilfools']
         pickAToonPath = self.pickAToonGui.find('**/tt_m_gui_pat_mainGUI_' + bgNodesNames[num])
         self.buttonBgs = []
         self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squareRed'))
         self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squareGreen'))
         self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squarePurple'))
         self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squareBlue'))
         self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squarePink'))
         self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squareYellow'))
         self['image'] = self.buttonBgs[position]
     self.setScale(1.01)
     if self.mode is AvatarChoice.MODE_LOCKED:
         if base.classicVisuals == 2:
             self['text0_scale'] = 0.1
             self['text1_scale'] = 0.115
             self['text2_scale'] = 0.115
             self['text0_fg'] = (0, 1, 0.8, 0.0)
             self['text1_fg'] = (0, 1, 0.8, 1)
             self['text2_fg'] = (0.3, 1, 0.9, 1)
             self['text_pos'] = (0, 0.19)
             logoModel = loader.loadModel('phase_3/models/gui/members_only_gui')
             logo = DirectFrame(parent=self, relief=None, image=logoModel.find('**/MembersOnly'), image_scale=(0.4375,
                                                                                                               0,
                                                                                                               0.375), image_pos=(0,
                                                                                                                                  0,
                                                                                                                                  0))
         else:
             self['command'] = self.__handleTrialer
             self['text'] = TTLocalizer.AvatarChoiceSubscribersOnly
             self['text0_scale'] = 0.1
             self['text1_scale'] = TTLocalizer.ACsubscribersOnly
             self['text2_scale'] = TTLocalizer.ACsubscribersOnly
             self['text0_fg'] = (0, 1, 0.8, 0.0)
             self['text1_fg'] = (0, 1, 0.8, 1)
             self['text2_fg'] = (0.3, 1, 0.9, 1)
             self['text_pos'] = (0, 0.19)
             upsellModel = loader.loadModel('phase_3/models/gui/tt_m_gui_ups_mainGui')
             upsellTex = upsellModel.find('**/tt_t_gui_ups_logo_noBubbles')
             self.logoModelImage = loader.loadModel('phase_3/models/gui/members_only_gui').find('**/MembersOnly')
             logo = DirectFrame(state=DGG.DISABLED, parent=self, relief=None, image=upsellTex, image_scale=(0.9,
                                                                                                            0,
                                                                                                            0.9), image_pos=(0,
                                                                                                                             0,
                                                                                                                             0), scale=0.45)
         logo.reparentTo(self.stateNodePath[0], 20)
         logo.instanceTo(self.stateNodePath[1], 20)
         logo.instanceTo(self.stateNodePath[2], 20)
         if base.classicVisuals == 2:
             logoModel.removeNode()
         else:
             self.logo = logo
             upsellModel.removeNode()
     elif self.mode is AvatarChoice.MODE_CREATE:
         self['command'] = self.__handleCreate
         self['text'] = (TTLocalizer.AvatarChoiceMakeAToon,)
         self['text_pos'] = (0, 0)
         self['text0_scale'] = 0.1
         self['text1_scale'] = TTLocalizer.ACmakeAToon
         self['text2_scale'] = TTLocalizer.ACmakeAToon
         self['text0_fg'] = (0, 1, 0.8, 0.5)
         self['text1_fg'] = (0, 1, 0.8, 1)
         self['text2_fg'] = (0.3, 1, 0.9, 1)
     else:
         self['command'] = self.__handleChoice
         if base.classicVisuals == 2:
             self['text'] = (
              '', TTLocalizer.AvatarChoicePlayThisToon, TTLocalizer.AvatarChoicePlayThisToon)
             self['text_scale'] = 0.12
             self['text_fg'] = (1, 0.9, 0.1, 1)
             self.nameText = DirectLabel(parent=self, relief=None, scale=0.089, pos=(0,
                                                                                     0,
                                                                                     0.27), text=self.name, text_fg=(1,
                                                                                                                     1,
                                                                                                                     1,
                                                                                                                     1), text_shadow=(0,
                                                                                                                                      0,
                                                                                                                                      0,
                                                                                                                                      1), text_wordwrap=7.5, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED)
         else:
             self['text'] = (
              '', TTLocalizer.AvatarChoicePlayThisToon, TTLocalizer.AvatarChoicePlayThisToon)
             self['text_scale'] = TTLocalizer.ACplayThisToon
             self['text_fg'] = (1, 0.9, 0.1, 1)
             self.nameText = DirectLabel(parent=self, relief=None, scale=0.08, pos=NAME_POSITIONS[position], text=self.name, hpr=(0, 0, NAME_ROTATIONS[position]), text_fg=(1,
                                                                                                                                                                            1,
                                                                                                                                                                            1,
                                                                                                                                                                            1), text_shadow=(0,
                                                                                                                                                                                             0,
                                                                                                                                                                                             0,
                                                                                                                                                                                             1), text_wordwrap=8, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED)
         if self.approvedName != '':
             self.nameText['text'] = self.approvedName
         guiButton = loader.loadModel('phase_3/models/gui/quit_button')
         self.nameYourToonButton = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), text=(TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon), text_fg=(1,
                                                                                                                                                                                                                                                                                                                         1,
                                                                                                                                                                                                                                                                                                                         1,
                                                                                                                                                                                                                                                                                                                         1), text_shadow=(0,
                                                                                                                                                                                                                                                                                                                                          0,
                                                                                                                                                                                                                                                                                                                                          0,
                                                                                                                                                                                                                                                                                                                                          1), text_scale=0.15, text_pos=(0,
                                                                                                                                                                                                                                                                                                                                                                         0.03), text_font=ToontownGlobals.getInterfaceFont(), pos=(-0.2,
                                                                                                                                                                                                                                                                                                                                                                                                                                   0,
                                                                                                                                                                                                                                                                                                                                                                                                                                   -0.3), scale=0.45, image_scale=(2,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   1,
                                                                                                                                                                                                                                                                                                                                                                                                                                                                   3), command=self.__handleNameYourToon)
         guiButton.removeNode()
         self.statusText = DirectLabel(parent=self, relief=None, scale=0.09, pos=(0,
                                                                                  0,
                                                                                  -0.24), text='', text_fg=(1,
                                                                                                            1,
                                                                                                            1,
                                                                                                            1), text_shadow=(0,
                                                                                                                             0,
                                                                                                                             0,
                                                                                                                             1), text_wordwrap=7.5, text_scale=TTLocalizer.ACstatusText, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED)
         if self.wantName != '':
             self.nameYourToonButton.hide()
             self.statusText['text'] = TTLocalizer.AvatarChoiceNameReview
         elif self.approvedName != '':
             self.nameYourToonButton.hide()
             self.statusText['text'] = TTLocalizer.AvatarChoiceNameApproved
         elif self.rejectedName != '':
             self.nameYourToonButton.hide()
             self.statusText['text'] = TTLocalizer.AvatarChoiceNameRejected
         elif self.allowedName == 1 and (base.cr.allowFreeNames() or self.hasPaid):
             self.nameYourToonButton.show()
             self.statusText['text'] = ''
         else:
             self.nameYourToonButton.hide()
             self.statusText['text'] = ''
         self.head = hidden.attachNewNode('head')
         self.head.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24, 0.24)
         self.head.reparentTo(self.stateNodePath[0], 20)
         self.head.instanceTo(self.stateNodePath[1], 20)
         self.head.instanceTo(self.stateNodePath[2], 20)
         self.headModel = ToonHead.ToonHead()
         self.headModel.setupHead(self.dna, forGui=1)
         self.headModel.reparentTo(self.head)
         animalStyle = self.dna.getAnimal()
         bodyScale = ToontownGlobals.toonBodyScales[animalStyle]
         self.headModel.setScale(bodyScale / 0.75)
         self.headModel.startBlink()
         self.headModel.startLookAround()
         trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui')
         if base.classicVisuals == 2:
             self.deleteButton = DirectButton(parent=self, image=(
              trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'),
              trashcanGui.find('**/TrashCan_RLVR')), text=(
              '', TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete), text_fg=(1,
                                                                                            1,
                                                                                            1,
                                                                                            1), text_shadow=(0,
                                                                                                             0,
                                                                                                             0,
                                                                                                             1), text_scale=0.15, text_pos=(0,
                                                                                                                                            -0.1), text_font=ToontownGlobals.getInterfaceFont(), relief=None, pos=(0.27,
                                                                                                                                                                                                                   0,
                                                                                                                                                                                                                   -0.25), scale=0.45, command=self.__handleDelete)
         else:
             self.deleteButton = DirectButton(parent=self, image=(trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete), text_fg=(1,
                                                                                                                                                                                                                                                                         1,
                                                                                                                                                                                                                                                                         1,
                                                                                                                                                                                                                                                                         1), text_shadow=(0,
                                                                                                                                                                                                                                                                                          0,
                                                                                                                                                                                                                                                                                          0,
                                                                                                                                                                                                                                                                                          1), text_scale=0.15, text_pos=(0,
                                                                                                                                                                                                                                                                                                                         -0.1), text_font=ToontownGlobals.getInterfaceFont(), relief=None, pos=DELETE_POSITIONS[position], scale=0.45, command=self.__handleDelete)
         trashcanGui.removeNode()
     self.resetFrameSize()
     self.avForLogging = None
     if av:
         self.avForLogging = str(av.id)
     else:
         self.avForLogging = None
     return
Пример #26
0
    def __init__(self, avatar, playerId = None):
        from toontown.friends import FriendsListPanel

        if base.cr.doId2do.get(avatar.getDoId()):
            avatar = base.cr.doId2do.get(avatar.getDoId())
        
        AvatarPanelBase.AvatarPanelBase.__init__(self, avatar, FriendsListPanel=FriendsListPanel)

        self.notify.debug('Opening toon panel, avId=%d' % self.avId)
        self.playerId = playerId

        if not self.playerId:
            av = base.cr.doId2do.get(self.avId)
            if av:
                self.playerId = avatar.DISLid
            else:
                self.playerId = 0

        self.playerInfo = None
        if self.playerId:
            self.playerInfo = base.cr.playerFriendsManager.playerId2Info.get(playerId)

        self.laffMeter = None
        wantsLaffMeter = hasattr(avatar, 'hp')

        if not hasattr(avatar, 'style'):
            self.notify.warning("Avatar has no 'style'. Abort initialization.")
            AvatarPanelBase.AvatarPanelBase.cleanup(self)
            return

        base.localAvatar.obscureFriendsListButton(1)

        gui = loader.loadModel('phase_3.5/models/gui/avatar_panel_gui')
        self.frame = DirectFrame(
                                 image=gui.find('**/avatar_panel'),
                                 relief=None,
                                 pos=(-0.22, 0, -0.47),
                                 parent=base.a2dTopRight)
        self.disabledImageColor = Vec4(1, 1, 1, 0.4)
        self.text0Color = Vec4(1, 1, 1, 1)
        self.text1Color = Vec4(0.5, 1, 0.5, 1)
        self.text2Color = Vec4(1, 1, 0.5, 1)
        self.text3Color = Vec4(0.6, 0.6, 0.6, 1)

        self.head = self.frame.attachNewNode('head')
        self.head.setPos(0.02, 0, 0.31)
        self.headModel = ToonHead.ToonHead()
        self.headModel.setupHead(avatar.style, forGui=1)
        self.headModel.fitAndCenterHead(0.175, forGui=1)
        self.headModel.reparentTo(self.head)

        self.headModel.startBlink()
        self.headModel.startLookAround()

        self.healthText = DirectLabel(
            parent=self.frame,
            text='',
            pos=(0.06, 0, 0.2),
            text_pos=(0, 0),
            text_scale=0.05)

        self.healthText.hide()

        self.nameLabel = DirectLabel(
            parent=self.frame,
            pos=(0.0125, 0, 0.4),
            relief=None,
            text=self.avName,
            text_font=avatar.getFont(),
            text_fg=Vec4(0, 0, 0, 1),
            text_pos=(0, 0),
            text_scale=0.042,
            text_wordwrap=7.5,
            text_shadow=(1, 1, 1, 1))

        self.closeButton = DirectButton(
            parent=self.frame,
            image=(
                gui.find('**/CloseBtn_UP'),
                gui.find('**/CloseBtn_DN'),
                gui.find('**/CloseBtn_Rllvr'),
                gui.find('**/CloseBtn_UP')),
            relief=None,
            pos=(0.157644, 0, -0.379167),
            command=self.__handleClose)

        self.friendButton = DirectButton(
            parent=self.frame,
            image=(
                gui.find('**/Frnds_Btn_UP'),
                gui.find('**/Frnds_Btn_DN'),
                gui.find('**/Frnds_Btn_RLVR'),
                gui.find('**/Frnds_Btn_UP')),
            image3_color=self.disabledImageColor,
            image_scale=0.9,
            relief=None,
            text=TTLocalizer.AvatarPanelFriends,
            text_scale=0.06,
            pos=(-0.103, 0, 0.133),
            text0_fg=self.text0Color,
            text1_fg=self.text1Color,
            text2_fg=self.text2Color,
            text3_fg=self.text3Color,
            text_pos=(0.06, -0.02),
            text_align=TextNode.ALeft,
            command=self.__handleFriend)

        if base.cr.playerFriendsManager.askTransientFriend(self.avId) and self.avId not in base.cr.doId2do:
            self.friendButton['state'] = DGG.DISABLED

        if base.cr.avatarFriendsManager.checkIgnored(self.avId):
            self.friendButton['state'] = DGG.DISABLED

        self.goToButton = DirectButton(
            parent=self.frame,
            image=(
                gui.find('**/Go2_Btn_UP'),
                gui.find('**/Go2_Btn_DN'),
                gui.find('**/Go2_Btn_RLVR'),
                gui.find('**/Go2_Btn_UP')),
            image3_color=self.disabledImageColor,
            image_scale=0.9,
            relief=None,
            pos=(-0.103, 0, 0.045),
            text=TTLocalizer.AvatarPanelGoTo,
            text0_fg=self.text0Color,
            text1_fg=self.text1Color,
            text2_fg=self.text2Color,
            text3_fg=self.text3Color,
            text_scale=0.06,
            text_pos=(0.06, -0.015),
            text_align=TextNode.ALeft,
            command=self.__handleGoto)

        if base.cr.avatarFriendsManager.checkIgnored(self.avId):
            self.goToButton['state'] = DGG.DISABLED

        self.whisperButton = DirectButton(
            parent=self.frame,
            image=(
                gui.find('**/ChtBx_ChtBtn_UP'),
                gui.find('**/ChtBx_ChtBtn_DN'),
                gui.find('**/ChtBx_ChtBtn_RLVR'),
                gui.find('**/ChtBx_ChtBtn_UP')),
            image3_color=self.disabledImageColor,
            image_scale=0.9,
            relief=None,
            pos=(-0.103, 0, -0.0375),
            text=TTLocalizer.AvatarPanelWhisper,
            text0_fg=self.text0Color,
            text1_fg=self.text1Color,
            text2_fg=self.text2Color,
            text3_fg=self.text3Color,
            text_scale=TTLocalizer.TAPwhisperButton,
            text_pos=(0.06, -0.0125),
            text_align=TextNode.ALeft,
            command=self.__handleWhisper)

        if base.cr.avatarFriendsManager.checkIgnored(self.avId):
            self.whisperButton['state'] = DGG.DISABLED

        self.secretsButton = DirectButton(
            parent=self.frame,
            image=(
                gui.find('**/Amuse_Btn_UP'),
                gui.find('**/Amuse_Btn_DN'),
                gui.find('**/Amuse_Btn_RLVR'),
                gui.find('**/Amuse_Btn_UP')),
            image3_color=self.disabledImageColor,
            image_scale=0.9,
            relief=None,
            pos=(-0.103, 0, -0.13),
            text='',
            text0_fg=self.text0Color,
            text1_fg=self.text1Color,
            text2_fg=self.text2Color,
            text3_fg=self.text3Color,
            text_scale=TTLocalizer.TAPsecretsButton,
            text_pos=(0.055, -0.01),
            text_align=TextNode.ALeft,
            command=self.__handleSecrets)
        self.secretsButton['state'] = DGG.DISABLED

        if base.cr.avatarFriendsManager.checkIgnored(self.avId):
            self.secretsButton['state'] = DGG.DISABLED

        from toontown.coghq import CogHQBossBattle
        if isinstance(base.cr.playGame.getPlace(), CogHQBossBattle.CogHQBossBattle) and \
                base.localAvatar.getGameAccess() != OTPGlobals.AccessFull:
            self.secretsButton['state'] = DGG.DISABLED

        ignoreStr, ignoreCmd, ignoreScale = self.getIgnoreButtonInfo()

        self.ignoreButton = DirectButton(
            parent=self.frame,
            image=(
                gui.find('**/Ignore_Btn_UP'),
                gui.find('**/Ignore_Btn_DN'),
                gui.find('**/Ignore_Btn_RLVR'),
                gui.find('**/Ignore_Btn_UP')),
            image3_color=self.disabledImageColor,
            image_scale=0.9,
            relief=None,
            pos=(-0.103697, 0, -0.21),
            text=ignoreStr,
            text0_fg=self.text0Color,
            text1_fg=self.text1Color,
            text2_fg=self.text2Color,
            text3_fg=self.text3Color,
            text_scale=ignoreScale,
            text_pos=(0.06, -0.015),
            text_align=TextNode.ALeft,
            command=ignoreCmd)

        if base.cr.productName not in ['JP', 'DE', 'BR', 'FR']:
            self.reportButton = DirectButton(
                parent=self.frame,
                image=(
                    gui.find('**/report_BtnUP'),
                    gui.find('**/report_BtnDN'),
                    gui.find('**/report_BtnRLVR'),
                    gui.find('**/report_BtnUP')),
                image3_color=self.disabledImageColor,
                image_scale=0.65,
                relief=None,
                pos=(-0.103, 0, -0.29738),
                text=TTLocalizer.AvatarPanelReport,
                text0_fg=self.text0Color,
                text1_fg=self.text1Color,
                text2_fg=self.text2Color,
                text3_fg=self.text3Color,
                text_scale=0.06,
                text_pos=(0.06, -0.015),
                text_align=TextNode.ALeft,
                command=self.handleReport)

        if not base.localAvatar.isTeleportAllowed():
            self.goToButton['state'] = DGG.DISABLED

        self.detailButton = DirectButton(
            parent=self.frame,
            image=(
                gui.find('**/ChtBx_BackBtn_UP'),
                gui.find('**/ChtBx_BackBtn_DN'),
                gui.find('**/ChtBx_BackBtn_Rllvr'),
                gui.find('**/ChtBx_BackBtn_UP')),
            relief=None,
            text=('', TTLocalizer.AvatarPanelDetail,
                  TTLocalizer.AvatarPanelDetail, ''),
            text_fg=self.text2Color,
            text_shadow=(0, 0, 0, 1),
            text_scale=0.055,
            text_pos=(-0.075, -0.01),
            text_align=TextNode.ARight,
            pos=(-0.133773, 0, -0.395),
            command=self.__handleDetails)

        self.__makeBoardingGui()
        self.__makePetGui(avatar)
        self.__checkGroupStatus()
        gui.removeNode()

        if wantsLaffMeter:
            self.__makeLaffMeter(avatar)
            self.__updateHp(avatar.hp, avatar.maxHp)
            self.healthText.show()
            self.laffMeter.show()

        menuX = -0.05
        menuScale = 0.064

        if self.avGenerateName:
            self.accept(self.avGenerateName, self.__handleGenerateAvatar)
        if self.avHpChangeName:
            self.accept(self.avHpChangeName, self.__updateHp)
        
        self.accept('updateLaffMeter', self.__updateLaffMeter)

        self.accept('updateGroupStatus', self.__checkGroupStatus)

        self.frame.show()
        messenger.send('avPanelDone')
Пример #27
0
 def __init__(self, av = None, position = 0):
     DirectButton.__init__(self, relief=None, text='', text_font=ToontownGlobals.getSignFont())
     self.initialiseoptions(AvatarChoice)
     self.mode = None
     if not av:
         self.mode = AvatarChoice.MODE_CREATE
         self.name = ''
         self.dna = None
     else:
         self.mode = AvatarChoice.MODE_CHOOSE
         self.name = av.name
         self.dna = ToonDNA.ToonDNA(av.dna)
         self.wantName = av.wantName
         self.approvedName = av.approvedName
         self.rejectedName = av.rejectedName
         self.allowedName = av.allowedName
     self.position = position
     self.doneEvent = 'avChoicePanel-' + str(self.position)
     self.deleteWithPasswordFrame = None
     self.pickAToonGui = loader.loadModel('phase_3/models/gui/tt_m_gui_pat_mainGui')
     self.buttonBgs = []
     self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareRed'))
     self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareGreen'))
     self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squarePurple'))
     self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareBlue'))
     self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squarePink'))
     self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareYellow'))
     self['image'] = self.buttonBgs[position]
     self.setScale(1.01)
     if self.mode is AvatarChoice.MODE_CREATE:
         self['command'] = self.__handleCreate
         self['text'] = (TTLocalizer.AvatarChoiceMakeAToon,)
         self['text_pos'] = (0, 0)
         self['text0_scale'] = 0.1
         self['text1_scale'] = TTLocalizer.ACmakeAToon
         self['text2_scale'] = TTLocalizer.ACmakeAToon
         self['text0_fg'] = (0, 1, 0.8, 0.5)
         self['text1_fg'] = (0, 1, 0.8, 1)
         self['text2_fg'] = (0.3, 1, 0.9, 1)
     else:
         self['command'] = self.__handleChoice
         self['text'] = ('', TTLocalizer.AvatarChoicePlayThisToon, TTLocalizer.AvatarChoicePlayThisToon)
         self['text_scale'] = TTLocalizer.ACplayThisToon
         self['text_fg'] = (1, 0.9, 0.1, 1)
         self.nameText = DirectLabel(parent=self, relief=None, scale=0.08, pos=NAME_POSITIONS[position], text=self.name, hpr=(0, 0, NAME_ROTATIONS[position]), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=8, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED)
         if self.approvedName != '':
             self.nameText['text'] = self.approvedName
         guiButton = loader.loadModel('phase_3/models/gui/quit_button')
         self.nameYourToonButton = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), text=(TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, 0.03), text_font=ToontownGlobals.getInterfaceFont(), pos=(-0.2, 0, -0.3), scale=0.45, image_scale=(2, 1, 3), command=self.__handleCreate)
         guiButton.removeNode()
         self.statusText = DirectLabel(parent=self, relief=None, scale=0.09, pos=(0, 0, -0.24), text='', text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=7.5, text_scale=TTLocalizer.ACstatusText, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED)
         if self.wantName != '':
             self.nameYourToonButton.hide()
             self.statusText['text'] = TTLocalizer.AvatarChoiceNameReview
         elif self.approvedName != '':
             self.nameYourToonButton.hide()
             self.statusText['text'] = TTLocalizer.AvatarChoiceNameApproved
         elif self.rejectedName != '':
             self.nameYourToonButton.hide()
             self.statusText['text'] = TTLocalizer.AvatarChoiceNameRejected
         elif self.allowedName == 1:
             self.nameYourToonButton.show()
             self.statusText['text'] = ''
         else:
             self.nameYourToonButton.hide()
             self.statusText['text'] = ''
         self.head = hidden.attachNewNode('head')
         self.head.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24, 0.24)
         self.head.reparentTo(self.stateNodePath[0], 20)
         self.head.instanceTo(self.stateNodePath[1], 20)
         self.head.instanceTo(self.stateNodePath[2], 20)
         self.headModel = ToonHead.ToonHead()
         self.headModel.setupHead(self.dna, forGui=1)
         self.headModel.reparentTo(self.head)
         animalStyle = self.dna.getAnimal()
         bodyScale = ToontownGlobals.toonBodyScales[animalStyle]
         self.headModel.setScale(bodyScale / 0.75)
         self.headModel.startBlink()
         self.headModel.startLookAround()
         trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui')
         self.deleteButton = DirectButton(parent=self, image=(trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, -0.1), text_font=ToontownGlobals.getInterfaceFont(), relief=None, pos=DELETE_POSITIONS[position], scale=0.45, command=self.__handleDelete)
         trashcanGui.removeNode()
     self.resetFrameSize()
     self.avForLogging = None
     if av:
         self.avForLogging = str(av.id)
     else:
         self.avForLogging = None
     return
Пример #28
0
    def setButtonNames(self):
        for k in self.avatarList:
            if k.position == 0:
                av1 = k
                self.head1 = hidden.attachNewNode('head1')
                self.head1.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24,
                                          0.24)
                self.head1.reparentTo(self.toon1)
                self.headModel1 = ToonHead.ToonHead()
                self.headModel1.setupHead(ToonDNA.ToonDNA(av1.dna), forGui=1)
                self.headModel1.reparentTo(self.head1)

        for k in self.avatarList:
            if k.position == 1:
                av2 = k
                self.head2 = hidden.attachNewNode('head2')
                self.head2.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24,
                                          0.24)
                self.head2.reparentTo(self.toon2)
                self.headModel2 = ToonHead.ToonHead()
                self.headModel2.setupHead(ToonDNA.ToonDNA(av2.dna), forGui=1)
                self.headModel2.reparentTo(self.head2)

        for k in self.avatarList:
            if k.position == 2:
                av3 = k
                self.head3 = hidden.attachNewNode('head3')
                self.head3.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24,
                                          0.24)
                self.head3.reparentTo(self.toon3)
                self.headModel3 = ToonHead.ToonHead()
                self.headModel3.setupHead(ToonDNA.ToonDNA(av3.dna), forGui=1)
                self.headModel3.reparentTo(self.head3)

        for k in self.avatarList:
            if k.position == 3:
                av4 = k
                self.head4 = hidden.attachNewNode('head4')
                self.head4.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24,
                                          0.24)
                self.head4.reparentTo(self.toon4)
                self.headModel4 = ToonHead.ToonHead()
                self.headModel4.setupHead(ToonDNA.ToonDNA(av4.dna), forGui=1)
                self.headModel4.reparentTo(self.head4)

        for k in self.avatarList:
            if k.position == 4:
                av5 = k
                self.head5 = hidden.attachNewNode('head5')
                self.head5.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24,
                                          0.24)
                self.head5.reparentTo(self.toon5)
                self.headModel5 = ToonHead.ToonHead()
                self.headModel5.setupHead(ToonDNA.ToonDNA(av5.dna), forGui=1)
                self.headModel5.reparentTo(self.head5)

        for k in self.avatarList:
            if k.position == 5:
                av6 = k
                self.head6 = hidden.attachNewNode('head6')
                self.head6.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24,
                                          0.24)
                self.head6.reparentTo(self.toon6)
                self.headModel6 = ToonHead.ToonHead()
                self.headModel6.setupHead(ToonDNA.ToonDNA(av6.dna), forGui=1)
                self.headModel6.reparentTo(self.head6)
Пример #29
0
    def __init__(self, av = None, position = 0, paid = 0, okToLockout = 1):
        """
        Set-up the avatar choice panel. If no av is passed in, offer the
        user the opportunity to create a new one
        """
        DirectButton.__init__(self,
                              relief = None,
                              text = "",
                              text_font = ToontownGlobals.getSignFont(),
                              )
        self.initialiseoptions(AvatarChoice)
        self.hasPaid = paid

        # if they haven't paid, lock out all panels except one
        self.mode = None
        if base.restrictTrialers and okToLockout:
            if position not in AvatarChoice.NEW_TRIALER_OPEN_POS:
                if not self.hasPaid:
                    self.mode = AvatarChoice.MODE_LOCKED
                    self.name = ""
                    self.dna = None

        if self.mode is not AvatarChoice.MODE_LOCKED:
            # see if this is a choice panel or a create panel
            if not av:
                # the 'locked' panel is most like the create panel
                self.mode = AvatarChoice.MODE_CREATE
                self.name = ""
                self.dna = None
            else:
                self.mode = AvatarChoice.MODE_CHOOSE
                # Handle the special case of GM toons
                if GMUtils.testGMIdentity(av.name):
                    self.name = self.__handleGMName(av.name)
                else:
                    self.name = av.name
                self.dna = ToonDNA.ToonDNA(av.dna)
                self.wantName = av.wantName
                self.approvedName = av.approvedName
                self.rejectedName = av.rejectedName
                self.allowedName = av.allowedName

        self.position = position
        self.doneEvent = "avChoicePanel-" + str(self.position)

        self.deleteWithPasswordFrame = None

        self.pickAToonGui = loader.loadModel("phase_3/models/gui/tt_m_gui_pat_mainGui")
        self.buttonBgs = []
        self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareRed"))
        self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareGreen"))
        self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squarePurple"))
        self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareBlue"))
        self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squarePink"))
        self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareYellow"))
        self['image'] = self.buttonBgs[position]

        self.setScale(1.01)

        # make interface buttons and signs
        if self.mode is AvatarChoice.MODE_LOCKED:
            self['command'] = self.__handleTrialer
            self['text'] = TTLocalizer.AvatarChoiceSubscribersOnly
            self['text0_scale'] = 0.1
            self['text1_scale'] = TTLocalizer.ACsubscribersOnly
            self['text2_scale'] = TTLocalizer.ACsubscribersOnly
            self['text0_fg'] = (0,1,0.8,0.0)
            self['text1_fg'] = (0,1,0.8,1)
            self['text2_fg'] = (0.3,1,0.9,1)
            self['text_pos'] = (0, 0.19)
            # use the logo on the background
            upsellModel = loader.loadModel("phase_3/models/gui/tt_m_gui_ups_mainGui")
            upsellTex = upsellModel.find("**/tt_t_gui_ups_logo_noBubbles")

            self.logoModelImage = loader.loadModel("phase_3/models/gui/members_only_gui").find("**/MembersOnly")

            logo = DirectFrame(
                state = DGG.DISABLED,
                parent = self,
                relief = None,
                image = upsellTex,
                image_scale = (0.9, 0, 0.9),
                image_pos = (0, 0, 0),
                scale = 0.45
                )
            logo.reparentTo(self.stateNodePath[0], 20)
            logo.instanceTo(self.stateNodePath[1], 20)
            logo.instanceTo(self.stateNodePath[2], 20)

            self.logo = logo
            upsellModel.removeNode()

        elif self.mode is AvatarChoice.MODE_CREATE:
            #print 'MODE_CREATE 2'
            # Click callback on the main button
            self['command'] = self.__handleCreate
            self['text'] = TTLocalizer.AvatarChoiceMakeAToon,
            self['text_pos'] = (0,0)
            self['text0_scale'] = 0.1
            self['text1_scale'] = TTLocalizer.ACmakeAToon
            self['text2_scale'] = TTLocalizer.ACmakeAToon
            self['text0_fg'] = (0,1,0.8,0.5)
            self['text1_fg'] = (0,1,0.8,1)
            self['text2_fg'] = (0.3,1,0.9,1)

            # TODO: Make new toon rollover text

        else:
            # Click callback on the main button
            self['command'] = self.__handleChoice
            self['text'] = ("",
                            TTLocalizer.AvatarChoicePlayThisToon,
                            TTLocalizer.AvatarChoicePlayThisToon)
            self['text_scale'] = TTLocalizer.ACplayThisToon
            self['text_fg'] = (1,0.9,0.1,1)

            # Support 3d on the frame for the avatar head

            # Actually, we don't need to do this now, since we are
            # clearing the 2-d depth buffer anyway in render2d.
            #self.setY(100)
            #self.setDepthWrite(1)

            # put the toon name across the top
            self.nameText = DirectLabel(
                parent = self,
                relief = None,
                scale = 0.08,
                pos = NAME_POSITIONS[position],
                text = self.name,
                hpr = (0, 0, NAME_ROTATIONS[position]),
                text_fg = (1,1,1,1),
                text_shadow = (0,0,0,1),
                text_wordwrap = 8,
                text_font = ToontownGlobals.getToonFont(),
                # Disable the label so it ignores mouse events
                state = DGG.DISABLED,
                )
            if self.approvedName != "":
                self.nameText['text'] = self.approvedName

            # Create the nameYourToon button
            guiButton = loader.loadModel("phase_3/models/gui/quit_button")
            self.nameYourToonButton = DirectButton(
                parent = self,
                relief = None,
                image = (guiButton.find("**/QuitBtn_UP"),
                         guiButton.find("**/QuitBtn_DN"),
                         guiButton.find("**/QuitBtn_RLVR"),
                         ),
                text = (TTLocalizer.AvatarChoiceNameYourToon,
                        TTLocalizer.AvatarChoiceNameYourToon,
                        TTLocalizer.AvatarChoiceNameYourToon),
                text_fg = (1,1,1,1),
                text_shadow = (0,0,0,1),
                text_scale = 0.15,
                text_pos = (0,.03),
                text_font = ToontownGlobals.getInterfaceFont(),
                pos = (-0.2, 0, -0.3),
                scale = 0.45,
                image_scale = (2,1,3),
                command = self.__handleNameYourToon,
                )
            guiButton.removeNode()

            # put the toon name status label in ("rejected", "approved", "under review", or "")
            self.statusText = DirectLabel(
                parent = self,
                relief = None,
                scale = 0.09,
                pos = (0, 0, -0.24),
                text = "",
                text_fg = (1,1,1,1),
                text_shadow = (0,0,0,1),
                text_wordwrap = 7.5,
                text_scale = TTLocalizer.ACstatusText,
                text_font = ToontownGlobals.getToonFont(),
                # Disable the label so it ignores mouse events
                state = DGG.DISABLED,
                )
            # Change the text to the appropiate name notice
            if self.wantName != "":
                self.nameYourToonButton.hide()
                self.statusText['text'] = TTLocalizer.AvatarChoiceNameReview
            elif self.approvedName != "":
                self.nameYourToonButton.hide()
                self.statusText['text'] = TTLocalizer.AvatarChoiceNameApproved
            elif self.rejectedName != "":
                self.nameYourToonButton.hide()
                self.statusText['text'] = TTLocalizer.AvatarChoiceNameRejected
            else:
                if self.allowedName == 1 and (base.cr.allowFreeNames() or self.hasPaid):
                    self.nameYourToonButton.show()
                    self.statusText['text'] = ""
                else:
                    self.nameYourToonButton.hide()
                    self.statusText['text'] = ""

            # put the toon head on the panel
            self.head = hidden.attachNewNode('head')
            self.head.setPosHprScale(0, 5, -0.1,
                                     180, 0, 0,
                                     0.24, 0.24, 0.24)
            self.head.reparentTo(self.stateNodePath[0], 20)
            self.head.instanceTo(self.stateNodePath[1], 20)
            self.head.instanceTo(self.stateNodePath[2], 20)

            self.headModel = ToonHead.ToonHead()
            self.headModel.setupHead(self.dna, forGui = 1)
            self.headModel.reparentTo(self.head)

            # Scale the head by the body scale, so mouse heads don't
            # seem out of proportion to horse heads.
            animalStyle = self.dna.getAnimal()
            bodyScale = ToontownGlobals.toonBodyScales[animalStyle]
            self.headModel.setScale(bodyScale / 0.75)

            # Start blinking and looking around.
            self.headModel.startBlink()
            self.headModel.startLookAround()

            # TODO:  play with button callback is __handleChoice

            trashcanGui = loader.loadModel("phase_3/models/gui/trashcan_gui")
            # create the delete-a-toon button
            self.deleteButton = DirectButton(
                parent = self,
                image = (trashcanGui.find("**/TrashCan_CLSD"),
                         trashcanGui.find("**/TrashCan_OPEN"),
                         trashcanGui.find("**/TrashCan_RLVR")),
                text = ("", TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete),
                text_fg = (1,1,1,1),
                text_shadow = (0,0,0,1),
                text_scale = 0.15,
                text_pos = (0, -0.1),
                text_font = ToontownGlobals.getInterfaceFont(),
                relief = None,
                pos = DELETE_POSITIONS[position],
                scale = 0.45,
                command = self.__handleDelete,
                )
            trashcanGui.removeNode()

        self.resetFrameSize()

        # Setup account/avatar logging to VRS collector to capture
        # the relationship between MAC->IP->Av ID

        self.avForLogging = None

        if av:
            self.avForLogging = str(av.id)
        else:
            self.avForLogging = None

        if __debug__:
            base.avChoice = self