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 __setupNamePlateCustom(self): self.notify.debug("__setupNamePlateCustom") # name plate above door if self.namePlate: self.namePlate.removeNode() del self.namePlate self.namePlate = None nameText = TextNode('nameText') nameText.setCardAsMargin(0.1, 0.1, 0.1, 0.1) nameText.setCardDecal(True) nameText.setCardColor(1.0, 1.0, 1.0, 0.0) r = self.randomGenerator.random() g = self.randomGenerator.random() b = self.randomGenerator.random() nameText.setTextColor(r, g, b, 1) nameText.setAlign(nameText.ACenter) nameText.setFont(ToontownGlobals.getBuildingNametagFont()) nameText.setShadowColor(0, 0, 0, 1) nameText.setBin('fixed') if TTLocalizer.BuildingNametagShadow: nameText.setShadow(*TTLocalizer.BuildingNametagShadow) nameText.setWordwrap(16.0) xScale = 1.0 numLines = 0 if (self.name == ""): # don't bother putting an empty string up return else: # make the name fit nicely on the floor mat houseName = TTLocalizer.AvatarsHouse % TTLocalizer.GetPossesive( self.name) nameText.setText(houseName) self.nameText = nameText # Since the text is wordwrapped, it may flow over more # than one line. Try to adjust the scale and position of # the sign accordingly. textHeight = nameText.getHeight() - 2 textWidth = nameText.getWidth() xScale = 1.0 if textWidth > 16: xScale = 16.0 / textWidth sign_origin = self.house.find("**/sign_origin") #debugAxis = loader.loadModel("models/misc/xyzAxis") #debugAxis.reparentTo(sign_origin) #debugAxis.wrtReparentTo(render) pos = sign_origin.getPos() sign_origin.setPosHpr(pos[0], pos[1], pos[2] + .15 * textHeight, 90, 0, 0) self.namePlate = sign_origin.attachNewNode(self.nameText) self.namePlate.setDepthWrite(0) self.namePlate.setPos(0, -0.05, 0) self.namePlate.setScale(xScale) return nameText
def spawnTitleText(self): """Spawn the title text.""" if not self.hostName: # potentially we don't have the host name yet return partyText = TTLocalizer.PartyTitleText % TTLocalizer.GetPossesive(self.hostName) self.doSpawnTitleText(partyText)
def __setupFloorMat(self, changeColor=True): if self.floorMat: self.floorMat.removeNode() del self.floorMat self.floorMat = None mat = self.house.find("**/mat") if changeColor: mat.setColor(0.400, 0.357, 0.259, 1.000) color = HouseGlobals.houseColors[self.housePosInd] matText = TextNode('matText') matText.setTextColor(color[0], color[1], color[2], 1) matText.setAlign(matText.ACenter) matText.setFont(ToontownGlobals.getBuildingNametagFont()) matText.setShadowColor(0, 0, 0, 1) matText.setBin('fixed') if TTLocalizer.BuildingNametagShadow: matText.setShadow(*TTLocalizer.BuildingNametagShadow) matText.setWordwrap(10.0) xScale = 1.0 numLines = 0 if (self.name == ""): # don't bother putting an empty string up return else: # make the name fit nicely on the floor mat houseName = TTLocalizer.AvatarsHouse % TTLocalizer.GetPossesive( self.name) matText.setText(houseName) self.matText = matText # Since the text is wordwrapped, it may flow over more # than one line. Try to adjust the scale and position of # the sign accordingly. textHeight = matText.getHeight() - 2 textWidth = matText.getWidth() xScale = 1.0 if textWidth > 8: xScale = 8.0 / textWidth mat_origin = self.house.find("**/mat_origin") pos = mat_origin.getPos() mat_origin.setPosHpr(pos[0] - .15 * textHeight, pos[1], pos[2], 90, -90, 0) self.floorMat = mat_origin.attachNewNode(self.matText) self.floorMat.setDepthWrite(0) self.floorMat.setPos(0, -.025, 0) self.floorMat.setScale(.45 * xScale)
def _DistributedHouse__setupNamePlateCustom(self): self.notify.debug('__setupNamePlateCustom') if self.namePlate: self.namePlate.removeNode() del self.namePlate self.namePlate = None nameText = TextNode('nameText') nameText.setCardAsMargin(0.10000000000000001, 0.10000000000000001, 0.10000000000000001, 0.10000000000000001) nameText.setCardDecal(True) nameText.setCardColor(1.0, 1.0, 1.0, 0.0) r = self.randomGenerator.random() g = self.randomGenerator.random() b = self.randomGenerator.random() nameText.setTextColor(r, g, b, 1) nameText.setAlign(nameText.ACenter) nameText.setFont(ToontownGlobals.getBuildingNametagFont()) nameText.setShadowColor(0, 0, 0, 1) nameText.setBin('fixed') if TTLocalizer.BuildingNametagShadow: nameText.setShadow(*TTLocalizer.BuildingNametagShadow) nameText.setWordwrap(16.0) xScale = 1.0 numLines = 0 if self.name == '': return None else: houseName = TTLocalizer.AvatarsHouse % TTLocalizer.GetPossesive(self.name) nameText.setText(houseName) self.nameText = nameText textHeight = nameText.getHeight() - 2 textWidth = nameText.getWidth() xScale = 1.0 if textWidth > 16: xScale = 16.0 / textWidth sign_origin = self.house.find('**/sign_origin') pos = sign_origin.getPos() sign_origin.setPosHpr(pos[0], pos[1], pos[2] + 0.14999999999999999 * textHeight, 90, 0, 0) self.namePlate = sign_origin.attachNewNode(self.nameText) self.namePlate.setDepthWrite(0) self.namePlate.setPos(0, -0.050000000000000003, 0) self.namePlate.setScale(xScale) return nameText
def __setupNametag(self): if self.nametag: self.clearNametag() if self.name == '': houseName = '' else: houseName = TTLocalizer.AvatarsHouse % TTLocalizer.GetPossesive(self.name) self.nametag = NametagGroup() self.nametag.setFont(ToontownGlobals.getBuildingNametagFont()) if TTLocalizer.BuildingNametagShadow: self.nametag.setShadow(*TTLocalizer.BuildingNametagShadow) self.nametag.setContents(Nametag.CName) self.nametag.setColorCode(NametagGroup.CCToonBuilding) self.nametag.setActive(0) self.nametag.setAvatar(self.house) self.nametag.setObjectCode(self.doId) self.nametag.setName(houseName) self.nametag.manage(base.marginManager)
def _DistributedHouse__setupFloorMat(self, changeColor = True): if self.floorMat: self.floorMat.removeNode() del self.floorMat self.floorMat = None mat = self.house.find('**/mat') if changeColor: mat.setColor(0.40000000000000002, 0.35699999999999998, 0.25900000000000001, 1.0) color = HouseGlobals.houseColors[self.housePosInd] matText = TextNode('matText') matText.setTextColor(color[0], color[1], color[2], 1) matText.setAlign(matText.ACenter) matText.setFont(ToontownGlobals.getBuildingNametagFont()) matText.setShadowColor(0, 0, 0, 1) matText.setBin('fixed') if TTLocalizer.BuildingNametagShadow: matText.setShadow(*TTLocalizer.BuildingNametagShadow) matText.setWordwrap(10.0) xScale = 1.0 numLines = 0 if self.name == '': return None else: houseName = TTLocalizer.AvatarsHouse % TTLocalizer.GetPossesive(self.name) matText.setText(houseName) self.matText = matText textHeight = matText.getHeight() - 2 textWidth = matText.getWidth() xScale = 1.0 if textWidth > 8: xScale = 8.0 / textWidth mat_origin = self.house.find('**/mat_origin') pos = mat_origin.getPos() mat_origin.setPosHpr(pos[0] - 0.14999999999999999 * textHeight, pos[1], pos[2], 90, -90, 0) self.floorMat = mat_origin.attachNewNode(self.matText) self.floorMat.setDepthWrite(0) self.floorMat.setPos(0, -0.025000000000000001, 0) self.floorMat.setScale(0.45000000000000001 * xScale)
def __setupNametag(self): if self.nametag: self.clearNametag() if self.name == '': houseName = '' else: houseName = TTLocalizer.AvatarsHouse % TTLocalizer.GetPossesive(self.name) self.nametag = NametagGroup() self.nametag.setNametag3d(None) self.nametag.setFont(ToontownGlobals.getBuildingNametagFont()) if TTLocalizer.BuildingNametagShadow: self.nametag.setShadow(*TTLocalizer.BuildingNametagShadow) self.nametag.hideChat() self.nametag.hideThought() nametagColor = NametagGlobals.NametagColors[NametagGlobals.CCToonBuilding] self.nametag.setNametagColor(nametagColor) self.nametag.setActive(False) self.nametag.setAvatar(self.house) self.nametag.setText(houseName) self.nametag.manage(base.marginManager) self.nametag.updateAll()
def spawnTitleText(self): if not self.hostName: return partyText = TTLocalizer.PartyTitleText % TTLocalizer.GetPossesive(self.hostName) self.doSpawnTitleText(partyText)
def enter(self): ShtikerPage.ShtikerPage.enter(self) # Get the current street name try: zone = base.cr.playGame.getPlace().getZoneId() except: zone = 0 # if we are going to an HQ, change the button if base.localAvatar.lastHood >= ToontownGlobals.BossbotHQ: self.safeZoneButton['text'] = TTLocalizer.MapPageBackToCogHQ else: self.safeZoneButton['text'] = TTLocalizer.MapPageBackToPlayground if ((zone and ZoneUtil.isPlayground(zone)) or self.book.safeMode): self.safeZoneButton.hide() else: self.safeZoneButton.show() if ((base.cr.playGame.getPlaceId() == ToontownGlobals.MyEstate and base.cr.playGame.hood.loader.atMyEstate()) or self.book.safeMode): self.goHomeButton.hide() elif base.housingEnabled: self.goHomeButton.show() if base.cr.playGame.getPlaceId() == ToontownGlobals.MyEstate: if base.cr.playGame.hood.loader.atMyEstate(): self.hoodLabel['text'] = (TTLocalizer.MapPageYouAreAtHome) self.hoodLabel.show() else: avatar = base.cr.identifyAvatar( base.cr.playGame.hood.loader.estateOwnerId) if avatar: avName = avatar.getName() self.hoodLabel['text'] = ( TTLocalizer.MapPageYouAreAtSomeonesHome % (TTLocalizer.GetPossesive(avName))) self.hoodLabel.show() elif zone: hoodName = ToontownGlobals.hoodNameMap.get( ZoneUtil.getCanonicalHoodId(zone), ("", ))[-1] streetName = ToontownGlobals.StreetNames.get( ZoneUtil.getCanonicalBranchZone(zone), ("", ))[-1] # Make sure we have a hoodName to report # It is ok if we do not have a street name, it will just be empty if hoodName: self.hoodLabel['text'] = (TTLocalizer.MapPageYouAreHere % (hoodName, streetName)) self.hoodLabel.show() else: self.hoodLabel.hide() else: self.hoodLabel.hide() safeZonesVisited = base.localAvatar.hoodsVisited hoodsAvailable = base.cr.hoodMgr.getAvailableZones() #print("### hoods visited = ", safeZonesVisited) #print("### hoods avail = ", hoodsAvailable) # The hoods that we can see is the intersection of the zones we have # visited and the hoods that are available hoodVisibleList = PythonUtil.intersection(safeZonesVisited, hoodsAvailable) #print("### hoods viz = ", hoodVisibleList) # The hoods that we can teleport to is the intersection of the hoods # we can see and the hoods the local toon has teleport access to hoodTeleportList = base.localAvatar.getTeleportAccess() for hood in self.allZones: label = self.labels[self.allZones.index(hood)] clouds = self.clouds[self.allZones.index(hood)] # If we can see that hood, show the button, hide the clouds if ((not self.book.safeMode) and (hood in hoodVisibleList)): label.show() for cloud in clouds: cloud.hide() fullname = base.cr.hoodMgr.getFullnameFromId(hood) if hood in hoodTeleportList: text = (TTLocalizer.MapPageGoTo % fullname) label['text'] = ("", text, text) else: label['text'] = ("", fullname, fullname) # If we cannot see that hood, hide the button, show the clouds else: label.hide() for cloud in clouds: cloud.show() return
def enter(self): ShtikerPage.ShtikerPage.enter(self) try: zone = base.cr.playGame.getPlace().getZoneId() except: zone = 0 if base.localAvatar.lastHood >= ToontownGlobals.BossbotHQ: self.safeZoneButton['text'] = TTLocalizer.MapPageBackToCogHQ else: self.safeZoneButton['text'] = TTLocalizer.MapPageBackToPlayground if zone and ZoneUtil.isPlayground(zone) or self.book.safeMode: self.safeZoneButton.hide() else: self.safeZoneButton.show() if base.cr.playGame.getPlaceId( ) == ToontownGlobals.MyEstate and base.cr.playGame.hood.loader.atMyEstate( ) or self.book.safeMode: self.goHomeButton.hide() elif base.housingEnabled: self.goHomeButton.show() if base.cr.playGame.getPlaceId() == ToontownGlobals.MyEstate: if base.cr.playGame.hood.loader.atMyEstate(): self.hoodLabel['text'] = TTLocalizer.MapPageYouAreAtHome self.hoodLabel.show() else: avatar = base.cr.identifyAvatar( base.cr.playGame.hood.loader.estateOwnerId) if avatar: avName = avatar.getName() self.hoodLabel[ 'text'] = TTLocalizer.MapPageYouAreAtSomeonesHome % TTLocalizer.GetPossesive( avName) self.hoodLabel.show() elif zone: hoodName = ToontownGlobals.hoodNameMap.get( ZoneUtil.getCanonicalHoodId(zone), ('', ))[-1] streetName = ToontownGlobals.StreetNames.get( ZoneUtil.getCanonicalBranchZone(zone), ('', ))[-1] if hoodName: self.hoodLabel['text'] = TTLocalizer.MapPageYouAreHere % ( hoodName, streetName) self.hoodLabel.show() else: self.hoodLabel.hide() else: self.hoodLabel.hide() safeZonesVisited = base.localAvatar.hoodsVisited hoodsAvailable = base.cr.hoodMgr.getAvailableZones() hoodVisibleList = PythonUtil.intersection(safeZonesVisited, hoodsAvailable) hoodTeleportList = base.localAvatar.getTeleportAccess() for hood in self.allZones: label = self.labels[self.allZones.index(hood)] clouds = self.clouds[self.allZones.index(hood)] if not self.book.safeMode and hood in hoodVisibleList: label['text_fg'] = (0, 0, 0, 1) label.show() for cloud in clouds: cloud.hide() fullname = base.cr.hoodMgr.getFullnameFromId(hood) if hood in hoodTeleportList: text = TTLocalizer.MapPageGoTo % fullname label['text'] = ('', text, text) else: label['text'] = ('', fullname, fullname) else: label['text_fg'] = (0, 0, 0, 0.65) label.show() for cloud in clouds: cloud.show()