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 generate(self): DistributedObjectAI.generate(self) actId2Class = {ActivityIds.PartyJukebox: DistributedPartyJukeboxActivityAI, ActivityIds.PartyTrampoline: DistributedPartyTrampolineActivityAI, ActivityIds.PartyVictoryTrampoline: DistributedPartyVictoryTrampolineActivityAI, ActivityIds.PartyCatch: DistributedPartyCatchActivityAI, ActivityIds.PartyDance: DistributedPartyDanceActivityAI, ActivityIds.PartyTugOfWar: DistributedPartyTugOfWarActivityAI, ActivityIds.PartyFireworks: DistributedPartyFireworksActivityAI, ActivityIds.PartyJukebox40: DistributedPartyJukebox40ActivityAI, ActivityIds.PartyDance20: DistributedPartyDance20ActivityAI, ActivityIds.PartyCog: DistributedPartyCogActivityAI} for activity in self.info['activities']: actId = activity[0] if actId in actId2Class: act = actId2Class[actId](self.air, self.doId, activity) act.generateWithRequired(self.zoneId) self.activities.append(act) elif actId == ActivityIds.PartyCannon: if not self.cannonActivity: self.cannonActivity = DistributedPartyCannonActivityAI(self.air, self.doId, activity) self.cannonActivity.generateWithRequired(self.zoneId) act = DistributedPartyCannonAI(self.air) act.setActivityDoId(self.cannonActivity.doId) x, y, h = activity[1:] x = PartyUtils.convertDistanceFromPartyGrid(x, 0) y = PartyUtils.convertDistanceFromPartyGrid(y, 1) h *= PartyGridHeadingConverter act.setPosHpr(x, y, 0, h, 0, 0) act.generateWithRequired(self.zoneId) self.activities.append(act)
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))
def announceGenerate(self): DistributedObject.DistributedObject.announceGenerate(self) self.sendUpdate('enteredParty', []) globalClock.syncFrameTime() self.startPartyClock() base.localAvatar.chatMgr.chatInputSpeedChat.addInsidePartiesMenu() self.spawnTitleText() messenger.send(self.generatedEvent) if config.GetBool('show-debug-party-grid', 0): self.testGrid = NodePath('test_grid') self.testGrid.reparentTo(base.cr.playGame.hood.loader.geom) for i in xrange(len(self.grid)): for j in xrange(len(self.grid[i])): cm = CardMaker('gridsquare') np = NodePath(cm.generate()) np.setScale(12) np.setP(-90.0) np.setPos( PartyUtils.convertDistanceFromPartyGrid(j, 0) - 6.0, PartyUtils.convertDistanceFromPartyGrid(i, 1) - 6.0, 0.1) np.reparentTo(self.testGrid) if self.grid[i][j]: np.setColorScale(0.0, 1.0, 0.0, 1.0) else: np.setColorScale(1.0, 0.0, 0.0, 1.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
def __init__(self, air, parent, activityTuple): DistributedObjectAI.__init__(self, air) self.parent = parent x, y, h = activityTuple[1:] # ignore activity ID self.x = PartyUtils.convertDistanceFromPartyGrid(x, 0) self.y = PartyUtils.convertDistanceFromPartyGrid(y, 1) self.h = h * PartyGlobals.PartyGridHeadingConverter self.toonsPlaying = []
def __init__(self, air, parent, activityTuple): DistributedObjectAI.__init__(self, air) self.parent = parent x, y, h = activityTuple[1:] self.x = PartyUtils.convertDistanceFromPartyGrid(x, 0) self.y = PartyUtils.convertDistanceFromPartyGrid(y, 1) self.h = h * PartyGlobals.PartyGridHeadingConverter self.toonsPlaying = []
def loadDecorations(self): self.decorationsList = [] for decorBase in self.partyInfo.decors: self.decorationsList.append( Decoration( PartyGlobals.DecorationIds.getString(decorBase.decorId), PartyUtils.convertDistanceFromPartyGrid(decorBase.x, 0), PartyUtils.convertDistanceFromPartyGrid(decorBase.y, 1), PartyUtils.convertDegreesFromPartyGrid(decorBase.h)))
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)
def getClearSquarePositions(self): clearPositions = [] for y in xrange(len(self.grid)): for x in xrange(len(self.grid[0])): if self.grid[y][x]: pos = (PartyUtils.convertDistanceFromPartyGrid(x, 0), PartyUtils.convertDistanceFromPartyGrid(y, 1), 0.1) clearPositions.append(pos) return clearPositions
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))
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 getCorrectRotation(self): """ Since the y value is inverted in our grid, we need to flip the rotation of elements that are to either side, but not top/bottom. """ 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)
def generate(self): DistributedPartyAI.notify.debug("DistParty generate: %s" % self.doId) DistributedObjectAI.generate(self) self.air.writeServerEvent("party_generate", self.partyInfo.partyId, "%d|%d" % (self.doId, self.partyInfo.hostId)) # Log that a GM party has been generated. try: host = simbase.air.doId2do.get(self.partyInfo.hostId) if host.hasGMName(): self.air.writeServerEvent("party_generate_gm", self.partyInfo.partyId, "%s" % self.partyInfo.hostId) assert self.notify.debug("GM-%s's party has started." % self.partyInfo.hostId) except: pass # We want to initialize all the activities that are at this party. # We'll loop through the activityList and see if we can import, create, # and generate the relevant AI class. This code assumes that the # activity classes are named according to the enum # PartyGlobals.ActivityIds # for example: # PartyGlobals.ActivityIds.PartyCatch would load # DistributedPartyCatchActivityAI for activity in self.partyInfo.activityList: # Location and heading in the activityList is in party space, so # we convert them to Panda space before passing them into the # activities #activityName = PartyGlobals.ActivityIds.getString(activity.activityId) x = PartyUtils.convertDistanceFromPartyGrid(activity.x, 0) y = PartyUtils.convertDistanceFromPartyGrid(activity.y, 1) h = PartyUtils.convertDegreesFromPartyGrid(activity.h) # Skip the party clock... if activity.activityId == PartyGlobals.ActivityIds.PartyClock: continue # Special case for cannon, add another cannon instead of creating # a new instance of the cannon activity if activity.activityId == PartyGlobals.ActivityIds.PartyCannon and \ self.getCannonActivity(): self.getCannonActivity().spawnCannonAt(x, y, h) continue actClass = ActivityIdsToClasses[activity.activityId] newAct = actClass(self.air, self.doId, x, y, h) newAct.generateWithRequired(self.zoneId) self.activityObjects.append(newAct)
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
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))
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)
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
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))
def handleToonExited(self, toonId): DistributedPartyTeamActivity.handleToonExited(self, toonId) if toonId == base.localAvatar.doId: self.cameraMoveIval.pause() if toonId not in self.fallenToons: if toonId in self.toonIdsToAnimIntervals and self.toonIdsToAnimIntervals[ toonId] is not None: self.toonIdsToAnimIntervals[toonId].finish() toon = self.getAvatar(toonId) targetH = fitDestAngle2Src(toon.getH(self.root), 180.0) targetPos = self.hopOffPositions[self.getTeam(toonId)][ self.getIndex(toonId, self.getTeam(toonId))] hopOffAnim = Sequence( Func(toon.startPosHprBroadcast, 0.1), toon.hprInterval(0.2, VBase3(targetH, 0.0, 0.0), other=self.root), Func(toon.b_setAnimState, 'jump', 1.0), Wait(0.4), PartyUtils.arcPosInterval(0.75, toon, targetPos, 5.0, self.root), Func(toon.stopPosHprBroadcast), Func(toon.sendCurrentPosition), Func(self.hopOffFinished, toonId)) self.toonIdsToAnimIntervals[toonId] = hopOffAnim self._hopOffFinishedSV.set(False) self.toonIdsToAnimIntervals[toonId].start() else: self._hopOffFinishedSV.set(True) del self.toonIdsToAnimIntervals[toonId]
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 loadGUI( self ): self.gui = loader.loadModel("phase_13/models/parties/trampolineGUI") self.gui.setX(-1.15) self.gui.reparentTo( self.screenPlaneElements ) 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() # sadly, the white jelly bean is named GreenJellyBean self.guiBeans = [guiBean.instanceUnderNode( jumpLineLocator, self.uniqueName( "guiBean%d" % i ) ) for i in range( 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=self.screenPlaneElements, 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=(1.15, 0, 0.6), 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.reparentTo(self.screenPlaneElements)
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 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
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
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, 3.6), 5.0, self.tramp), Func(self.postHopOn)) self.hopOnAnim.start()
def releaseToon(self): self._hideFlashMessage() self.ignore('arrow_left') self.ignore('arrow_left-up') self.ignore('arrow_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()
def releaseToon(self): self._hideFlashMessage() self.ignore("arrow_left") self.ignore("arrow_left-up") self.ignore("arrow_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()
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): 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
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 None 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.69999999999999996) self._songFrame = DirectFrame(image = guiNode.find('**/songTitle_background'), parent = self._windowFrame, relief = None) self._currentlyPlayingLabel = self._JukeboxGui__createLabel(guiNode, 'currentlyPlaying', parent = self._windowFrame, text = TTLocalizer.JukeboxCurrentlyPlayingNothing, scale = TTLocalizer.JGcurrentlyPlayingLabel) self._songNameLabel = self._JukeboxGui__createLabel(guiNode, 'songName', parent = self._windowFrame, text = TTLocalizer.JukeboxCurrentSongNothing, scale = TTLocalizer.JGsongNameLabel) (self._queueList, self._queueLabel) = self._JukeboxGui__createLabeledScrolledList(guiNode, 'queue', label = TTLocalizer.JukeboxQueueLabel, parent = self._windowFrame) (self._songsList, self._songsLabel) = self._JukeboxGui__createLabeledScrolledList(guiNode, 'songs', label = TTLocalizer.JukeboxSongsLabel, parent = self._windowFrame) pos = guiNode.find('**/addButton_text_locator').getPos() self._addSongButton = self._JukeboxGui__createButton(guiNode, 'addSongButton', parent = self._windowFrame, command = self._JukeboxGui__handleAddSongButtonClick, image3_color = Vec4(0.59999999999999998, 0.59999999999999998, 0.59999999999999998, 0.59999999999999998), text = TTLocalizer.JukeboxAddSong, text_align = TextNode.ACenter, text_pos = (pos[0], pos[2]), text_scale = TTLocalizer.JGaddSongButton) self._closeButton = self._JukeboxGui__createButton(guiNode, 'can_cancelButton', parent = self._windowFrame, command = self._JukeboxGui__handleCloseButtonClick) pos = guiNode.find('**/close_text_locator').getPos() self._closeButton = self._JukeboxGui__createButton(guiNode, 'close', parent = self._windowFrame, command = self._JukeboxGui__handleCloseButtonClick, text = TTLocalizer.JukeboxClose, text_align = TextNode.ACenter, text_pos = (pos[0], pos[2]), text_scale = 0.080000000000000002) self._moveToTopButton = self._JukeboxGui__createButton(guiNode, 'moveToTop', command = self._JukeboxGui__handleMoveToTopButtonClick) guiNode.removeNode() self._loaded = True
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
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
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
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 load(self): """ Loads the Jukebox GUI model and initializes the lists, buttons and labels """ if self.isLoaded(): return guiNode = loader.loadModel("phase_13/models/parties/jukeboxGUI") # Timer self._timerGui = PartyUtils.getNewToontownTimer() # Window self._windowFrame = DirectFrame( image=guiNode.find("**/background"), relief=None, pos=(0, 0, 0), scale=0.7, ) # Dashboard 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, ) # Playlist Queue self._queueList, self._queueLabel = self.__createLabeledScrolledList( guiNode, "queue", label=TTLocalizer.JukeboxQueueLabel, parent=self._windowFrame, ) # Song List 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
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
def load(self): if self.__loaded: return # Load Timer self.__timerPad = PartyUtils.getNewToontownTimer() # set up the cannon aiming/firing gui 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() # Set up the fire and arrow buttons 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., 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), ) # Make the aim pad semi transparent self.__aimPad.setColor(1,1,1, 0.9) # Set up the button press/release handlers # Buttons have the ability send signal as long as they're pressed. 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
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)
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 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 setPartyClockInfo(self, x, y, h): x = PartyUtils.convertDistanceFromPartyGrid(x, 0) y = PartyUtils.convertDistanceFromPartyGrid(y, 1) h = PartyUtils.convertDegreesFromPartyGrid(h) self.partyClockInfo = (x, y, h) self.loadPartyCountdownTimer()
def releaseToon(self): self._hideFlashMessage() self.ignore(base.Move_Left) self.ignore(base.Move_Left + '-up') self.ignore(base.Move_Right) self.ignore(base.Move_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()
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 if 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)