nametag: Properly implement chat bubble fonts

This commit is contained in:
Joey Z 2014-08-12 19:30:51 -04:00
parent 8e4737bfb4
commit c7e4abd13f
6 changed files with 25 additions and 2 deletions

View file

@ -39,6 +39,7 @@ class Avatar(Actor, ShadowCaster):
Actor.__init__(self, None, None, other, flattenable=0, setFinal=0)
ShadowCaster.__init__(self)
self.__font = OTPGlobals.getInterfaceFont()
self.__speechFont = OTPGlobals.getInterfaceFont()
self.soundChatBubble = None
self.avatarType = ''
self.nametagNodePath = None
@ -46,6 +47,7 @@ class Avatar(Actor, ShadowCaster):
self.nametag = NametagGroup()
self.nametag.setAvatar(self)
self.nametag.setFont(OTPGlobals.getInterfaceFont())
self.nametag.setSpeechFont(OTPGlobals.getInterfaceFont())
self.nametag2dContents = Nametag.CName | Nametag.CSpeech
self.nametag2dDist = Nametag.CName | Nametag.CSpeech
self.nametag2dNormalContents = Nametag.CName | Nametag.CSpeech
@ -91,6 +93,7 @@ class Avatar(Actor, ShadowCaster):
self.ignoreNametagAmbientLightChange()
self.Avatar_deleted = 1
del self.__font
del self.__speechFont
del self.style
del self.soundChatBubble
self.nametag.destroy()
@ -252,6 +255,13 @@ class Avatar(Actor, ShadowCaster):
self.__font = font
self.nametag.setFont(font)
def getSpeechFont(self):
return self.__speechFont
def setSpeechFont(self, font):
self.__speechFont = font
self.nametag.setSpeechFont(font)
def getStyle(self):
return self.style

View file

@ -30,7 +30,7 @@ class Nametag(ClickablePopup):
self.chatWordWrap = None
self.font = None
self.speechFont = OTPGlobals.getInterfaceFont()
self.speechFont = None
self.name = ''
self.displayName = ''
self.qtColor = VBase4(1,1,1,1)
@ -93,6 +93,9 @@ class Nametag(ClickablePopup):
self.showName()
def showBalloon(self, balloon, text):
if not self.speechFont:
# If no font is set, we can't display anything yet...
return
color = self.qtColor if (self.chatFlags&CFQuicktalker) else self.chatBg
if color[3] > self.CHAT_ALPHA:
color = (color[0], color[1], color[2], self.CHAT_ALPHA)

View file

@ -26,6 +26,7 @@ class NametagGroup:
self.chatTimeoutTask = None
self.font = None
self.speechFont = None
self.name = ''
self.displayName = ''
self.wordWrap = None
@ -141,6 +142,10 @@ class NametagGroup:
self.font = font
self.updateTags()
def setSpeechFont(self, font):
self.speechFont = font
self.updateTags()
def setWordwrap(self, wrap):
self.wordWrap = wrap
self.updateTags()
@ -227,6 +232,7 @@ class NametagGroup:
def updateNametag(self, tag):
tag.font = self.font
tag.speechFont = self.speechFont
tag.name = self.name
tag.wordWrap = self.wordWrap or DEFAULT_WORDWRAPS[self.colorCode]
tag.displayName = self.displayName or self.name

View file

@ -344,6 +344,7 @@ class Suit(Avatar.Avatar):
Avatar.Avatar.__init__(self)
self.setFont(ToontownGlobals.getSuitFont())
self.setSpeechFont(ToontownGlobals.getSuitFont())
self.setPlayerType(NametagGroup.CCSuit)
self.setPickable(1)
self.leftHand = None

View file

@ -2623,7 +2623,7 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
else:
self.gmToonLockStyle = False
self.removeGMIcon()
self.setNametagStyle(0)
self.setNametagStyle(100)
def setGMIcon(self, gmType = None):
if hasattr(self, 'gmIcon') and self.gmIcon:

View file

@ -504,6 +504,7 @@ class Toon(Avatar.Avatar, ToonHead):
self.jar = None
self.setTag('pieCode', str(ToontownGlobals.PieCodeToon))
self.setFont(ToontownGlobals.getToonFont())
self.setSpeechFont(ToontownGlobals.getToonFont())
self.soundChatBubble = base.loadSfx('phase_3/audio/sfx/GUI_balloon_popup.ogg')
self.animFSM = ClassicFSM('Toon', [State('off', self.enterOff, self.exitOff),
State('neutral', self.enterNeutral, self.exitNeutral),
@ -2971,6 +2972,7 @@ class Toon(Avatar.Avatar, ToonHead):
self.suit.loop('neutral')
self.isDisguised = 1
self.setFont(ToontownGlobals.getSuitFont())
self.setSpeechFont(ToontownGlobals.getSuitFont())
if setDisplayName:
if hasattr(base, 'idTags') and base.idTags:
name = self.getAvIdName()
@ -3004,6 +3006,7 @@ class Toon(Avatar.Avatar, ToonHead):
Emote.globalEmote.releaseAll(self)
self.isDisguised = 0
self.setFont(ToontownGlobals.getToonFont())
self.setSpeechFont(ToontownGlobals.getToonFont())
self.nametag.setWordwrap(None)
if hasattr(base, 'idTags') and base.idTags:
name = self.getAvIdName()