Exemple #1
0
 def show(self):
     # we do this weirdness so it doesn't get clipped by the PlaneNode
     self.reparentTo(self.parent)
     self.setPos(0.1, 0, -0.018)
     newParent = self.parent.getParent().getParent()
     self.wrtReparentTo(newParent)
     if self.whosePartyLabel["text"] == " ":
         host = base.cr.identifyAvatar(self.partyInfo.hostId)
         if host:
             name = host.getName()
             if GMUtils.testGMIdentity(name):
                 name = GMUtils.handleGMName(name)
             self.whosePartyLabel["text"] = name
     if self.whenTextLabel["text"] == " ":
         time = myStrftime(self.partyInfo.startTime)
         self.whenTextLabel["text"] = time
     if self.partyStatusLabel["text"] == " ":
         if self.partyInfo.status == PartyGlobals.PartyStatus.Cancelled:
             self.partyStatusLabel[
                 "text"] = TTLocalizer.CalendarPartyCancelled
         elif self.partyInfo.status == PartyGlobals.PartyStatus.Finished:
             self.partyStatusLabel[
                 "text"] = TTLocalizer.CalendarPartyFinished
         elif self.partyInfo.status == PartyGlobals.PartyStatus.Started:
             self.partyStatusLabel["text"] = TTLocalizer.CalendarPartyGo
         elif self.partyInfo.status == PartyGlobals.PartyStatus.NeverStarted:
             self.partyStatusLabel[
                 "text"] = TTLocalizer.CalendarPartyNeverStarted
         else:
             self.partyStatusLabel[
                 "text"] = TTLocalizer.CalendarPartyGetReady
     DirectFrame.show(self)
Exemple #2
0
    def getSenderName(self, avId):
        """Return the name of the toon that matches avId."""
        assert (MailboxScreen.notify.debug("getSenderName"))
        sender = base.cr.identifyFriend(avId)
        nameOfSender = ""
        if sender:
            nameOfSender = sender.getName()
        else:
            sender = self.checkFamily(avId)  # check family
            if sender:
                nameOfSender = sender.name  # careful a family member returns a PotentialAvatar not a handle
            elif hasattr(base.cr,
                         "playerFriendsManager"):  # check transient toons
                sender = base.cr.playerFriendsManager.getAvHandleFromId(avId)
                if sender:
                    nameOfSender = sender.getName()

        if GMUtils.testGMIdentity(nameOfSender):
            nameOfSender = GMUtils.handleGMName(nameOfSender)

        if not sender:
            nameOfSender = TTLocalizer.MailboxGiftTagAnonymous
            if hasattr(base.cr, "playerFriendsManager"):  # request the info
                base.cr.playerFriendsManager.requestAvatarInfo(avId)
                self.accept('friendsListChanged', self.__showCurrentItem
                            )  # accepts this as long as it stays up
        return nameOfSender
Exemple #3
0
    def setBestHeightInfo(self, toonName, height):

        if GMUtils.testGMIdentity(toonName):
            toonName = GMUtils.handleGMName(toonName)

        self.bestHeightInfo = (toonName, height)
        DistributedPartyTrampolineActivity.notify.debug( "%s has the best height of %d" % (toonName, height) )

        if height > 0:
            self.setSignNote( TTLocalizer.PartyTrampolineBestHeight % self.bestHeightInfo )
        else:
            self.setSignNote( TTLocalizer.PartyTrampolineNoHeightYet )
Exemple #4
0
    def setHostName(self, hostName):
        """Handle AI telling us the hostname."""
        self.hostName = hostName

        if GMUtils.testGMIdentity(self.hostName):
            self.hostName = GMUtils.handleGMName(self.hostName)

        # it is possible to get here initially without the model being loaded yet,
        # hence the hasattr self
        if hasattr(self, "partyClockSignFront"):
            self.attachHostNameToSign(self.partyClockSignFront)
        if hasattr(self, "partyClockSignBack"):
            self.attachHostNameToSign(self.partyClockSignBack)
Exemple #5
0
    def __init__(self, doId, name, style, petId, isAPet=False):
        self.doId = doId
        self.style = style
        self.commonChatFlags = 0
        self.whitelistChatFlags = 0
        self.petId = petId
        self.isAPet = isAPet
        self.chatGarbler = ToonChatGarbler.ToonChatGarbler()

        if GMUtils.testGMIdentity(name):
            self.name = GMUtils.handleGMName(name)
        else:
            self.name = name
Exemple #6
0
    def setHighScore(self, toonName, score):
        """
        Displays the high score on the activity sign.

        Parameters:
            toonName a string with the name of the last toon that hit a high scoore
            score the score amount the last toon reached
        """
        if GMUtils.testGMIdentity(toonName):
            toonName = GMUtils.handleGMName(toonName)

        assert(self.notify.debug("setHighScore %s %d" % (toonName, score)))

        self.setSignNote(TTLocalizer.PartyCogSignNote % (toonName, score))
Exemple #7
0
    def updateInvitation(self, hostsName, partyInfo):
        self.partyInfo = partyInfo

        hostsName = TTLocalizer.GetPossesive(hostsName)
        if GMUtils.testGMIdentity(hostsName):
            hostsName = self.__handleGMName(hostsName)
        self.whosePartyLabel["text"] = TTLocalizer.PartyPlannerInvitationWhoseSentence % \
         hostsName

        if self.partyInfo.isPrivate:
            publicPrivateText = TTLocalizer.PartyPlannerPrivate.lower()
        else:
            publicPrivateText = TTLocalizer.PartyPlannerPublic.lower()

        activities = self.getActivitiesFormattedCorrectly()
        if self.noFriends:
            self.activityTextLabel[
                "text"] = TTLocalizer.PartyPlannerInvitationThemeWhatSentenceNoFriends % (
                    publicPrivateText,
                    activities,
                )
        else:
            self.activityTextLabel[
                "text"] = TTLocalizer.PartyPlannerInvitationThemeWhatSentence % (
                    publicPrivateText,
                    activities,
                )
        if self.noFriends:
            self.whenTextLabel[
                "text"] = TTLocalizer.PartyPlannerInvitationWhenSentenceNoFriends % (
                    PartyUtils.formatDate(self.partyInfo.startTime.year,
                                          self.partyInfo.startTime.month,
                                          self.partyInfo.startTime.day),
                    PartyUtils.formatTime(self.partyInfo.startTime.hour,
                                          self.partyInfo.startTime.minute),
                )
        else:
            self.whenTextLabel[
                "text"] = TTLocalizer.PartyPlannerInvitationWhenSentence % (
                    PartyUtils.formatDate(self.partyInfo.startTime.year,
                                          self.partyInfo.startTime.month,
                                          self.partyInfo.startTime.day),
                    PartyUtils.formatTime(self.partyInfo.startTime.hour,
                                          self.partyInfo.startTime.minute),
                )

        self.changeTheme(partyInfo.inviteTheme)
Exemple #8
0
    def __handleGMName(self, name):
        gmName = GMUtils.handleGMName(name)

        return gmName
Exemple #9
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
Exemple #10
0
    def refresh(self, partyInfoTupleList):
        """
        Called when the public party gui is shown.  partyInfoTupleList is a list
        of tuples of the form:
        ( shardId, zoneId, numberOfGuests, hostName, activityIds, lane )
        """
        PublicPartyGui.notify.debug("refresh : partyInfoTupleList = %s" %
                                    partyInfoTupleList)
        self.selectedItem = None
        self.partyList.removeAndDestroyAllItems()
        self.activityList.removeAndDestroyAllItems()
        self.partyStartButton["state"] = DirectGuiGlobals.DISABLED
        # put parties with most toons at the top
        sortedList = partyInfoTupleList[:]

        #for i in xrange(20):
        #    sortedList.append((202000000, 61000, i+2, "Good ol' Knuckles CrunchenGrooven", [0, 1, 2, 4, 5, 7], 30-i))

        def cmp(left, right):
            if left[2] < right[2]:
                return -1
            elif left[2] == right[2]:
                if len(left[4]) < len(right[4]):
                    return -1
                elif len(left[4]) == len(right[4]):
                    return 0
                else:
                    return 1
            else:
                return 1

        sortedList.sort(cmp, reverse=True)

        # put parties with 20 or more toons on the bottom
        indexToCut = -1
        for index, partyTuple in enumerate(sortedList):
            numberOfGuests = partyTuple[2]
            if numberOfGuests < PartyGlobals.MaxToonsAtAParty:
                indexToCut = index
                break
        if indexToCut > 0:
            sortedList = sortedList[indexToCut:] + sortedList[:indexToCut]

        for index, partyTuple in enumerate(sortedList):
            shardId = partyTuple[0]
            zoneId = partyTuple[1]
            numberOfGuests = partyTuple[2]
            hostName = partyTuple[3]
            if GMUtils.testGMIdentity(hostName):
                hostName = GMUtils.handleGMName(hostName)
            activityIds = partyTuple[4]
            minLeft = partyTuple[5]
            item = DirectButton(
                relief=DGG.RIDGE,
                borderWidth=(0.01, 0.01),
                frameSize=(-0.01, 0.45, -0.015, 0.04),
                frameColor=self.normalFrameColor,
                text=hostName,
                text_align=TextNode.ALeft,
                text_bg=Vec4(0.0, 0.0, 0.0, 0.0),
                text_scale=0.045,
                command=self.partyClicked,
            )
            otherInfoWidth = 0.08
            numActivities = len(activityIds)
            PartyUtils.truncateTextOfLabelBasedOnWidth(
                item, hostName, PartyGlobals.EventsPageGuestNameMaxWidth)
            num = DirectLabel(
                relief=DGG.RIDGE,
                borderWidth=(0.01, 0.01),
                frameSize=(0., otherInfoWidth, -0.015, 0.04),
                frameColor=self.normalFrameColor,
                text="%d" % numberOfGuests,
                text_align=TextNode.ALeft,
                text_scale=0.045,
                text_pos=(0.01, 0, 0),
                pos=(0.45, 0.0, 0.0),
            )
            num.reparentTo(item)
            item.numLabel = num

            actLabelPos = num.getPos()
            actLabelPos.setX(actLabelPos.getX() + otherInfoWidth)
            actLabel = DirectLabel(
                relief=DGG.RIDGE,
                borderWidth=(0.01, 0.01),
                frameSize=(0.0, otherInfoWidth, -0.015, 0.04),
                frameColor=self.normalFrameColor,
                text="%d" % numActivities,
                text_align=TextNode.ALeft,
                text_scale=0.045,
                text_pos=(0.01, 0, 0),
                pos=actLabelPos,
            )
            actLabel.reparentTo(item)
            item.actLabel = actLabel

            minLabelPos = actLabel.getPos()
            minLabelPos.setX(minLabelPos.getX() + otherInfoWidth)
            minLabel = DirectLabel(
                relief=DGG.RIDGE,
                borderWidth=(0.01, 0.01),
                frameSize=(0.0, otherInfoWidth, -0.015, 0.04),
                frameColor=self.normalFrameColor,
                text="%d" % minLeft,
                text_align=TextNode.ALeft,
                text_scale=0.045,
                text_pos=(0.01, 0, 0),
                pos=minLabelPos,
            )
            minLabel.reparentTo(item)
            item.minLabel = minLabel

            item["extraArgs"] = [item]
            item.setPythonTag("shardId", shardId)
            item.setPythonTag("zoneId", zoneId)
            item.setPythonTag("activityIds", activityIds)
            self.partyList.addItem(item)