示例#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)
示例#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
示例#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 )
示例#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)
示例#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
示例#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))
示例#7
0
    def __handleGMName(self, name):
        gmName = GMUtils.handleGMName(name)

        return gmName
示例#8
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)