def generate(self):
        DistributedObjectAI.generate(self)

        for activityInfo in self.partyInfo['activities']:

            if activityInfo[0] not in self.ACTIVITIES:
                self.notify.warning('Tried to generate invalid activity %s' % activityInfo[0])
                continue

            if activityInfo[0] == PartyGlobals.ActivityIds.PartyCannon:
                if not self.cannonActivityGenerated:
                    self.cannonActivity = DistributedPartyCannonActivityAI(self.air, self, activityInfo)
                    self.cannonActivity.generateWithRequired(self.zoneId)
                    self.cannonActivityGenerated = 1

                activity = DistributedPartyCannonAI(self.air)
                activity.setActivityDoId(self.cannonActivity.doId)
                x = PartyUtils.convertDistanceFromPartyGrid(activityInfo[1], 0)
                y = PartyUtils.convertDistanceFromPartyGrid(activityInfo[2], 1)
                h = activityInfo[3] * PartyGlobals.PartyGridHeadingConverter
                activity.setPosHpr(x, y, 0, h, 0, 0)
            else:
                activity = self.ACTIVITIES[activityInfo[0]](self.air, self, activityInfo)

            activity.generateWithRequired(self.zoneId)
            self.activities.append(activity)
예제 #2
0
 def updateInvitation(self, hostsName, partyInfo):
     self.partyInfo = partyInfo
     hostsName = TTLocalizer.GetPossesive(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)
예제 #3
0
 def getCorrectRotation(self):
     r = self.getR()
     if r == 90.0:
         r = 270.0
     elif r == 270.0:
         r = 90.0
     if self.id == PartyGlobals.ActivityIds.PartyCannon:
         return PartyUtils.convertDegreesToPartyGrid(r + 180.0)
     return PartyUtils.convertDegreesToPartyGrid(r)
예제 #4
0
 def getGuestItem(self, name, inviteStatus):
     label = DirectLabel(relief=None, text=name, text_scale=0.045, text_align=TextNode.ALeft, textMayChange=True)
     dot = DirectFrame(relief=None, geom=self.hostingGui.find("**/questionMark"), pos=(0.5, 0.0, 0.01))
     if inviteStatus == PartyGlobals.InviteStatus.Accepted:
         dot["geom"] = (self.hostingGui.find("**/checkmark"),)
     elif inviteStatus == PartyGlobals.InviteStatus.Rejected:
         dot["geom"] = (self.hostingGui.find("**/x"),)
     PartyUtils.truncateTextOfLabelBasedOnWidth(label, name, PartyGlobals.EventsPageGuestNameMaxWidth)
     dot.reparentTo(label)
     return label
    def __init__(self, air, parent, activityInfo):
        DistributedObjectAI.__init__(self, air)

        self.parent = parent
        self.state = None

        self.x = PartyUtils.convertDistanceFromPartyGrid(activityInfo[1], 0)
        self.y = PartyUtils.convertDistanceFromPartyGrid(activityInfo[2], 1)
        self.h = activityInfo[3] * PartyGlobals.PartyGridHeadingConverter

        self.toonsPlaying = {}
예제 #6
0
    def __init__(self, air, parent, activityInfo):
        DistributedObjectAI.__init__(self, air)

        self.parent = parent
        self.state = None

        self.x = PartyUtils.convertDistanceFromPartyGrid(activityInfo[1], 0)
        self.y = PartyUtils.convertDistanceFromPartyGrid(activityInfo[2], 1)
        self.h = activityInfo[3] * PartyGlobals.PartyGridHeadingConverter

        self.toonsPlaying = {}
    def load(self):
        if self.__loaded:
            return
        self.__timerPad = PartyUtils.getNewToontownTimer()
        guiModel = 'phase_4/models/gui/cannon_game_gui'
        guiNode = loader.loadModel(guiModel)
        self.__aimPad = DirectFrame(image=guiNode.find('**/CannonFire_PAD'), relief=None, pos=(0.7, 0, -0.553333), scale=0.8)
        guiNode.removeNode()
        self.fireButton = DirectButton(parent=self.__aimPad, image=((guiModel, '**/Fire_Btn_UP'), (guiModel, '**/Fire_Btn_DN'), (guiModel, '**/Fire_Btn_RLVR')), relief=None, pos=(0.0115741, 0, 0.00505051), scale=1.0, command=self.__firePressed)
        self.upButton = DirectButton(parent=self.__aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(0.0115741, 0, 0.221717))
        self.downButton = DirectButton(parent=self.__aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(0.0136112, 0, -0.210101), image_hpr=(0, 0, 180))
        self.leftButton = DirectButton(parent=self.__aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(-0.199352, 0, -0.000505269), image_hpr=(0, 0, -90))
        self.rightButton = DirectButton(parent=self.__aimPad, image=((guiModel, '**/Cannon_Arrow_UP'), (guiModel, '**/Cannon_Arrow_DN'), (guiModel, '**/Cannon_Arrow_RLVR')), relief=None, pos=(0.219167, 0, -0.00101024), image_hpr=(0, 0, 90))
        self.__aimPad.setColor(1, 1, 1, 0.9)

        def bindButton(button, upHandler, downHandler):
            button.bind(DGG.B1PRESS, lambda x, handler = upHandler: handler())
            button.bind(DGG.B1RELEASE, lambda x, handler = downHandler: handler())

        bindButton(self.upButton, self.__upPressed, self.__upReleased)
        bindButton(self.downButton, self.__downPressed, self.__downReleased)
        bindButton(self.leftButton, self.__leftPressed, self.__leftReleased)
        bindButton(self.rightButton, self.__rightPressed, self.__rightReleased)
        self.__loaded = True
        return
예제 #8
0
 def changeValue(self, amount):
     if type == 'ampm':
         self.alterPartyTime(hour=(self.partyTime.hour + 12) % 24)
         newAmount = self.getCurrentAmPm()
         label['text'] = newAmount
     else:
         if type == 'hour':
             newAmount = getattr(self.partyTime, type) + amount
             newAmount = newAmount % 12
             if self.timeInputAmPmLabel['text'] == TTLocalizer.PartyTimeFormatMeridiemPM:
                 newAmount = newAmount % 12 + 12
             self.alterPartyTime(hour=newAmount)
         elif type == 'minute':
             newAmount = getattr(self.partyTime, type) + amount
             self.alterPartyTime(minute=newAmount)
         else:
             PartyPlanner.notify.error('Invalid type for changeValue in PartyPlanner: %s' % type)
         newAmount = getattr(self.partyTime, type)
         if newAmount < 10 and type == 'minute':
             label['text'] = '0%d' % newAmount
         else:
             if type == 'hour':
                 newAmount = newAmount % 12
                 if newAmount == 0:
                     newAmount = 12
             label['text'] = '%d' % newAmount
     self.timePageRecapToontownTimeLabel2['text'] = '%s' % PartyUtils.formatDateTime(self.partyTime)
     self.timePageRecapLocalTimeLabel['text'] = '%s%s' % (TTLocalizer.PartyPlannerTimeLocalTime, PartyUtils.formatDateTime(self.partyTime, inLocalTime=True))
예제 #9
0
 def enterTime(self, *args):
     self.prevButton.show()
     self.prevButton['state'] = DirectGuiGlobals.NORMAL
     self.nextButton.show()
     self.timePage.show()
     self.timePageRecapToontownTimeLabel2['text'] = '%s' % PartyUtils.formatDateTime(self.partyTime)
     self.timePageRecapLocalTimeLabel['text'] = '%s%s' % (TTLocalizer.PartyPlannerTimeLocalTime, PartyUtils.formatDateTime(self.partyTime, inLocalTime=True))
예제 #10
0
    def fillActivityList(self, activityIds):
        self.activityList.removeAndDestroyAllItems()
        sortedList = activityIds[:]
        sortedList.sort()
        lastActivityId = -1
        for activityId in sortedList:
            if activityId == lastActivityId:
                continue
            lastActivityId = activityId
            number = sortedList.count(activityId)
            text = TTLocalizer.PartyActivityNameDict[activityId]['generic']
            if number > 1:
                text += ' X %d' % number
            item = DirectLabel(
                relief=None,
                text=text,
                text_align=TextNode.ACenter,
                text_scale=0.05,
                text_pos=(0.0, -0.15),
                geom_scale=0.3,
                geom_pos=Vec3(0.0, 0.0, 0.07),
                geom=PartyUtils.getPartyActivityIcon(
                    self.activityIconsModel,
                    PartyGlobals.ActivityIds.getString(activityId)))
            self.activityList.addItem(item)

        return
 def loadGUI(self):
     self.gui = loader.loadModel('phase_13/models/parties/trampolineGUI')
     self.gui.reparentTo(base.a2dTopLeft)
     self.gui.setPos(0.115, 0, -1)
     self.gui.hide()
     self.toonIndicator = self.gui.find('**/trampolineGUI_MovingBar')
     jumpLineLocator = self.gui.find('**/jumpLine_locator')
     guiBean = self.gui.find('**/trampolineGUI_GreenJellyBean')
     self.gui.find('**/trampolineGUI_GreenJellyBean').stash()
     self.guiBeans = [ guiBean.instanceUnderNode(jumpLineLocator, self.uniqueName('guiBean%d' % i)) for i in xrange(self.numJellyBeans) ]
     self.guiBeans[-1].setScale(1.5)
     heightTextNode = TextNode(self.uniqueName('TrampolineActivity.heightTextNode'))
     heightTextNode.setFont(ToontownGlobals.getSignFont())
     heightTextNode.setAlign(TextNode.ALeft)
     heightTextNode.setText('0.0')
     heightTextNode.setShadow(0.05, 0.05)
     heightTextNode.setShadowColor(0.0, 0.0, 0.0, 1.0)
     heightTextNode.setTextColor(1.0, 1.0, 1.0, 1.0)
     self.heightText = jumpLineLocator.attachNewNode(heightTextNode)
     self.heightText.setX(0.15)
     self.heightText.setScale(0.1)
     self.heightText.setAlphaScale(0.0)
     self.quitEarlyButtonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui')
     quitEarlyUp = self.quitEarlyButtonModels.find('**//InventoryButtonUp')
     quitEarlyDown = self.quitEarlyButtonModels.find('**/InventoryButtonDown')
     quitEarlyRollover = self.quitEarlyButtonModels.find('**/InventoryButtonRollover')
     self.quitEarlyButton = DirectButton(parent=base.a2dTopRight, relief=None, text=TTLocalizer.PartyTrampolineQuitEarlyButton, text_fg=(1, 1, 0.65, 1), text_pos=(0, -0.23), text_scale=0.7, image=(quitEarlyUp, quitEarlyDown, quitEarlyRollover), image_color=(1, 0, 0, 1), image_scale=(20, 1, 11), pos=(-0.183, 0, -0.4), scale=0.09, command=self.leaveTrampoline)
     self.quitEarlyButton.stash()
     self.flashText = OnscreenText(text='', pos=(0.0, -0.45), scale=0.2, fg=(1.0, 1.0, 0.65, 1.0), align=TextNode.ACenter, font=ToontownGlobals.getSignFont(), mayChange=True)
     self.timer = PartyUtils.getNewToontownTimer()
     self.timer.posInTopRightCorner()
     return
예제 #12
0
 def getGuestItem(self, name, inviteStatus):
     label = DirectLabel(relief=None,
                         text=name,
                         text_scale=0.045,
                         text_align=TextNode.ALeft,
                         textMayChange=True)
     dot = DirectFrame(relief=None,
                       geom=self.hostingGui.find('**/questionMark'),
                       pos=(0.5, 0.0, 0.01))
     if inviteStatus == PartyGlobals.InviteStatus.Accepted:
         dot['geom'] = (self.hostingGui.find('**/checkmark'), )
     elif inviteStatus == PartyGlobals.InviteStatus.Rejected:
         dot['geom'] = (self.hostingGui.find('**/x'), )
     PartyUtils.truncateTextOfLabelBasedOnWidth(
         label, name, PartyGlobals.EventsPageGuestNameMaxWidth)
     dot.reparentTo(label)
     return label
예제 #13
0
 def loadGUI(self):
     self.gui = loader.loadModel('phase_13/models/parties/trampolineGUI')
     self.gui.reparentTo(base.a2dTopLeft)
     self.gui.setPos(0.115, 0, -1)
     self.gui.hide()
     self.toonIndicator = self.gui.find('**/trampolineGUI_MovingBar')
     jumpLineLocator = self.gui.find('**/jumpLine_locator')
     guiBean = self.gui.find('**/trampolineGUI_GreenJellyBean')
     self.gui.find('**/trampolineGUI_GreenJellyBean').stash()
     self.guiBeans = [
         guiBean.instanceUnderNode(jumpLineLocator,
                                   self.uniqueName('guiBean%d' % i))
         for i in xrange(self.numJellyBeans)
     ]
     self.guiBeans[-1].setScale(1.5)
     heightTextNode = TextNode(
         self.uniqueName('TrampolineActivity.heightTextNode'))
     heightTextNode.setFont(ToontownGlobals.getSignFont())
     heightTextNode.setAlign(TextNode.ALeft)
     heightTextNode.setText('0.0')
     heightTextNode.setShadow(0.05, 0.05)
     heightTextNode.setShadowColor(0.0, 0.0, 0.0, 1.0)
     heightTextNode.setTextColor(1.0, 1.0, 1.0, 1.0)
     self.heightText = jumpLineLocator.attachNewNode(heightTextNode)
     self.heightText.setX(0.15)
     self.heightText.setScale(0.1)
     self.heightText.setAlphaScale(0.0)
     self.quitEarlyButtonModels = loader.loadModel(
         'phase_3.5/models/gui/inventory_gui')
     quitEarlyUp = self.quitEarlyButtonModels.find('**//InventoryButtonUp')
     quitEarlyDown = self.quitEarlyButtonModels.find(
         '**/InventoryButtonDown')
     quitEarlyRollover = self.quitEarlyButtonModels.find(
         '**/InventoryButtonRollover')
     self.quitEarlyButton = DirectButton(
         parent=base.a2dTopRight,
         relief=None,
         text=TTLocalizer.PartyTrampolineQuitEarlyButton,
         text_fg=(1, 1, 0.65, 1),
         text_pos=(0, -0.23),
         text_scale=0.7,
         image=(quitEarlyUp, quitEarlyDown, quitEarlyRollover),
         image_color=(1, 0, 0, 1),
         image_scale=(20, 1, 11),
         pos=(-0.183, 0, -0.4),
         scale=0.09,
         command=self.leaveTrampoline)
     self.quitEarlyButton.stash()
     self.flashText = OnscreenText(text='',
                                   pos=(0.0, -0.45),
                                   scale=0.2,
                                   fg=(1.0, 1.0, 0.65, 1.0),
                                   align=TextNode.ACenter,
                                   font=ToontownGlobals.getSignFont(),
                                   mayChange=True)
     self.timer = PartyUtils.getNewToontownTimer()
     self.timer.posInTopRightCorner()
     return
예제 #14
0
 def invitePartyClicked(self, item):
     if item.getPythonTag("partyStatus") == PartyGlobals.PartyStatus.Started:
         self.invitePartyGoButton["state"] = DirectGuiGlobals.NORMAL
     else:
         self.invitePartyGoButton["state"] = DirectGuiGlobals.DISABLED
     if self.selectedInvitationItem is not None:
         self.selectedInvitationItem["state"] = DirectGuiGlobals.NORMAL
         self.selectedInvitationItem["text_bg"] = Vec4(0.0, 0.0, 0.0, 0.0)
     self.selectedInvitationItem = item
     self.selectedInvitationItem["state"] = DirectGuiGlobals.DISABLED
     self.selectedInvitationItem["text_bg"] = Vec4(1.0, 1.0, 0.0, 1.0)
     self.fillInviteActivityList(item.getPythonTag("activityIds"))
     startTime = item.getPythonTag("startTime")
     self.invitationDateTimeLabel["text"] = TTLocalizer.EventsPageInvitedTabTime % (
         PartyUtils.formatDate(startTime.year, startTime.month, startTime.day),
         PartyUtils.formatTime(startTime.hour, startTime.minute),
     )
     return
예제 #15
0
 def load(self):
     buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui')
     upButton = buttonModels.find('**//InventoryButtonUp')
     downButton = buttonModels.find('**/InventoryButtonDown')
     rolloverButton = buttonModels.find('**/InventoryButtonRollover')
     self.exitButton = DirectButton(
         relief=None,
         text=TTLocalizer.PartyTeamActivityExitButton,
         text_fg=(1, 1, 0.65, 1),
         text_pos=(0, -0.15),
         text_scale=0.5,
         image=(upButton, downButton, rolloverButton),
         image_color=(1, 0, 0, 1),
         image_scale=(14.5, 1, 9),
         pos=(0, 0, 0.8),
         scale=0.15,
         command=self.handleExitButtonClick)
     self.exitButton.hide()
     if self.activity.toonsCanSwitchTeams():
         self.switchButton = DirectButton(
             relief=None,
             text=TTLocalizer.PartyTeamActivitySwitchTeamsButton,
             text_fg=(1, 1, 1, 1),
             text_pos=(0, 0.1),
             text_scale=0.5,
             image=(upButton, downButton, rolloverButton),
             image_color=(0, 1, 0, 1),
             image_scale=(15, 1, 15),
             pos=(0, 0, 0.5),
             scale=0.15,
             command=self.handleSwitchButtonClick)
         self.switchButton.hide()
     else:
         self.switchButton = None
     buttonModels.removeNode()
     self.countdownText = OnscreenText(
         text='',
         pos=(0.0, -0.2),
         scale=PartyGlobals.TeamActivityTextScale * 1.2,
         fg=(1.0, 1.0, 0.65, 1.0),
         align=TextNode.ACenter,
         font=ToontownGlobals.getSignFont(),
         mayChange=True)
     self.countdownText.hide()
     self.statusText = OnscreenText(
         text='',
         pos=(0.0, 0.0),
         scale=PartyGlobals.TeamActivityTextScale,
         fg=PartyGlobals.TeamActivityStatusColor,
         align=TextNode.ACenter,
         font=ToontownGlobals.getSignFont(),
         mayChange=True)
     self.statusText.hide()
     self.timer = PartyUtils.getNewToontownTimer()
     self.timer.hide()
     return
예제 #16
0
 def invitePartyClicked(self, item):
     if item.getPythonTag(
             'partyStatus') == PartyGlobals.PartyStatus.Started:
         self.invitePartyGoButton['state'] = DirectGuiGlobals.NORMAL
     else:
         self.invitePartyGoButton['state'] = DirectGuiGlobals.DISABLED
     if self.selectedInvitationItem is not None:
         self.selectedInvitationItem['state'] = DirectGuiGlobals.NORMAL
         self.selectedInvitationItem['text_bg'] = Vec4(0.0, 0.0, 0.0, 0.0)
     self.selectedInvitationItem = item
     self.selectedInvitationItem['state'] = DirectGuiGlobals.DISABLED
     self.selectedInvitationItem['text_bg'] = Vec4(1.0, 1.0, 0.0, 1.0)
     self.fillInviteActivityList(item.getPythonTag('activityIds'))
     startTime = item.getPythonTag('startTime')
     self.invitationDateTimeLabel[
         'text'] = TTLocalizer.EventsPageInvitedTabTime % (
             PartyUtils.formatDate(startTime.year, startTime.month,
                                   startTime.day),
             PartyUtils.formatTime(startTime.hour, startTime.minute))
     return
예제 #17
0
    def loadInvitations(self):
        EventsPage.notify.debug("loadInvitations")
        self.selectedInvitationItem = None
        self.invitationPartyList.removeAndDestroyAllItems()
        self.invitationActivityList.removeAndDestroyAllItems()
        self.invitePartyGoButton["state"] = DirectGuiGlobals.DISABLED
        for partyInfo in base.localAvatar.partiesInvitedTo:
            if (
                partyInfo.status == PartyGlobals.PartyStatus.Cancelled
                or partyInfo.status == PartyGlobals.PartyStatus.Finished
            ):
                continue
            inviteInfo = None
            for inviteInfo in base.localAvatar.invites:
                if partyInfo.partyId == inviteInfo.partyId:
                    break

            if inviteInfo is None:
                EventsPage.notify.error("No invitation info for party id %d" % partyInfo.partyId)
                return
            if inviteInfo.status == PartyGlobals.InviteStatus.NotRead:
                continue
            hostName = self.getToonNameFromAvId(partyInfo.hostId)
            item = DirectButton(
                relief=None,
                text=hostName,
                text_align=TextNode.ALeft,
                text_bg=Vec4(0.0, 0.0, 0.0, 0.0),
                text_scale=0.045,
                textMayChange=True,
                command=self.invitePartyClicked,
            )
            PartyUtils.truncateTextOfLabelBasedOnWidth(item, hostName, PartyGlobals.EventsPageHostNameMaxWidth)
            item["extraArgs"] = [item]
            item.setPythonTag("activityIds", partyInfo.getActivityIds())
            item.setPythonTag("partyStatus", partyInfo.status)
            item.setPythonTag("hostId", partyInfo.hostId)
            item.setPythonTag("startTime", partyInfo.startTime)
            self.invitationPartyList.addItem(item)

        return
예제 #18
0
    def loadInvitations(self):
        EventsPage.notify.debug('loadInvitations')
        self.selectedInvitationItem = None
        self.invitationPartyList.removeAndDestroyAllItems()
        self.invitationActivityList.removeAndDestroyAllItems()
        self.invitePartyGoButton['state'] = DirectGuiGlobals.DISABLED
        for partyInfo in base.localAvatar.partiesInvitedTo:
            if partyInfo.status == PartyGlobals.PartyStatus.Cancelled or partyInfo.status == PartyGlobals.PartyStatus.Finished:
                continue
            inviteInfo = None
            for inviteInfo in base.localAvatar.invites:
                if partyInfo.partyId == inviteInfo.partyId:
                    break

            if inviteInfo is None:
                EventsPage.notify.error('No invitation info for party id %d' %
                                        partyInfo.partyId)
                return
            if inviteInfo.status == PartyGlobals.InviteStatus.NotRead:
                continue
            hostName = self.getToonNameFromAvId(partyInfo.hostId)
            item = DirectButton(relief=None,
                                text=hostName,
                                text_align=TextNode.ALeft,
                                text_bg=Vec4(0.0, 0.0, 0.0, 0.0),
                                text_scale=0.045,
                                textMayChange=True,
                                command=self.invitePartyClicked)
            PartyUtils.truncateTextOfLabelBasedOnWidth(
                item, hostName, PartyGlobals.EventsPageHostNameMaxWidth)
            item['extraArgs'] = [item]
            item.setPythonTag('activityIds', partyInfo.getActivityIds())
            item.setPythonTag('partyStatus', partyInfo.status)
            item.setPythonTag('hostId', partyInfo.hostId)
            item.setPythonTag('startTime', partyInfo.startTime)
            self.invitationPartyList.addItem(item)

        return
예제 #19
0
 def releaseToon(self):
     self._hideFlashMessage()
     self.ignore(base.Move_Left)
     self.ignore('arrow_left-up')
     self.ignore(base.Move_Right)
     self.ignore('arrow_right-up')
     taskMgr.remove(self.uniqueName('TrampolineActivity.updateTask'))
     self.hopOffAnim = Sequence(
         self.toon.hprInterval(0.5,
                               VBase3(-90.0, 0.0, 0.0),
                               other=self.tramp),
         Func(self.toon.b_setAnimState, 'jump', 1.0),
         Func(self.toon.dropShadow.reparentTo, hidden), Wait(0.4),
         PartyUtils.arcPosInterval(0.75, self.toon, self.hopOffPos, 5.0,
                                   self.tramp), Func(self.postHopOff))
     self.hopOffAnim.start()
예제 #20
0
 def acquireToon(self):
     self.toon.disableSmartCameraViews()
     self.toon.stopUpdateSmartCamera()
     camera.wrtReparentTo(render)
     self.toon.dropShadow.reparentTo(hidden)
     self.toon.startPosHprBroadcast(period=0.2)
     self.toonAcceleration = 0.0
     self.toonVelocity = 0.0
     self.topHeight = 0.0
     self.trampB = self.normalTrampB
     self.leavingTrampoline = False
     self.hopOnAnim = Sequence(
         Func(self.toon.b_setAnimState, 'jump', 1.0), Wait(0.4),
         PartyUtils.arcPosInterval(0.75, self.toon,
                                   Point3(0.0, 0.0, self.trampHeight), 5.0,
                                   self.tramp), Func(self.postHopOn))
     self.hopOnAnim.start()
 def load(self):
     buttonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui')
     upButton = buttonModels.find('**//InventoryButtonUp')
     downButton = buttonModels.find('**/InventoryButtonDown')
     rolloverButton = buttonModels.find('**/InventoryButtonRollover')
     self.exitButton = DirectButton(relief=None, text=TTLocalizer.PartyTeamActivityExitButton, text_fg=(1, 1, 0.65, 1), text_pos=(0, -0.15), text_scale=0.5, image=(upButton, downButton, rolloverButton), image_color=(1, 0, 0, 1), image_scale=(14.5, 1, 9), pos=(0, 0, 0.8), scale=0.15, command=self.handleExitButtonClick)
     self.exitButton.hide()
     if self.activity.toonsCanSwitchTeams():
         self.switchButton = DirectButton(relief=None, text=TTLocalizer.PartyTeamActivitySwitchTeamsButton, text_fg=(1, 1, 1, 1), text_pos=(0, 0.1), text_scale=0.5, image=(upButton, downButton, rolloverButton), image_color=(0, 1, 0, 1), image_scale=(15, 1, 15), pos=(0, 0, 0.5), scale=0.15, command=self.handleSwitchButtonClick)
         self.switchButton.hide()
     else:
         self.switchButton = None
     buttonModels.removeNode()
     self.countdownText = OnscreenText(text='', pos=(0.0, -0.2), scale=PartyGlobals.TeamActivityTextScale * 1.2, fg=(1.0, 1.0, 0.65, 1.0), align=TextNode.ACenter, font=ToontownGlobals.getSignFont(), mayChange=True)
     self.countdownText.hide()
     self.statusText = OnscreenText(text='', pos=(0.0, 0.0), scale=PartyGlobals.TeamActivityTextScale, fg=PartyGlobals.TeamActivityStatusColor, align=TextNode.ACenter, font=ToontownGlobals.getSignFont(), mayChange=True)
     self.statusText.hide()
     self.timer = PartyUtils.getNewToontownTimer()
     self.timer.hide()
     return
 def load(self):
     if self.isLoaded():
         return
     guiNode = loader.loadModel('phase_13/models/parties/jukeboxGUI')
     self._timerGui = PartyUtils.getNewToontownTimer()
     self._windowFrame = DirectFrame(image=guiNode.find('**/background'), relief=None, pos=(0, 0, 0), scale=0.7)
     self._songFrame = DirectFrame(image=guiNode.find('**/songTitle_background'), parent=self._windowFrame, relief=None)
     self._currentlyPlayingLabel = self.__createLabel(guiNode, 'currentlyPlaying', parent=self._windowFrame, text=TTLocalizer.JukeboxCurrentlyPlayingNothing, scale=TTLocalizer.JGcurrentlyPlayingLabel)
     self._songNameLabel = self.__createLabel(guiNode, 'songName', parent=self._windowFrame, text=TTLocalizer.JukeboxCurrentSongNothing, scale=TTLocalizer.JGsongNameLabel)
     self._queueList, self._queueLabel = self.__createLabeledScrolledList(guiNode, 'queue', label=TTLocalizer.JukeboxQueueLabel, parent=self._windowFrame)
     self._songsList, self._songsLabel = self.__createLabeledScrolledList(guiNode, 'songs', label=TTLocalizer.JukeboxSongsLabel, parent=self._windowFrame)
     pos = guiNode.find('**/addButton_text_locator').getPos()
     self._addSongButton = self.__createButton(guiNode, 'addSongButton', parent=self._windowFrame, command=self.__handleAddSongButtonClick, image3_color=Vec4(0.6, 0.6, 0.6, 0.6), text=TTLocalizer.JukeboxAddSong, text_align=TextNode.ACenter, text_pos=(pos[0], pos[2]), text_scale=TTLocalizer.JGaddSongButton)
     self._closeButton = self.__createButton(guiNode, 'can_cancelButton', parent=self._windowFrame, command=self.__handleCloseButtonClick)
     pos = guiNode.find('**/close_text_locator').getPos()
     self._closeButton = self.__createButton(guiNode, 'close', parent=self._windowFrame, command=self.__handleCloseButtonClick, text=TTLocalizer.JukeboxClose, text_align=TextNode.ACenter, text_pos=(pos[0], pos[2]), text_scale=0.08)
     self._moveToTopButton = self.__createButton(guiNode, 'moveToTop', command=self.__handleMoveToTopButtonClick)
     guiNode.removeNode()
     self._loaded = True
     return
 def releaseToon(self):
     self._hideFlashMessage()
     self.ignore(base.Move_Left)
     self.ignore('arrow_left-up')
     self.ignore(base.Move_Right)
     self.ignore('arrow_right-up')
     taskMgr.remove(self.uniqueName('TrampolineActivity.updateTask'))
     self.hopOffAnim = Sequence(self.toon.hprInterval(0.5, VBase3(-90.0, 0.0, 0.0), other=self.tramp), Func(self.toon.b_setAnimState, 'jump', 1.0), Func(self.toon.dropShadow.reparentTo, hidden), Wait(0.4), PartyUtils.arcPosInterval(0.75, self.toon, self.hopOffPos, 5.0, self.tramp), Func(self.postHopOff))
     self.hopOffAnim.start()
예제 #24
0
 def _createTimePage(self):
     page = DirectFrame(self.frame)
     page.setName('PartyPlannerTimePage')
     self.createTimeTitleLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerTimeTitle, pos=self.gui.find('**/title_locator').getPos(), scale=self.titleScale)
     self.clockImage = DirectFrame(parent=page, relief=None, geom=self.gui.find('**/toontownTime_background'))
     self.timePageToontownLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerTimeToontown, pos=self.gui.find('**/step_03_toontown_locator').getPos(), scale=0.15, text_fg=(1.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getSignFont())
     self.timePageTimeLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerTimeTime, pos=self.gui.find('**/step_03_time_locator').getPos(), scale=0.15, text_fg=(1.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getSignFont())
     self.timePageRecapLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerTimeRecap, pos=self.gui.find('**/step_03_partyDateAndTime_locator').getPos(), scale=0.09)
     self.timePageRecapToontownTimeLabel1 = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerTimeToontownTime, pos=self.gui.find('**/step_03_toontownTime_locator').getPos(), scale=0.06)
     self.timePageRecapToontownTimeLabel2 = DirectLabel(parent=page, relief=None, text='%s' % PartyUtils.formatDateTime(self.partyTime), pos=self.gui.find('**/step_03_toontownDateAndTime_loactor').getPos(), textMayChange=True, scale=0.06)
     self.timePageRecapLocalTimeLabel = DirectLabel(parent=page, relief=None, text='%s%s' % (TTLocalizer.PartyPlannerTimeLocalTime, PartyUtils.formatDateTime(self.partyTime, inLocalTime=True)), pos=self.gui.find('**/step_03_localDateAndTime_loactor').getPos(), textMayChange=True, scale=0.06, text_fg=(1.0, 0.0, 0.0, 1.0))
     self.timeInputHourLabel, self.timeInputHourUpButton, self.timeInputHourDownButton = self.getTimeWidgets(page, 'hour')
     self.timeInputMinuteLabel, self.timeInputMinuteUpButton, self.timeInputMinuteDownButton = self.getTimeWidgets(page, 'minute')
     self.timeInputAmPmLabel, self.timeInputAmPmUpButton, self.timeInputAmPmDownButton = self.getTimeWidgets(page, 'ampm')
     self.timePagecolonLabel = DirectLabel(parent=page, relief=None, text=':', pos=self.gui.find('**/step_03_colon_locator').getPos(), scale=0.15)
     return page
예제 #25
0
    def loadHostedPartyInfo(self):
        self.unloadGuests()
        self.unloadActivities()
        self.unloadDecorations()
        self.hostedPartyInfo = None
        self.confirmCancelPartyGui.doneStatus = ""
        self.confirmCancelPartyGui.hide()
        self.cancelPartyResultGui.doneStatus = ""
        self.cancelPartyResultGui.hide()
        if base.localAvatar.hostedParties is not None and len(base.localAvatar.hostedParties) > 0:
            for partyInfo in base.localAvatar.hostedParties:
                if (
                    partyInfo.status == PartyGlobals.PartyStatus.Pending
                    or partyInfo.status == PartyGlobals.PartyStatus.CanStart
                    or partyInfo.status == PartyGlobals.PartyStatus.NeverStarted
                    or partyInfo.status == PartyGlobals.PartyStatus.Started
                ):
                    self.hostedPartyInfo = partyInfo
                    self.loadGuests()
                    self.loadActivities()
                    self.loadDecorations()
                    self.hostingDateLabel["text"] = TTLocalizer.EventsPageHostTabDateTimeLabel % (
                        PartyUtils.formatDate(
                            partyInfo.startTime.year, partyInfo.startTime.month, partyInfo.startTime.day
                        ),
                        PartyUtils.formatTime(partyInfo.startTime.hour, partyInfo.startTime.minute),
                    )
                    self.isPrivate = partyInfo.isPrivate
                    self.__setPublicPrivateButton()
                    if partyInfo.status == PartyGlobals.PartyStatus.CanStart:
                        self.partyGoButton["state"] = DirectGuiGlobals.NORMAL
                        self.partyGoButton["text"] = (TTLocalizer.EventsPageGoButton,)
                    elif partyInfo.status == PartyGlobals.PartyStatus.Started:
                        place = base.cr.playGame.getPlace()
                        if isinstance(place, Party):
                            if hasattr(base, "distributedParty"):
                                if base.distributedParty.partyInfo.hostId == base.localAvatar.doId:
                                    self.partyGoButton["state"] = DirectGuiGlobals.DISABLED
                                else:
                                    self.partyGoButton["state"] = DirectGuiGlobals.NORMAL
                            else:
                                self.partyGoButton["state"] = DirectGuiGlobals.NORMAL
                                self.notify.warning(
                                    "base.distributedParty is not defined when base.cr.playGame.getPlace is party. This should never happen."
                                )
                        else:
                            self.partyGoButton["state"] = DirectGuiGlobals.NORMAL
                        self.partyGoButton["text"] = (TTLocalizer.EventsPageGoBackButton,)
                    else:
                        self.partyGoButton["text"] = (TTLocalizer.EventsPageGoButton,)
                        self.partyGoButton["state"] = DirectGuiGlobals.DISABLED
                    if partyInfo.status not in (PartyGlobals.PartyStatus.Pending, PartyGlobals.PartyStatus.CanStart):
                        self.hostingCancelButton["state"] = DirectGuiGlobals.DISABLED
                    else:
                        self.hostingCancelButton["state"] = DirectGuiGlobals.NORMAL
                    self.hostingDateLabel.show()
                    self.hostedPartyDisplay.show()
                    return

        self.hostingDateLabel["text"] = TTLocalizer.EventsPageHostingTabNoParty
        self.hostingCancelButton["state"] = DirectGuiGlobals.DISABLED
        self.partyGoButton["state"] = DirectGuiGlobals.DISABLED
        self.publicButton["state"] = DirectGuiGlobals.DISABLED
        self.privateButton["state"] = DirectGuiGlobals.DISABLED
        self.hostedPartyDisplay.show()
        return
예제 #26
0
    def loadHostedPartyInfo(self):
        self.unloadGuests()
        self.unloadActivities()
        self.unloadDecorations()
        self.hostedPartyInfo = None
        self.confirmCancelPartyGui.doneStatus = ''
        self.confirmCancelPartyGui.hide()
        self.cancelPartyResultGui.doneStatus = ''
        self.cancelPartyResultGui.hide()
        if base.localAvatar.hostedParties is not None and len(
                base.localAvatar.hostedParties) > 0:
            for partyInfo in base.localAvatar.hostedParties:
                if partyInfo.status == PartyGlobals.PartyStatus.Pending or partyInfo.status == PartyGlobals.PartyStatus.CanStart or partyInfo.status == PartyGlobals.PartyStatus.NeverStarted or partyInfo.status == PartyGlobals.PartyStatus.Started:
                    self.hostedPartyInfo = partyInfo
                    self.loadGuests()
                    self.loadActivities()
                    self.loadDecorations()
                    self.hostingDateLabel[
                        'text'] = TTLocalizer.EventsPageHostTabDateTimeLabel % (
                            PartyUtils.formatDate(partyInfo.startTime.year,
                                                  partyInfo.startTime.month,
                                                  partyInfo.startTime.day),
                            PartyUtils.formatTime(partyInfo.startTime.hour,
                                                  partyInfo.startTime.minute))
                    self.isPrivate = partyInfo.isPrivate
                    self.__setPublicPrivateButton()
                    if partyInfo.status == PartyGlobals.PartyStatus.CanStart:
                        self.partyGoButton['state'] = DirectGuiGlobals.NORMAL
                        self.partyGoButton['text'] = (
                            TTLocalizer.EventsPageGoButton, )
                    elif partyInfo.status == PartyGlobals.PartyStatus.Started:
                        place = base.cr.playGame.getPlace()
                        if isinstance(place, Party):
                            if hasattr(base, 'distributedParty'):
                                if base.distributedParty.partyInfo.hostId == base.localAvatar.doId:
                                    self.partyGoButton[
                                        'state'] = DirectGuiGlobals.DISABLED
                                else:
                                    self.partyGoButton[
                                        'state'] = DirectGuiGlobals.NORMAL
                            else:
                                self.partyGoButton[
                                    'state'] = DirectGuiGlobals.NORMAL
                                self.notify.warning(
                                    'base.distributedParty is not defined when base.cr.playGame.getPlace is party. This should never happen.'
                                )
                        else:
                            self.partyGoButton[
                                'state'] = DirectGuiGlobals.NORMAL
                        self.partyGoButton['text'] = (
                            TTLocalizer.EventsPageGoBackButton, )
                    else:
                        self.partyGoButton['text'] = (
                            TTLocalizer.EventsPageGoButton, )
                        self.partyGoButton['state'] = DirectGuiGlobals.DISABLED
                    if partyInfo.status not in (
                            PartyGlobals.PartyStatus.Pending,
                            PartyGlobals.PartyStatus.CanStart):
                        self.hostingCancelButton[
                            'state'] = DirectGuiGlobals.DISABLED
                    else:
                        self.hostingCancelButton[
                            'state'] = DirectGuiGlobals.NORMAL
                    self.hostingDateLabel.show()
                    self.hostedPartyDisplay.show()
                    return

        self.hostingDateLabel['text'] = TTLocalizer.EventsPageHostingTabNoParty
        self.hostingCancelButton['state'] = DirectGuiGlobals.DISABLED
        self.partyGoButton['state'] = DirectGuiGlobals.DISABLED
        self.publicButton['state'] = DirectGuiGlobals.DISABLED
        self.privateButton['state'] = DirectGuiGlobals.DISABLED
        self.hostedPartyDisplay.show()
        return
예제 #27
0
    def load(self):
        if self.__loaded:
            return
        self.__timerPad = PartyUtils.getNewToontownTimer()
        guiModel = 'phase_4/models/gui/cannon_game_gui'
        guiNode = loader.loadModel(guiModel)
        self.__aimPad = DirectFrame(image=guiNode.find('**/CannonFire_PAD'),
                                    relief=None,
                                    pos=(0.7, 0, -0.553333),
                                    scale=0.8)
        guiNode.removeNode()
        self.fireButton = DirectButton(parent=self.__aimPad,
                                       image=((guiModel, '**/Fire_Btn_UP'),
                                              (guiModel, '**/Fire_Btn_DN'),
                                              (guiModel, '**/Fire_Btn_RLVR')),
                                       relief=None,
                                       pos=(0.0115741, 0, 0.00505051),
                                       scale=1.0,
                                       command=self.__firePressed)
        self.upButton = DirectButton(parent=self.__aimPad,
                                     image=((guiModel, '**/Cannon_Arrow_UP'),
                                            (guiModel, '**/Cannon_Arrow_DN'),
                                            (guiModel,
                                             '**/Cannon_Arrow_RLVR')),
                                     relief=None,
                                     pos=(0.0115741, 0, 0.221717))
        self.downButton = DirectButton(parent=self.__aimPad,
                                       image=((guiModel, '**/Cannon_Arrow_UP'),
                                              (guiModel, '**/Cannon_Arrow_DN'),
                                              (guiModel,
                                               '**/Cannon_Arrow_RLVR')),
                                       relief=None,
                                       pos=(0.0136112, 0, -0.210101),
                                       image_hpr=(0, 0, 180))
        self.leftButton = DirectButton(parent=self.__aimPad,
                                       image=((guiModel, '**/Cannon_Arrow_UP'),
                                              (guiModel, '**/Cannon_Arrow_DN'),
                                              (guiModel,
                                               '**/Cannon_Arrow_RLVR')),
                                       relief=None,
                                       pos=(-0.199352, 0, -0.000505269),
                                       image_hpr=(0, 0, -90))
        self.rightButton = DirectButton(
            parent=self.__aimPad,
            image=((guiModel, '**/Cannon_Arrow_UP'),
                   (guiModel, '**/Cannon_Arrow_DN'), (guiModel,
                                                      '**/Cannon_Arrow_RLVR')),
            relief=None,
            pos=(0.219167, 0, -0.00101024),
            image_hpr=(0, 0, 90))
        self.__aimPad.setColor(1, 1, 1, 0.9)

        def bindButton(button, upHandler, downHandler):
            button.bind(DGG.B1PRESS, lambda x, handler=upHandler: handler())
            button.bind(DGG.B1RELEASE,
                        lambda x, handler=downHandler: handler())

        bindButton(self.upButton, self.__upPressed, self.__upReleased)
        bindButton(self.downButton, self.__downPressed, self.__downReleased)
        bindButton(self.leftButton, self.__leftPressed, self.__leftReleased)
        bindButton(self.rightButton, self.__rightPressed, self.__rightReleased)
        self.__loaded = True
        return
예제 #28
0
 def load(self):
     if self.isLoaded():
         return
     guiNode = loader.loadModel('phase_13/models/parties/jukeboxGUI')
     self._timerGui = PartyUtils.getNewToontownTimer()
     self._windowFrame = DirectFrame(image=guiNode.find('**/background'),
                                     relief=None,
                                     pos=(0, 0, 0),
                                     scale=0.7)
     self._songFrame = DirectFrame(
         image=guiNode.find('**/songTitle_background'),
         parent=self._windowFrame,
         relief=None)
     self._currentlyPlayingLabel = self.__createLabel(
         guiNode,
         'currentlyPlaying',
         parent=self._windowFrame,
         text=TTLocalizer.JukeboxCurrentlyPlayingNothing,
         scale=TTLocalizer.JGcurrentlyPlayingLabel)
     self._songNameLabel = self.__createLabel(
         guiNode,
         'songName',
         parent=self._windowFrame,
         text=TTLocalizer.JukeboxCurrentSongNothing,
         scale=TTLocalizer.JGsongNameLabel)
     self._queueList, self._queueLabel = self.__createLabeledScrolledList(
         guiNode,
         'queue',
         label=TTLocalizer.JukeboxQueueLabel,
         parent=self._windowFrame)
     self._songsList, self._songsLabel = self.__createLabeledScrolledList(
         guiNode,
         'songs',
         label=TTLocalizer.JukeboxSongsLabel,
         parent=self._windowFrame)
     pos = guiNode.find('**/addButton_text_locator').getPos()
     self._addSongButton = self.__createButton(
         guiNode,
         'addSongButton',
         parent=self._windowFrame,
         command=self.__handleAddSongButtonClick,
         image3_color=Vec4(0.6, 0.6, 0.6, 0.6),
         text=TTLocalizer.JukeboxAddSong,
         text_align=TextNode.ACenter,
         text_pos=(pos[0], pos[2]),
         text_scale=TTLocalizer.JGaddSongButton)
     self._closeButton = self.__createButton(
         guiNode,
         'can_cancelButton',
         parent=self._windowFrame,
         command=self.__handleCloseButtonClick)
     pos = guiNode.find('**/close_text_locator').getPos()
     self._closeButton = self.__createButton(
         guiNode,
         'close',
         parent=self._windowFrame,
         command=self.__handleCloseButtonClick,
         text=TTLocalizer.JukeboxClose,
         text_align=TextNode.ACenter,
         text_pos=(pos[0], pos[2]),
         text_scale=0.08)
     self._moveToTopButton = self.__createButton(
         guiNode, 'moveToTop', command=self.__handleMoveToTopButtonClick)
     guiNode.removeNode()
     self._loaded = True
     return
 def updateInvitation(self, hostsName, partyInfo):
     self.partyInfo = partyInfo
     hostsName = TTLocalizer.GetPossesive(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)
    def fillActivityList(self, activityIds):
        self.activityList.removeAndDestroyAllItems()
        sortedList = activityIds[:]
        sortedList.sort()
        lastActivityId = -1
        for activityId in sortedList:
            if activityId == lastActivityId:
                continue
            lastActivityId = activityId
            number = sortedList.count(activityId)
            text = TTLocalizer.PartyActivityNameDict[activityId]['generic']
            if number > 1:
                text += ' X %d' % number
            item = DirectLabel(relief=None, text=text, text_align=TextNode.ACenter, text_scale=0.05, text_pos=(0.0, -0.15), geom_scale=0.3, geom_pos=Vec3(0.0, 0.0, 0.07), geom=PartyUtils.getPartyActivityIcon(self.activityIconsModel, PartyGlobals.ActivityIds.getString(activityId)))
            self.activityList.addItem(item)

        return
    def refresh(self, partyInfoTupleList):
        PublicPartyGui.notify.debug('refresh : partyInfoTupleList = %s' % partyInfoTupleList)
        self.selectedItem = None
        self.partyList.removeAndDestroyAllItems()
        self.activityList.removeAndDestroyAllItems()
        self.partyStartButton['state'] = DirectGuiGlobals.DISABLED
        sortedList = partyInfoTupleList[:]

        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)
        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]
            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.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)

        return
 def acquireToon(self):
     self.toon.disableSmartCameraViews()
     self.toon.stopUpdateSmartCamera()
     camera.wrtReparentTo(render)
     self.toon.dropShadow.reparentTo(hidden)
     self.toon.startPosHprBroadcast(period=0.2)
     self.toonAcceleration = 0.0
     self.toonVelocity = 0.0
     self.topHeight = 0.0
     self.trampB = self.normalTrampB
     self.leavingTrampoline = False
     self.hopOnAnim = Sequence(Func(self.toon.b_setAnimState, 'jump', 1.0), Wait(0.4), PartyUtils.arcPosInterval(0.75, self.toon, Point3(0.0, 0.0, self.trampHeight), 5.0, self.tramp), Func(self.postHopOn))
     self.hopOnAnim.start()
예제 #33
0
    def refresh(self, partyInfoTupleList):
        PublicPartyGui.notify.debug('refresh : partyInfoTupleList = %s' %
                                    partyInfoTupleList)
        self.selectedItem = None
        self.partyList.removeAndDestroyAllItems()
        self.activityList.removeAndDestroyAllItems()
        self.partyStartButton['state'] = DirectGuiGlobals.DISABLED
        sortedList = partyInfoTupleList[:]

        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)
        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]
            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.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)

        return