Proper positions for everything above the head

This commit is contained in:
John 2015-06-20 15:19:09 +03:00
parent c57ebf03ed
commit 5a76de3d72
5 changed files with 114 additions and 74 deletions

View file

@ -70,7 +70,7 @@ class NametagGroup:
taskMgr.remove(self.tickTask) taskMgr.remove(self.tickTask)
self.tickTask = None self.tickTask = None
self.clearChatText(timeout=False) self.clearChatText()
for nametag in list(self.nametags): for nametag in list(self.nametags):
self.remove(nametag) self.remove(nametag)
@ -280,14 +280,14 @@ class NametagGroup:
# other words, we need to clear the current chat text, pause for a # other words, we need to clear the current chat text, pause for a
# brief moment, and then display the new chat text: # brief moment, and then display the new chat text:
if self.getChatText(): if self.getChatText():
self.clearChatText(timeout=False) self.clearChatText()
self.stompChatText = chatText self.stompChatText = chatText
self.stompTask = taskMgr.doMethodLater( self.stompTask = taskMgr.doMethodLater(
self.CHAT_STOMP_DELAY, self.__chatStomp, self.stompTaskName, self.CHAT_STOMP_DELAY, self.__chatStomp, self.stompTaskName,
extraArgs=[timeout]) extraArgs=[timeout])
return return
self.clearChatText(timeout=False) self.clearChatText()
self.chatPages = chatText.split('\x07') self.chatPages = chatText.split('\x07')
self.setChatPageIndex(0) self.setChatPageIndex(0)
@ -306,7 +306,7 @@ class NametagGroup:
return '' return ''
return self.chatPages[self.chatPageIndex] return self.chatPages[self.chatPageIndex]
def clearChatText(self, task=None, timeout=True): def clearChatText(self, task=None):
if self.stompTask is not None: if self.stompTask is not None:
taskMgr.remove(self.stompTask) taskMgr.remove(self.stompTask)
self.stompTask = None self.stompTask = None
@ -324,9 +324,6 @@ class NametagGroup:
nametag.setChatText('') nametag.setChatText('')
nametag.update() nametag.update()
if timeout:
messenger.send(self.chatTimeoutTaskName)
if task is not None: if task is not None:
return Task.done return Task.done
@ -441,4 +438,4 @@ class NametagGroup:
def __chatStomp(self, timeout=False): def __chatStomp(self, timeout=False):
self.setChatText(self.stompChatText, timeout=timeout) self.setChatText(self.stompChatText, timeout=timeout)
self.stompChatText = '' self.stompChatText = ''

View file

@ -354,14 +354,6 @@ class DistributedParty(DistributedObject.DistributedObject):
Toon.loadMinigameAnims() Toon.loadMinigameAnims()
self.defaultSignModel = loader.loadModel('phase_13/models/parties/eventSign') self.defaultSignModel = loader.loadModel('phase_13/models/parties/eventSign')
self.activityIconsModel = loader.loadModel('phase_4/models/parties/eventSignIcons') 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.defaultLeverModel = loader.loadModel('phase_13/models/parties/partyLeverBase')
self.defaultStickModel = loader.loadModel('phase_13/models/parties/partyLeverStick') self.defaultStickModel = loader.loadModel('phase_13/models/parties/partyLeverStick')
@ -395,8 +387,7 @@ class DistributedParty(DistributedObject.DistributedObject):
del self.testGrid del self.testGrid
self.ignoreAll() self.ignoreAll()
Toon.unloadMinigameAnims() Toon.unloadMinigameAnims()
self.partyHat.removeNode() self.removePartyHats()
del self.partyHat
if hasattr(base, 'partyHasJukebox'): if hasattr(base, 'partyHasJukebox'):
del base.partyHasJukebox del base.partyHasJukebox
@ -425,6 +416,11 @@ class DistributedParty(DistributedObject.DistributedObject):
else: else:
np.setColorScale(1.0, 0.0, 0.0, 1.0) 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): def getClearSquarePos(self):
clearPositions = self.getClearSquarePositions() clearPositions = self.getClearSquarePositions()
if len(clearPositions) == 0: if len(clearPositions) == 0:

View file

@ -195,10 +195,7 @@ class Party(Place.Place):
def __setPartyHat(self, doId = None): def __setPartyHat(self, doId = None):
if hasattr(base, 'distributedParty'): if hasattr(base, 'distributedParty'):
if base.distributedParty.partyInfo.hostId in base.cr.doId2do: if base.distributedParty.partyInfo.hostId in base.cr.doId2do:
host = base.cr.doId2do[base.distributedParty.partyInfo.hostId] base.cr.doId2do[base.distributedParty.partyInfo.hostId].setPartyHat()
if not (hasattr(host, 'gmIcon') and host.gmIcon):
np = NodePath(host.nametag.getIcon())
base.distributedParty.partyHat.reparentTo(np)
def enterTeleportOut(self, requestStatus): def enterTeleportOut(self, requestStatus):
Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone) Place.Place.enterTeleportOut(self, requestStatus, self.__teleportOutDone)

View file

@ -209,7 +209,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
self.tunnelTrack.finish() self.tunnelTrack.finish()
self.tunnelTrack = None self.tunnelTrack = None
self.setTrophyScore(0) self.setTrophyScore(0)
self.removeGMIcon()
if self.doId in self.cr.toons: if self.doId in self.cr.toons:
del self.cr.toons[self.doId] del self.cr.toons[self.doId]
DistributedPlayer.DistributedPlayer.disable(self) DistributedPlayer.DistributedPlayer.disable(self)
@ -232,7 +231,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
self.startBlink() self.startBlink()
self.startSmooth() self.startSmooth()
self.accept('clientCleanup', self._handleClientCleanup) self.accept('clientCleanup', self._handleClientCleanup)
return
def announceGenerate(self): def announceGenerate(self):
DistributedPlayer.DistributedPlayer.announceGenerate(self) DistributedPlayer.DistributedPlayer.announceGenerate(self)
@ -250,7 +248,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
DistributedPlayer.DistributedPlayer.setAdminAccess(self, access) DistributedPlayer.DistributedPlayer.setAdminAccess(self, access)
self.removeGMIcon() self.removeGMIcon()
if self.isAdmin(): if self.isAdmin():
self.setGMIcon() self.setGMIcon(access)
def setDNA(self, dna): def setDNA(self, dna):
if base.cr.newsManager: if base.cr.newsManager:
@ -1409,14 +1407,11 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
if self.trophyStarSpeed != 0: if self.trophyStarSpeed != 0:
taskMgr.remove(self.uniqueName('starSpin')) taskMgr.remove(self.uniqueName('starSpin'))
self.trophyStarSpeed = 0 self.trophyStarSpeed = 0
if hasattr(self, 'gmIcon') and self.gmIcon:
return
if self.trophyScore >= ToontownGlobals.TrophyStarLevels[4]: if self.trophyScore >= ToontownGlobals.TrophyStarLevels[4]:
self.trophyStar = loader.loadModel('phase_3.5/models/gui/name_star') self.trophyStar = loader.loadModel('phase_3.5/models/gui/name_star')
np = NodePath(self.nametag.getIcon()) np = NodePath(self.nametag.getIcon())
self.trophyStar.reparentTo(np) self.trophyStar.reparentTo(np)
self.trophyStar.setScale(2) self.trophyStar.setScale(2)
self.trophyStar.setZ(2)
self.trophyStar.setColor(ToontownGlobals.TrophyStarColors[4]) self.trophyStar.setColor(ToontownGlobals.TrophyStarColors[4])
self.trophyStarSpeed = 15 self.trophyStarSpeed = 15
if self.trophyScore >= ToontownGlobals.TrophyStarLevels[5]: if self.trophyScore >= ToontownGlobals.TrophyStarLevels[5]:
@ -1426,7 +1421,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
np = NodePath(self.nametag.getIcon()) np = NodePath(self.nametag.getIcon())
self.trophyStar.reparentTo(np) self.trophyStar.reparentTo(np)
self.trophyStar.setScale(1.5) self.trophyStar.setScale(1.5)
self.trophyStar.setZ(1.6)
self.trophyStar.setColor(ToontownGlobals.TrophyStarColors[2]) self.trophyStar.setColor(ToontownGlobals.TrophyStarColors[2])
self.trophyStarSpeed = 10 self.trophyStarSpeed = 10
if self.trophyScore >= ToontownGlobals.TrophyStarLevels[3]: if self.trophyScore >= ToontownGlobals.TrophyStarLevels[3]:
@ -1436,11 +1430,11 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
np = NodePath(self.nametag.getIcon()) np = NodePath(self.nametag.getIcon())
self.trophyStar.reparentTo(np) self.trophyStar.reparentTo(np)
self.trophyStar.setScale(1.5) self.trophyStar.setScale(1.5)
self.trophyStar.setZ(1.6)
self.trophyStar.setColor(ToontownGlobals.TrophyStarColors[0]) self.trophyStar.setColor(ToontownGlobals.TrophyStarColors[0])
self.trophyStarSpeed = 8 self.trophyStarSpeed = 8
if self.trophyScore >= ToontownGlobals.TrophyStarLevels[1]: if self.trophyScore >= ToontownGlobals.TrophyStarLevels[1]:
taskMgr.add(self.__starSpin, self.uniqueName('starSpin')) taskMgr.add(self.__starSpin, self.uniqueName('starSpin'))
self.setHeadPositions()
def __starSpin(self, task): def __starSpin(self, task):
now = globalClock.getFrameTime() now = globalClock.getFrameTime()
@ -2093,8 +2087,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
def displayTalk(self, chatString): def displayTalk(self, chatString):
flags = CFSpeech | CFTimeout flags = CFSpeech | CFTimeout
self.nametag.setChatType(NametagGlobals.CHAT) self.nametag.setChatType(NametagGlobals.CHAT)
self.hideHeadMeter()
self.accept(self.nametag.chatTimeoutTaskName, self.showHeadMeter)
if ChatUtil.isThought(chatString): if ChatUtil.isThought(chatString):
flags = CFThought flags = CFThought
self.nametag.setChatBalloonType(NametagGlobals.THOUGHT_BALLOON) 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 = 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() 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): def setAnimalSound(self, index):
self.animalSound = index self.animalSound = index

View file

@ -13,6 +13,7 @@ import TTEmote
import ToonDNA import ToonDNA
import LaffMeter import LaffMeter
from ToonHead import * from ToonHead import *
from otp.ai.MagicWordGlobal import *
from otp.avatar import Avatar from otp.avatar import Avatar
from otp.avatar import Emote from otp.avatar import Emote
from otp.avatar.Avatar import teleportNotify from otp.avatar.Avatar import teleportNotify
@ -449,6 +450,8 @@ class Toon(Avatar.Avatar, ToonHead):
self.defaultColorScale = None self.defaultColorScale = None
self.jar = None self.jar = None
self.headMeter = None self.headMeter = None
self.gmIcon = None
self.partyHat = None
self.setTag('pieCode', str(ToontownGlobals.PieCodeToon)) self.setTag('pieCode', str(ToontownGlobals.PieCodeToon))
self.setFont(ToontownGlobals.getToonFont()) self.setFont(ToontownGlobals.getToonFont())
self.soundChatBubble = base.loadSfx('phase_3/audio/sfx/GUI_balloon_popup.ogg') 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.delete()
self.motion = None self.motion = None
if self.headMeter: self.removeHeadMeter()
self.headMeter.destroy() self.removeGMIcon()
self.headMeter = None self.removePartyHat()
Avatar.Avatar.delete(self) Avatar.Avatar.delete(self)
ToonHead.delete(self) ToonHead.delete(self)
return
def updateToonDNA(self, newDNA, fForce = 0): def updateToonDNA(self, newDNA, fForce = 0):
self.style.gender = newDNA.getGender() self.style.gender = newDNA.getGender()
oldDNA = self.style oldDNA = self.style
@ -3024,16 +3024,19 @@ class Toon(Avatar.Avatar, ToonHead):
if self.headMeter: if self.headMeter:
return return
nodePath = NodePath(self.nametag.getIcon())
if nodePath.isEmpty():
return
self.headMeter = LaffMeter.LaffMeter(self.style, self.getHp(), self.getMaxHp()) self.headMeter = LaffMeter.LaffMeter(self.style, self.getHp(), self.getMaxHp())
self.headMeter.av = self self.headMeter.av = self
self.headMeter.reparentTo(self) self.headMeter.reparentTo(nodePath)
self.headMeter.setPos(0, 0, self.getHeight() + 1.3) self.headMeter.setScale(1)
self.headMeter.setScale(0.3)
self.headMeter.setBin("fixed", 40) self.headMeter.setBin("fixed", 40)
self.headMeter.setDepthTest(False)
self.headMeter.setDepthWrite(False) self.headMeter.setDepthWrite(False)
self.headMeter.setBillboardPointWorld()
self.headMeter.start() self.headMeter.start()
self.setHeadPositions()
def removeHeadMeter(self): def removeHeadMeter(self):
if not self.headMeter: if not self.headMeter:
@ -3041,18 +3044,97 @@ class Toon(Avatar.Avatar, ToonHead):
self.headMeter.destroy() self.headMeter.destroy()
self.headMeter = None self.headMeter = None
self.setHeadPositions()
def hideHeadMeter(self):
if not self.headMeter: def setGMIcon(self, access):
if self.gmIcon:
return 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 np.isEmpty() or not self.gmIcon:
if not self.headMeter:
return 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() loadModels()
compileGlobalAnimList() 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()