def __createNametag(self, parent): if self.nametagGroup == None: self.nametagGroup = NametagGroup() self.nametagGroup.setFont(ToontownGlobals.getToonFont()) self.nametagGroup.setSpeechFont(ToontownGlobals.getToonFont()) self.nametagGroup.setActive(0) self.nametagGroup.setAvatar(self.partyPlannerHead) self.nametagGroup.manage(base.marginManager) self.nametagGroup.setColorCode(self.nametagGroup.CCNonPlayer) self.nametagGroup.getNametag2d().setContents(0) self.nametagNode = NametagFloat2d() self.nametagNode.setContents(Nametag.CName) self.nametagGroup.addNametag(self.nametagNode) self.nametagGroup.setName(base.cr.partyManager.getPartyPlannerName()) self.nametagNP = parent.attachNewNode(self.nametagNode) nametagPos = self.gui.find('**/step_01_partymanPeteNametag_locator').getPos() self.nametagNP.setPosHprScale(nametagPos[0], 0, nametagPos[2], 0, 0, 0, 0.1, 1, 0.1) self.chatNode = NametagFloat2d() self.chatNode.setContents(Nametag.CSpeech | Nametag.CThought) self.nametagGroup.addNametag(self.chatNode) self.nametagGroup.setChat(TTLocalizer.PartyPlannerInstructions, CFSpeech) self.chatNP = parent.attachNewNode(self.chatNode) chatPos = self.gui.find('**/step_01_partymanPeteText_locator').getPos() self.chatNP.setPosHprScale(chatPos[0], 0, chatPos[2], 0, 0, 0, 0.08, 1, 0.08) return
def knockKnockTrack(self, avatar, duration): if avatar is None: return self.rimshot = base.loadSfx("phase_5/audio/sfx/AA_heal_telljoke.ogg") self.knockSfx = base.loadSfx("phase_5/audio/sfx/GUI_knock_%s.ogg" % random.randint(1, 4)) joke = KnockKnockJokes[self.propId % len(KnockKnockJokes)] place = base.cr.playGame.getPlace() doorName = TTLocalizer.DoorNametag self.nametag = None self.nametagNP = None doorNP = render.find("**/KnockKnockDoorSphere_" + str(self.propId) + ";+s") if doorNP.isEmpty(): self.notify.warning("Could not find KnockKnockDoorSphere_%s" % self.propId) return self.nametag = NametagGroup() self.nametag.setAvatar(doorNP) self.nametag.setFont(ToontownGlobals.getToonFont()) self.nametag.setSpeechFont(ToontownGlobals.getToonFont()) self.nametag.setName(doorName) self.nametag.setActive(0) self.nametag.manage(base.marginManager) self.nametag.getNametag3d().setBillboardOffset(4) nametagNode = self.nametag.getNametag3d() self.nametagNP = render.attachNewNode(nametagNode) self.nametagNP.setName("knockKnockDoor_nt_" + str(self.propId)) pos = doorNP.getBounds().getCenter() self.nametagNP.setPos(pos + Vec3(0, 0, avatar.getHeight() + 2)) d = duration * 0.125 track = Sequence( Parallel( Sequence(Wait(d * 0.5), SoundInterval(self.knockSfx)), Func(self.nametag.setChat, TTLocalizer.DoorKnockKnock, CFSpeech), Wait(d), ), Func(avatar.setChatAbsolute, TTLocalizer.DoorWhosThere, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[0], CFSpeech), Wait(d), Func(avatar.setChatAbsolute, joke[0] + TTLocalizer.DoorWhoAppendix, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[1], CFSpeech), ) if avatar == base.localAvatar: track.append(Func(self.sendUpdate, "requestToonup")) track.append(Parallel(SoundInterval(self.rimshot, startTime=2.0), Wait(d * 4))) track.append(Func(self.cleanupTrack)) track.delayDelete = DelayDelete.DelayDelete(avatar, "knockKnockTrack") return track
def buildFrame(self, name, dnaTuple): frame = loader.loadModel('phase_3.5/models/modules/trophy_frame') dna = ToonDNA.ToonDNA() apply(dna.newToonFromProperties, dnaTuple) head = ToonHead.ToonHead() head.setupHead(dna) head.setPosHprScale(0, -0.050000000000000003, -0.050000000000000003, 180, 0, 0, 0.55000000000000004, 0.02, 0.55000000000000004) if dna.head[0] == 'r': head.setZ(-0.14999999999999999) elif dna.head[0] == 'h': head.setZ(0.050000000000000003) elif dna.head[0] == 'm': head.setScale(0.45000000000000001, 0.02, 0.45000000000000001) head.reparentTo(frame) nameText = TextNode('trophy') nameText.setFont(ToontownGlobals.getToonFont()) nameText.setAlign(TextNode.ACenter) nameText.setTextColor(0, 0, 0, 1) nameText.setWordwrap(5.3600000000000003 * FrameScale) nameText.setText(name) namePath = frame.attachNewNode(nameText.generate()) namePath.setPos(0, -0.029999999999999999, -0.59999999999999998) namePath.setScale(0.186 / FrameScale) frame.setScale(FrameScale, 1.0, FrameScale) return frame
def __init__(self): self.__expectedCount = 0 self.__count = 0 self.screen = loader.loadModel('phase_3/models/gui/progress-background') self.gui = self.screen.find('**/bg') self.banner = loader.loadModel('phase_3.5/models/gui/stickerbook_gui').find('**/paper_note') self.banner.reparentTo(self.gui) self.banner.setScale(1.15, 1.0, 1.0) self.banner.setZ(-0.13) self.tip = DirectLabel(guiId='ToontownLoadingScreenTip', parent = self.banner, relief = None, text='', text_scale = TTLocalizer.TLStip, textMayChange = 1, pos=(-0.41, 0.0, 0.235), text_fg = (0.4, 0.3, 0.2, 1), text_wordwrap = 9, text_align = TextNode.ALeft) self.title = DirectLabel(guiId = 'ToontownLoadingScreenTitle', parent = self.gui, relief = None, pos = (-1.06, 0, -0.77), text = '', textMayChange = 1, text_scale = 0.08, text_fg = (1, .9, 0, 1), text_align = TextNode.ALeft, text_font = ToontownGlobals.getToonFont()) self.waitBar = DirectWaitBar(guiId = 'ToontownLoadingScreenWaitBar', parent = self.gui, frameSize = (-1.06, 1.06, -0.03, 0.03), pos = (0, 0, -0.85), text = '') self.logo = OnscreenImage('phase_3/maps/toontown-logo.png') self.logo.reparentTo(self.gui) self.logo.setScale(self.gui, (0.53,1,0.35)) self.logo.setTransparency(TransparencyAttrib.MAlpha) self.logo.setZ(0.73)
def knockKnockTrack(self, avatar, duration): if avatar == None: return self.rimshot = base.loadSfx('phase_5/audio/sfx/AA_heal_telljoke.ogg') self.knockSfx = base.loadSfx('phase_5/audio/sfx/GUI_knock_3.ogg') joke = KnockKnockJokes[self.propId % len(KnockKnockJokes)] place = base.cr.playGame.getPlace() doorName = TTLocalizer.DoorNametag if place: zone = place.getZoneId() branch = ZoneUtil.getBranchZone(zone) self.nametag = None self.nametagNP = None doorNP = render.find('**/KnockKnockDoorSphere_' + str(self.propId) + ';+s') if doorNP.isEmpty(): self.notify.warning('Could not find KnockKnockDoorSphere_%s' % self.propId) return self.nametag = NametagGroup() self.nametag.setAvatar(doorNP) self.nametag.setFont(ToontownGlobals.getToonFont()) self.nametag.setName(doorName) self.nametag.setActive(0) self.nametag.manage(base.marginManager) self.nametag.getNametag3d().setBillboardOffset(4) nametagNode = self.nametag.getNametag3d() self.nametagNP = render.attachNewNode(nametagNode) self.nametagNP.setName('knockKnockDoor_nt_' + str(self.propId)) pos = doorNP.node().getSolid(0).getCenter() self.nametagNP.setPos(pos + Vec3(0, 0, avatar.getHeight() + 2)) d = duration * 0.125 track = Sequence(Parallel(Sequence(Wait(d * 0.5), SoundInterval(self.knockSfx)), Func(self.nametag.setChat, TTLocalizer.DoorKnockKnock, CFSpeech), Wait(d)), Func(avatar.setChatAbsolute, TTLocalizer.DoorWhosThere, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[0], CFSpeech), Wait(d), Func(avatar.setChatAbsolute, joke[0] + TTLocalizer.DoorWhoAppendix, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[1], CFSpeech), Parallel(SoundInterval(self.rimshot, startTime=2.0), Wait(d * 4)), Func(self.cleanupTrack)) track.delayDelete = DelayDelete.DelayDelete(avatar, 'knockKnockTrack') return track
def buildFrame(self, name, dnaTuple): frame = loader.loadModel("phase_3.5/models/modules/trophy_frame") dna = ToonDNA.ToonDNA() apply(dna.newToonFromProperties, dnaTuple) head = ToonHead.ToonHead() head.setupHead(dna) head.setPosHprScale(0, -0.05, -0.05, 180, 0, 0, 0.55, 0.02, 0.55) if dna.head[0] == "r": head.setZ(-0.15) elif dna.head[0] == "h": head.setZ(0.05) elif dna.head[0] == "m": head.setScale(0.45, 0.02, 0.45) head.reparentTo(frame) nameText = TextNode("trophy") nameText.setFont(ToontownGlobals.getToonFont()) nameText.setAlign(TextNode.ACenter) nameText.setTextColor(0, 0, 0, 1) nameText.setWordwrap(5.36 * FrameScale) nameText.setText(name) namePath = frame.attachNewNode(nameText.generate()) namePath.setPos(0, -0.03, -0.6) namePath.setScale(0.186 / FrameScale) frame.setScale(FrameScale, 1.0, FrameScale) return frame
def __init__(self): DirectFrame.__init__(self, frameColor=(.3, .2, .6, 1), frameSize=(.4, -1.2, .8, -.8)) self.initialiseoptions(CustomStatePanel) self._font = ToontownGlobals.getToonFont() gui = loader.loadModel('phase_3/models/gui/tt_m_gui_mat_nameShop') self.squareUp = gui.find('**/tt_t_gui_mat_namePanelSquareUp') self.squareDown = gui.find('**/tt_t_gui_mat_namePanelSquareDown') self.squareHover = gui.find('**/tt_t_gui_mat_namePanelSquareHover') self.title = OnscreenText(parent=self, text=T_TITLE, pos=(-.4, .7), scale=.085, font=self._font) self.screen1 = self.attachNewNode('screen1') self.__hood = -1 self.__trackChoice = [-1, -1] DirectButton(parent=self.screen1, text_scale=.075, text=T_HELP, pos=(-.4, 0, .6), relief=None, text_font=self._font, image=(self.squareUp, self.squareDown, self.squareHover, self.squareUp), text_pos=(0, -.02), command=self.__help) DirectButton(parent=self.screen1, scale=.075, text=T_TTC, pos=(-.8, 0, .45), relief=None, text_font=self._font, command=self.__hoodChosen, extraArgs=[0]) DirectButton(parent=self.screen1, scale=.075, text=T_DD, pos=(0, 0, .45), relief=None, text_font=self._font, command=self.__hoodChosen, extraArgs=[1]) DirectButton(parent=self.screen1, scale=.075, text=T_DG, pos=(-.8 if config.GetBool('csp-want-mm', False) else -.4, 0, -.2), relief=None, text_font=self._font, command=self.__hoodChosen, extraArgs=[2]) if config.GetBool('csp-want-mm', False): DirectButton(parent=self.screen1, scale=.075, text=T_MM, pos=(0, 0, -.2), relief=None, text_font=self._font, command=self.__hoodChosen, extraArgs=[3])
def makeFriendButton(self, friendTuple, colorChoice = None, bold = 0): avId, flags = friendTuple command = self.__choseFriend handle = base.cr.identifyFriend(avId) if handle: toonName = handle.getName() else: base.cr.fillUpFriendsMap() return fg = ToontownGlobals.ColorNoChat if flags & ToontownGlobals.FriendChat: fg = ToontownGlobals.ColorAvatar if colorChoice: fg = colorChoice fontChoice = ToontownGlobals.getToonFont() fontScale = 0.04 bg = None if colorChoice and bold: fontScale = 0.04 colorS = 0.7 bg = (colorChoice[0] * colorS, colorChoice[1] * colorS, colorChoice[2] * colorS, colorChoice[3]) db = DirectButton(relief=None, text=toonName, text_scale=fontScale, text_align=TextNode.ALeft, text_fg=fg, text_shadow=bg, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, text_font=fontChoice, textMayChange=0, command=command, extraArgs=[avId]) return db
def getPicture(self, avatar): frame = self.makeFrame() if self.nametagStyle == 100: inFont = ToontownGlobals.getToonFont() else: inFont = ToontownGlobals.getNametagFont(self.nametagStyle) nameTagDemo = DirectLabel(parent=frame, relief=None, pos=(0, 0, 0.24), scale=0.5, text=localAvatar.getName(), text_fg=(1.0, 1.0, 1.0, 1), text_shadow=(0, 0, 0, 1), text_font=inFont, text_wordwrap=9) self.hasPicture = True return (frame, None)
def updateBuyButton(self): if not self.loaded: return if not base.cr.isPaid(): self.buyButton['command'] = self.getTeaserPanel() self.buyButton.show() typeCode = self['item'].getTypeCode() orderCount = base.localAvatar.onOrder.count(self['item']) if orderCount > 0: if orderCount > 1: auxText = '%d %s' % (orderCount, TTLocalizer.CatalogOnOrderText) else: auxText = TTLocalizer.CatalogOnOrderText else: auxText = '' isNameTag = typeCode == CatalogItemTypes.NAMETAG_ITEM if isNameTag and not localAvatar.getGameAccess() == OTPGlobals.AccessFull: if self['item'].nametagStyle == 100: if localAvatar.getFont() == ToontownGlobals.getToonFont(): auxText = TTLocalizer.CatalogCurrent self.buyButton['state'] = DGG.DISABLED elif self['item'].getPrice(self['type']) > base.localAvatar.getMoney() + base.localAvatar.getBankMoney(): self.buyButton['state'] = DGG.DISABLED elif isNameTag and self['item'].nametagStyle == localAvatar.getNametagStyle(): auxText = TTLocalizer.CatalogCurrent self.buyButton['state'] = DGG.DISABLED elif self['item'].reachedPurchaseLimit(base.localAvatar): max = self['item'].getPurchaseLimit() if max <= 1: auxText = TTLocalizer.CatalogPurchasedText if self['item'].hasBeenGifted(base.localAvatar): auxText = TTLocalizer.CatalogGiftedText else: auxText = TTLocalizer.CatalogPurchasedMaxText self.buyButton['state'] = DGG.DISABLED elif hasattr(self['item'], 'noGarden') and self['item'].noGarden(base.localAvatar): auxText = TTLocalizer.NoGarden self.buyButton['state'] = DGG.DISABLED elif hasattr(self['item'], 'isSkillTooLow') and self['item'].isSkillTooLow(base.localAvatar): auxText = TTLocalizer.SkillTooLow self.buyButton['state'] = DGG.DISABLED elif hasattr(self['item'], 'getDaysToGo') and self['item'].getDaysToGo(base.localAvatar): auxText = TTLocalizer.DaysToGo % self['item'].getDaysToGo(base.localAvatar) self.buyButton['state'] = DGG.DISABLED elif self['item'].getEmblemPrices() and not base.localAvatar.isEnoughMoneyAndEmblemsToBuy(self['item'].getPrice(self['type']), self['item'].getEmblemPrices()): self.buyButton['state'] = DGG.DISABLED elif self['item'].__class__.__name__ == "CatalogHouseItem" and self['item'].houseId == localAvatar.houseType: auxText = TTLocalizer.CatalogPurchasedMaxText self.buyButton['state'] = DGG.DISABLED elif self['item'].getPrice(self['type']) <= base.localAvatar.getMoney() + base.localAvatar.getBankMoney(): self.buyButton['state'] = DGG.NORMAL self.buyButton.show() else: self.buyButton['state'] = DGG.DISABLED self.buyButton.show() self.auxText['text'] = auxText
def _createPartyEditorPage(self): page = DirectFrame(self.frame) page.setName('PartyPlannerEditorPage') self.LayoutTitleLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerEditorTitle, pos=self.gui.find('**/title_locator').getPos() + Point3(0.0, 0.0, 0.075), scale=self.titleScale) self.costLabel = DirectLabel(parent=page, pos=(-0.74, 0.0, 0.17), relief=None, text=TTLocalizer.PartyPlannerTotalCost % 0, text_align=TextNode.ACenter, scale=TTLocalizer.PPcostLabel, textMayChange=True) self.partyGridBackground = DirectFrame(parent=page, relief=None, geom=self.gui.find('**/partyGrid_flat')) self.partyGroundsLabel = DirectLabel(parent=page, relief=None, text=TTLocalizer.PartyPlannerPartyGrounds, text_font=ToontownGlobals.getSignFont(), text_fg=VBase4(1.0, 0.0, 0.0, 1.0), text_scale=TTLocalizer.PPpartyGroundsLabel, pos=self.gui.find('**/step_05_partyGrounds_text_locator').getPos(), scale=0.1) self.activityBackground = DirectFrame(parent=page, relief=None, geom=self.gui.find('**/activitiesDecorations_flat1'), pos=(0.0, 0.0, 0.04)) pos = self.gui.find('**/step_05_instructions_locator').getPos() self.instructionLabel = DirectLabel(parent=page, relief=None, text=' ', text_pos=(pos[0], pos[2]), text_scale=TTLocalizer.PPinstructionLabel, textMayChange=True, geom=self.gui.find('**/instructions_flat')) self.elementTitleLabel = DirectLabel(parent=page, relief=None, text=' ', pos=self.gui.find('**/step_05_activitiesName_text_locator').getPos() + Point3(0.0, 0.0, 0.04), text_scale=TTLocalizer.PPelementTitleLabel, textMayChange=True) self.elementPriceNode = TextNode('ElementPrice') self.elementPriceNode.setAlign(TextNode.ALeft) self.elementPriceNode.setTextColor(0.0, 0.0, 0.0, 1.0) self.elementPriceNode.setFont(ToontownGlobals.getToonFont()) self.elementPrice = page.attachNewNode(self.elementPriceNode) self.elementPrice.setScale(TTLocalizer.PPelementPriceNode) self.elementPrice.setPos(self.gui.find('**/step_05_activityPrice_text_locator').getPos() + Point3(-0.02, 0.0, 0.04)) self.elementDescriptionNode = TextNode('ElementDescription') self.elementDescriptionNode.setAlign(TextNode.ACenter) self.elementDescriptionNode.setWordwrap(8) self.elementDescriptionNode.setFont(ToontownGlobals.getToonFont()) self.elementDescriptionNode.setTextColor(0.0, 0.0, 0.0, 1.0) self.elementDescription = page.attachNewNode(self.elementDescriptionNode) self.elementDescription.setScale(TTLocalizer.PPelementDescription) self.elementDescription.setPos(self.gui.find('**/step_05_activityDescription_text_locator').getPos() + Point3(0.0, 0.0, 0.04)) self.totalMoney = base.localAvatar.getTotalMoney() catalogGui = loader.loadModel('phase_5.5/models/gui/catalog_gui') self.beanBank = DirectLabel(parent=page, relief=None, text=str(self.totalMoney), text_align=TextNode.ARight, text_scale=0.075, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_pos=(0.495, -0.53), text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=catalogGui.find('**/bean_bank'), image_scale=(0.65, 0.65, 0.65), scale=0.9, pos=(-0.75, 0.0, 0.6)) catalogGui.removeNode() del catalogGui self.accept(localAvatar.uniqueName('moneyChange'), self.__moneyChange) self.accept(localAvatar.uniqueName('bankMoneyChange'), self.__moneyChange) self.partyEditor = PartyEditor(self, page) self.partyEditor.request('Hidden') pos = self.gui.find('**/step_05_add_text_locator').getPos() self.elementBuyButton = DirectButton(parent=page, relief=None, text=TTLocalizer.PartyPlannerBuy, text_pos=(pos[0], pos[2]), text_scale=TTLocalizer.PPelementBuyButton, geom=(self.gui.find('**/add_up'), self.gui.find('**/add_down'), self.gui.find('**/add_rollover')), geom3_color=VBase4(0.5, 0.5, 0.5, 1.0), textMayChange=True, pos=(0.0, 0.0, 0.04), command=self.partyEditor.buyCurrentElement) self.okWithPartyGroundsLayoutEvent = 'okWithPartyGroundsLayoutEvent' self.accept(self.okWithPartyGroundsLayoutEvent, self.okWithPartyGroundsLayout) self.okWithGroundsGui = TTDialog.TTGlobalDialog(dialogName=self.uniqueName('PartyEditorOkGui'), doneEvent=self.okWithPartyGroundsLayoutEvent, message=TTLocalizer.PartyPlannerOkWithGroundsLayout, style=TTDialog.YesNo, okButtonText=OTPLocalizer.DialogYes, cancelButtonText=OTPLocalizer.DialogNo) self.okWithGroundsGui.doneStatus = '' self.okWithGroundsGui.hide() return page
def getFontByName(self, fontname): if fontname == 'toon': return ToontownGlobals.getToonFont() elif fontname == 'building': return ToontownGlobals.getBuildingNametagFont() elif fontname == 'minnie': return ToontownGlobals.getMinnieFont() elif fontname == 'suit': return ToontownGlobals.getSuitFont() else: return MagicWordManager.MagicWordManager.getFontByName(self, fontname)
def load(self): self.setPos(-0.5,0,-0.115) self.jbs = OnscreenText(text='0',font=ToontownGlobals.getToonFont(),parent=self) self.jbs.node().setTextColor(1,1,0,1) self.jbs.node().setShadowColor(0,0,0,1) self.jbs.node().setShadow(0.1,0.1) self.jbs.setScale(0.1) self.icon = loader.loadModel('phase_4/models/minigames/jellyBean') self.icon.reparentTo(self) self.icon.setScale(0.1) self.icon.setPos(-.090,0,0.010)
def getFontByName(self, fontname): if fontname == "toon": return ToontownGlobals.getToonFont() elif fontname == "building": return ToontownGlobals.getBuildingNametagFont() elif fontname == "minnie": return ToontownGlobals.getMinnieFont() elif fontname == "suit": return ToontownGlobals.getSuitFont() else: return MagicWordManager.MagicWordManager.getFontByName(self, fontname)
def makeTextNodes(self): self.notify.debugStateCall(self) self.trackNameNode, trackNameNodePath = self.getSignTextNodes('trackNameNode') trackNameNodePath.setZ(0.7) trackNameNodePath.setScale(0.875) trackNameNodePath.flattenLight() self.trackTypeNode, trackTypeNodePath = self.getSignTextNodes('trackTypeNode') trackTypeNodePath.setZ(-0.35) trackTypeNodePath.setScale(0.875) trackTypeNodePath.flattenLight() self.depositNode, depositNodePath = self.getSignTextNodes('depositNode', ToontownGlobals.getToonFont()) self.depositNode.setTextColor(0, 0, 0, 1) depositNodePath.setPos(4.0, -1.0, -2.0) depositNodePath.setScale(0.75) depositNodePath.flattenLight() self.qualifyNode, qualifyNodePath = self.getSignTextNodes('qualifyNode', ToontownGlobals.getToonFont()) self.qualifyNode.setTextColor(0, 0, 0, 1) qualifyNodePath.setPos(-4.0, 1.2, -2.0) qualifyNodePath.setScale(0.75) qualifyNodePath.flattenLight()
def prepare(self): font1 = ToontownGlobals.getToonFont() slideUpTextNd = TextNode('slideUpText') slideUpTextNd.setFont(font1) slideUpTextNd.setTextColor(255,255,255,1) slideUpTextNd.setShadowColor(0,0,0,1) slideUpTextNd.setShadow(0.1,0.1) self.slideUpText = self.parent.attachNewNode(slideUpTextNd) self.slideUpText.setPos(self.SUTextX,0,self.SUTextZ) self.slideUpText.setScale(0) self.slideUpText.setR(-10) self.slideUpText.hide()
def load(self): from toontown.toonbase import ToontownGlobals from pandac.PandaModules import TextNode textNode = TextNode('moviedialogue') textNode.setTextColor(0, 0, 0, 1) textNode.setCardColor(1, 1, 1, 1) textNode.setCardAsMargin(0, 0, 0, 0) textNode.setCardDecal(True) textNode.setWordwrap(27.0) textNode.setAlign(TextNode.ACenter) textNode.setFont(ToontownGlobals.getToonFont()) self._dialogueLabel = aspect2d.attachNewNode(textNode) self._dialogueLabel.setScale(0.06, 0.06, 0.06) self._dialogueLabel.setPos(0.32, 0, -0.7325) self._dialogueLabel.reparentTo(hidden)
def load(self): from toontown.toonbase import ToontownGlobals from pandac.PandaModules import TextNode textNode = TextNode('moviedialogue') textNode.setTextColor(0, 0, 0, 1) textNode.setCardColor(1, 1, 1, 1) textNode.setCardAsMargin(0, 0, 0, 0) textNode.setCardDecal(True) textNode.setWordwrap(27.0) textNode.setAlign(TextNode.ACenter) textNode.setFont(ToontownGlobals.getToonFont()) self._dialogueLabel = aspect2d.attachNewNode(textNode) self._dialogueLabel.setScale(0.06, 0.06, 0.06) self._dialogueLabel.setPos(0.32, 0, -0.75) self._dialogueLabel.reparentTo(hidden)
def __createNametag(self, parent): if self.nametagGroup == None: self.nametagGroup = NametagGroup() self.nametagGroup.setFont(ToontownGlobals.getToonFont()) self.nametagGroup.setSpeechFont(ToontownGlobals.getToonFont()) self.nametagGroup.setActive(0) self.nametagGroup.setAvatar(self.partyPlannerHead) self.nametagGroup.manage(base.marginManager) self.nametagGroup.setColorCode(self.nametagGroup.CCNonPlayer) self.nametagGroup.getNametag2d().setContents(0) self.nametagNode = NametagFloat2d() self.nametagNode.setContents(Nametag.CName) self.nametagGroup.addNametag(self.nametagNode) self.nametagGroup.setName(base.cr.partyManager.getPartyPlannerName()) self.nametagNP = parent.attachNewNode(self.nametagNode) nametagPos = self.gui.find('**/step_01_partymanPeteNametag_locator').getPos() self.nametagNP.setPosHprScale(nametagPos[0], 0, nametagPos[2], 0, 0, 0, 0.1, 1, 0.1) self.chatNode = NametagFloat2d() self.chatNode.setContents(Nametag.CSpeech | Nametag.CThought) self.nametagGroup.addNametag(self.chatNode) self.nametagGroup.setChat(TTLocalizer.PartyPlannerInstructions, CFSpeech) self.chatNP = parent.attachNewNode(self.chatNode) chatPos = self.gui.find('**/step_01_partymanPeteText_locator').getPos() self.chatNP.setPosHprScale(chatPos[0], 0, chatPos[2], 0, 0, 0, 0.08, 1, 0.08)
def knockKnockTrack(self, avatar, duration): if avatar == None: return self.rimshot = base.loadSfx('phase_5/audio/sfx/AA_heal_telljoke.ogg') self.knockSfx = base.loadSfx('phase_5/audio/sfx/GUI_knock_3.ogg') joke = KnockKnockJokes[self.propId % len(KnockKnockJokes)] place = base.cr.playGame.getPlace() doorName = TTLocalizer.DoorNametag self.nametag = None self.nametagNP = None doorNP = render.find('**/KnockKnockDoorSphere_' + str(self.propId) + ';+s') if doorNP.isEmpty(): self.notify.warning('Could not find KnockKnockDoorSphere_%s' % self.propId) return self.nametag = NametagGroup() self.nametag.setAvatar(doorNP) self.nametag.setFont(ToontownGlobals.getToonFont()) self.nametag.setName(doorName) self.nametag.setActive(0) self.nametag.manage(base.marginManager) self.nametag.getNametag3d().setBillboardOffset(4) nametagNode = self.nametag.getNametag3d() self.nametagNP = render.attachNewNode(nametagNode) self.nametagNP.setName('knockKnockDoor_nt_' + str(self.propId)) pos = doorNP.node().getSolid(0).getCenter() self.nametagNP.setPos(pos + Vec3(0, 0, avatar.getHeight() + 2)) d = duration * 0.125 track = Sequence( Parallel( Sequence(Wait(d * 0.5), SoundInterval(self.knockSfx)), Func(self.nametag.setChat, TTLocalizer.DoorKnockKnock, CFSpeech), Wait(d)), Func(avatar.setChatAbsolute, TTLocalizer.DoorWhosThere, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[0], CFSpeech), Wait(d), Func(avatar.setChatAbsolute, joke[0] + TTLocalizer.DoorWhoAppendix, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[1], CFSpeech), Parallel(SoundInterval(self.rimshot, startTime=2.0), Wait(d * 4)), Func(self.cleanupTrack)) track.delayDelete = DelayDelete.DelayDelete(avatar, 'knockKnockTrack') return track
def getPicture(self, avatar): frame = self.makeFrame() if self.nametagStyle == 100: inFont = ToontownGlobals.getToonFont() else: inFont = ToontownGlobals.getNametagFont(self.nametagStyle) nameTagDemo = DirectLabel(parent=frame, relief=None, pos=(0, 0, 0.24), scale=0.5, text=localAvatar.getName(), text_fg=(1.0, 1.0, 1.0, 1), text_shadow=(0, 0, 0, 1), text_font=inFont, text_wordwrap=9) self.hasPicture = True return ( frame, None)
def __setupName(self): DistributedMailbox.notify.debug('__setupName') if self.nameText: self.nameText.removeNode() self.nameText = None nameOrigin = self.model.find('**/nameLocator') if not nameOrigin.isEmpty(): text = TextNode('nameText') text.setTextColor(*self.nameColor) text.setAlign(TextNode.ACenter) text.setFont(ToontownGlobals.getToonFont()) text.setWordwrap(7.5) text.setText(self.name) self.nameText = nameOrigin.attachNewNode(text) self.nameText.setH(90) self.nameText.setScale(0.2)
def toggleFrameRateMeter(self, flag): if flag: if not self.frameRateMeter: self.frameRateMeter = OnscreenText( parent=base.a2dTopRight, text='', pos=(-0.1125, -0.05, 0.0), scale=0.05, style=3, bg=(0, 0, 0, 0.4), font=ToontownGlobals.getToonFont()) taskMgr.add(self.frameRateCounter, 'fps') else: if self.frameRateMeter: self.frameRateMeter.destroy() self.frameRateMeter = None
def _initModel(self): self._countLabel = DirectLabel( parent=self, relief=None, pos=(0.0625, 0, -0.025), scale=CogdoGameConsts.MemoGuiTextScale, text=str(0), text_fg=CogdoGameConsts.MemoGuiTextColor, text_shadow=(0.2, 0.2, 0.2, 1), text_align=TextNode.ALeft, text_font=ToontownGlobals.getToonFont()) self._memoIcon = CogdoUtil.loadModel('memo_card', game='shared', group='gui') self._memoIcon.reparentTo(self) self._memoIcon.setScale(MEMOICON_SCALE) return
def load(self, numBlocks): self.blocks = {} self.lastBlockZ = 0.030 for i in range(numBlocks): block = OnscreenImage(image=self.BlockImageDir,parent=self) block.setTransparency(TransparencyAttrib.MAlpha) block.setScale(0.030) block.setX(-.1) block.setZ(self.lastBlockZ + 0.060) self.blocks[len(self.blocks)] = block self.lastBlockZ = block.getZ() self.title = OnscreenText(text=TTLocalizer.SurfersMap,font=ToontownGlobals.getToonFont(),parent=self) self.title.setPos(0,1) self.title.setR(-15) self.title.node().setTextColor(255,255,255,1) self.title.node().setShadowColor(0,0,0,1) self.title.node().setShadow(0.1,0.1) base.accept('NewModule', self.__handleNewBlock)
def load(self): self.setPos(-0.8,0,-0.115) self.ups = OnscreenText(text='0',font=ToontownGlobals.getToonFont(),parent=self) self.ups.node().setTextColor(1,1,0,1) self.ups.node().setShadowColor(0,0,0,1) self.ups.node().setShadow(0.1,0.1) self.ups.setScale(0.1) self.icon = loader.loadModel('phase_4/models/minigames/jellyBean') self.icon.setColor(SurfersGlobals.SpeedupPickupColors[0]) self.button = DirectButton(image=self.icon,relief=None,parent=self,command=self.__useSpeed) self.button.reparentTo(self) self.button.setScale(0.1) self.button.setPos(-.080,0,0.010) self.arrow = loader.loadModel('phase_3/models/props/arrow') self.arrow.reparentTo(self) self.arrow.setScale(0.130) self.arrow.setR(-70) self.arrow.setPos(-0.090,0,-0.1) self.arrow.hide()
def load(self, numBlocks): self.blocks = {} self.lastBlockZ = 0.030 for i in range(numBlocks): block = OnscreenImage(image=self.BlockImageDir, parent=self) block.setTransparency(TransparencyAttrib.MAlpha) block.setScale(0.030) block.setX(-.1) block.setZ(self.lastBlockZ + 0.060) self.blocks[len(self.blocks)] = block self.lastBlockZ = block.getZ() self.title = OnscreenText(text=TTLocalizer.SurfersMap, font=ToontownGlobals.getToonFont(), parent=self) self.title.setPos(0, 1) self.title.setR(-15) self.title.node().setTextColor(255, 255, 255, 1) self.title.node().setShadowColor(0, 0, 0, 1) self.title.node().setShadow(0.1, 0.1) base.accept('NewModule', self.__handleNewBlock)
def makeFriendButton(self, avId, color): handle = base.cr.identifyFriend(avId) if not handle: base.cr.fillUpFriendsMap() return return DirectButton(relief=None, text=handle.getName(), text_scale=0.04, text_align=TextNode.ALeft, text_fg=color, text_shadow=None, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, text_font=ToontownGlobals.getToonFont(), textMayChange=0, command=self.__choseFriend, extraArgs=[avId])
def load(self): self.title = OnscreenText(text=TTLocalizer.SurfersRadar,font=ToontownGlobals.getToonFont(),parent=self) self.title.setPos(0.270,-0.660) self.title.node().setTextColor(255,255,255,1) self.title.node().setShadowColor(0,0,0,1) self.title.node().setShadow(0.1,0.1) icon = loader.loadModel('phase_6/models/karting/race_mapspot') icon.setScale(0.1) self.radarImage = OnscreenImage(image=self.radarImageDir,parent=self) self.radarImage.setTransparency(TransparencyAttrib.MAlpha) self.radarImage.setScale(0.290) self.radarImage.setPos(0.3,0,-0.320) self.toon = icon.copyTo(self.radarImage) self.toon.setColor(0,1,0,1) self.cog = icon.copyTo(self.radarImage) self.cog.setColor(1,0,0,1) self.proximitySound = base.loadSfx(self.proximityAlertSound) self.proximitySound.setLoop(1) self.proximitySound.setVolume(0.3) taskMgr.add(self.__updateDistance, 'update-map-distance')
def load(self): self.title = OnscreenText(text=TTLocalizer.SurfersRadar, font=ToontownGlobals.getToonFont(), parent=self) self.title.setPos(0.270, -0.660) self.title.node().setTextColor(255, 255, 255, 1) self.title.node().setShadowColor(0, 0, 0, 1) self.title.node().setShadow(0.1, 0.1) icon = loader.loadModel('phase_6/models/karting/race_mapspot') icon.setScale(0.1) self.radarImage = OnscreenImage(image=self.radarImageDir, parent=self) self.radarImage.setTransparency(TransparencyAttrib.MAlpha) self.radarImage.setScale(0.290) self.radarImage.setPos(0.3, 0, -0.320) self.toon = icon.copyTo(self.radarImage) self.toon.setColor(0, 1, 0, 1) self.cog = icon.copyTo(self.radarImage) self.cog.setColor(1, 0, 0, 1) self.proximitySound = base.loadSfx(self.proximityAlertSound) self.proximitySound.setLoop(1) self.proximitySound.setVolume(0.3) taskMgr.add(self.__updateDistance, 'update-map-distance')
def buildFrame(self, name, dnaTuple): assert self.notify.debugStateCall(self) frame = loader.loadModel('phase_3.5/models/modules/trophy_frame') dna = ToonDNA.ToonDNA() dna.newToonFromProperties(*dnaTuple) head = ToonHead.ToonHead() head.setupHead(dna) head.setPosHprScale(0, -0.05, -0.05, 180, 0, 0, 0.55, 0.02, 0.55) if dna.head[0] == 'r': # Give rabbits a bit more space above the head. head.setZ(-0.15) elif dna.head[0] == 'h': # Give horses a bit more space below the head. head.setZ(0.05) elif dna.head[0] == 'm': # Mice should be a bit smaller to fit the ears. head.setScale(0.45, 0.02, 0.45) head.reparentTo(frame) nameText = TextNode("trophy") nameText.setFont(ToontownGlobals.getToonFont()) nameText.setAlign(TextNode.ACenter) nameText.setTextColor(0, 0, 0, 1) nameText.setWordwrap(5.36 * FrameScale) nameText.setText(name) namePath = frame.attachNewNode(nameText.generate()) namePath.setPos(0, -0.03, -.6) namePath.setScale(0.186 / FrameScale) frame.setScale(FrameScale, 1.0, FrameScale) return frame
def load(self): self.setPos(-0.8, 0, -0.115) self.ups = OnscreenText(text='0', font=ToontownGlobals.getToonFont(), parent=self) self.ups.node().setTextColor(1, 1, 0, 1) self.ups.node().setShadowColor(0, 0, 0, 1) self.ups.node().setShadow(0.1, 0.1) self.ups.setScale(0.1) self.icon = loader.loadModel('phase_4/models/minigames/jellyBean') self.icon.setColor(SurfersGlobals.SpeedupPickupColors[0]) self.button = DirectButton(image=self.icon, relief=None, parent=self, command=self.__useSpeed) self.button.reparentTo(self) self.button.setScale(0.1) self.button.setPos(-.080, 0, 0.010) self.arrow = loader.loadModel('phase_3/models/props/arrow') self.arrow.reparentTo(self) self.arrow.setScale(0.130) self.arrow.setR(-70) self.arrow.setPos(-0.090, 0, -0.1) self.arrow.hide()
def buildFrame(self, name, dnaNetString): frame = loader.loadModel('phase_3.5/models/modules/trophy_frame') dna = ToonDNA.ToonDNA(dnaNetString) head = ToonHead.ToonHead() head.setupHead(dna) head.setPosHprScale(0, -0.05, -0.05, 180, 0, 0, 0.55, 0.02, 0.55) if dna.head[0] == 'r': head.setZ(-0.15) elif dna.head[0] == 'h': head.setZ(0.05) elif dna.head[0] == 'm': head.setScale(0.45, 0.02, 0.45) head.reparentTo(frame) nameText = TextNode('trophy') nameText.setFont(ToontownGlobals.getToonFont()) nameText.setAlign(TextNode.ACenter) nameText.setTextColor(0, 0, 0, 1) nameText.setWordwrap(5.36 * FrameScale) nameText.setText(name) namePath = frame.attachNewNode(nameText.generate()) namePath.setPos(0, -0.03, -0.6) namePath.setScale(0.186 / FrameScale) frame.setScale(FrameScale, 1.0, FrameScale) return frame
def createScrolledList(self): # First create a frame in which direct elements maybe placed self.frame = DirectFrame(scale=1.1, relief=1, frameSize=(-0.5, 0.2, -0.05, 0.59), frameColor=(0.737, 0.573, 0.345, 0.000)) numItemsVisible = 9 itemHeight = 0.05 gui = loader.loadModel("resources/level_editor_gui.bam") myScrolledList = DirectScrolledList( decButton_pos=(0.4, 0, 0.53), decButton_scale=0.1, decButton_relief=None, decButton_image=(gui.find("**/arrow_u_n"), gui.find("**/arrow_u_d"), gui.find("**/arrow_u_r"), gui.find("**/arrow_u_i")), incButton_pos=(0.4, 0, -0.02), incButton_scale=0.1, incButton_relief=None, incButton_image=(gui.find("**/arrow_d_n"), gui.find("**/arrow_d_d"), gui.find("**/arrow_d_r"), gui.find("**/arrow_d_i")), image=gui.find("**/editor_list_frame"), image_pos=(.4, 0, 0.26), image_scale=(1.4, 1, 0.7), frameSize=(-0.1, 0.9, -0.05, 0.59), frameColor=(0, 0, 1, 0.0), pos=(-0.5, 0, 0), items=[], numItemsVisible=numItemsVisible, forceHeight=itemHeight, itemFrame_pos=(0.4, 0, 0.45), ) for t in self.textList: myScrolledList.addItem( DirectButton( text=(t, t, t), text_scale=0.05, command=self.__selected, extraArgs=[t], relief=None, text_style=3, text_font=ToontownGlobals.getToonFont(), text0_fg=(0.152, 0.750, 0.258, 1), text1_fg=(0.152, 0.750, 0.258, 1), text2_fg=(0.977, 0.816, 0.133, 1), )) myScrolledList.reparentTo(self.frame) # An exit button b1 = DirectButton(parent=self.frame, text="Exit", text_font=ToontownGlobals.getSignFont(), text0_fg=(0.152, 0.750, 0.258, 1), text1_fg=(0.152, 0.750, 0.258, 1), text2_fg=(0.977, 0.816, 0.133, 1), text_scale=0.05, borderWidth=(0.01, 0.01), relief=1, command=self.__hide) b1.setPos(0.15, 0, -0.025) self.frame.reparentTo(self.parent)
def __init__(self, av=None, position=0, paid=0, okToLockout=1): DirectButton.__init__(self, relief=None, text="", text_font=ToontownGlobals.getSignFont()) self.initialiseoptions(AvatarChoice) self.hasPaid = paid self.mode = None if base.restrictTrialers and okToLockout: if position not in AvatarChoice.NEW_TRIALER_OPEN_POS: if not self.hasPaid: self.mode = AvatarChoice.MODE_LOCKED self.name = "" self.dna = None if self.mode is not AvatarChoice.MODE_LOCKED: if not av: self.mode = AvatarChoice.MODE_CREATE self.name = "" self.dna = None else: self.mode = AvatarChoice.MODE_CHOOSE self.name = av.name self.dna = ToonDNA.ToonDNA(av.dna) self.wantName = av.wantName self.approvedName = av.approvedName self.rejectedName = av.rejectedName self.allowedName = av.allowedName self.position = position self.doneEvent = "avChoicePanel-" + str(self.position) self.deleteWithPasswordFrame = None self.pickAToonGui = loader.loadModel("phase_3/models/gui/tt_m_gui_pat_mainGui") self.pickAToonGui.flattenMedium() self.buttonBgs = [] self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareRed")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareGreen")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squarePurple")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareBlue")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squarePink")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareYellow")) for button in self.buttonBgs: button.hide() self["image"] = self.buttonBgs[position] self.setScale(1.01) if self.mode is AvatarChoice.MODE_LOCKED: self["command"] = self.__handleTrialer self["text"] = TTLocalizer.AvatarChoiceSubscribersOnly self["text0_scale"] = 0.1 self["text1_scale"] = TTLocalizer.ACsubscribersOnly self["text2_scale"] = TTLocalizer.ACsubscribersOnly self["text0_fg"] = (0, 1, 0.8, 0.0) self["text1_fg"] = (0, 1, 0.8, 1) self["text2_fg"] = (0.3, 1, 0.9, 1) self["text_pos"] = (0, 0.19) upsellModel = loader.loadModel("phase_3/models/gui/tt_m_gui_ups_mainGui") upsellTex = upsellModel.find("**/tt_t_gui_ups_logo_noBubbles") self.logoModelImage = loader.loadModel("phase_3/models/gui/members_only_gui").find("**/MembersOnly") logo = DirectFrame( state=DGG.DISABLED, parent=self, relief=None, image=upsellTex, image_scale=(0.9, 0, 0.9), image_pos=(0, 0, 0), scale=0.45, ) logo.reparentTo(self.stateNodePath[0], 20) logo.instanceTo(self.stateNodePath[1], 20) logo.instanceTo(self.stateNodePath[2], 20) self.logo = logo upsellModel.removeNode() elif self.mode is AvatarChoice.MODE_CREATE: self["command"] = self.__handleCreate self["text"] = (TTLocalizer.AvatarChoiceMakeAToon,) self["text_pos"] = (0, 0) self["text0_scale"] = 0.1 self["text1_scale"] = TTLocalizer.ACmakeAToon self["text2_scale"] = TTLocalizer.ACmakeAToon self["text0_fg"] = (0, 1, 0.8, 0.5) self["text1_fg"] = (0, 1, 0.8, 1) self["text2_fg"] = (0.3, 1, 0.9, 1) else: self["command"] = self.__handleChoice self["text"] = ("", TTLocalizer.AvatarChoicePlayThisToon, TTLocalizer.AvatarChoicePlayThisToon) self["text_scale"] = TTLocalizer.ACplayThisToon self["text_fg"] = (1, 0.9, 0.1, 1) self.nameText = DirectLabel( parent=self, relief=None, scale=0.08, pos=NAME_POSITIONS[position], text=self.name, hpr=(0, 0, NAME_ROTATIONS[position]), text_fg=(1, 1, 1, 1), text_wordwrap=8, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED, ) self.nameText.flattenStrong() if self.approvedName != "": self.nameText["text"] = self.approvedName guiButton = loader.loadModel("phase_3/models/gui/quit_button") self.nameYourToonButton = DirectButton( parent=self, relief=None, image=( guiButton.find("**/QuitBtn_UP"), guiButton.find("**/QuitBtn_DN"), guiButton.find("**/QuitBtn_RLVR"), ), text=( TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon, ), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, 0.03), text_font=ToontownGlobals.getInterfaceFont(), pos=(-0.2, 0, -0.3), scale=0.45, image_scale=(2, 1, 3), command=self.__handleNameYourToon, ) self.nameYourToonButton.flattenMedium() guiButton.removeNode() self.statusText = DirectLabel( parent=self, relief=None, scale=0.09, pos=(0, 0, -0.24), text="", text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=7.5, text_scale=TTLocalizer.ACstatusText, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED, ) self.statusText.flattenStrong() if self.wantName != "": self.nameYourToonButton.hide() self.statusText["text"] = TTLocalizer.AvatarChoiceNameReview elif self.approvedName != "": self.nameYourToonButton.hide() self.statusText["text"] = TTLocalizer.AvatarChoiceNameApproved elif self.rejectedName != "": self.nameYourToonButton.hide() self.statusText["text"] = TTLocalizer.AvatarChoiceNameRejected elif self.allowedName == 1 and (base.cr.allowFreeNames() or self.hasPaid): self.nameYourToonButton.show() self.statusText["text"] = "" else: self.nameYourToonButton.hide() self.statusText["text"] = "" self.head = hidden.attachNewNode("head") self.head.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24, 0.24) self.head.reparentTo(self.stateNodePath[0], 20) self.head.instanceTo(self.stateNodePath[1], 20) self.head.instanceTo(self.stateNodePath[2], 20) self.headModel = ToonHead.ToonHead() self.headModel.setupHead(self.dna, forGui=1) self.headModel.reparentTo(self.head) animalStyle = self.dna.getAnimal() bodyScale = ToontownGlobals.toonBodyScales[animalStyle] self.headModel.setScale(bodyScale / 0.75) self.headModel.startBlink() self.headModel.startLookAround() trashcanGui = loader.loadModel("phase_3/models/gui/trashcan_gui") self.deleteButton = DirectButton( parent=self, image=( trashcanGui.find("**/TrashCan_CLSD"), trashcanGui.find("**/TrashCan_OPEN"), trashcanGui.find("**/TrashCan_RLVR"), ), text=("", TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, -0.1), text_font=ToontownGlobals.getInterfaceFont(), relief=None, pos=DELETE_POSITIONS[position], scale=0.45, command=self.__handleDelete, ) self.deleteButton.flattenMedium() trashcanGui.removeNode() self.resetFrameSize() self.avForLogging = None if av: self.avForLogging = str(av.id) else: self.avForLogging = None return
def load(self): self.gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui') self.listXorigin = -0.5 self.listFrameSizeX = 1.5 self.listZorigin = -0.9 self.listFrameSizeZ = 1.04 self.arrowButtonScale = 1.3 self.itemFrameXorigin = -0.237 self.itemFrameZorigin = 0.365 self.labelXstart = self.itemFrameXorigin + 0.293 self.scrollList = DirectScrolledList( parent=self, relief=None, pos=(0, 0, 0), incButton_image=(self.gui.find('**/FndsLst_ScrollUp'), self.gui.find('**/FndsLst_ScrollDN'), self.gui.find('**/FndsLst_ScrollUp_Rllvr'), self.gui.find('**/FndsLst_ScrollUp')), incButton_relief=None, incButton_scale=(self.arrowButtonScale, self.arrowButtonScale, -self.arrowButtonScale), incButton_pos=(self.labelXstart, 0, self.itemFrameZorigin - 0.999), incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=(self.gui.find('**/FndsLst_ScrollUp'), self.gui.find('**/FndsLst_ScrollDN'), self.gui.find('**/FndsLst_ScrollUp_Rllvr'), self.gui.find('**/FndsLst_ScrollUp')), decButton_relief=None, decButton_scale=(self.arrowButtonScale, self.arrowButtonScale, self.arrowButtonScale), decButton_pos=(self.labelXstart, 0, self.itemFrameZorigin + 0.227), decButton_image3_color=Vec4(1, 1, 1, 0.2), itemFrame_pos=(self.itemFrameXorigin, 0, self.itemFrameZorigin), itemFrame_scale=1.0, itemFrame_relief=DGG.SUNKEN, itemFrame_frameSize=(self.listXorigin, self.listXorigin + self.listFrameSizeX, self.listZorigin, self.listZorigin + self.listFrameSizeZ), itemFrame_frameColor=(0.85, 0.95, 1, 1), itemFrame_borderWidth=(0.01, 0.01), numItemsVisible=12, forceHeight=0.083, items=[]) for courseId in GolfGlobals.CourseInfo: courseName = GolfGlobals.getCourseName(courseId) frame = DirectFrame(parent=self.scrollList, relief=None) courseNameDisplay = DirectLabel( parent=frame, relief=None, pos=(-0.475, 0, 0.05), text=courseName, text_align=TextNode.ALeft, text_scale=0.075, text_fg=(0.85, 0.64, 0.13, 1.0), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getSignFont()) bestScoreDisplay = DirectLabel( parent=frame, relief=None, pos=(0.9, 0, 0.05), text=TTLocalizer.KartRace_Unraced, text_scale=0.06, text_fg=(0.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getToonFont()) self.bestDisplayList.append(bestScoreDisplay) self.scrollList.addItem(frame) for holeId in GolfGlobals.HoleInfo: holeName = GolfGlobals.getHoleName(holeId) frame = DirectFrame(parent=self.scrollList, relief=None) holeNameDisplay = DirectLabel( parent=frame, relief=None, pos=(-0.475, 0, 0.05), text=holeName, text_align=TextNode.ALeft, text_scale=0.075, text_fg=(0.95, 0.95, 0.0, 1.0), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getSignFont()) bestScoreDisplay = DirectLabel( parent=frame, relief=None, pos=(0.9, 0, 0.05), text=TTLocalizer.KartRace_Unraced, text_scale=0.06, text_fg=(0.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getToonFont()) self.bestDisplayList.append(bestScoreDisplay) self.scrollList.addItem(frame) return
def _createPartyEditorPage(self): page = DirectFrame(self.frame) page.setName('PartyPlannerEditorPage') self.LayoutTitleLabel = DirectLabel( parent=page, relief=None, text=TTLocalizer.PartyPlannerEditorTitle, pos=self.gui.find('**/title_locator').getPos() + Point3(0.0, 0.0, 0.075), scale=self.titleScale) self.costLabel = DirectLabel(parent=page, pos=(-0.74, 0.0, 0.17), relief=None, text=TTLocalizer.PartyPlannerTotalCost % 0, text_align=TextNode.ACenter, scale=TTLocalizer.PPcostLabel, textMayChange=True) self.partyGridBackground = DirectFrame( parent=page, relief=None, geom=self.gui.find('**/partyGrid_flat')) self.partyGroundsLabel = DirectLabel( parent=page, relief=None, text=TTLocalizer.PartyPlannerPartyGrounds, text_font=ToontownGlobals.getSignFont(), text_fg=VBase4(1.0, 0.0, 0.0, 1.0), text_scale=TTLocalizer.PPpartyGroundsLabel, pos=self.gui.find('**/step_05_partyGrounds_text_locator').getPos(), scale=0.1) self.activityBackground = DirectFrame( parent=page, relief=None, geom=self.gui.find('**/activitiesDecorations_flat1'), pos=(0.0, 0.0, 0.04)) pos = self.gui.find('**/step_05_instructions_locator').getPos() self.instructionLabel = DirectLabel( parent=page, relief=None, text=' ', text_pos=(pos[0], pos[2]), text_scale=TTLocalizer.PPinstructionLabel, textMayChange=True, geom=self.gui.find('**/instructions_flat')) self.elementTitleLabel = DirectLabel( parent=page, relief=None, text=' ', pos=self.gui.find( '**/step_05_activitiesName_text_locator').getPos() + Point3(0.0, 0.0, 0.04), text_scale=TTLocalizer.PPelementTitleLabel, textMayChange=True) self.elementPriceNode = TextNode('ElementPrice') self.elementPriceNode.setAlign(TextNode.ALeft) self.elementPriceNode.setTextColor(0.0, 0.0, 0.0, 1.0) self.elementPriceNode.setFont(ToontownGlobals.getToonFont()) self.elementPrice = page.attachNewNode(self.elementPriceNode) self.elementPrice.setScale(TTLocalizer.PPelementPriceNode) self.elementPrice.setPos( self.gui.find('**/step_05_activityPrice_text_locator').getPos() + Point3(-0.02, 0.0, 0.04)) self.elementDescriptionNode = TextNode('ElementDescription') self.elementDescriptionNode.setAlign(TextNode.ACenter) self.elementDescriptionNode.setWordwrap(8) self.elementDescriptionNode.setFont(ToontownGlobals.getToonFont()) self.elementDescriptionNode.setTextColor(0.0, 0.0, 0.0, 1.0) self.elementDescription = page.attachNewNode( self.elementDescriptionNode) self.elementDescription.setScale(TTLocalizer.PPelementDescription) self.elementDescription.setPos( self.gui.find( '**/step_05_activityDescription_text_locator').getPos() + Point3(0.0, 0.0, 0.04)) self.totalMoney = base.localAvatar.getTotalMoney() catalogGui = loader.loadModel('phase_5.5/models/gui/catalog_gui') self.beanBank = DirectLabel(parent=page, relief=None, text=str(self.totalMoney), text_align=TextNode.ARight, text_scale=0.075, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1), text_pos=(0.495, -0.53), text_font=ToontownGlobals.getSignFont(), textMayChange=True, image=catalogGui.find('**/bean_bank'), image_scale=(0.65, 0.65, 0.65), scale=0.9, pos=(-0.75, 0.0, 0.6)) catalogGui.removeNode() del catalogGui self.accept(localAvatar.uniqueName('moneyChange'), self.__moneyChange) self.accept(localAvatar.uniqueName('bankMoneyChange'), self.__moneyChange) self.partyEditor = PartyEditor(self, page) self.partyEditor.request('Hidden') pos = self.gui.find('**/step_05_add_text_locator').getPos() self.elementBuyButton = DirectButton( parent=page, relief=None, text=TTLocalizer.PartyPlannerBuy, text_pos=(pos[0], pos[2]), text_scale=TTLocalizer.PPelementBuyButton, geom=(self.gui.find('**/add_up'), self.gui.find('**/add_down'), self.gui.find('**/add_rollover')), geom3_color=VBase4(0.5, 0.5, 0.5, 1.0), textMayChange=True, pos=(0.0, 0.0, 0.04), command=self.partyEditor.buyCurrentElement) self.okWithPartyGroundsLayoutEvent = 'okWithPartyGroundsLayoutEvent' self.accept(self.okWithPartyGroundsLayoutEvent, self.okWithPartyGroundsLayout) self.okWithGroundsGui = TTDialog.TTGlobalDialog( dialogName=self.uniqueName('PartyEditorOkGui'), doneEvent=self.okWithPartyGroundsLayoutEvent, message=TTLocalizer.PartyPlannerOkWithGroundsLayout, style=TTDialog.YesNo, okButtonText=OTPLocalizer.DialogYes, cancelButtonText=OTPLocalizer.DialogNo) self.okWithGroundsGui.doneStatus = '' self.okWithGroundsGui.hide() return page
def makeFriendButton(self, friendTuple, colorChoice = None, bold = 0): playerName = None toonName = None if len(friendTuple) == 2: avId, flags = friendTuple playerId = None showType = 0 elif len(friendTuple) == 3: avId, flags, playerId = friendTuple showType = 0 elif len(friendTuple) == 4: avId, flags, playerId, showType = friendTuple command = self.__choseFriend playerName = None if playerId: playerInfo = base.cr.playerFriendsManager.playerId2Info.get(playerId, None) if playerInfo: playerName = playerInfo.playerName toonName = None hasManager = hasattr(base.cr, 'playerFriendsManager') handle = base.cr.identifyFriend(avId) if not handle and hasManager: handle = base.cr.playerFriendsManager.getAvHandleFromId(avId) if handle: toonName = handle.getName() if showType == 1 and playerId: if not playerName: return print 'ABORTING!!!' friendName = playerName rolloverName = toonName else: if not toonName: base.cr.fillUpFriendsMap() return friendName = toonName if playerName: rolloverName = playerName else: rolloverName = 'Unknown' if playerId: command = self.__chosePlayerFriend thing = playerId else: thing = avId fg = ToontownGlobals.ColorNoChat if flags & ToontownGlobals.FriendChat: fg = ToontownGlobals.ColorAvatar if playerId: fg = ToontownGlobals.ColorPlayer if colorChoice: fg = colorChoice fontChoice = ToontownGlobals.getToonFont() fontScale = 0.04 bg = None if colorChoice and bold: fontScale = 0.04 colorS = 0.7 bg = (colorChoice[0] * colorS, colorChoice[1] * colorS, colorChoice[2] * colorS, colorChoice[3]) db = DirectButton(relief=None, text=friendName, text_scale=fontScale, text_align=TextNode.ALeft, text_fg=fg, text_shadow=bg, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, text_font=fontChoice, textMayChange=0, command=command, extraArgs=[thing, showType]) if playerId: accountName = DirectLabel(parent=db, pos=Vec3(-0.02, 0, 0), text=rolloverName, text_fg=(0, 0, 0, 1), text_bg=(1, 1, 1, 1), text_pos=(0, 0), text_scale=0.045, text_align=TextNode.ARight) accountName.reparentTo(db.stateNodePath[2]) return db
def _initModel(self): self._countLabel = DirectLabel(parent=self, relief=None, pos=(0.0625, 0, -0.025), scale=CogdoGameConsts.MemoGuiTextScale, text=str(0), text_fg=CogdoGameConsts.MemoGuiTextColor, text_shadow=(0.2, 0.2, 0.2, 1), text_align=TextNode.ALeft, text_font=ToontownGlobals.getToonFont()) self._memoIcon = CogdoUtil.loadModel('memo_card', game='shared', group='gui') self._memoIcon.reparentTo(self) self._memoIcon.setScale(MEMOICON_SCALE) return
def __init__(self): self.__expectedCount = 0 self.__count = 0 self.gui = loader.loadModel('phase_3/models/gui/progress-background.bam') self.title = DirectLabel(guiId='ToontownLoadingScreenTitle', parent=self.gui, relief=None, pos=(base.a2dRight/5, 0, 0.235), text='', textMayChange=1, text_scale=0.08, text_fg=(0, 0, 0, 1), text_align=TextNode.ALeft, text_font=ToontownGlobals.getToonFont()) self.waitBar = self.waitBar = DirectWaitBar(guiId='ToontownLoadingScreenWaitBar', parent=self.gui, frameSize=(base.a2dLeft+(base.a2dRight/4.95), base.a2dRight-(base.a2dRight/4.95), -0.03, 0.03), pos=(0, 0, 0.15), text='') logoScale = 0.55 # Locked aspect ratio scale. self.logo = OnscreenImage( image='phase_3/maps/toontown-logo.png', scale=(((16.0 / 9.0)*logoScale) / (4.0/3.0), 1, logoScale / (4.0/3.0))) self.logo.reparentTo(hidden) self.logo.setTransparency(TransparencyAttrib.MAlpha) scale = self.logo.getScale() # self.logo.setPos(scale[0], 0, -scale[2]) self.logo.setPos(0, 0, -scale[2]) self.toon = None
def knockKnockTrack(self, avatar, duration): if avatar == None: return None # NOTE: the use of this rimshot sfx (which is in phase_5) # means we better not have any knock knock doors in phase_4, # which is true now. self.rimshot = base.loadSfx("phase_5/audio/sfx/AA_heal_telljoke.mp3") self.knockSfx = base.loadSfx("phase_5/audio/sfx/GUI_knock_3.mp3") joke = KnockKnockJokes[self.propId%len(KnockKnockJokes)] # For a marketing contest we are putting user-submitted knock knock jokes on # the first side doors (on the left) of the three TTC streets. place = base.cr.playGame.getPlace() if place: zone = place.getZoneId() branch = ZoneUtil.getBranchZone(zone) if branch == ToontownGlobals.SillyStreet: if self.propId == 44: joke = KnockKnockContestJokes[ToontownGlobals.SillyStreet] elif branch == ToontownGlobals.LoopyLane: if self.propId in list(KnockKnockContestJokes[ToontownGlobals.LoopyLane].keys()): joke = KnockKnockContestJokes[ToontownGlobals.LoopyLane][self.propId] elif branch == ToontownGlobals.PunchlinePlace: if self.propId == 1: joke = KnockKnockContestJokes[ToontownGlobals.PunchlinePlace] elif branch == ToontownGlobals.PolarPlace: if self.propId in list(KnockKnockContestJokes[ToontownGlobals.PolarPlace].keys()): joke = KnockKnockContestJokes[ToontownGlobals.PolarPlace][self.propId] self.nametag = None self.nametagNP = None doorNP=render.find("**/KnockKnockDoorSphere_"+str(self.propId)+";+s") if doorNP.isEmpty(): self.notify.warning("Could not find KnockKnockDoorSphere_%s" % (self.propId)) return None self.nametag = NametagGroup() self.nametag.setAvatar(doorNP) self.nametag.setFont(ToontownGlobals.getToonFont()) # nametag.setName must come after setFont(). self.nametag.setName(TTLocalizer.DoorNametag) # Do not allow user to click on door nametag self.nametag.setActive(0) self.nametag.manage(base.marginManager) self.nametag.getNametag3d().setBillboardOffset(4) nametagNode = self.nametag.getNametag3d().upcastToPandaNode() self.nametagNP=render.attachNewNode(nametagNode) self.nametagNP.setName("knockKnockDoor_nt_"+str(self.propId)) pos=doorNP.node().getSolid(0).getCenter() self.nametagNP.setPos(pos+Vec3(0, 0, avatar.getHeight()+2)) d=duration*0.125 track=Sequence( Parallel( Sequence(Wait(d * 0.5), SoundInterval(self.knockSfx)), Func(self.nametag.setChat, TTLocalizer.DoorKnockKnock, CFSpeech), Wait(d) ), Func(avatar.setChatAbsolute, TTLocalizer.DoorWhosThere, CFSpeech | CFTimeout, openEnded = 0), Wait(d), Func(self.nametag.setChat, joke[0], CFSpeech), Wait(d), Func(avatar.setChatAbsolute, joke[0]+TTLocalizer.DoorWhoAppendix, CFSpeech | CFTimeout, openEnded = 0), Wait(d), Func(self.nametag.setChat, joke[1], CFSpeech), Parallel( SoundInterval(self.rimshot, startTime = 2.0), Wait(d*4), ), Func(self.cleanupTrack) ) track.delayDelete = DelayDelete.DelayDelete(avatar, 'knockKnockTrack') return track
def getFont(self): return ToontownGlobals.getToonFont()
def __init__(self, av = None, position = 0): DirectButton.__init__(self, relief=None, text='', text_font=ToontownGlobals.getSignFont()) self.initialiseoptions(AvatarChoice) self.mode = None if not av: self.mode = AvatarChoice.MODE_CREATE self.name = '' self.dna = None else: self.mode = AvatarChoice.MODE_CHOOSE self.name = av.name self.dna = ToonDNA.ToonDNA(av.dna) self.wantName = av.wantName self.approvedName = av.approvedName self.rejectedName = av.rejectedName self.allowedName = av.allowedName self.position = position self.doneEvent = 'avChoicePanel-' + str(self.position) self.deleteWithPasswordFrame = None self.pickAToonGui = loader.loadModel('phase_3/models/gui/tt_m_gui_pat_mainGui') self.buttonBgs = [] self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareRed')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareGreen')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squarePurple')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareBlue')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squarePink')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareYellow')) self['image'] = self.buttonBgs[position] self.setScale(1.01) if self.mode is AvatarChoice.MODE_CREATE: self['command'] = self.__handleCreate self['text'] = (TTLocalizer.AvatarChoiceMakeAToon,) self['text_pos'] = (0, 0) self['text0_scale'] = 0.1 self['text1_scale'] = TTLocalizer.ACmakeAToon self['text2_scale'] = TTLocalizer.ACmakeAToon self['text0_fg'] = (0, 1, 0.8, 0.5) self['text1_fg'] = (0, 1, 0.8, 1) self['text2_fg'] = (0.3, 1, 0.9, 1) else: self['command'] = self.__handleChoice self['text'] = ('', TTLocalizer.AvatarChoicePlayThisToon, TTLocalizer.AvatarChoicePlayThisToon) self['text_scale'] = TTLocalizer.ACplayThisToon self['text_fg'] = (1, 0.9, 0.1, 1) self.nameText = DirectLabel(parent=self, relief=None, scale=0.08, pos=NAME_POSITIONS[position], text=self.name, hpr=(0, 0, NAME_ROTATIONS[position]), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=8, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED) if self.approvedName != '': self.nameText['text'] = self.approvedName guiButton = loader.loadModel('phase_3/models/gui/quit_button') self.nameYourToonButton = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), text=(TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, 0.03), text_font=ToontownGlobals.getInterfaceFont(), pos=(-0.2, 0, -0.3), scale=0.45, image_scale=(2, 1, 3), command=self.__handleNameYourToon) guiButton.removeNode() self.statusText = DirectLabel(parent=self, relief=None, scale=0.09, pos=(0, 0, -0.24), text='', text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=7.5, text_scale=TTLocalizer.ACstatusText, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED) if self.wantName != '': self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameReview elif self.approvedName != '': self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameApproved elif self.rejectedName != '': self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameRejected elif self.allowedName == 1: self.nameYourToonButton.show() self.statusText['text'] = '' else: self.nameYourToonButton.hide() self.statusText['text'] = '' self.head = hidden.attachNewNode('head') self.head.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24, 0.24) self.head.reparentTo(self.stateNodePath[0], 20) self.head.instanceTo(self.stateNodePath[1], 20) self.head.instanceTo(self.stateNodePath[2], 20) self.headModel = ToonHead.ToonHead() self.headModel.setupHead(self.dna, forGui=1) self.headModel.reparentTo(self.head) animalStyle = self.dna.getAnimal() bodyScale = ToontownGlobals.toonBodyScales[animalStyle] self.headModel.setScale(bodyScale / 0.75) self.headModel.startBlink() self.headModel.startLookAround() trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui') self.deleteButton = DirectButton(parent=self, image=(trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, -0.1), text_font=ToontownGlobals.getInterfaceFont(), relief=None, pos=DELETE_POSITIONS[position], scale=0.45, command=self.__handleDelete) trashcanGui.removeNode() self.resetFrameSize() self.avForLogging = None if av: self.avForLogging = str(av.id) else: self.avForLogging = None return
def makeFriendButton(self, friendTuple, colorChoice=None, bold=0): playerName = None toonName = None if len(friendTuple) == 2: avId, flags = friendTuple playerId = None showType = 0 elif len(friendTuple) == 3: avId, flags, playerId = friendTuple showType = 0 elif len(friendTuple) == 4: avId, flags, playerId, showType = friendTuple command = self.__choseFriend playerName = None if playerId: playerInfo = base.cr.playerFriendsManager.playerId2Info.get( playerId, None) if playerInfo: playerName = playerInfo.playerName toonName = None hasManager = hasattr(base.cr, 'playerFriendsManager') handle = base.cr.identifyFriend(avId) if not handle and hasManager: handle = base.cr.playerFriendsManager.getAvHandleFromId(avId) if handle: toonName = handle.getName() if showType == 1 and playerId: if not playerName: return print 'ABORTING!!!' friendName = playerName rolloverName = toonName else: if not toonName: base.cr.fillUpFriendsMap() return friendName = toonName if playerName: rolloverName = playerName else: rolloverName = 'Unknown' if playerId: command = self.__chosePlayerFriend thing = playerId else: thing = avId fg = ToontownGlobals.ColorNoChat if flags & ToontownGlobals.FriendChat: fg = ToontownGlobals.ColorAvatar if playerId: fg = ToontownGlobals.ColorPlayer if colorChoice: fg = colorChoice fontChoice = ToontownGlobals.getToonFont() fontScale = 0.04 bg = None if colorChoice and bold: fontScale = 0.04 colorS = 0.7 bg = (colorChoice[0] * colorS, colorChoice[1] * colorS, colorChoice[2] * colorS, colorChoice[3]) db = DirectButton(relief=None, text=friendName, text_scale=fontScale, text_align=TextNode.ALeft, text_fg=fg, text_shadow=bg, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, text_font=fontChoice, textMayChange=0, command=command, extraArgs=[thing, showType]) if playerId: accountName = DirectLabel(parent=db, pos=Vec3(-0.02, 0, 0), text=rolloverName, text_fg=(0, 0, 0, 1), text_bg=(1, 1, 1, 1), text_pos=(0, 0), text_scale=0.045, text_align=TextNode.ARight) accountName.reparentTo(db.stateNodePath[2]) return db
def __init__(self, av = None, position = 0): DirectButton.__init__(self, relief=None, text='', text_font=ToontownGlobals.getSignFont()) self.initialiseoptions(AvatarChoice) self.mode = None if not av: self.mode = AvatarChoice.MODE_CREATE self.name = '' self.dna = None else: self.mode = AvatarChoice.MODE_CHOOSE self.name = av.name self.dna = ToonDNA.ToonDNA(av.dna) self.wantName = av.wantName self.approvedName = av.approvedName self.rejectedName = av.rejectedName self.allowedName = av.allowedName self.position = position self.doneEvent = 'avChoicePanel-' + str(self.position) self.deleteWithPasswordFrame = None self.pickAToonGui = loader.loadModel('phase_3/models/gui/tt_m_gui_pat_mainGui') self.buttonBgs = [] self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareRed')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareGreen')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squarePurple')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareBlue')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squarePink')) self.buttonBgs.append(self.pickAToonGui.find('**/tt_t_gui_pat_squareYellow')) self['image'] = self.buttonBgs[position] self.setScale(1.01) if self.mode is AvatarChoice.MODE_CREATE: self['command'] = self.__handleCreate self['text'] = (TTLocalizer.AvatarChoiceMakeAToon,) self['text_pos'] = (0, 0) self['text0_scale'] = 0.1 self['text1_scale'] = TTLocalizer.ACmakeAToon self['text2_scale'] = TTLocalizer.ACmakeAToon self['text0_fg'] = (0, 1, 0.8, 0.5) self['text1_fg'] = (0, 1, 0.8, 1) self['text2_fg'] = (0.3, 1, 0.9, 1) else: self['command'] = self.__handleChoice self['text'] = ('', TTLocalizer.AvatarChoicePlayThisToon, TTLocalizer.AvatarChoicePlayThisToon) self['text_scale'] = TTLocalizer.ACplayThisToon self['text_fg'] = (1, 0.9, 0.1, 1) self.nameText = DirectLabel(parent=self, relief=None, scale=0.08, pos=NAME_POSITIONS[position], text=self.name, hpr=(0, 0, NAME_ROTATIONS[position]), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=8, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED) if self.approvedName != '': self.nameText['text'] = self.approvedName guiButton = loader.loadModel('phase_3/models/gui/quit_button') self.nameYourToonButton = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), text=(TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, 0.03), text_font=ToontownGlobals.getInterfaceFont(), pos=(-0.2, 0, -0.3), scale=0.45, image_scale=(2, 1, 3), command=self.__handleCreate) guiButton.removeNode() self.statusText = DirectLabel(parent=self, relief=None, scale=0.09, pos=(0, 0, -0.24), text='', text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=7.5, text_scale=TTLocalizer.ACstatusText, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED) if self.wantName != '': self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameReview elif self.approvedName != '': self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameApproved elif self.rejectedName != '': self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameRejected elif self.allowedName == 1: self.nameYourToonButton.show() self.statusText['text'] = '' else: self.nameYourToonButton.hide() self.statusText['text'] = '' self.head = hidden.attachNewNode('head') self.head.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24, 0.24) self.head.reparentTo(self.stateNodePath[0], 20) self.head.instanceTo(self.stateNodePath[1], 20) self.head.instanceTo(self.stateNodePath[2], 20) self.headModel = ToonHead.ToonHead() self.headModel.setupHead(self.dna, forGui=1) self.headModel.reparentTo(self.head) animalStyle = self.dna.getAnimal() bodyScale = ToontownGlobals.toonBodyScales[animalStyle] self.headModel.setScale(bodyScale / 0.75) self.headModel.startBlink() self.headModel.startLookAround() trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui') self.deleteButton = DirectButton(parent=self, image=(trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, -0.1), text_font=ToontownGlobals.getInterfaceFont(), relief=None, pos=DELETE_POSITIONS[position], scale=0.45, command=self.__handleDelete) trashcanGui.removeNode() self.resetFrameSize() self.avForLogging = None if av: self.avForLogging = str(av.id) else: self.avForLogging = None return
def makeFriendButton(self, friendTuple, colorChoice = None, bold = 0): playerName = None toonName = None if len(friendTuple) == 2: avId, flags = friendTuple playerId = None showType = 0 elif len(friendTuple) == 3: avId, flags, playerId = friendTuple showType = 0 elif len(friendTuple) == 4: avId, flags, playerId, showType = friendTuple command = self.__choseFriend # look up player name (if id given) playerName = None if playerId: playerInfo = base.cr.playerFriendsManager.playerId2Info.get(playerId, None) if playerInfo: playerName = playerInfo.playerName # look up toon name toonName = None hasManager = hasattr(base.cr, "playerFriendsManager") handle = base.cr.identifyFriend(avId) if not handle and hasManager: handle = base.cr.playerFriendsManager.getAvHandleFromId(avId) if handle: toonName = handle.getName() #print("makeFriendButton %s %s" % (playerName, toonName)) if showType == 1 and playerId: # we need a player name and didn't get one if not playerName: return None print("ABORTING!!!") friendName = playerName rolloverName = toonName else: if not toonName: # If we don't know who this friend is, we can't make a # button. We'll find out later; for now, leave it out. base.cr.fillUpFriendsMap() return None friendName = toonName if playerName: rolloverName = playerName else: rolloverName = "Unknown" if playerId: command = self.__chosePlayerFriend thing = playerId else: thing = avId # What color should we display the name in? Use the # appropriate nametag color, according to whether we are # "special friends" or not. #colorCode = NametagGroup.CCNoChat fg = ToontownGlobals.ColorNoChat if (flags & ToontownGlobals.FriendChat): #colorCode = NametagGroup.CCNormal fg = ToontownGlobals.ColorAvatar if playerId: fg = ToontownGlobals.ColorPlayer if colorChoice: fg = colorChoice fontChoice = ToontownGlobals.getToonFont() fontScale = 0.04 bg = None if colorChoice and bold: #fontChoice = ToontownGlobals.getMinnieFont() fontScale = 0.04 colorS = 0.7 bg = ((colorChoice[0] * colorS), (colorChoice[1] * colorS), (colorChoice[2] * colorS), (colorChoice[3])) #bg = (0,0,0,1) #fg = NametagGlobals.getNameFg(colorCode, PGButton.SInactive) #import pdb; pdb.set_trace() db = DirectButton( relief = None, text = friendName, text_scale = fontScale, text_align = TextNode.ALeft, text_fg = fg, text_shadow = bg, text1_bg = self.textDownColor, text2_bg = self.textRolloverColor, text3_fg = self.textDisabledColor, text_font = fontChoice, textMayChange = 0, command = command, extraArgs = [thing, showType], ) if playerId: accountName = DirectLabel( parent = db, pos = Vec3(-0.02, 0, 0), text = rolloverName, text_fg = (0, 0, 0, 1), text_bg = (1, 1, 1, 1), text_pos = (0, 0), text_scale = 0.045, text_align = TextNode.ARight, ) accountName.reparentTo(db.stateNodePath[2]) return db
def load(self): self.patNode = render.attachNewNode('patNode') self.patNode2d = aspect2d.attachNewNode('patNode2d') gui = loader.loadModel('phase_3/models/gui/pick_a_toon_gui') gui2 = loader.loadModel('phase_3/models/gui/quit_button') newGui = loader.loadModel('phase_3/models/gui/tt_m_gui_pat_mainGui') self.background = loader.loadModel( 'phase_3.5/models/modules/gagShop_interior') self.background.reparentTo(render) self.background.setPosHpr(-50, 0, 8.1, -90, 0, 0) for frame in render.findAllMatches('*/doorFrame*'): frame.removeNode() self.sky = loader.loadModel('phase_3.5/models/props/TT_sky') SkyUtil.startCloudSky(self) base.camera.setPosHpr(MAIN_POS, MAIN_HPR) self.title = OnscreenText(TTLocalizer.AvatarChooserPickAToon, scale=TTLocalizer.ACtitle, parent=hidden, fg=(1, 0.9, 0.1, 1), pos=(0.0, 0.82)) # Quit Button quitHover = gui.find('**/QuitBtn_RLVR') self.quitHover = quitHover self.quitButton = DirectButton(image=(quitHover, quitHover, quitHover), relief=None, text=TTLocalizer.AvatarChooserQuit, text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=TTLocalizer.ACquitButtonPos, text_scale=TTLocalizer.ACquitButton, image_scale=1, image1_scale=1.05, image2_scale=1.05, scale=1.05, pos=(1.08, 0, -0.907), command=self.__handleQuit) self.quitButton.reparentTo(base.a2dBottomLeft) self.quitButton.setPos(0.25, 0, 0.075) # Options Button self.optionsButton = DirectButton( image=(quitHover, quitHover, quitHover), relief=None, text="Options", text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=TTLocalizer.ACquitButtonPos, text_scale=TTLocalizer.ACquitButton, image_scale=1, image1_scale=1.05, image2_scale=1.05, scale=1.05, pos=(1.08, 0, -0.907), command=self.openOptions) self.optionsButton.reparentTo(base.a2dBottomRight) self.optionsButton.setPos(-0.25, 0, 0.075) # Shard Selector Button self.shardsButton = DirectButton( image=(quitHover, quitHover, quitHover), relief=None, text="Districts", text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=TTLocalizer.ACquitButtonPos, text_scale=0.08, image_scale=1, image1_scale=1.05, image2_scale=1.05, scale=1.05, pos=(1.08, 0, -0.907), command=self.openShardPicker) self.shardsButton.reparentTo(base.a2dBottomLeft) self.shardsButton.setPos(0.25, 0, 0.2) gui.removeNode() gui2.removeNode() newGui.removeNode() # Area toon is in self.area = OnscreenText(parent=self.patNode2d, font=ToontownGlobals.getToonFont(), pos=(-.1, -.1), scale=.075, text='', shadow=(0, 0, 0, 1), fg=COLORS[self.selectedToon]) # DMENU Pat Screen Stuff self.play = DirectButton(relief=None, image=(quitHover, quitHover, quitHover), text='PLAY THIS TOON', text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=(0, -.016), text_scale=0.045, image_scale=1, image1_scale=1.05, image2_scale=1.05, scale=1.4, pos=(0, 0, -0.90), command=self.playGame, parent=self.patNode2d) self.toon = Toon.Toon() self.toon.setPosHpr(-46, 0, 8.1, 90, 0, 0) self.toon.reparentTo(self.patNode) self.toon.stopLookAroundNow() self.pickAToonGui = loader.loadModel( 'phase_3/models/gui/tt_m_gui_pat_mainGui') self.buttonBgs = [] self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squareRed')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squareGreen')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squarePurple')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squareBlue')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squarePink')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squareYellow')) self.toon1 = DirectButton(text=' ', relief=None, command=self.selectToon, extraArgs=[0], image=self.buttonBgs[0]) self.toon1.reparentTo(self.patNode2d) self.toon1.setPos(-1, 0, 0.5) self.toon1.setScale(.5) self.toon2 = DirectButton(text=' ', relief=None, command=self.selectToon, extraArgs=[1], image=self.buttonBgs[1]) self.toon2.reparentTo(self.patNode2d) self.toon2.setPos(-.6, 0, 0.5) self.toon2.setScale(.5) self.toon3 = DirectButton(text=' ', relief=None, command=self.selectToon, extraArgs=[2], image=self.buttonBgs[2]) self.toon3.reparentTo(self.patNode2d) self.toon3.setPos(-.2, 0, 0.5) self.toon3.setScale(.5) self.toon4 = DirectButton(text=' ', relief=None, command=self.selectToon, extraArgs=[3], image=self.buttonBgs[3]) self.toon4.reparentTo(self.patNode2d) self.toon4.setPos(.2, 0, 0.5) self.toon4.setScale(.5) self.toon5 = DirectButton(text=' ', relief=None, command=self.selectToon, extraArgs=[4], image=self.buttonBgs[4]) self.toon5.reparentTo(self.patNode2d) self.toon5.setPos(.6, 0, 0.5) self.toon5.setScale(.5) self.toon6 = DirectButton(text=' ', relief=None, command=self.selectToon, extraArgs=[5], image=self.buttonBgs[5]) self.toon6.reparentTo(self.patNode2d) self.toon6.setPos(1, 0, 0.5) self.toon6.setScale(.5) # Delete Toon button trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui.bam') self.deleteButton = DirectButton( parent=base.a2dBottomRight, geom=(trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete, ''), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, -0.1), relief=None, scale=.5, command=self.__handleDelete, pos=(-.2, 0, .25))
def knockKnockTrack(self, avatar, duration): if avatar == None: return None self.rimshot = base.loadSfx("phase_5/audio/sfx/AA_heal_telljoke.mp3") self.knockSfx = base.loadSfx("phase_5/audio/sfx/GUI_knock_3.mp3") joke = KnockKnockJokes[self.propId % len(KnockKnockJokes)] place = base.cr.playGame.getPlace() if place: zone = place.getZoneId() branch = ZoneUtil.getBranchZone(zone) if branch == ToontownGlobals.SillyStreet: if self.propId == 44: joke = KnockKnockContestJokes[ToontownGlobals.SillyStreet] elif branch == ToontownGlobals.LoopyLane: if self.propId in KnockKnockContestJokes[ToontownGlobals.LoopyLane].keys(): joke = KnockKnockContestJokes[ToontownGlobals.LoopyLane][self.propId] elif branch == ToontownGlobals.PunchlinePlace: if self.propId == 1: joke = KnockKnockContestJokes[ToontownGlobals.PunchlinePlace] elif branch == ToontownGlobals.PolarPlace: if self.propId in KnockKnockContestJokes[ToontownGlobals.PolarPlace].keys(): joke = KnockKnockContestJokes[ToontownGlobals.PolarPlace][self.propId] self.nametag = None self.nametagNP = None doorNP = render.find("**/KnockKnockDoorSphere_" + str(self.propId) + ";+s") if doorNP.isEmpty(): self.notify.warning("Could not find KnockKnockDoorSphere_%s" % self.propId) return None self.nametag = NametagGroup() self.nametag.setAvatar(doorNP) self.nametag.setFont(ToontownGlobals.getToonFont()) self.nametag.setName(TTLocalizer.DoorNametag) self.nametag.setActive(0) self.nametag.manage(base.marginManager) self.nametag.getNametag3d().setBillboardOffset(4) nametagNode = self.nametag.getNametag3d().upcastToPandaNode() self.nametagNP = render.attachNewNode(nametagNode) self.nametagNP.setName("knockKnockDoor_nt_" + str(self.propId)) pos = doorNP.node().getSolid(0).getCenter() self.nametagNP.setPos(pos + Vec3(0, 0, avatar.getHeight() + 2)) d = duration * 0.125 track = Sequence( Parallel( Sequence(Wait(d * 0.5), SoundInterval(self.knockSfx)), Func(self.nametag.setChat, TTLocalizer.DoorKnockKnock, CFSpeech), Wait(d), ), Func(avatar.setChatAbsolute, TTLocalizer.DoorWhosThere, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[0], CFSpeech), Wait(d), Func(avatar.setChatAbsolute, joke[0] + TTLocalizer.DoorWhoAppendix, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChat, joke[1], CFSpeech), Parallel(SoundInterval(self.rimshot, startTime=2.0), Wait(d * 4)), Func(self.cleanupTrack), ) track.delayDelete = DelayDelete.DelayDelete(avatar, "knockKnockTrack") return track
def updateBuyButton(self): # display the correct button based on item status # if reached purchase limit if not self.loaded: return # Only paid members can purchase if not base.cr.isPaid(): self.buyButton['command'] = self.getTeaserPanel() #print (self['item'].getName()) # Show if on order self.buyButton.show() typeCode = self['item'].getTypeCode() orderCount = base.localAvatar.onOrder.count(self['item']) if (orderCount > 0): if orderCount > 1: auxText = "%d %s" % (orderCount, TTLocalizer.CatalogOnOrderText) else: auxText = TTLocalizer.CatalogOnOrderText #self.buyButton.hide() else: auxText = "" # else if you have the current nametag isNameTag = (typeCode == CatalogItemTypes.NAMETAG_ITEM) if isNameTag and not (localAvatar.getGameAccess() == OTPGlobals.AccessFull): # If the item panel is the free player nametag if (self['item'].nametagStyle == 100): if (localAvatar.getFont() == ToontownGlobals.getToonFont()): auxText = TTLocalizer.CatalogCurrent self.buyButton['state'] = DGG.DISABLED elif isNameTag and (self['item'].nametagStyle == localAvatar.getNametagStyle()): auxText = TTLocalizer.CatalogCurrent self.buyButton['state'] = DGG.DISABLED elif (self['item'].reachedPurchaseLimit(base.localAvatar)): max = self['item'].getPurchaseLimit() # Override aux text if max <= 1: auxText = TTLocalizer.CatalogPurchasedText if self['item'].hasBeenGifted(base.localAvatar): auxText = TTLocalizer.CatalogGiftedText else: auxText = TTLocalizer.CatalogPurchasedMaxText self.buyButton['state'] = DGG.DISABLED #self.buyButton.hide() # else if can afford elif (hasattr(self['item'], 'noGarden') and self['item'].noGarden(base.localAvatar)): auxText = TTLocalizer.NoGarden self.buyButton['state'] = DGG.DISABLED elif (hasattr(self['item'], 'isSkillTooLow') and self['item'].isSkillTooLow(base.localAvatar)): auxText = TTLocalizer.SkillTooLow self.buyButton['state'] = DGG.DISABLED elif (hasattr(self['item'], 'getDaysToGo') and self['item'].getDaysToGo(base.localAvatar)): auxText = TTLocalizer.DaysToGo % self['item'].getDaysToGo( base.localAvatar) self.buyButton['state'] = DGG.DISABLED elif (self['item'].getPrice(self['type']) <= (base.localAvatar.getMoney() + base.localAvatar.getBankMoney())): self.buyButton['state'] = DGG.NORMAL self.buyButton.show() # else ghosted buy button else: self.buyButton['state'] = DGG.DISABLED self.buyButton.show() self.auxText['text'] = auxText
def __init__(self, av = None, position = 0, paid = 0, okToLockout = 1): """ Set-up the avatar choice panel. If no av is passed in, offer the user the opportunity to create a new one """ DirectButton.__init__(self, relief = None, text = "", text_font = ToontownGlobals.getSignFont(), ) self.initialiseoptions(AvatarChoice) self.hasPaid = paid # if they haven't paid, lock out all panels except one self.mode = None if base.restrictTrialers and okToLockout: if position not in AvatarChoice.NEW_TRIALER_OPEN_POS: if not self.hasPaid: self.mode = AvatarChoice.MODE_LOCKED self.name = "" self.dna = None if self.mode is not AvatarChoice.MODE_LOCKED: # see if this is a choice panel or a create panel if not av: # the 'locked' panel is most like the create panel self.mode = AvatarChoice.MODE_CREATE self.name = "" self.dna = None else: self.mode = AvatarChoice.MODE_CHOOSE # Handle the special case of GM toons if GMUtils.testGMIdentity(av.name): self.name = self.__handleGMName(av.name) else: self.name = av.name self.dna = ToonDNA.ToonDNA(av.dna) self.wantName = av.wantName self.approvedName = av.approvedName self.rejectedName = av.rejectedName self.allowedName = av.allowedName self.position = position self.doneEvent = "avChoicePanel-" + str(self.position) self.deleteWithPasswordFrame = None self.pickAToonGui = loader.loadModel("phase_3/models/gui/tt_m_gui_pat_mainGui") self.buttonBgs = [] self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareRed")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareGreen")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squarePurple")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareBlue")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squarePink")) self.buttonBgs.append(self.pickAToonGui.find("**/tt_t_gui_pat_squareYellow")) self['image'] = self.buttonBgs[position] self.setScale(1.01) # make interface buttons and signs if self.mode is AvatarChoice.MODE_LOCKED: self['command'] = self.__handleTrialer self['text'] = TTLocalizer.AvatarChoiceSubscribersOnly self['text0_scale'] = 0.1 self['text1_scale'] = TTLocalizer.ACsubscribersOnly self['text2_scale'] = TTLocalizer.ACsubscribersOnly self['text0_fg'] = (0,1,0.8,0.0) self['text1_fg'] = (0,1,0.8,1) self['text2_fg'] = (0.3,1,0.9,1) self['text_pos'] = (0, 0.19) # use the logo on the background upsellModel = loader.loadModel("phase_3/models/gui/tt_m_gui_ups_mainGui") upsellTex = upsellModel.find("**/tt_t_gui_ups_logo_noBubbles") self.logoModelImage = loader.loadModel("phase_3/models/gui/members_only_gui").find("**/MembersOnly") logo = DirectFrame( state = DGG.DISABLED, parent = self, relief = None, image = upsellTex, image_scale = (0.9, 0, 0.9), image_pos = (0, 0, 0), scale = 0.45 ) logo.reparentTo(self.stateNodePath[0], 20) logo.instanceTo(self.stateNodePath[1], 20) logo.instanceTo(self.stateNodePath[2], 20) self.logo = logo upsellModel.removeNode() elif self.mode is AvatarChoice.MODE_CREATE: #print 'MODE_CREATE 2' # Click callback on the main button self['command'] = self.__handleCreate self['text'] = TTLocalizer.AvatarChoiceMakeAToon, self['text_pos'] = (0,0) self['text0_scale'] = 0.1 self['text1_scale'] = TTLocalizer.ACmakeAToon self['text2_scale'] = TTLocalizer.ACmakeAToon self['text0_fg'] = (0,1,0.8,0.5) self['text1_fg'] = (0,1,0.8,1) self['text2_fg'] = (0.3,1,0.9,1) # TODO: Make new toon rollover text else: # Click callback on the main button self['command'] = self.__handleChoice self['text'] = ("", TTLocalizer.AvatarChoicePlayThisToon, TTLocalizer.AvatarChoicePlayThisToon) self['text_scale'] = TTLocalizer.ACplayThisToon self['text_fg'] = (1,0.9,0.1,1) # Support 3d on the frame for the avatar head # Actually, we don't need to do this now, since we are # clearing the 2-d depth buffer anyway in render2d. #self.setY(100) #self.setDepthWrite(1) # put the toon name across the top self.nameText = DirectLabel( parent = self, relief = None, scale = 0.08, pos = NAME_POSITIONS[position], text = self.name, hpr = (0, 0, NAME_ROTATIONS[position]), text_fg = (1,1,1,1), text_shadow = (0,0,0,1), text_wordwrap = 8, text_font = ToontownGlobals.getToonFont(), # Disable the label so it ignores mouse events state = DGG.DISABLED, ) if self.approvedName != "": self.nameText['text'] = self.approvedName # Create the nameYourToon button guiButton = loader.loadModel("phase_3/models/gui/quit_button") self.nameYourToonButton = DirectButton( parent = self, relief = None, image = (guiButton.find("**/QuitBtn_UP"), guiButton.find("**/QuitBtn_DN"), guiButton.find("**/QuitBtn_RLVR"), ), text = (TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon), text_fg = (1,1,1,1), text_shadow = (0,0,0,1), text_scale = 0.15, text_pos = (0,.03), text_font = ToontownGlobals.getInterfaceFont(), pos = (-0.2, 0, -0.3), scale = 0.45, image_scale = (2,1,3), command = self.__handleNameYourToon, ) guiButton.removeNode() # put the toon name status label in ("rejected", "approved", "under review", or "") self.statusText = DirectLabel( parent = self, relief = None, scale = 0.09, pos = (0, 0, -0.24), text = "", text_fg = (1,1,1,1), text_shadow = (0,0,0,1), text_wordwrap = 7.5, text_scale = TTLocalizer.ACstatusText, text_font = ToontownGlobals.getToonFont(), # Disable the label so it ignores mouse events state = DGG.DISABLED, ) # Change the text to the appropiate name notice if self.wantName != "": self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameReview elif self.approvedName != "": self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameApproved elif self.rejectedName != "": self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameRejected else: if self.allowedName == 1 and (base.cr.allowFreeNames() or self.hasPaid): self.nameYourToonButton.show() self.statusText['text'] = "" else: self.nameYourToonButton.hide() self.statusText['text'] = "" # put the toon head on the panel self.head = hidden.attachNewNode('head') self.head.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24, 0.24) self.head.reparentTo(self.stateNodePath[0], 20) self.head.instanceTo(self.stateNodePath[1], 20) self.head.instanceTo(self.stateNodePath[2], 20) self.headModel = ToonHead.ToonHead() self.headModel.setupHead(self.dna, forGui = 1) self.headModel.reparentTo(self.head) # Scale the head by the body scale, so mouse heads don't # seem out of proportion to horse heads. animalStyle = self.dna.getAnimal() bodyScale = ToontownGlobals.toonBodyScales[animalStyle] self.headModel.setScale(bodyScale / 0.75) # Start blinking and looking around. self.headModel.startBlink() self.headModel.startLookAround() # TODO: play with button callback is __handleChoice trashcanGui = loader.loadModel("phase_3/models/gui/trashcan_gui") # create the delete-a-toon button self.deleteButton = DirectButton( parent = self, image = (trashcanGui.find("**/TrashCan_CLSD"), trashcanGui.find("**/TrashCan_OPEN"), trashcanGui.find("**/TrashCan_RLVR")), text = ("", TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete), text_fg = (1,1,1,1), text_shadow = (0,0,0,1), text_scale = 0.15, text_pos = (0, -0.1), text_font = ToontownGlobals.getInterfaceFont(), relief = None, pos = DELETE_POSITIONS[position], scale = 0.45, command = self.__handleDelete, ) trashcanGui.removeNode() self.resetFrameSize() # Setup account/avatar logging to VRS collector to capture # the relationship between MAC->IP->Av ID self.avForLogging = None if av: self.avForLogging = str(av.id) else: self.avForLogging = None if __debug__: base.avChoice = self
def load(self): self.gui = loader.loadModel('phase_3.5/models/gui/friendslist_gui') self.listXorigin = -0.5 self.listFrameSizeX = 1.5 self.listZorigin = -0.9 self.listFrameSizeZ = 1.04 self.arrowButtonScale = 1.3 self.itemFrameXorigin = -0.237 self.itemFrameZorigin = 0.365 self.labelXstart = self.itemFrameXorigin + 0.293 self.scrollList = DirectScrolledList(parent=self, relief=None, pos=(0, 0, 0), incButton_image=(self.gui.find('**/FndsLst_ScrollUp'), self.gui.find('**/FndsLst_ScrollDN'), self.gui.find('**/FndsLst_ScrollUp_Rllvr'), self.gui.find('**/FndsLst_ScrollUp')), incButton_relief=None, incButton_scale=(self.arrowButtonScale, self.arrowButtonScale, -self.arrowButtonScale), incButton_pos=(self.labelXstart, 0, self.itemFrameZorigin - 0.999), incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=(self.gui.find('**/FndsLst_ScrollUp'), self.gui.find('**/FndsLst_ScrollDN'), self.gui.find('**/FndsLst_ScrollUp_Rllvr'), self.gui.find('**/FndsLst_ScrollUp')), decButton_relief=None, decButton_scale=(self.arrowButtonScale, self.arrowButtonScale, self.arrowButtonScale), decButton_pos=(self.labelXstart, 0, self.itemFrameZorigin + 0.227), decButton_image3_color=Vec4(1, 1, 1, 0.2), itemFrame_pos=(self.itemFrameXorigin, 0, self.itemFrameZorigin), itemFrame_scale=1.0, itemFrame_relief=DGG.SUNKEN, itemFrame_frameSize=(self.listXorigin, self.listXorigin + self.listFrameSizeX, self.listZorigin, self.listZorigin + self.listFrameSizeZ), itemFrame_frameColor=(0.85, 0.95, 1, 1), itemFrame_borderWidth=(0.01, 0.01), numItemsVisible=12, forceHeight=0.083, items=[]) for courseId in GolfGlobals.CourseInfo: courseName = GolfGlobals.getCourseName(courseId) frame = DirectFrame(parent=self.scrollList, relief=None) courseNameDisplay = DirectLabel(parent=frame, relief=None, pos=(-0.475, 0, 0.05), text=courseName, text_align=TextNode.ALeft, text_scale=0.075, text_fg=(0.85, 0.64, 0.13, 1.0), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getSignFont()) bestScoreDisplay = DirectLabel(parent=frame, relief=None, pos=(0.9, 0, 0.05), text=TTLocalizer.KartRace_Unraced, text_scale=0.06, text_fg=(0.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getToonFont()) self.bestDisplayList.append(bestScoreDisplay) self.scrollList.addItem(frame) for holeId in GolfGlobals.HoleInfo: holeName = GolfGlobals.getHoleName(holeId) frame = DirectFrame(parent=self.scrollList, relief=None) holeNameDisplay = DirectLabel(parent=frame, relief=None, pos=(-0.475, 0, 0.05), text=holeName, text_align=TextNode.ALeft, text_scale=0.075, text_fg=(0.95, 0.95, 0.0, 1.0), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getSignFont()) bestScoreDisplay = DirectLabel(parent=frame, relief=None, pos=(0.9, 0, 0.05), text=TTLocalizer.KartRace_Unraced, text_scale=0.06, text_fg=(0.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getToonFont()) self.bestDisplayList.append(bestScoreDisplay) self.scrollList.addItem(frame) return
def updateBuyButton(self): if not self.loaded: return if not base.cr.isPaid(): self.buyButton['command'] = self.getTeaserPanel() self.buyButton.show() typeCode = self['item'].getTypeCode() orderCount = base.localAvatar.onOrder.count(self['item']) if orderCount > 0: if orderCount > 1: auxText = '%d %s' % (orderCount, TTLocalizer.CatalogOnOrderText) else: auxText = TTLocalizer.CatalogOnOrderText else: auxText = '' isNameTag = typeCode == CatalogItemTypes.NAMETAG_ITEM if isNameTag and not localAvatar.getGameAccess( ) == OTPGlobals.AccessFull: if self['item'].nametagStyle == 100: if localAvatar.getFont() == ToontownGlobals.getToonFont(): auxText = TTLocalizer.CatalogCurrent self.buyButton['state'] = DGG.DISABLED elif self['item'].getPrice( self['type'] ) > base.localAvatar.getMoney() + base.localAvatar.getBankMoney(): self.buyButton['state'] = DGG.DISABLED elif isNameTag and self[ 'item'].nametagStyle == localAvatar.getNametagStyle(): auxText = TTLocalizer.CatalogCurrent self.buyButton['state'] = DGG.DISABLED elif self['item'].reachedPurchaseLimit(base.localAvatar): max = self['item'].getPurchaseLimit() if max <= 1: auxText = TTLocalizer.CatalogPurchasedText if self['item'].hasBeenGifted(base.localAvatar): auxText = TTLocalizer.CatalogGiftedText else: auxText = TTLocalizer.CatalogPurchasedMaxText self.buyButton['state'] = DGG.DISABLED elif hasattr(self['item'], 'noGarden') and self['item'].noGarden( base.localAvatar): auxText = TTLocalizer.NoGarden self.buyButton['state'] = DGG.DISABLED elif hasattr(self['item'], 'isSkillTooLow') and self['item'].isSkillTooLow( base.localAvatar): auxText = TTLocalizer.SkillTooLow self.buyButton['state'] = DGG.DISABLED elif hasattr(self['item'], 'getDaysToGo') and self['item'].getDaysToGo( base.localAvatar): auxText = TTLocalizer.DaysToGo % self['item'].getDaysToGo( base.localAvatar) self.buyButton['state'] = DGG.DISABLED elif self['item'].getEmblemPrices( ) and not base.localAvatar.isEnoughMoneyAndEmblemsToBuy( self['item'].getPrice(self['type']), self['item'].getEmblemPrices()): self.buyButton['state'] = DGG.DISABLED elif self['item'].getPrice( self['type'] ) <= base.localAvatar.getMoney() + base.localAvatar.getBankMoney(): self.buyButton['state'] = DGG.NORMAL self.buyButton.show() else: self.buyButton['state'] = DGG.DISABLED self.buyButton.show() self.auxText['text'] = auxText
def load(self): self.patNode = render.attachNewNode('patNode') self.patNode2d = aspect2d.attachNewNode('patNode2d') self.patNode.setTransparency(1) self.patNode2d.setTransparency(1) self.patNode.setColorScale(1, 1, 1, 0) self.patNode2d.setColorScale(1, 1, 1, 0) gui = base.patgui gui2 = base.gui2 newGui = base.newGui matGui = base.matGui shuffleUp = base.shuffleUp shuffleDown = base.shuffleDown self.title = OnscreenText(TTLocalizer.AvatarChooserPickAToon, font=ToontownGlobals.getSignFont(), scale=TTLocalizer.ACtitle, parent=hidden, fg=(1, 0.9, 0.1, 1), pos=(0.0, 0.82)) quitHover = gui.find('**/QuitBtn_RLVR') self.quitHover = quitHover self.quitButton = DirectButton(image=(shuffleUp, shuffleDown, shuffleUp), relief=None, image_scale=(0.8, 0.7, 0.7), image1_scale=(0.83, 0.73, 0.73), image2_scale=(0.83, 0.73, 0.73), text=TTLocalizer.AvatarChooserQuit, text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=(0, -0.02), text_scale=0.06, scale=1, pos=(1.08, 0, -0.907), command=self.quitGame) self.quitButton.reparentTo(base.a2dBottomLeft) self.quitButton.setPos(0.25, 0, 0.075) self.optionsButton = DirectButton( image=(shuffleUp, shuffleDown, shuffleUp), relief=None, image_scale=(0.8, 0.7, 0.7), image1_scale=(0.83, 0.73, 0.73), image2_scale=(0.83, 0.73, 0.73), text='Options', text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=(0, -0.02), text_scale=0.06, scale=1, pos=(1.08, 0, -0.907), command=self.openOptions) self.optionsButton.reparentTo(base.a2dBottomRight) self.optionsButton.setPos(-0.25, 0, 0.075) self.shardsButton = DirectButton( image=(shuffleUp, shuffleDown, shuffleUp), relief=None, image_scale=(0.8, 0.7, 0.7), image1_scale=(0.83, 0.73, 0.73), image2_scale=(0.83, 0.73, 0.73), text='Districts', text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=(0, -0.02), text_scale=0.06, scale=1, pos=(1.08, 0, -0.907), command=self.openShardPicker) self.shardsButton.reparentTo(base.a2dBottomLeft) self.shardsButton.setPos(0.25, 0, 0.2) self.area = OnscreenText(parent=self.patNode2d, font=ToontownGlobals.getToonFont(), pos=(-0.1, -0.1), scale=0.075, text='', shadow=(0, 0, 0, 1), fg=COLORS[self.selectedToon]) self.play = DirectButton(relief=None, image=(shuffleUp, shuffleDown, shuffleUp), image_scale=(0.8, 0.7, 0.7), image1_scale=(0.83, 0.73, 0.73), image2_scale=(0.83, 0.73, 0.73), text='PLAY THIS TOON', text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=(0, -0.016), text_scale=0.035, scale=1.4, pos=(0, 0, -0.9), command=self.playGame, parent=self.patNode2d) self.toon = Toon.Toon() self.toon.setPosHpr(Vec3(5, 0, 0), Vec3(150, 0, 0)) self.toon.reparentTo(base.cr.DMENU_SCREEN.background) self.toon.stopLookAroundNow() self.pickAToonGui = newGui self.buttonBgs = [] self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squareRed')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squareGreen')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squarePurple')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squareBlue')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squarePink')) self.buttonBgs.append( self.pickAToonGui.find('**/tt_t_gui_pat_squareYellow')) buttonIndex = [] for av in self.avatarList: self.setupButtons(av, position=av.position) buttonIndex.append(av.position) for pos in xrange(0, 6): if pos not in buttonIndex: button = self.setupButtons(position=pos) base.graphicsEngine.renderFrame() self.changeName = DirectButton(relief=None, image=(quitHover, quitHover, quitHover), text='NAME THIS TOON', text_font=ToontownGlobals.getSignFont(), text_fg=(0.977, 0.816, 0.133, 1), text_pos=(0, -0.016), text_scale=0.045, image_scale=1, image1_scale=1.05, image2_scale=1.05, scale=1.4, pos=(0, 0, -0.75), command=self.__handleNameYourToon, parent=self.patNode2d) LerpColorScaleInterval(self.patNode, 0.5, Vec4(1, 1, 1, 1), Vec4(1, 1, 1, 0)).start() LerpColorScaleInterval(self.patNode2d, 0.5, Vec4(1, 1, 1, 1), Vec4(1, 1, 1, 0)).start()
def __init__(self, av=None, position=0, paid=0, okToLockout=1): DirectButton.__init__(self, relief=None, text='', text_font=ToontownGlobals.getSignFont()) self.initialiseoptions(AvatarChoice) self.hasPaid = paid self.mode = None if base.restrictTrialers and okToLockout: if position not in AvatarChoice.NEW_TRIALER_OPEN_POS: if not self.hasPaid: self.mode = AvatarChoice.MODE_LOCKED self.name = '' self.dna = None if self.mode is not AvatarChoice.MODE_LOCKED: if not av: self.mode = AvatarChoice.MODE_CREATE self.name = '' self.dna = None else: self.mode = AvatarChoice.MODE_CHOOSE self.name = av.name self.dna = ToonDNA.ToonDNA(av.dna) self.wantName = av.wantName self.approvedName = av.approvedName self.rejectedName = av.rejectedName self.allowedName = av.allowedName self.position = position self.doneEvent = 'avChoicePanel-' + str(self.position) self.deleteWithPasswordFrame = None if base.classicVisuals == 2: self.pickAToonGui = loader.loadModel('phase_3/models/gui/pick_a_toon_gui') else: self.pickAToonGui = loader.loadModel('phase_3/models/gui/tt_m_gui_pat_mainGui') self.buttonBgs = [] if base.classicVisuals == 2: self['image'] = self.pickAToonGui.find('**/av-chooser_Square_UP') else: num = 0 bgNodesNames = ['default', 'halloween', 'holiday', 'aprilfools'] pickAToonPath = self.pickAToonGui.find('**/tt_m_gui_pat_mainGUI_' + bgNodesNames[num]) self.buttonBgs = [] self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squareRed')) self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squareGreen')) self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squarePurple')) self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squareBlue')) self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squarePink')) self.buttonBgs.append(pickAToonPath.find('**/tt_t_gui_pat_squareYellow')) self['image'] = self.buttonBgs[position] self.setScale(1.01) if self.mode is AvatarChoice.MODE_LOCKED: if base.classicVisuals == 2: self['text0_scale'] = 0.1 self['text1_scale'] = 0.115 self['text2_scale'] = 0.115 self['text0_fg'] = (0, 1, 0.8, 0.0) self['text1_fg'] = (0, 1, 0.8, 1) self['text2_fg'] = (0.3, 1, 0.9, 1) self['text_pos'] = (0, 0.19) logoModel = loader.loadModel('phase_3/models/gui/members_only_gui') logo = DirectFrame(parent=self, relief=None, image=logoModel.find('**/MembersOnly'), image_scale=(0.4375, 0, 0.375), image_pos=(0, 0, 0)) else: self['command'] = self.__handleTrialer self['text'] = TTLocalizer.AvatarChoiceSubscribersOnly self['text0_scale'] = 0.1 self['text1_scale'] = TTLocalizer.ACsubscribersOnly self['text2_scale'] = TTLocalizer.ACsubscribersOnly self['text0_fg'] = (0, 1, 0.8, 0.0) self['text1_fg'] = (0, 1, 0.8, 1) self['text2_fg'] = (0.3, 1, 0.9, 1) self['text_pos'] = (0, 0.19) upsellModel = loader.loadModel('phase_3/models/gui/tt_m_gui_ups_mainGui') upsellTex = upsellModel.find('**/tt_t_gui_ups_logo_noBubbles') self.logoModelImage = loader.loadModel('phase_3/models/gui/members_only_gui').find('**/MembersOnly') logo = DirectFrame(state=DGG.DISABLED, parent=self, relief=None, image=upsellTex, image_scale=(0.9, 0, 0.9), image_pos=(0, 0, 0), scale=0.45) logo.reparentTo(self.stateNodePath[0], 20) logo.instanceTo(self.stateNodePath[1], 20) logo.instanceTo(self.stateNodePath[2], 20) if base.classicVisuals == 2: logoModel.removeNode() else: self.logo = logo upsellModel.removeNode() elif self.mode is AvatarChoice.MODE_CREATE: self['command'] = self.__handleCreate self['text'] = (TTLocalizer.AvatarChoiceMakeAToon,) self['text_pos'] = (0, 0) self['text0_scale'] = 0.1 self['text1_scale'] = TTLocalizer.ACmakeAToon self['text2_scale'] = TTLocalizer.ACmakeAToon self['text0_fg'] = (0, 1, 0.8, 0.5) self['text1_fg'] = (0, 1, 0.8, 1) self['text2_fg'] = (0.3, 1, 0.9, 1) else: self['command'] = self.__handleChoice if base.classicVisuals == 2: self['text'] = ( '', TTLocalizer.AvatarChoicePlayThisToon, TTLocalizer.AvatarChoicePlayThisToon) self['text_scale'] = 0.12 self['text_fg'] = (1, 0.9, 0.1, 1) self.nameText = DirectLabel(parent=self, relief=None, scale=0.089, pos=(0, 0, 0.27), text=self.name, text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=7.5, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED) else: self['text'] = ( '', TTLocalizer.AvatarChoicePlayThisToon, TTLocalizer.AvatarChoicePlayThisToon) self['text_scale'] = TTLocalizer.ACplayThisToon self['text_fg'] = (1, 0.9, 0.1, 1) self.nameText = DirectLabel(parent=self, relief=None, scale=0.08, pos=NAME_POSITIONS[position], text=self.name, hpr=(0, 0, NAME_ROTATIONS[position]), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=8, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED) if self.approvedName != '': self.nameText['text'] = self.approvedName guiButton = loader.loadModel('phase_3/models/gui/quit_button') self.nameYourToonButton = DirectButton(parent=self, relief=None, image=(guiButton.find('**/QuitBtn_UP'), guiButton.find('**/QuitBtn_DN'), guiButton.find('**/QuitBtn_RLVR')), text=(TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon, TTLocalizer.AvatarChoiceNameYourToon), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, 0.03), text_font=ToontownGlobals.getInterfaceFont(), pos=(-0.2, 0, -0.3), scale=0.45, image_scale=(2, 1, 3), command=self.__handleNameYourToon) guiButton.removeNode() self.statusText = DirectLabel(parent=self, relief=None, scale=0.09, pos=(0, 0, -0.24), text='', text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_wordwrap=7.5, text_scale=TTLocalizer.ACstatusText, text_font=ToontownGlobals.getToonFont(), state=DGG.DISABLED) if self.wantName != '': self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameReview elif self.approvedName != '': self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameApproved elif self.rejectedName != '': self.nameYourToonButton.hide() self.statusText['text'] = TTLocalizer.AvatarChoiceNameRejected elif self.allowedName == 1 and (base.cr.allowFreeNames() or self.hasPaid): self.nameYourToonButton.show() self.statusText['text'] = '' else: self.nameYourToonButton.hide() self.statusText['text'] = '' self.head = hidden.attachNewNode('head') self.head.setPosHprScale(0, 5, -0.1, 180, 0, 0, 0.24, 0.24, 0.24) self.head.reparentTo(self.stateNodePath[0], 20) self.head.instanceTo(self.stateNodePath[1], 20) self.head.instanceTo(self.stateNodePath[2], 20) self.headModel = ToonHead.ToonHead() self.headModel.setupHead(self.dna, forGui=1) self.headModel.reparentTo(self.head) animalStyle = self.dna.getAnimal() bodyScale = ToontownGlobals.toonBodyScales[animalStyle] self.headModel.setScale(bodyScale / 0.75) self.headModel.startBlink() self.headModel.startLookAround() trashcanGui = loader.loadModel('phase_3/models/gui/trashcan_gui') if base.classicVisuals == 2: self.deleteButton = DirectButton(parent=self, image=( trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR')), text=( '', TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, -0.1), text_font=ToontownGlobals.getInterfaceFont(), relief=None, pos=(0.27, 0, -0.25), scale=0.45, command=self.__handleDelete) else: self.deleteButton = DirectButton(parent=self, image=(trashcanGui.find('**/TrashCan_CLSD'), trashcanGui.find('**/TrashCan_OPEN'), trashcanGui.find('**/TrashCan_RLVR')), text=('', TTLocalizer.AvatarChoiceDelete, TTLocalizer.AvatarChoiceDelete), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.15, text_pos=(0, -0.1), text_font=ToontownGlobals.getInterfaceFont(), relief=None, pos=DELETE_POSITIONS[position], scale=0.45, command=self.__handleDelete) trashcanGui.removeNode() self.resetFrameSize() self.avForLogging = None if av: self.avForLogging = str(av.id) else: self.avForLogging = None return
class DistributedCannonGame(DistributedMinigame): notify = DirectNotifyGlobal.directNotify.newCategory('DistributedMinigame') font = ToontownGlobals.getToonFont() LOCAL_CANNON_MOVE_TASK = 'localCannonMoveTask' REWARD_COUNTDOWN_TASK = 'cannonGameRewardCountdown' HIT_GROUND = 0 HIT_TOWER = 1 HIT_WATER = 2 FIRE_KEY = base.JUMP UP_KEY = base.MOVE_UP DOWN_KEY = base.MOVE_DOWN LEFT_KEY = base.MOVE_LEFT RIGHT_KEY = base.MOVE_RIGHT INTRO_TASK_NAME = 'CannonGameIntro' INTRO_TASK_NAME_CAMERA_LERP = 'CannonGameIntroCamera' def __init__(self, cr): DistributedMinigame.__init__(self, cr) self.gameFSM = ClassicFSM.ClassicFSM('DistributedCannonGame', [ State.State('off', self.enterOff, self.exitOff, ['aim']), State.State('aim', self.enterAim, self.exitAim, ['shoot', 'waitForToonsToLand', 'cleanup']), State.State('shoot', self.enterShoot, self.exitShoot, ['aim', 'waitForToonsToLand', 'cleanup']), State.State('waitForToonsToLand', self.enterWaitForToonsToLand, self.exitWaitForToonsToLand, ['cleanup']), State.State('cleanup', self.enterCleanup, self.exitCleanup, []) ], 'off', 'cleanup') self.addChildGameFSM(self.gameFSM) self.cannonLocationDict = {} self.cannonPositionDict = {} self.cannonDict = {} self.toonModelDict = {} self.dropShadowDict = {} self.toonHeadDict = {} self.toonScaleDict = {} self.toonIntervalDict = {} self.leftPressed = 0 self.rightPressed = 0 self.upPressed = 0 self.downPressed = 0 self.cannonMoving = 0 self.modelCount = 14 def getTitle(self): return TTLocalizer.CannonGameTitle def getInstructions(self): return TTLocalizer.CannonGameInstructions def getMaxDuration(self): return CannonGameGlobals.GameTime def load(self): self.notify.debug('load') DistributedMinigame.load(self) self.sky = loader.loadModel('phase_3.5/models/props/TT_sky') self.ground = loader.loadModel( 'phase_4/models/minigames/toon_cannon_gameground') self.tower = loader.loadModel( 'phase_4/models/minigames/toon_cannon_water_tower') self.cannon = loader.loadModel('phase_4/models/minigames/toon_cannon') self.dropShadow = loader.loadModel('phase_3/models/props/drop_shadow') self.hill = loader.loadModel('phase_4/models/minigames/cannon_hill') self.sky.setScale(WORLD_SCALE) self.ground.setScale(GROUND_SCALE) self.cannon.setScale(CANNON_SCALE) self.dropShadow.setColor(0, 0, 0, 0.5) self.ground.setColor(0.85, 0.85, 0.85, 1.0) self.hill.setScale(1, 1, CANNON_Z / 20.0) self.dropShadow.setBin('fixed', 0, 1) self.splash = Splash.Splash(render) self.dustCloud = DustCloud.DustCloud(render) purchaseModels = loader.loadModel('phase_4/models/gui/purchase_gui') self.jarImage = purchaseModels.find('**/Jar') self.jarImage.reparentTo(hidden) self.rewardPanel = DirectLabel(parent=hidden, relief=None, pos=(-0.173, 0.0, -0.55), scale=0.65, text='', text_scale=0.2, text_fg=(0.95, 0.95, 0, 1), text_pos=(0, -0.13), text_font=ToontownGlobals.getSignFont(), image=self.jarImage) self.rewardPanelTitle = DirectLabel(parent=self.rewardPanel, relief=None, pos=(0, 0, 0.06), scale=0.08, text=TTLocalizer.CannonGameReward, text_fg=(0.95, 0.95, 0, 1), text_shadow=(0, 0, 0, 1)) self.music = base.loader.loadMusic( 'phase_4/audio/bgm/MG_cannon_game.ogg') self.sndCannonMove = base.loader.loadSfx( 'phase_4/audio/sfx/MG_cannon_adjust.ogg') self.sndCannonFire = base.loader.loadSfx( 'phase_4/audio/sfx/MG_cannon_fire_alt.ogg') self.sndHitGround = base.loader.loadSfx( 'phase_4/audio/sfx/MG_cannon_hit_dirt.ogg') self.sndHitTower = base.loader.loadSfx( 'phase_4/audio/sfx/MG_cannon_hit_tower.ogg') self.sndHitWater = base.loader.loadSfx( 'phase_4/audio/sfx/MG_cannon_splash.ogg') self.sndWhizz = base.loader.loadSfx( 'phase_4/audio/sfx/MG_cannon_whizz.ogg') self.sndWin = base.loader.loadSfx('phase_4/audio/sfx/MG_win.ogg') self.sndRewardTick = base.loader.loadSfx( 'phase_3.5/audio/sfx/tick_counter.ogg') guiModel = 'phase_4/models/gui/cannon_game_gui' cannonGui = loader.loadModel(guiModel) self.aimPad = DirectFrame(image=cannonGui.find('**/CannonFire_PAD'), relief=None, pos=(0.7, 0, -0.553333), scale=0.8) cannonGui.removeNode() self.aimPad.hide() 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.timer = ToontownTimer.ToontownTimer() self.timer.posInTopRightCorner() self.timer.hide() self.DEBUG_TOWER_RANGE = 0 self.DEBUG_CANNON_FAR_LEFT = 0 self.DEBUG_TOWER_NEAR = 1 self.DEBUG_TOWER_FAR_LEFT = 1 def unload(self): self.notify.debug('unload') DistributedMinigame.unload(self) self.sky.removeNode() del self.sky self.ground.removeNode() del self.ground self.tower.removeNode() del self.tower self.cannon.removeNode() del self.cannon del self.dropShadowDict self.dropShadow.removeNode() del self.dropShadow self.splash.destroy() del self.splash self.dustCloud.destroy() del self.dustCloud self.hill.removeNode() del self.hill self.rewardPanel.destroy() del self.rewardPanel self.jarImage.removeNode() del self.jarImage del self.music del self.sndCannonMove del self.sndCannonFire del self.sndHitGround del self.sndHitTower del self.sndHitWater del self.sndWhizz del self.sndWin del self.sndRewardTick self.aimPad.destroy() del self.aimPad del self.fireButton del self.upButton del self.downButton del self.leftButton del self.rightButton for avId in self.toonHeadDict.keys(): head = self.toonHeadDict[avId] head.stopBlink() head.stopLookAroundNow() av = self.getAvatar(avId) if av: av.loop('neutral') av.setPlayRate(1.0, 'run') av.nametag.remove(head.tag) head.delete() del self.toonHeadDict for model in self.toonModelDict.values(): model.removeNode() del self.toonModelDict del self.toonScaleDict for interval in self.toonIntervalDict.values(): interval.finish() del self.toonIntervalDict for avId in self.avIdList: self.cannonDict[avId][0].removeNode() del self.cannonDict[avId][0] del self.cannonDict self.timer.destroy() del self.timer del self.cannonLocationDict self.removeChildGameFSM(self.gameFSM) del self.gameFSM def onstage(self): self.notify.debug('onstage') DistributedMinigame.onstage(self) self.__createCannons() for avId in self.avIdList: self.cannonDict[avId][0].reparentTo(render) self.towerPos = self.getTowerPosition() self.tower.setPos(self.towerPos) self.tower.reparentTo(render) self.sky.reparentTo(render) self.ground.reparentTo(render) self.hill.setPosHpr(0, CANNON_Y + 2.33, 0, 0, 0, 0) self.hill.reparentTo(render) self.splash.reparentTo(render) self.dustCloud.reparentTo(render) self.__createToonModels(self.localAvId) camera.reparentTo(render) self.__oldCamFar = base.camLens.getFar() base.camLens.setFar(FAR_PLANE_DIST) self.__startIntro() base.transitions.irisIn(0.4) base.playMusic(self.music, looping=1, volume=0.8) def offstage(self): self.notify.debug('offstage') self.sky.reparentTo(hidden) self.ground.reparentTo(hidden) self.hill.reparentTo(hidden) self.tower.reparentTo(hidden) for avId in self.avIdList: self.cannonDict[avId][0].reparentTo(hidden) if avId in self.dropShadowDict: self.dropShadowDict[avId].reparentTo(hidden) av = self.getAvatar(avId) if av: av.dropShadow.show() av.resetLOD() self.splash.reparentTo(hidden) self.splash.stop() self.dustCloud.reparentTo(hidden) self.dustCloud.stop() self.__stopIntro() base.camLens.setFar(self.__oldCamFar) self.timer.reparentTo(hidden) self.rewardPanel.reparentTo(hidden) DistributedMinigame.offstage(self) def getTowerPosition(self): yRange = TOWER_Y_RANGE yMin = int(yRange * 0.3) yMax = yRange if self.DEBUG_TOWER_RANGE: if self.DEBUG_TOWER_NEAR: y = yMin else: y = yMax else: y = self.randomNumGen.randint(yMin, yMax) xRange = TOWER_X_RANGE if self.DEBUG_TOWER_RANGE: if self.DEBUG_TOWER_FAR_LEFT: x = 0 else: x = xRange else: x = self.randomNumGen.randint(0, xRange) x = x - int(xRange / 2.0) if base.wantMinigameDifficulty: diff = self.getDifficulty() scale = 0.5 + 0.5 * diff x *= scale yCenter = (yMin + yMax) / 2.0 y = (y - yCenter) * scale + yCenter x = float(x) * (float(y) / float(yRange)) y = y - int(yRange / 2.0) self.notify.debug('getTowerPosition: ' + str(x) + ', ' + str(y)) return Point3(x, y, 0.0) def __createCannons(self): for avId in self.avIdList: cannon = self.cannon.copyTo(hidden) barrel = cannon.find('**/cannon') self.cannonDict[avId] = [cannon, barrel] numAvs = self.numPlayers for i in xrange(numAvs): avId = self.avIdList[i] self.cannonLocationDict[avId] = Point3( i * CANNON_X_SPACING - (numAvs - 1) * CANNON_X_SPACING / 2, CANNON_Y, CANNON_Z) if self.DEBUG_TOWER_RANGE: if self.DEBUG_CANNON_FAR_LEFT: self.cannonLocationDict[avId] = Point3( 0 * CANNON_X_SPACING - 3 * CANNON_X_SPACING / 2, CANNON_Y, CANNON_Z) else: self.cannonLocationDict[avId] = Point3( 3 * CANNON_X_SPACING - 3 * CANNON_X_SPACING / 2, CANNON_Y, CANNON_Z) self.cannonPositionDict[avId] = [ 0, CannonGameGlobals.CANNON_ANGLE_MIN ] self.cannonDict[avId][0].setPos(self.cannonLocationDict[avId]) self.__updateCannonPosition(avId) def setGameReady(self): if not self.hasLocalToon: return self.notify.debug('setGameReady') if DistributedMinigame.setGameReady(self): return for avId in self.avIdList: if avId != self.localAvId: self.__createToonModels(avId) def __createToonModels(self, avId): toon = self.getAvatar(avId) self.toonScaleDict[avId] = toon.getScale() toon.useLOD(1000) toonParent = render.attachNewNode('toonOriginChange') toon.reparentTo(toonParent) toon.setPosHpr(0, 0, -(toon.getHeight() / 2.0), 0, 0, 0) self.toonModelDict[avId] = toonParent head = ToonHead.ToonHead() head.setupHead(self.getAvatar(avId).style) head.reparentTo(hidden) self.toonHeadDict[avId] = head toon = self.getAvatar(avId) tag = NametagFloat3d() tag.hideNametag() tag.update() tag.setBillboardOffset(0) tag.setAvatar(head) toon.nametag.add(tag) tagPath = head.attachNewNode(tag) tagPath.setPos(0, 0, 1) head.tag = tag self.__loadToonInCannon(avId) self.getAvatar(avId).dropShadow.hide() self.dropShadowDict[avId] = self.dropShadow.copyTo(hidden) def setGameStart(self, timestamp): if not self.hasLocalToon: return self.notify.debug('setGameStart') DistributedMinigame.setGameStart(self, timestamp) self.__stopIntro() self.__putCameraBehindCannon() if not base.config.GetBool('endless-cannon-game', 0): self.timer.show() self.timer.countdown(CannonGameGlobals.GameTime, self.__gameTimerExpired) self.rewardPanel.reparentTo(base.a2dTopRight) self.scoreMult = MinigameGlobals.getScoreMult(self.cr.playGame.hood.id) self.__startRewardCountdown() self.airborneToons = 0 self.clockStopTime = None self.gameFSM.request('aim') def __gameTimerExpired(self): self.notify.debug('game timer expired') self.gameOver() def __playing(self): return self.gameFSM.getCurrentState() != self.gameFSM.getFinalState() def updateCannonPosition(self, avId, zRot, angle): if not self.hasLocalToon: return if not self.__playing(): return if avId != self.localAvId: self.cannonPositionDict[avId] = [zRot, angle] self.__updateCannonPosition(avId) def setCannonWillFire(self, avId, fireTime, zRot, angle): if not self.hasLocalToon: return if not self.__playing(): return self.notify.debug('setCannonWillFire: ' + str(avId) + ': zRot=' + str(zRot) + ', angle=' + str(angle) + ', time=' + str(fireTime)) self.cannonPositionDict[avId][0] = zRot self.cannonPositionDict[avId][1] = angle self.__updateCannonPosition(avId) task = Task(self.__fireCannonTask) task.avId = avId task.fireTime = fireTime timeToWait = task.fireTime - self.getCurrentGameTime() if timeToWait > 0.0: fireTask = Task.sequence(Task.pause(timeToWait), task) else: fireTask = task fireTask = task taskMgr.add(fireTask, 'fireCannon' + str(avId)) self.airborneToons += 1 def announceToonWillLandInWater(self, avId, landTime): if not self.hasLocalToon: return self.notify.debug('announceToonWillLandInWater: ' + str(avId) + ': time=' + str(landTime)) if self.clockStopTime == None: self.clockStopTime = landTime def enterOff(self): self.notify.debug('enterOff') def exitOff(self): pass def enterAim(self): self.notify.debug('enterAim') self.__enableAimInterface() self.__putCameraBehindCannon() def exitAim(self): self.__disableAimInterface() def enterShoot(self): self.notify.debug('enterShoot') self.__broadcastLocalCannonPosition() self.sendUpdate('setCannonLit', [ self.cannonPositionDict[self.localAvId][0], self.cannonPositionDict[self.localAvId][1] ]) def exitShoot(self): pass def __somebodyWon(self, avId): if avId == self.localAvId: base.playSfx(self.sndWin) self.__killRewardCountdown() self.timer.stop() self.gameFSM.request('waitForToonsToLand') def enterWaitForToonsToLand(self): self.notify.debug('enterWaitForToonsToLand') if not self.airborneToons: self.gameOver() def exitWaitForToonsToLand(self): pass def enterCleanup(self): self.notify.debug('enterCleanup') self.music.stop() self.__killRewardCountdown() if hasattr(self, 'jarIval'): self.jarIval.finish() del self.jarIval for avId in self.avIdList: taskMgr.remove('fireCannon' + str(avId)) taskMgr.remove('flyingToon' + str(avId)) def exitCleanup(self): pass def __enableAimInterface(self): self.aimPad.show() self.accept(self.FIRE_KEY, self.__fireKeyPressed) self.accept(self.UP_KEY, self.__upKeyPressed) self.accept(self.DOWN_KEY, self.__downKeyPressed) self.accept(self.LEFT_KEY, self.__leftKeyPressed) self.accept(self.RIGHT_KEY, self.__rightKeyPressed) self.__spawnLocalCannonMoveTask() def __disableAimInterface(self): self.aimPad.hide() self.ignore(self.FIRE_KEY) self.ignore(self.UP_KEY) self.ignore(self.DOWN_KEY) self.ignore(self.LEFT_KEY) self.ignore(self.RIGHT_KEY) self.ignore(self.FIRE_KEY + '-up') self.ignore(self.UP_KEY + '-up') self.ignore(self.DOWN_KEY + '-up') self.ignore(self.LEFT_KEY + '-up') self.ignore(self.RIGHT_KEY + '-up') self.__killLocalCannonMoveTask() def __fireKeyPressed(self): self.ignore(self.FIRE_KEY) self.accept(self.FIRE_KEY + '-up', self.__fireKeyReleased) self.__firePressed() def __upKeyPressed(self): self.ignore(self.UP_KEY) self.accept(self.UP_KEY + '-up', self.__upKeyReleased) self.__upPressed() def __downKeyPressed(self): self.ignore(self.DOWN_KEY) self.accept(self.DOWN_KEY + '-up', self.__downKeyReleased) self.__downPressed() def __leftKeyPressed(self): self.ignore(self.LEFT_KEY) self.accept(self.LEFT_KEY + '-up', self.__leftKeyReleased) self.__leftPressed() def __rightKeyPressed(self): self.ignore(self.RIGHT_KEY) self.accept(self.RIGHT_KEY + '-up', self.__rightKeyReleased) self.__rightPressed() def __fireKeyReleased(self): self.ignore(self.FIRE_KEY + '-up') self.accept(self.FIRE_KEY, self.__fireKeyPressed) self.__fireReleased() def __leftKeyReleased(self): self.ignore(self.LEFT_KEY + '-up') self.accept(self.LEFT_KEY, self.__leftKeyPressed) self.__leftReleased() def __rightKeyReleased(self): self.ignore(self.RIGHT_KEY + '-up') self.accept(self.RIGHT_KEY, self.__rightKeyPressed) self.__rightReleased() def __upKeyReleased(self): self.ignore(self.UP_KEY + '-up') self.accept(self.UP_KEY, self.__upKeyPressed) self.__upReleased() def __downKeyReleased(self): self.ignore(self.DOWN_KEY + '-up') self.accept(self.DOWN_KEY, self.__downKeyPressed) self.__downReleased() def __firePressed(self): self.notify.debug('fire pressed') self.gameFSM.request('shoot') def __upPressed(self): self.notify.debug('up pressed') self.upPressed = self.__enterControlActive(self.upPressed) def __downPressed(self): self.notify.debug('down pressed') self.downPressed = self.__enterControlActive(self.downPressed) def __leftPressed(self): self.notify.debug('left pressed') self.leftPressed = self.__enterControlActive(self.leftPressed) def __rightPressed(self): self.notify.debug('right pressed') self.rightPressed = self.__enterControlActive(self.rightPressed) def __upReleased(self): self.notify.debug('up released') self.upPressed = self.__exitControlActive(self.upPressed) def __downReleased(self): self.notify.debug('down released') self.downPressed = self.__exitControlActive(self.downPressed) def __leftReleased(self): self.notify.debug('left released') self.leftPressed = self.__exitControlActive(self.leftPressed) def __rightReleased(self): self.notify.debug('right released') self.rightPressed = self.__exitControlActive(self.rightPressed) def __enterControlActive(self, control): return control + 1 def __exitControlActive(self, control): return max(0, control - 1) def __spawnLocalCannonMoveTask(self): self.leftPressed = 0 self.rightPressed = 0 self.upPressed = 0 self.downPressed = 0 self.cannonMoving = 0 task = Task(self.__localCannonMoveTask) task.lastPositionBroadcastTime = 0.0 taskMgr.add(task, self.LOCAL_CANNON_MOVE_TASK) def __killLocalCannonMoveTask(self): taskMgr.remove(self.LOCAL_CANNON_MOVE_TASK) if self.cannonMoving: self.sndCannonMove.stop() def __localCannonMoveTask(self, task): pos = self.cannonPositionDict[self.localAvId] oldRot = pos[0] oldAng = pos[1] rotVel = 0 if self.leftPressed: rotVel += CannonGameGlobals.CANNON_ROTATION_VEL if self.rightPressed: rotVel -= CannonGameGlobals.CANNON_ROTATION_VEL pos[0] += rotVel * globalClock.getDt() if pos[0] < CannonGameGlobals.CANNON_ROTATION_MIN: pos[0] = CannonGameGlobals.CANNON_ROTATION_MIN elif pos[0] > CannonGameGlobals.CANNON_ROTATION_MAX: pos[0] = CannonGameGlobals.CANNON_ROTATION_MAX angVel = 0 if self.upPressed: angVel += CannonGameGlobals.CANNON_ANGLE_VEL if self.downPressed: angVel -= CannonGameGlobals.CANNON_ANGLE_VEL pos[1] += angVel * globalClock.getDt() if pos[1] < CannonGameGlobals.CANNON_ANGLE_MIN: pos[1] = CannonGameGlobals.CANNON_ANGLE_MIN elif pos[1] > CannonGameGlobals.CANNON_ANGLE_MAX: pos[1] = CannonGameGlobals.CANNON_ANGLE_MAX if oldRot != pos[0] or oldAng != pos[1]: if self.cannonMoving == 0: self.cannonMoving = 1 base.playSfx(self.sndCannonMove, looping=1) self.__updateCannonPosition(self.localAvId) if task.time - task.lastPositionBroadcastTime > CANNON_MOVE_UPDATE_FREQ: task.lastPositionBroadcastTime = task.time self.__broadcastLocalCannonPosition() elif self.cannonMoving: self.cannonMoving = 0 self.sndCannonMove.stop() self.__broadcastLocalCannonPosition() return Task.cont def __broadcastLocalCannonPosition(self): self.sendUpdate('setCannonPosition', [ self.cannonPositionDict[self.localAvId][0], self.cannonPositionDict[self.localAvId][1] ]) def __updateCannonPosition(self, avId): self.cannonDict[avId][0].setHpr(self.cannonPositionDict[avId][0], 0.0, 0.0) self.cannonDict[avId][1].setHpr(0.0, self.cannonPositionDict[avId][1], 0.0) def __getCameraPositionBehindCannon(self): return Point3(self.cannonLocationDict[self.localAvId][0], CANNON_Y - 25.0, CANNON_Z + 7) def __putCameraBehindCannon(self): camera.setPos(self.__getCameraPositionBehindCannon()) camera.setHpr(0, 0, 0) def __loadToonInCannon(self, avId): self.toonModelDict[avId].detachNode() head = self.toonHeadDict[avId] head.startBlink() head.startLookAround() head.reparentTo(self.cannonDict[avId][1]) head.setPosHpr(0, 6, 0, 0, -45, 0) sc = self.toonScaleDict[avId] head.setScale(render, sc[0], sc[1], sc[2]) def __toRadians(self, angle): return angle * 2.0 * math.pi / 360.0 def __toDegrees(self, angle): return angle * 360.0 / (2.0 * math.pi) def __calcFlightResults(self, avId, launchTime): head = self.toonHeadDict[avId] startPos = head.getPos(render) startHpr = head.getHpr(render) hpr = self.cannonDict[avId][1].getHpr(render) towerPos = self.tower.getPos(render) rotation = self.__toRadians(hpr[0]) angle = self.__toRadians(hpr[1]) horizVel = INITIAL_VELOCITY * math.cos(angle) xVel = horizVel * -math.sin(rotation) yVel = horizVel * math.cos(rotation) zVel = INITIAL_VELOCITY * math.sin(angle) startVel = Vec3(xVel, yVel, zVel) trajectory = Trajectory.Trajectory(launchTime, startPos, startVel) towerList = [ towerPos + Point3(0, 0, BUCKET_HEIGHT), TOWER_RADIUS, TOWER_HEIGHT - BUCKET_HEIGHT ] self.notify.debug( 'calcFlightResults(%s): rotation(%s), angle(%s), horizVel(%s), xVel(%s), yVel(%s), zVel(%s), startVel(%s), trajectory(%s), towerList(%s)' % (avId, rotation, angle, horizVel, xVel, yVel, zVel, startVel, trajectory, towerList)) timeOfImpact, hitWhat = self.__calcToonImpact(trajectory, towerList) return (startPos, startHpr, startVel, trajectory, timeOfImpact, hitWhat) def __fireCannonTask(self, task): launchTime = task.fireTime avId = task.avId self.notify.debug('FIRING CANNON FOR AVATAR ' + str(avId)) startPos, startHpr, startVel, trajectory, timeOfImpact, hitWhat = self.__calcFlightResults( avId, launchTime) self.notify.debug('start position: ' + str(startPos)) self.notify.debug('start velocity: ' + str(startVel)) self.notify.debug('time of launch: ' + str(launchTime)) self.notify.debug('time of impact: ' + str(timeOfImpact)) self.notify.debug('location of impact: ' + str(trajectory.getPos(timeOfImpact))) if hitWhat == self.HIT_WATER: self.notify.debug('toon will land in the water') elif hitWhat == self.HIT_TOWER: self.notify.debug('toon will hit the tower') else: self.notify.debug('toon will hit the ground') head = self.toonHeadDict[avId] head.stopBlink() head.stopLookAroundNow() head.reparentTo(hidden) av = self.toonModelDict[avId] av.reparentTo(render) av.setPos(startPos) av.setHpr(startHpr) avatar = self.getAvatar(avId) avatar.loop('swim') avatar.setPosHpr(0, 0, -(avatar.getHeight() / 2.0), 0, 0, 0) shootTask = Task(self.__shootTask) flyTask = Task(self.__flyTask) seqDoneTask = Task(self.__flySequenceDoneTask) info = {} info['avId'] = avId info['trajectory'] = trajectory info['launchTime'] = launchTime info['timeOfImpact'] = timeOfImpact info['hitWhat'] = hitWhat info['toon'] = self.toonModelDict[avId] info['hRot'] = self.cannonPositionDict[avId][0] info['haveWhistled'] = 0 info['maxCamPullback'] = CAMERA_PULLBACK_MIN info['timeEnterTowerXY'], info[ 'timeExitTowerXY'] = trajectory.calcEnterAndLeaveCylinderXY( self.tower.getPos(render), TOWER_RADIUS) shootTask.info = info flyTask.info = info seqDoneTask.info = info seqTask = Task.sequence(shootTask, flyTask, Task.pause(LAND_TIME), seqDoneTask) taskMgr.add(seqTask, 'flyingToon' + str(avId)) if avId == self.localAvId: if info['hitWhat'] == self.HIT_WATER: self.sendUpdate('setToonWillLandInWater', [info['timeOfImpact']]) return Task.done def __calcToonImpact(self, trajectory, waterTower): self.notify.debug('trajectory: %s' % trajectory) self.notify.debug('waterTower: %s' % waterTower) waterDiscCenter = Point3(waterTower[0]) waterDiscCenter.setZ(waterDiscCenter[2] + waterTower[2]) t_waterImpact = trajectory.checkCollisionWithDisc( waterDiscCenter, waterTower[1]) self.notify.debug('t_waterImpact: %s' % t_waterImpact) if t_waterImpact > 0: return (t_waterImpact, self.HIT_WATER) else: t_towerImpact = trajectory.checkCollisionWithCylinderSides( waterTower[0], waterTower[1], waterTower[2]) self.notify.debug('t_towerImpact: %s' % t_towerImpact) if t_towerImpact > 0: return (t_towerImpact, self.HIT_TOWER) t_groundImpact = trajectory.checkCollisionWithGround() self.notify.debug('t_groundImpact: %s' % t_groundImpact) if t_groundImpact >= trajectory.getStartTime(): return (t_groundImpact, self.HIT_GROUND) self.notify.error('__calcToonImpact: toon never impacts ground?') return (self.startTime, self.HIT_GROUND) def __shootTask(self, task): base.playSfx(self.sndCannonFire) self.dropShadowDict[task.info['avId']].reparentTo(render) return Task.done def __flyTask(self, task): curTime = task.time + task.info['launchTime'] t = min(curTime, task.info['timeOfImpact']) pos = task.info['trajectory'].getPos(t) task.info['toon'].setPos(pos) shadowPos = Point3(pos) if t >= task.info['timeEnterTowerXY'] and t <= task.info[ 'timeExitTowerXY'] and pos[2] >= self.tower.getPos( render)[2] + TOWER_HEIGHT: shadowPos.setZ( self.tower.getPos(render)[2] + TOWER_HEIGHT + SHADOW_Z_OFFSET) else: shadowPos.setZ(SHADOW_Z_OFFSET) self.dropShadowDict[task.info['avId']].setPos(shadowPos) vel = task.info['trajectory'].getVel(t) run = math.sqrt(vel[0] * vel[0] + vel[1] * vel[1]) rise = vel[2] theta = self.__toDegrees(math.atan(rise / run)) task.info['toon'].setHpr(task.info['hRot'], -90 + theta, 0) if task.info['avId'] == self.localAvId: lookAt = self.tower.getPos(render) lookAt.setZ(lookAt.getZ() - TOWER_HEIGHT / 2.0) towerPos = Point3(self.towerPos) towerPos.setZ(TOWER_HEIGHT) ttVec = Vec3(pos - towerPos) toonTowerDist = ttVec.length() multiplier = 0.0 if toonTowerDist < TOON_TOWER_THRESHOLD: up = Vec3(0.0, 0.0, 1.0) perp = up.cross(vel) perp.normalize() if ttVec.dot(perp) > 0.0: perp = Vec3(-perp[0], -perp[1], -perp[2]) a = 1.0 - toonTowerDist / TOON_TOWER_THRESHOLD a_2 = a * a multiplier = -2.0 * a_2 * a + 3 * a_2 lookAt = lookAt + perp * (multiplier * MAX_LOOKAT_OFFSET) foo = Vec3(pos - lookAt) foo.normalize() task.info['maxCamPullback'] = max( task.info['maxCamPullback'], CAMERA_PULLBACK_MIN + multiplier * (CAMERA_PULLBACK_MAX - CAMERA_PULLBACK_MIN)) foo = foo * task.info['maxCamPullback'] camPos = pos + Point3(foo) camera.setPos(camPos) camera.lookAt(pos) if task.info['haveWhistled'] == 0: if -vel[2] > WHISTLE_SPEED: if t < task.info['timeOfImpact'] - 0.5: task.info['haveWhistled'] = 1 base.playSfx(self.sndWhizz) if t == task.info['timeOfImpact']: if task.info['haveWhistled']: self.sndWhizz.stop() self.dropShadowDict[task.info['avId']].reparentTo(hidden) avatar = self.getAvatar(task.info['avId']) if task.info['hitWhat'] == self.HIT_WATER: avatar.loop('neutral') self.splash.setPos(task.info['toon'].getPos()) self.splash.setScale(2) self.splash.play() base.playSfx(self.sndHitWater) task.info['toon'].setHpr(task.info['hRot'], 0, 0) self.__somebodyWon(task.info['avId']) elif task.info['hitWhat'] == self.HIT_TOWER: toon = task.info['toon'] pos = toon.getPos() ttVec = Vec3(pos - self.towerPos) ttVec.setZ(0) ttVec.normalize() h = rad2Deg(math.asin(ttVec[0])) toon.setHpr(h, 94, 0) deltaZ = TOWER_HEIGHT - BUCKET_HEIGHT sf = min(max(pos[2] - BUCKET_HEIGHT, 0), deltaZ) / deltaZ hitPos = pos + Point3(ttVec * (0.75 * sf)) toon.setPos(hitPos) hitPos.setZ(hitPos[2] - 1.0) s = Sequence( Wait(0.5), toon.posInterval(duration=LAND_TIME - 0.5, pos=hitPos, blendType='easeIn')) self.toonIntervalDict[task.info['avId']] = s s.start() avatar.iPos() avatar.pose('slip-forward', 25) base.playSfx(self.sndHitTower) elif task.info['hitWhat'] == self.HIT_GROUND: task.info['toon'].setP(render, -150.0) self.dustCloud.setPos(task.info['toon'], 0, 0, -2.5) self.dustCloud.setScale(0.35) self.dustCloud.play() base.playSfx(self.sndHitGround) avatar.setPlayRate(2.0, 'run') avatar.loop('run') return Task.done return Task.cont def __flySequenceDoneTask(self, task): self.airborneToons -= 1 if self.gameFSM.getCurrentState().getName() == 'waitForToonsToLand': if 0 == self.airborneToons: self.gameOver() else: self.__loadToonInCannon(task.info['avId']) if task.info['avId'] == self.localAvId: self.gameFSM.request('aim') return Task.done def __startRewardCountdown(self): taskMgr.remove(self.REWARD_COUNTDOWN_TASK) taskMgr.add(self.__updateRewardCountdown, self.REWARD_COUNTDOWN_TASK) def __killRewardCountdown(self): taskMgr.remove(self.REWARD_COUNTDOWN_TASK) def __updateRewardCountdown(self, task): if not hasattr(self, 'rewardPanel'): return Task.cont curTime = self.getCurrentGameTime() if self.clockStopTime is not None: if self.clockStopTime < curTime: self.__killRewardCountdown() curTime = self.clockStopTime score = int(self.scoreMult * CannonGameGlobals.calcScore(curTime) + 0.5) if not hasattr(task, 'curScore'): task.curScore = score self.rewardPanel['text'] = str(score) if task.curScore != score: if hasattr(self, 'jarIval'): self.jarIval.finish() s = self.rewardPanel.getScale() self.jarIval = Parallel(Sequence( self.rewardPanel.scaleInterval(0.15, s * 3.0 / 4.0, blendType='easeOut'), self.rewardPanel.scaleInterval(0.15, s, blendType='easeIn')), SoundInterval(self.sndRewardTick), name='cannonGameRewardJarThrob') self.jarIval.start() task.curScore = score return Task.cont def __startIntro(self): self.T_WATER = 1 self.T_WATER2LONGVIEW = 1 self.T_LONGVIEW = 1 self.T_LONGVIEW2TOONHEAD = 2 self.T_TOONHEAD = 2 self.T_TOONHEAD2CANNONBACK = 2 self.__introCameraInterval = None taskLookInWater = Task(self.__taskLookInWater) taskPullBackFromWater = Task(self.__taskPullBackFromWater) taskFlyUpToToon = Task(self.__flyUpToToon) taskFlyToBackOfCannon = Task(self.__flyToBackOfCannon) commonData = {} taskLookInWater.data = commonData taskPullBackFromWater.data = commonData taskFlyUpToToon.data = commonData taskFlyToBackOfCannon.data = commonData introTask = Task.sequence( taskLookInWater, Task.pause(self.T_WATER), taskPullBackFromWater, Task.pause(self.T_WATER2LONGVIEW + self.T_LONGVIEW), taskFlyUpToToon, Task.pause(self.T_LONGVIEW2TOONHEAD + self.T_TOONHEAD), taskFlyToBackOfCannon) taskMgr.add(introTask, self.INTRO_TASK_NAME) def __stopIntro(self): taskMgr.remove(self.INTRO_TASK_NAME) if self.__introCameraInterval: self.__introCameraInterval.finish() camera.wrtReparentTo(render) def __spawnCameraLookAtLerp(self, targetPos, targetLookAt, duration): oldPos = camera.getPos() oldHpr = camera.getHpr() camera.setPos(targetPos) camera.lookAt(targetLookAt) targetQuat = Quat() targetQuat.setHpr(camera.getHpr()) camera.setPos(oldPos) camera.setHpr(oldHpr) if self.__introCameraInterval: self.__introCameraInterval.finish() self.__introCameraInterval = camera.posQuatInterval( duration, Point3(targetPos), targetQuat, blendType='easeInOut') self.__introCameraInterval.start() def __taskLookInWater(self, task): task.data['cannonCenter'] = Point3(0, CANNON_Y, CANNON_Z) task.data['towerWaterCenter'] = Point3(self.towerPos + Point3(0, 0, TOWER_HEIGHT)) task.data['vecTowerToCannon'] = Point3(task.data['cannonCenter'] - task.data['towerWaterCenter']) vecAwayFromCannons = Vec3( Point3(0, 0, 0) - task.data['vecTowerToCannon']) vecAwayFromCannons.setZ(0.0) vecAwayFromCannons.normalize() camLoc = Point3(vecAwayFromCannons * 20) + Point3(0, 0, 20) camLoc = camLoc + task.data['towerWaterCenter'] camera.setPos(camLoc) camera.lookAt(task.data['towerWaterCenter']) task.data['vecAwayFromCannons'] = vecAwayFromCannons return Task.done def __taskPullBackFromWater(self, task): camLoc = Point3(task.data['vecAwayFromCannons'] * 40) + Point3( 0, 0, 20) camLoc = camLoc + task.data['towerWaterCenter'] lookAt = task.data['cannonCenter'] self.__spawnCameraLookAtLerp(camLoc, lookAt, self.T_WATER2LONGVIEW) return Task.done def __flyUpToToon(self, task): headPos = self.toonHeadDict[self.localAvId].getPos(render) camLoc = headPos + Point3(0, 5, 0) lookAt = Point3(headPos) self.__spawnCameraLookAtLerp(camLoc, lookAt, self.T_LONGVIEW2TOONHEAD) return Task.done def __flyToBackOfCannon(self, task): lerpNode = hidden.attachNewNode('CannonGameCameraLerpNode') lerpNode.reparentTo(render) lerpNode.setPos(self.cannonLocationDict[self.localAvId] + Point3(0, 1, 0)) relCamPos = camera.getPos(lerpNode) relCamHpr = camera.getHpr(lerpNode) startRotation = lerpNode.getHpr() endRotation = Point3(-180, 0, 0) lerpNode.setHpr(endRotation) camera.setPos(self.__getCameraPositionBehindCannon()) endPos = camera.getPos(lerpNode) lerpNode.setHpr(startRotation) camera.reparentTo(lerpNode) camera.setPos(relCamPos) camera.setHpr(relCamHpr) if self.__introCameraInterval: self.__introCameraInterval.finish() self.__introCameraInterval = Parallel( lerpNode.hprInterval(self.T_TOONHEAD2CANNONBACK, endRotation, blendType='easeInOut'), camera.posInterval(self.T_TOONHEAD2CANNONBACK, endPos, blendType='easeInOut')) self.__introCameraInterval.start() return Task.done
def getFont(self): # All friends are toons. return ToontownGlobals.getToonFont()
def load(self): """ Purpose: The load Method handles the construction of the specific UI components that make up the RaceRecordsUI object. Params: None Return: None """ self.gui = loader.loadModel("phase_3.5/models/gui/friendslist_gui") self.listXorigin = -0.5 self.listFrameSizeX = 1.5 self.listZorigin = -0.9 self.listFrameSizeZ = 1.04 self.arrowButtonScale = 1.3 self.itemFrameXorigin = -0.237 self.itemFrameZorigin = 0.365 self.labelXstart = self.itemFrameXorigin + 0.293 self.scrollList = DirectScrolledList( parent=self, relief=None, pos=(0, 0, 0), # inc and dec are DirectButtons # incButton is on the bottom of page, decButton is on the top! incButton_image=( self.gui.find("**/FndsLst_ScrollUp"), self.gui.find("**/FndsLst_ScrollDN"), self.gui.find("**/FndsLst_ScrollUp_Rllvr"), self.gui.find("**/FndsLst_ScrollUp"), ), incButton_relief=None, incButton_scale=(self.arrowButtonScale, self.arrowButtonScale, -self.arrowButtonScale), incButton_pos=(self.labelXstart, 0, self.itemFrameZorigin - 0.999), # Make the disabled button fade out incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=( self.gui.find("**/FndsLst_ScrollUp"), self.gui.find("**/FndsLst_ScrollDN"), self.gui.find("**/FndsLst_ScrollUp_Rllvr"), self.gui.find("**/FndsLst_ScrollUp"), ), decButton_relief=None, decButton_scale=(self.arrowButtonScale, self.arrowButtonScale, self.arrowButtonScale), decButton_pos=(self.labelXstart, 0, self.itemFrameZorigin + 0.227), # Make the disabled button fade out decButton_image3_color=Vec4(1, 1, 1, 0.2), # itemFrame is a DirectFrame itemFrame_pos=(self.itemFrameXorigin, 0, self.itemFrameZorigin), itemFrame_scale=1.0, itemFrame_relief=DGG.SUNKEN, # frameSize is (minX,maxX,minZ,maxZ); where x goes left->right neg->pos, # and z goes bottom->top neg->pos itemFrame_frameSize=(self.listXorigin, self.listXorigin + self.listFrameSizeX, self.listZorigin, self.listZorigin + self.listFrameSizeZ), itemFrame_frameColor=(0.85, 0.95, 1, 1), itemFrame_borderWidth=(0.01, 0.01), # each item is a button with text on it numItemsVisible=12, # need to set height of each entry to avoid list text running off end of listbox forceHeight=0.083, items=[], ) # course bests for courseId in GolfGlobals.CourseInfo: courseName = GolfGlobals.getCourseName(courseId) frame = DirectFrame(parent=self.scrollList, relief=None) courseNameDisplay = DirectLabel( parent=frame, relief=None, pos=(-0.475, 0, 0.05), text=courseName, text_align=TextNode.ALeft, text_scale=0.075, text_fg=(0.85, 0.64, 0.13, 1.0), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getSignFont()) bestScoreDisplay = DirectLabel( parent=frame, relief=None, pos=(0.9, 0, 0.05), text=TTLocalizer.KartRace_Unraced, text_scale=0.06, text_fg=(0.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getToonFont()) # save this one for updating self.bestDisplayList.append(bestScoreDisplay) # add to scrolled list self.scrollList.addItem(frame) # hole bests for holeId in GolfGlobals.HoleInfo: holeName = GolfGlobals.getHoleName(holeId) frame = DirectFrame(parent=self.scrollList, relief=None) holeNameDisplay = DirectLabel( parent=frame, relief=None, pos=(-0.475, 0, 0.05), text=holeName, text_align=TextNode.ALeft, text_scale=0.075, text_fg=(0.95, 0.95, 0.0, 1.0), text_shadow=(0, 0, 0, 1), text_font=ToontownGlobals.getSignFont()) bestScoreDisplay = DirectLabel( parent=frame, relief=None, pos=(0.9, 0, 0.05), text=TTLocalizer.KartRace_Unraced, text_scale=0.06, text_fg=(0.0, 0.0, 0.0, 1.0), text_font=ToontownGlobals.getToonFont()) # save this one for updating self.bestDisplayList.append(bestScoreDisplay) # add to scrolled list self.scrollList.addItem(frame)