diff --git a/toontown/nametag/NametagGroup.py b/toontown/nametag/NametagGroup.py index 6eea0991..b8d0fe0a 100755 --- a/toontown/nametag/NametagGroup.py +++ b/toontown/nametag/NametagGroup.py @@ -70,7 +70,7 @@ class NametagGroup: taskMgr.remove(self.tickTask) self.tickTask = None - self.clearChatText(timeout=False) + self.clearChatText() for nametag in list(self.nametags): self.remove(nametag) @@ -280,14 +280,14 @@ class NametagGroup: # other words, we need to clear the current chat text, pause for a # brief moment, and then display the new chat text: if self.getChatText(): - self.clearChatText(timeout=False) + self.clearChatText() self.stompChatText = chatText self.stompTask = taskMgr.doMethodLater( self.CHAT_STOMP_DELAY, self.__chatStomp, self.stompTaskName, extraArgs=[timeout]) return - self.clearChatText(timeout=False) + self.clearChatText() self.chatPages = chatText.split('\x07') self.setChatPageIndex(0) @@ -306,7 +306,7 @@ class NametagGroup: return '' return self.chatPages[self.chatPageIndex] - def clearChatText(self, task=None, timeout=True): + def clearChatText(self, task=None): if self.stompTask is not None: taskMgr.remove(self.stompTask) self.stompTask = None @@ -324,9 +324,6 @@ class NametagGroup: nametag.setChatText('') nametag.update() - if timeout: - messenger.send(self.chatTimeoutTaskName) - if task is not None: return Task.done @@ -441,4 +438,4 @@ class NametagGroup: def __chatStomp(self, timeout=False): self.setChatText(self.stompChatText, timeout=timeout) - self.stompChatText = '' + self.stompChatText = '' \ No newline at end of file diff --git a/toontown/parties/DistributedParty.py b/toontown/parties/DistributedParty.py index 6ba74a38..940f8f85 100755 --- a/toontown/parties/DistributedParty.py +++ b/toontown/parties/DistributedParty.py @@ -354,14 +354,6 @@ class DistributedParty(DistributedObject.DistributedObject): Toon.loadMinigameAnims() self.defaultSignModel = loader.loadModel('phase_13/models/parties/eventSign') self.activityIconsModel = loader.loadModel('phase_4/models/parties/eventSignIcons') - model = loader.loadModel('phase_4/models/parties/partyStickerbook') - self.partyHat = model.find('**/Stickerbook_PartyIcon') - self.partyHat.setPos(0.0, 0.1, 2.5) - self.partyHat.setHpr(0.0, 0.0, -50.0) - self.partyHat.setScale(4.0) - self.partyHat.setBillboardAxis() - self.partyHat.reparentTo(hidden) - model.removeNode() self.defaultLeverModel = loader.loadModel('phase_13/models/parties/partyLeverBase') self.defaultStickModel = loader.loadModel('phase_13/models/parties/partyLeverStick') @@ -395,8 +387,7 @@ class DistributedParty(DistributedObject.DistributedObject): del self.testGrid self.ignoreAll() Toon.unloadMinigameAnims() - self.partyHat.removeNode() - del self.partyHat + self.removePartyHats() if hasattr(base, 'partyHasJukebox'): del base.partyHasJukebox @@ -425,6 +416,11 @@ class DistributedParty(DistributedObject.DistributedObject): else: np.setColorScale(1.0, 0.0, 0.0, 1.0) + def removePartyHats(self): + for av in base.cr.doId2do.values(): + if isinstance(av, Toon.Toon): + av.removePartyHat() + def getClearSquarePos(self): clearPositions = self.getClearSquarePositions() if len(clearPositions) == 0: diff --git a/toontown/parties/Party.py b/toontown/parties/Party.py index 8e896383..38b393b1 100755 --- a/toontown/parties/Party.py +++ b/toontown/parties/Party.py @@ -195,10 +195,7 @@ class Party(Place.Place): def __setPartyHat(self, doId = None): if hasattr(base, 'distributedParty'): if base.distributedParty.partyInfo.hostId in base.cr.doId2do: - host = base.cr.doId2do[base.distributedParty.partyInfo.hostId] - if not (hasattr(host, 'gmIcon') and host.gmIcon): - np = NodePath(host.nametag.getIcon()) - base.distributedParty.partyHat.reparentTo(np) + base.cr.doId2do[base.distributedParty.partyInfo.hostId].setPartyHat() def enterTeleportOut(self, requestStatus): Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone) diff --git a/toontown/toon/DistributedToon.py b/toontown/toon/DistributedToon.py index f21743a8..ed43e020 100755 --- a/toontown/toon/DistributedToon.py +++ b/toontown/toon/DistributedToon.py @@ -209,7 +209,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute self.tunnelTrack.finish() self.tunnelTrack = None self.setTrophyScore(0) - self.removeGMIcon() if self.doId in self.cr.toons: del self.cr.toons[self.doId] DistributedPlayer.DistributedPlayer.disable(self) @@ -232,7 +231,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute self.startBlink() self.startSmooth() self.accept('clientCleanup', self._handleClientCleanup) - return def announceGenerate(self): DistributedPlayer.DistributedPlayer.announceGenerate(self) @@ -250,7 +248,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute DistributedPlayer.DistributedPlayer.setAdminAccess(self, access) self.removeGMIcon() if self.isAdmin(): - self.setGMIcon() + self.setGMIcon(access) def setDNA(self, dna): if base.cr.newsManager: @@ -1409,14 +1407,11 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute if self.trophyStarSpeed != 0: taskMgr.remove(self.uniqueName('starSpin')) self.trophyStarSpeed = 0 - if hasattr(self, 'gmIcon') and self.gmIcon: - return if self.trophyScore >= ToontownGlobals.TrophyStarLevels[4]: self.trophyStar = loader.loadModel('phase_3.5/models/gui/name_star') np = NodePath(self.nametag.getIcon()) self.trophyStar.reparentTo(np) self.trophyStar.setScale(2) - self.trophyStar.setZ(2) self.trophyStar.setColor(ToontownGlobals.TrophyStarColors[4]) self.trophyStarSpeed = 15 if self.trophyScore >= ToontownGlobals.TrophyStarLevels[5]: @@ -1426,7 +1421,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute np = NodePath(self.nametag.getIcon()) self.trophyStar.reparentTo(np) self.trophyStar.setScale(1.5) - self.trophyStar.setZ(1.6) self.trophyStar.setColor(ToontownGlobals.TrophyStarColors[2]) self.trophyStarSpeed = 10 if self.trophyScore >= ToontownGlobals.TrophyStarLevels[3]: @@ -1436,11 +1430,11 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute np = NodePath(self.nametag.getIcon()) self.trophyStar.reparentTo(np) self.trophyStar.setScale(1.5) - self.trophyStar.setZ(1.6) self.trophyStar.setColor(ToontownGlobals.TrophyStarColors[0]) self.trophyStarSpeed = 8 if self.trophyScore >= ToontownGlobals.TrophyStarLevels[1]: taskMgr.add(self.__starSpin, self.uniqueName('starSpin')) + self.setHeadPositions() def __starSpin(self, task): now = globalClock.getFrameTime() @@ -2093,8 +2087,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute def displayTalk(self, chatString): flags = CFSpeech | CFTimeout self.nametag.setChatType(NametagGlobals.CHAT) - self.hideHeadMeter() - self.accept(self.nametag.chatTimeoutTaskName, self.showHeadMeter) if ChatUtil.isThought(chatString): flags = CFThought self.nametag.setChatBalloonType(NametagGlobals.THOUGHT_BALLOON) @@ -2361,30 +2353,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute seq = Sequence(self.hpText.posInterval(1.0, Point3(0, 0, self.height + 1.5), blendType='easeOut'), Wait(0.85), self.hpText.colorInterval(0.1, Vec4(r, g, b, 0)), Func(self.hideHpText)) seq.start() - def setGMIcon(self): - if hasattr(self, 'gmIcon') and self.gmIcon: - return - icons = loader.loadModel('phase_3/models/props/gm_icons') - self.gmIcon = icons.find('**/access_level_' + str(self.adminAccess)) - np = NodePath(self.nametag.getIcon()) - if np.isEmpty() or not self.gmIcon: - return - self.gmIcon.flattenStrong() - self.gmIcon.reparentTo(np) - self.gmIcon.setScale(1.6) - self.gmIcon.setZ(2.05) - self.setTrophyScore(self.trophyScore) - self.gmIconInterval = LerpHprInterval(self.gmIcon, 3.0, Point3(0, 0, 0), Point3(-360, 0, 0)) - self.gmIconInterval.loop() - - def removeGMIcon(self): - if hasattr(self, 'gmIconInterval') and self.gmIconInterval: - self.gmIconInterval.finish() - del self.gmIconInterval - if hasattr(self, 'gmIcon') and self.gmIcon: - self.gmIcon.detachNode() - del self.gmIcon - def setAnimalSound(self, index): self.animalSound = index diff --git a/toontown/toon/Toon.py b/toontown/toon/Toon.py index c299fb3b..81774ec3 100755 --- a/toontown/toon/Toon.py +++ b/toontown/toon/Toon.py @@ -13,6 +13,7 @@ import TTEmote import ToonDNA import LaffMeter from ToonHead import * +from otp.ai.MagicWordGlobal import * from otp.avatar import Avatar from otp.avatar import Emote from otp.avatar.Avatar import teleportNotify @@ -449,6 +450,8 @@ class Toon(Avatar.Avatar, ToonHead): self.defaultColorScale = None self.jar = None self.headMeter = None + self.gmIcon = None + self.partyHat = None self.setTag('pieCode', str(ToontownGlobals.PieCodeToon)) self.setFont(ToontownGlobals.getToonFont()) self.soundChatBubble = base.loadSfx('phase_3/audio/sfx/GUI_balloon_popup.ogg') @@ -550,15 +553,12 @@ class Toon(Avatar.Avatar, ToonHead): self.motion.delete() self.motion = None - if self.headMeter: - self.headMeter.destroy() - self.headMeter = None - + self.removeHeadMeter() + self.removeGMIcon() + self.removePartyHat() Avatar.Avatar.delete(self) ToonHead.delete(self) - return - def updateToonDNA(self, newDNA, fForce = 0): self.style.gender = newDNA.getGender() oldDNA = self.style @@ -3024,16 +3024,19 @@ class Toon(Avatar.Avatar, ToonHead): if self.headMeter: return + nodePath = NodePath(self.nametag.getIcon()) + + if nodePath.isEmpty(): + return + self.headMeter = LaffMeter.LaffMeter(self.style, self.getHp(), self.getMaxHp()) self.headMeter.av = self - self.headMeter.reparentTo(self) - self.headMeter.setPos(0, 0, self.getHeight() + 1.3) - self.headMeter.setScale(0.3) + self.headMeter.reparentTo(nodePath) + self.headMeter.setScale(1) self.headMeter.setBin("fixed", 40) - self.headMeter.setDepthTest(False) self.headMeter.setDepthWrite(False) - self.headMeter.setBillboardPointWorld() self.headMeter.start() + self.setHeadPositions() def removeHeadMeter(self): if not self.headMeter: @@ -3041,18 +3044,97 @@ class Toon(Avatar.Avatar, ToonHead): self.headMeter.destroy() self.headMeter = None - - def hideHeadMeter(self): - if not self.headMeter: + self.setHeadPositions() + + def setGMIcon(self, access): + if self.gmIcon: return - self.headMeter.hide() + icons = loader.loadModel('phase_3/models/props/gm_icons') + self.gmIcon = icons.find('**/access_level_%s' % access) + np = NodePath(self.nametag.getIcon()) - def showHeadMeter(self): - if not self.headMeter: + if np.isEmpty() or not self.gmIcon: return - self.headMeter.show() + self.gmIcon.flattenStrong() + self.gmIcon.reparentTo(np) + self.gmIcon.setScale(1.6) + self.gmIconInterval = LerpHprInterval(self.gmIcon, 3.0, Point3(0, 0, 0), Point3(-360, 0, 0)) + self.gmIconInterval.loop() + self.setHeadPositions() + + def removeGMIcon(self): + if not self.gmIcon: + return + + self.gmIconInterval.finish() + self.gmIcon.detachNode() + del self.gmIconInterval + self.gmIcon = None + self.setHeadPositions() + + def setPartyHat(self): + if self.partyHat: + return + + nodePath = NodePath(self.nametag.getIcon()) + + if nodePath.isEmpty(): + return + + model = loader.loadModel('phase_4/models/parties/partyStickerbook') + self.partyHat = model.find('**/Stickerbook_PartyIcon') + self.partyHat.setHpr(0.0, 0.0, -50.0) + self.partyHat.setScale(4) + self.partyHat.setBillboardAxis() + self.partyHat.reparentTo(nodePath) + model.removeNode() + self.setHeadPositions() + + def removePartyHat(self): + if not self.partyHat: + return + + self.partyHat.detachNode() + self.partyHat = None + self.setHeadPositions() + + def setHeadPositions(self): + position = 2.5 + + if self.gmIcon: + self.gmIcon.setZ(position) + position += (2.5 if self.trophyStar else 2.7) + + if self.trophyStar: + self.trophyStar.setZ(position) + position += 2.7 + + if self.headMeter: + self.headMeter.setZ(position) + position += 3.3 + + if self.partyHat: + self.partyHat.setZ(position) loadModels() compileGlobalAnimList() + +@magicWord(category=CATEGORY_PROGRAMMER, types=[int]) +def headMeter(create=True): + """ + Create or remove the head meter. + """ + for av in base.cr.doId2do.values(): + if isinstance(av, Toon): + av.createHeadMeter() if create else av.removeHeadMeter() + +@magicWord(category=CATEGORY_PROGRAMMER, types=[int]) +def partyHat(create=True): + """ + Create or remove the party hat. + """ + for av in base.cr.doId2do.values(): + if isinstance(av, Toon): + av.setPartyHat() if create else av.removePartyHat() \ No newline at end of file