Merge branch 'JawhnL5/nametags'

Conflicts:
	toontown/building/DistributedKnockKnockDoor.py
	toontown/pets/Pet.py
	toontown/safezone/Playground.py
	toontown/town/Street.py
This commit is contained in:
Loudrob 2015-07-03 14:52:24 -04:00
commit 3a29c8995f
158 changed files with 2084 additions and 2857 deletions

View file

@ -12,9 +12,9 @@ from otp.chat import ChatUtil
from otp.otpbase import OTPGlobals
from otp.otpbase import OTPLocalizer
from otp.otpbase import OTPRender
from toontown.chat.ChatGlobals import *
from toontown.nametag import NametagGlobals
from toontown.nametag.NametagGroup import NametagGroup
from otp.nametag.Nametag import Nametag
from otp.nametag.NametagGroup import NametagGroup
from otp.nametag.NametagConstants import CFSpeech, CFThought, CFTimeout, CFPageButton, CFNoQuitButton, CFQuitButton
teleportNotify = DirectNotifyGlobal.directNotify.newCategory('Teleport')
@ -43,15 +43,18 @@ class Avatar(Actor, ShadowCaster):
Actor.__init__(self, None, None, other, flattenable=0, setFinal=1)
ShadowCaster.__init__(self)
self.__font = OTPGlobals.getInterfaceFont()
self.__speechFont = OTPGlobals.getInterfaceFont()
self.soundChatBubble = None
self.avatarType = ''
self.nametagNodePath = None
self.__nameVisible = 1
self.nametag = NametagGroup()
self.nametag.setAvatar(self)
interfaceFont = OTPGlobals.getInterfaceFont()
self.nametag.setFont(interfaceFont)
self.nametag.setChatFont(interfaceFont)
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
self.nametag3d = self.attachNewNode('nametag3d')
self.nametag3d.setTag('cam', 'nametag')
self.nametag3d.setLightOff()
@ -69,7 +72,7 @@ class Avatar(Actor, ShadowCaster):
self.battleTubeRadius = 0.0
self.style = None
self.understandable = 1
self.setPlayerType(NametagGlobals.CCNormal)
self.setPlayerType(NametagGroup.CCNormal)
self.ghostMode = 0
self.__chatParagraph = None
self.__chatMessage = None
@ -79,7 +82,6 @@ class Avatar(Actor, ShadowCaster):
self.__chatDialogueList = []
self.__chatSet = 0
self.__chatLocal = 0
self.__chatQuitButton = False
self.__currentDialogue = None
def delete(self):
@ -92,6 +94,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()
@ -121,50 +124,39 @@ class Avatar(Actor, ShadowCaster):
self.notify.warning('no nametag attributed, but would have been used.')
return
if self.isUnderstandable():
nametagColor = NametagGlobals.NametagColors[self.playerType]
self.nametag.setNametagColor(nametagColor)
chatColor = NametagGlobals.ChatColors[self.playerType]
self.nametag.setChatColor(chatColor)
self.nametag.setColorCode(self.playerType)
else:
nametagColor = NametagGlobals.NametagColors[NametagGlobals.CCNonPlayer]
self.nametag.setNametagColor(nametagColor)
chatColor = NametagGlobals.ChatColors[NametagGlobals.CCNonPlayer]
self.nametag.setChatColor(chatColor)
self.nametag.setColorCode(NametagGroup.CCNoChat)
self.setNametagName()
self.nametag.updateAll()
def considerUnderstandable(self):
if self.playerType in (NametagGlobals.CCNormal, NametagGlobals.CCSpeedChat):
self.setPlayerType(NametagGlobals.CCSpeedChat)
if self.playerType in (NametagGroup.CCNormal, NametagGroup.CCSpeedChat):
self.setPlayerType(NametagGroup.CCSpeedChat)
if hasattr(base, 'localAvatar') and (self == base.localAvatar):
self.understandable = 1
self.setPlayerType(NametagGlobals.CCNormal)
self.setPlayerType(NametagGroup.CCNormal)
elif hasattr(self, 'adminAccess') and self.isAdmin():
self.understandable = 2
self.setPlayerType(NametagGlobals.CCAdmin)
elif self.playerType == NametagGlobals.CCSuit:
self.setPlayerType(NametagGroup.CCAdmin)
elif self.playerType == NametagGroup.CCSuit:
self.understandable = 1
self.setPlayerType(NametagGlobals.CCSuit)
elif self.playerType not in (NametagGlobals.CCNormal, NametagGlobals.CCSpeedChat):
self.setPlayerType(NametagGroup.CCSuit)
elif self.playerType not in (NametagGroup.CCNormal, NametagGroup.CCSpeedChat):
self.understandable = 1
self.setPlayerType(NametagGlobals.CCNonPlayer)
self.setPlayerType(NametagGroup.CCNonPlayer)
elif settings['trueFriends'] and base.localAvatar.isTrueFriends(self.doId):
self.understandable = 2
self.setPlayerType(NametagGlobals.CCNormal)
self.setPlayerType(NametagGroup.CCNormal)
elif settings['speedchatPlus']:
self.understandable = 1
self.setPlayerType(NametagGlobals.CCSpeedChat)
self.setPlayerType(NametagGroup.CCSpeedChat)
else:
self.understandable = 0
self.setPlayerType(NametagGlobals.CCSpeedChat)
self.setPlayerType(NametagGroup.CCSpeedChat)
if not hasattr(self, 'nametag'):
self.notify.warning('no nametag attributed, but would have been used')
else:
nametagColor = NametagGlobals.NametagColors[self.playerType]
self.nametag.setNametagColor(nametagColor)
chatColor = NametagGlobals.ChatColors[self.playerType]
self.nametag.setChatColor(chatColor)
self.nametag.updateAll()
self.nametag.setColorCode(self.playerType)
def isUnderstandable(self):
return self.understandable
@ -217,10 +209,11 @@ class Avatar(Actor, ShadowCaster):
return self.avatarType
def setName(self, name):
if hasattr(self, 'isDisguised'):
if self.isDisguised:
return
if hasattr(self, 'isDisguised') and self.isDisguised:
return
self.name = name
if hasattr(self, 'nametag'):
self.setNametagName()
@ -233,6 +226,8 @@ class Avatar(Actor, ShadowCaster):
def setNametagName(self, name=None):
if not name:
name = self.name
self.nametag.setName(name)
if hasattr(self, 'adminAccess') and self.isAdmin():
access = self.getAdminAccess()
@ -240,7 +235,7 @@ class Avatar(Actor, ShadowCaster):
if access in OTPLocalizer.AccessToString:
name += '\n\x01shadow\x01%s\x02' % OTPLocalizer.AccessToString[access]
self.nametag.setText(name)
self.nametag.setDisplayName(name)
def getFont(self):
return self.__font
@ -248,7 +243,13 @@ class Avatar(Actor, ShadowCaster):
def setFont(self, font):
self.__font = font
self.nametag.setFont(font)
self.nametag.setChatFont(font)
def getSpeechFont(self):
return self.__speechFont
def setSpeechFont(self, font):
self.__speechFont = font
self.nametag.setSpeechFont(font)
def getStyle(self):
return self.style
@ -266,7 +267,7 @@ class Avatar(Actor, ShadowCaster):
if dialogue:
base.playSfx(dialogue, node=self)
elif chatFlags & CFSpeech != 0 and self.nametag.getNumChatPages() > 0:
self.playDialogueForString(self.nametag.getChatText())
self.playDialogueForString(self.nametag.getChat())
if self.soundChatBubble != None:
base.playSfx(self.soundChatBubble, node=self)
@ -344,28 +345,7 @@ class Avatar(Actor, ShadowCaster):
def setChatAbsolute(self, chatString, chatFlags, dialogue=None, interrupt=1):
self.clearChat()
if chatFlags & CFQuicktalker:
self.nametag.setChatType(NametagGlobals.SPEEDCHAT)
else:
self.nametag.setChatType(NametagGlobals.CHAT)
if chatFlags & CFThought:
self.nametag.setChatBalloonType(NametagGlobals.THOUGHT_BALLOON)
else:
self.nametag.setChatBalloonType(NametagGlobals.CHAT_BALLOON)
if chatFlags & CFPageButton:
self.nametag.setChatButton(NametagGlobals.pageButton)
else:
self.nametag.setChatButton(NametagGlobals.noButton)
if chatFlags & CFReversed:
self.nametag.setChatReversed(True)
else:
self.nametag.setChatReversed(False)
self.nametag.setChatText(chatString, timeout=(chatFlags & CFTimeout))
self.nametag.setChat(chatString, chatFlags)
self.playCurrentDialogue(dialogue, chatFlags, interrupt)
def setChatMuted(self, chatString, chatFlags, dialogue = None, interrupt = 1, quiet = 0):
@ -374,18 +354,14 @@ class Avatar(Actor, ShadowCaster):
def displayTalk(self, chatString):
if not base.localAvatar.isIgnored(self.doId):
self.clearChat()
self.nametag.setChatType(NametagGlobals.CHAT)
self.nametag.setChatButton(NametagGlobals.noButton)
if ChatUtil.isThought(chatString):
chatString = ChatUtil.removeThoughtPrefix(chatString)
self.nametag.setChatBalloonType(NametagGlobals.THOUGHT_BALLOON)
self.nametag.setChatText(chatString)
self.nametag.setChat(chatString, CFThought)
else:
self.nametag.setChatBalloonType(NametagGlobals.CHAT_BALLOON)
self.nametag.setChatText(chatString, timeout=True)
self.nametag.setChat(chatString, CFSpeech | CFTimeout)
def clearChat(self):
self.nametag.clearChatText()
self.nametag.clearChat()
def isInView(self):
pos = self.getPos(camera)
@ -404,62 +380,44 @@ class Avatar(Actor, ShadowCaster):
def hideName(self):
nametag3d = self.nametag.getNametag3d()
nametag3d.hideNametag()
nametag3d.showChat()
nametag3d.showThought()
nametag3d.update()
nametag3d.setContents(Nametag.CSpeech | Nametag.CThought)
def showName(self):
if self.__nameVisible and (not self.ghostMode):
nametag3d = self.nametag.getNametag3d()
nametag3d.showNametag()
nametag3d.showChat()
nametag3d.showThought()
nametag3d.update()
nametag3d.setContents(Nametag.CName | Nametag.CSpeech | Nametag.CThought)
def hideNametag2d(self):
nametag2d = self.nametag.getNametag2d()
nametag2d.hideNametag()
nametag2d.hideChat()
nametag2d.update()
self.nametag2dContents = 0
nametag2d.setContents(self.nametag2dContents & self.nametag2dDist)
def showNametag2d(self):
nametag2d = self.nametag.getNametag2d()
if not self.ghostMode:
nametag2d.showNametag()
nametag2d.showChat()
else:
nametag2d.hideNametag()
nametag2d.hideChat()
nametag2d.update()
self.nametag2dContents = self.nametag2dNormalContents
if self.ghostMode:
self.nametag2dContents = Nametag.CSpeech
nametag2d.setContents(self.nametag2dContents & self.nametag2dDist)
def hideNametag3d(self):
nametag3d = self.nametag.getNametag3d()
nametag3d.hideNametag()
nametag3d.hideChat()
nametag3d.hideThought()
nametag3d.update()
nametag3d.setContents(0)
def showNametag3d(self):
nametag3d = self.nametag.getNametag3d()
if self.__nameVisible and (not self.ghostMode):
nametag3d.showNametag()
nametag3d.showChat()
nametag3d.showThought()
nametag3d.setContents(Nametag.CName | Nametag.CSpeech | Nametag.CThought)
else:
nametag3d.hideNametag()
nametag3d.hideChat()
nametag3d.hideThought()
nametag3d.update()
nametag3d.setContents(0)
def setPickable(self, flag):
self.nametag.setActive(flag)
def clickedNametag(self):
MagicWordManager.lastClickedNametag = self
if self.nametag.getChatText() and self.nametag.hasChatButton():
if self.nametag.hasButton():
self.advancePageNumber()
elif self.nametag.getActive():
elif self.nametag.isActive():
messenger.send('clickedNametag', [self])
def setPageChat(self, addressee, paragraph, message, quitButton,
@ -468,9 +426,10 @@ class Avatar(Actor, ShadowCaster):
self.__chatPageNumber = None
self.__chatParagraph = paragraph
self.__chatMessage = message
self.__chatFlags = CFSpeech
if extraChatFlags is not None:
self.__chatFlags |= extraChatFlags
if extraChatFlags is None:
self.__chatFlags = CFSpeech
else:
self.__chatFlags = CFSpeech | extraChatFlags
self.__chatDialogueList = dialogueList
self.__chatSet = 0
self.__chatLocal = 0
@ -478,7 +437,10 @@ class Avatar(Actor, ShadowCaster):
if addressee == base.localAvatar.doId:
if pageButton:
self.__chatFlags |= CFPageButton
self.__chatQuitButton = quitButton
if quitButton == None:
self.__chatFlags |= CFNoQuitButton
elif quitButton:
self.__chatFlags |= CFQuitButton
self.b_setPageNumber(self.__chatParagraph, 0)
def setLocalPageChat(self, message, quitButton, extraChatFlags=None,
@ -487,14 +449,18 @@ class Avatar(Actor, ShadowCaster):
self.__chatPageNumber = None
self.__chatParagraph = None
self.__chatMessage = message
self.__chatFlags = CFSpeech
if extraChatFlags is not None:
self.__chatFlags |= extraChatFlags
if extraChatFlags is None:
self.__chatFlags = CFSpeech
else:
self.__chatFlags = CFSpeech | extraChatFlags
self.__chatDialogueList = dialogueList
self.__chatSet = 1
self.__chatLocal = 1
self.__chatFlags |= CFPageButton
self.__chatQuitButton = quitButton
if quitButton == None:
self.__chatFlags |= CFNoQuitButton
elif quitButton:
self.__chatFlags |= CFQuitButton
if len(dialogueList) > 0:
dialogue = dialogueList[0]
else:
@ -529,9 +495,6 @@ class Avatar(Actor, ShadowCaster):
pageNumber += 1
if pageNumber >= self.nametag.getNumChatPages():
pageNumber = -1
if self.__chatQuitButton:
if pageNumber == self.nametag.getNumChatPages() - 1:
self.nametag.setChatButton(NametagGlobals.quitButton)
if self.__chatLocal:
self.setPageNumber(self.__chatParagraph, pageNumber)
else:
@ -550,10 +513,7 @@ class Avatar(Actor, ShadowCaster):
self.setChatAbsolute(self.__chatMessage, self.__chatFlags, dialogue)
self.__chatSet = 1
if pageNumber < self.nametag.getNumChatPages():
if (self.__chatAddressee == base.localAvatar.doId) and self.__chatQuitButton:
if pageNumber == self.nametag.getNumChatPages() - 1:
self.nametag.setChatButton(NametagGlobals.quitButton)
self.nametag.setChatPageIndex(pageNumber)
self.nametag.setPageNumber(pageNumber)
if pageNumber > 0:
if len(self.__chatDialogueList) > pageNumber:
dialogue = self.__chatDialogueList[pageNumber]
@ -573,7 +533,7 @@ class Avatar(Actor, ShadowCaster):
self.deleteNametag3d()
nametagNode = self.nametag.getNametag3d()
self.nametagNodePath = self.nametag3d.attachNewNode(nametagNode)
iconNodePath = self.nametag.getIcon()
iconNodePath = self.nametag.getNameIcon()
for cJoint in self.getNametagJoints():
cJoint.clearNetTransforms()
cJoint.addNetTransform(nametagNode)
@ -622,7 +582,7 @@ class Avatar(Actor, ShadowCaster):
Avatar.ActiveAvatars.append(self)
self.nametag.manage(base.marginManager)
self.accept(self.nametag.getUniqueName(), self.clickedNametag)
self.accept(self.nametag.getUniqueId(), self.clickedNametag)
def removeActive(self):
if base.wantNametags:
@ -632,7 +592,7 @@ class Avatar(Actor, ShadowCaster):
pass
self.nametag.unmanage(base.marginManager)
self.ignore(self.nametag.getUniqueName())
self.ignore(self.nametag.getUniqueId())
def loop(self, animName, restart = 1, partName = None, fromFrame = None, toFrame = None):
return Actor.loop(self, animName, restart, partName, fromFrame, toFrame)

View file

@ -9,6 +9,7 @@ from Avatar import Avatar
from otp.ai.MagicWordGlobal import *
from otp.otpbase import OTPGlobals
from toontown.battle.BattleProps import globalPropPool
from otp.nametag.Nametag import Nametag
class DistributedAvatar(DistributedActor, Avatar):
@ -84,12 +85,11 @@ class DistributedAvatar(DistributedActor, Avatar):
def do_setParent(self, parentToken):
if not self.isDisabled():
nametag2d = self.nametag.getNametag2d()
if parentToken == OTPGlobals.SPHidden:
nametag2d.hideNametag()
self.nametag2dDist &= ~Nametag.CName
else:
nametag2d.showNametag()
nametag2d.update()
self.nametag2dDist |= Nametag.CName
self.nametag.getNametag2d().setContents(self.nametag2dContents & self.nametag2dDist)
DistributedActor.do_setParent(self, parentToken)
self.__setTags()

View file

@ -11,8 +11,8 @@ from otp.chat import ChatGarbler, TalkAssistant
from otp.distributed.TelemetryLimited import TelemetryLimited
from otp.otpbase import OTPGlobals, OTPLocalizer
from otp.speedchat import SCDecoders
from toontown.chat.ChatGlobals import *
from toontown.chat.WhisperPopup import WhisperPopup
from otp.nametag.NametagConstants import *
from otp.margins.WhisperPopup import WhisperPopup
class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBase, TelemetryLimited):
chatGarbler = ChatGarbler.ChatGarbler({'default': OTPLocalizer.ChatGarblerDefault})
@ -114,7 +114,7 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
if self is localAvatar:
return True
def setSystemMessage(self, aboutId, chatString, whisperType = WTSystem):
def setSystemMessage(self, aboutId, chatString, whisperType = WhisperPopup.WTSystem):
self.displayWhisper(aboutId, chatString, whisperType)
def displayWhisper(self, fromId, chatString, whisperType):
@ -130,7 +130,7 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
return
chatString = SCDecoders.decodeSCStaticTextMsg(msgIndex)
if chatString:
self.displayWhisper(fromId, chatString, WTNormal)
self.displayWhisper(fromId, chatString, WhisperPopup.WTNormal)
return
def whisperSCCustomTo(self, msgIndex, sendToId):
@ -151,7 +151,7 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
return
chatString = SCDecoders.decodeSCCustomMsg(msgIndex)
if chatString:
self.displayWhisper(fromId, chatString, WTNormal)
self.displayWhisper(fromId, chatString, WhisperPopup.WTNormal)
def whisperSCEmoteTo(self, emoteId, sendToId):
messenger.send('wakeup')
@ -163,7 +163,7 @@ class DistributedPlayer(DistributedAvatar.DistributedAvatar, PlayerBase.PlayerBa
return
chatString = SCDecoders.decodeSCEmoteWhisperMsg(emoteId, handle.getName())
if chatString:
self.displayWhisper(fromId, chatString, WTEmote)
self.displayWhisper(fromId, chatString, WhisperPopup.WTEmote)
return
def setChatAbsolute(self, chatString, chatFlags, dialogue = None, interrupt = 1, quiet = 0):

View file

@ -19,7 +19,7 @@ import DistributedAvatar
from otp.ai.MagicWordGlobal import *
from otp.otpbase import OTPGlobals
from otp.otpbase import OTPLocalizer
from toontown.chat.ChatGlobals import *
from otp.nametag.NametagConstants import *
from toontown.toonbase import ToontownGlobals

View file

@ -1,9 +1,37 @@
import string
NORMAL_CHAT = 1
WHISPER_CHAT = 2
GUILD_CHAT = 3
CREW_CHAT = 4
SHIPPVP_CHAT = 5
ERROR_NONE = None
ERROR_NO_OPEN_CHAT = 1
ERROR_NOT_FRIENDS = 2
ERROR_NO_RECEIVER = 3
ERROR_NO_GUILD_CHAT = 4
ERROR_NO_CREW_CHAT = 5
ERROR_NO_SHIPPVP_CHAT = 6
TYPEDCHAT = 0
SPEEDCHAT_NORMAL = 1
SPEEDCHAT_EMOTE = 2
SPEEDCHAT_CUSTOM = 3
SPEEDCHAT_QUEST = 4
SYSTEMCHAT = 4
GAMECHAT = 5
GUILDCHAT = 6
PARTYCHAT = 7
SPEEDCHAT_QUEST = 8
FRIEND_UPDATE = 9
CREW_UPDATE = 10
GUILD_UPDATE = 11
AVATAR_UNAVAILABLE = 12
SHIPPVPCHAT = 13
GMCHAT = 14
ChatEvent = 'ChatEvent'
NormalChatEvent = 'NormalChatEvent'
SCChatEvent = 'SCChatEvent'
SCCustomChatEvent = 'SCCustomChatEvent'
SCEmoteChatEvent = 'SCEmoteChatEvent'
SCEmoteChatEvent = 'SCEmoteChatEvent'
SCQuestEvent = 'SCQuestEvent'
OnScreen = 0
OffScreen = 1
Thought = 2

View file

@ -5,7 +5,7 @@ from direct.gui.DirectGui import *
from direct.showbase import DirectObject
from panda3d.core import *
from otp.otpbase import OTPLocalizer
from toontown.chat.ChatGlobals import *
from otp.nametag.NametagConstants import *
import ChatUtil
ChatEvent = 'ChatEvent'

View file

@ -1,7 +1,7 @@
from direct.directnotify import DirectNotifyGlobal
from direct.showbase import DirectObject
from otp.chat.ChatGlobals import *
from toontown.chat.ChatGlobals import *
from otp.nametag.NametagConstants import *
import ChatUtil
class TalkAssistant(DirectObject.DirectObject):

View file

@ -16,7 +16,7 @@ from otp.distributed.OtpDoGlobals import *
from otp.distributed.TelemetryLimiter import TelemetryLimiter
from otp.otpbase import OTPGlobals, OTPLocalizer
from otp.otpgui import OTPDialog
from toontown.chat.ChatGlobals import *
from otp.nametag.NametagConstants import *
import sys, time, types, random
class OTPClientRepository(ClientRepositoryBase):

View file

@ -0,0 +1,162 @@
from pandac.PandaModules import *
from direct.showbase.DirectObject import DirectObject
from otp.nametag import NametagGlobals
class ClickablePopup(PandaNode, DirectObject):
CS_NORMAL = 0
CS_CLICK = 1
CS_HOVER = 2
CS_DISABLED = 3
def __init__(self, cam=None):
PandaNode.__init__(self, 'popup')
DirectObject.__init__(self)
self.__mwn = NametagGlobals.mouseWatcher
self.__name = 'clickregion-%d' % id(self)
self.__cam = cam
self.__region = MouseWatcherRegion(self.__name, 0, 0, 0, 0)
self.__mwn.addRegion(self.__region)
self.__disabled = False
self.__clicked = False
self.__hovered = False
self.__onscreen = False
self.__clickState = 0
self.__clickArgs = []
self.__clickEvent = ''
self.accept(self.__getEvent(self.__mwn.getEnterPattern()), self.__mouseEnter)
self.accept(self.__getEvent(self.__mwn.getLeavePattern()), self.__mouseLeave)
self.accept(self.__getEvent(self.__mwn.getButtonDownPattern()), self.__buttonDown)
self.accept(self.__getEvent(self.__mwn.getButtonUpPattern()), self.__buttonUp)
def destroy(self):
self.__mwn.removeRegion(self.__region)
self.ignoreAll()
def setClickRegionEvent(self, event, clickArgs=[]):
if event is None:
# The caller is disabling us, so instead:
self.__disabled = True
self.__region.setActive(False)
self.__updateClickState()
else:
self.__clickEvent = event
self.__clickArgs = clickArgs
self.__disabled = False
self.__region.setActive(True)
self.__updateClickState()
def getClickState(self):
return self.__clickState
def clickStateChanged(self):
pass # Intended for subclasses.
def __getEvent(self, pattern):
return pattern.replace('%r', self.__name)
def __mouseEnter(self, region, extra):
self.__hovered = True
self.__updateClickState()
def __mouseLeave(self, region, extra):
self.__hovered = False
self.__updateClickState()
def __buttonDown(self, region, button):
if button == 'mouse1':
self.__clicked = True
self.__updateClickState()
def __buttonUp(self, region, button):
if button == 'mouse1':
self.__clicked = False
self.__updateClickState()
def __updateClickState(self):
if self.__disabled:
state = self.CS_DISABLED
elif self.__clicked:
state = self.CS_CLICK
elif self.__hovered:
state = self.CS_HOVER
else:
state = self.CS_NORMAL
if self.__clickState == state: return
oldState = self.__clickState
self.__clickState = state
if oldState == self.CS_NORMAL and state == self.CS_HOVER:
# Play rollover sound:
base.playSfx(NametagGlobals.rolloverSound)
elif state == self.CS_CLICK:
# Play click sound:
base.playSfx(NametagGlobals.clickSound)
elif oldState == self.CS_CLICK and state == self.CS_HOVER:
# Fire click event:
messenger.send(self.__clickEvent, self.__clickArgs)
self.clickStateChanged()
def updateClickRegion(self, left, right, bottom, top, offset=0):
transform = NodePath.anyPath(self).getNetTransform()
if self.__cam:
# We have a camera, so get its transform and move our net transform
# into the coordinate space of the camera:
camTransform = self.__cam.getNetTransform()
transform = camTransform.invertCompose(transform)
# We must discard the rotational component on our transform, thus:
transform = transform.setQuat(Quat())
# Next, we'll transform the frame into camspace:
mat = transform.getMat()
cTopLeft = mat.xformPoint(Point3(left, 0, top))
cBottomRight = mat.xformPoint(Point3(right, 0, bottom))
# Shift along the offset while in camspace, not worldspace.
if offset:
mid = mat.xformPoint(Point3(0,0,0))
length = mid.length()
shift = mid*(length - offset)/length - mid
cTopLeft += shift
cBottomRight += shift
if self.__cam:
# We must go further and project to screenspace:
lens = self.__cam.node().getLens()
sTopLeft = Point2()
sBottomRight = Point2()
if not (lens.project(Point3(cTopLeft), sTopLeft) and
lens.project(Point3(cBottomRight), sBottomRight)):
# Not on-screen! Disable the click region:
self.__region.setActive(False)
self.__onscreen = False
return
else:
# No cam; the "camspace" (actually just net transform) IS the
# screenspace transform.
sTopLeft = Point2(cTopLeft[0], cTopLeft[2])
sBottomRight = Point2(cBottomRight[0], cBottomRight[2])
sLeft, sTop = sTopLeft
sRight, sBottom = sBottomRight
self.__region.setFrame(sLeft, sRight, sBottom, sTop)
self.__region.setActive(not self.__disabled)
self.__onscreen = True
def stashClickRegion(self):
self.__region.setActive(False)
self.__onscreen = False
def isOnScreen(self):
return self.__onscreen

83
otp/margins/MarginCell.py Normal file
View file

@ -0,0 +1,83 @@
from pandac.PandaModules import *
class MarginCell(NodePath):
def __init__(self, manager):
NodePath.__init__(self, 'cell')
self.manager = manager
self.content = None
self.available = False
self.debugSquare = None
self.debugMode = False
self.setDebug(config.GetBool('want-cell-debug', False))
def setAvailable(self, available):
if not available and self.hasContent():
self.setContent(None)
self.available = available
self.updateDebug()
def setContent(self, content):
if self.content:
self.content._assignedCell = None
self.contentNP.removeNode()
self.content.marginVisibilityChanged()
if content:
content._assignedCell = self
content._lastCell = self
self.contentNP = self.attachNewNode(content)
content.marginVisibilityChanged()
self.content = content
self.updateDebug()
def hasContent(self):
return self.content is not None
def getContent(self):
return self.content
def isAvailable(self):
return self.available
def isFree(self):
return self.isAvailable() and not self.hasContent()
def setDebugColor(self, color):
if not self.debugSquare:
cm = CardMaker('debugSquare')
cm.setFrameFullscreenQuad()
self.debugSquare = self.attachNewNode(cm.generate())
self.debugSquare.setTransparency(1)
self.debugSquare.setY(1)
self.debugSquare.setColor(color)
def updateDebug(self):
if not self.debugMode: return
if self.hasContent():
self.setDebugColor(VBase4(0.0, 0.8, 0.0, 0.5))
elif self.isAvailable():
self.setDebugColor(VBase4(0.0, 0.0, 0.8, 0.5))
else:
self.setDebugColor(VBase4(0.8, 0.0, 0.0, 0.5))
def setDebug(self, status):
if bool(status) == self.debugMode:
return
self.debugMode = status
if self.debugMode:
self.updateDebug()
elif self.debugSquare:
self.debugSquare.removeNode()
self.debugSquare = None

View file

@ -0,0 +1,83 @@
from pandac.PandaModules import *
from MarginCell import MarginCell
import random
class MarginManager(PandaNode):
def __init__(self):
PandaNode.__init__(self, 'margins')
self.cells = set()
self.visiblePopups = set()
def addGridCell(self, x, y, a2d):
# Yucky!
nodePath = NodePath.anyPath(self)
a2d.reparentTo(nodePath)
cell = MarginCell(self)
cell.reparentTo(a2d)
cell.setScale(0.2)
cell.setPos(x, 0, y + 0.025)
cell.setAvailable(True)
cell.setPythonTag('MarginCell', cell)
self.cells.add(cell)
self.reorganize()
return cell
def setCellAvailable(self, cell, available):
cell = cell.getPythonTag('MarginCell')
cell.setAvailable(available)
self.reorganize()
def addVisiblePopup(self, popup):
self.visiblePopups.add(popup)
self.reorganize()
def removeVisiblePopup(self, popup):
if popup not in self.visiblePopups: return
self.visiblePopups.remove(popup)
self.reorganize()
def reorganize(self):
# First, get all active cells:
activeCells = [cell for cell in self.cells if cell.isAvailable()]
# Next, get all visible popups, sorted by priority:
popups = list(self.visiblePopups)
popups.sort(key=lambda x: -x.getPriority())
# We can only display so many popups, so truncate to the number of active
# margin cells:
popups = popups[:len(activeCells)]
# Now, we need to build up a list of free cells:
freeCells = []
for cell in activeCells:
if not cell.hasContent():
freeCells.append(cell)
elif cell.getContent() in popups:
# It's already displaying something we want to show, so we can
# safely ignore this cell/popup pair:
popups.remove(cell.getContent())
else:
# It's not displaying something we want to see, evict the old
# popup:
cell.setContent(None)
freeCells.append(cell)
# At this point, there should be enough cells to show the popups:
assert len(freeCells) >= len(popups)
# Now we assign the popups:
for popup in popups:
if popup._lastCell in freeCells and popup._lastCell.isFree():
# The last cell it had assigned is available, so let's assign it
# again:
popup._lastCell.setContent(popup)
freeCells.remove(popup._lastCell)
else:
# We assign a cell at random.
cell = random.choice(freeCells)
cell.setContent(popup)
freeCells.remove(cell)

View file

@ -0,0 +1,52 @@
from pandac.PandaModules import *
class MarginPopup:
def __init__(self):
self.__manager = None
self.__visible = False
self.__priority = 0
# The margin management system uses these:
self._assignedCell = None
self._lastCell = None
def setVisible(self, visibility):
visibility = bool(visibility)
if self.__visible == visibility: return
self.__visible = visibility
if self.__manager is not None:
if visibility:
self.__manager.addVisiblePopup(self)
else:
self.__manager.removeVisiblePopup(self)
def getPriority(self):
return self.__priority
def setPriority(self, priority):
self.__priority = priority
if self.__manager is not None:
self.__manager.reorganize()
def isDisplayed(self):
return self._assignedCell is not None
def marginVisibilityChanged(self):
pass # Fired externally when the result of isDisplayed changes. For subclasses.
def manage(self, manager):
if self.__manager:
self.unmanage(self.__manager)
self.__manager = manager
if self.__visible:
manager.addVisiblePopup(self)
def unmanage(self, manager):
if self.__manager is not None:
if self.__visible:
self.__manager.removeVisiblePopup(self)
self.__manager = None

View file

@ -0,0 +1,97 @@
from MarginPopup import *
from ClickablePopup import *
from otp.nametag import NametagGlobals
from otp.nametag.NametagConstants import *
class WhisperPopup(MarginPopup, ClickablePopup):
WTNormal = WTNormal
WTQuickTalker = WTQuickTalker
WTSystem = WTSystem
WTBattleSOS = WTBattleSOS
WTEmote = WTEmote
WTToontownBoardingGroup = WTToontownBoardingGroup
WORDWRAP = 7.5
SCALE_2D = 0.25
def __init__(self, text, font, whisperType, timeout=10.0):
ClickablePopup.__init__(self)
MarginPopup.__init__(self)
self.innerNP = NodePath.anyPath(self).attachNewNode('innerNP')
self.innerNP.setScale(self.SCALE_2D)
self.text = text
self.font = font
self.whisperType = whisperType
self.timeout = timeout
self.active = False
self.fromId = 0
self.left = 0.0
self.right = 0.0
self.top = 0.0
self.bottom = 0.0
self.updateContents()
self.setPriority(2)
self.setVisible(True)
def updateContents(self):
if self.whisperType in WHISPER_COLORS:
cc = self.whisperType
else:
cc = WTSystem
fgColor, bgColor = WHISPER_COLORS[cc][self.getClickState()]
self.innerNP.node().removeAllChildren()
balloon, frame = NametagGlobals.speechBalloon2d.generate(
self.text, self.font, textColor=fgColor, balloonColor=bgColor,
wordWrap=self.WORDWRAP)
balloon.reparentTo(self.innerNP)
# Calculate the center of the TextNode.
text = balloon.find('**/+TextNode')
t = text.node()
self.left, self.right, self.bottom, self.top = t.getFrameActual()
center = self.innerNP.getRelativePoint(text, ((self.left + self.right) / 2., 0, (self.bottom + self.top) / 2.))
# Next translate the balloon along the inverse.
balloon.setPos(balloon, -center)
if self.active and self.fromId:
self.setClickRegionEvent('clickedWhisper', clickArgs=[self.fromId])
def setClickable(self, senderName, fromId, todo=0):
self.active = True
self.fromId = fromId
self.updateContents()
self.__updateClickRegion()
def marginVisibilityChanged(self):
self.__updateClickRegion()
def __updateClickRegion(self):
if self.isDisplayed() and self.active:
self.updateClickRegion(-1, 1, self.bottom, self.top)
else:
self.stashClickRegion()
def clickStateChanged(self):
self.updateContents()
def manage(self, manager):
MarginPopup.manage(self, manager)
taskMgr.doMethodLater(self.timeout, self.unmanage, 'whisper-timeout-%d' % id(self), [manager])
# Manually Clean up
def unmanage(self, manager):
MarginPopup.unmanage(self, manager)
ClickablePopup.destroy(self)
self.innerNP.removeNode()

View file

View file

@ -1,6 +1,6 @@
from panda3d.core import *
from pandac.PandaModules import *
class CatalogChatBalloon:
class ChatBalloon:
TEXT_SHIFT = (0.1, -0.05, 1.1)
TEXT_SHIFT_REVERSED = -0.05
TEXT_SHIFT_PROP = 0.08

160
otp/nametag/Nametag.py Normal file
View file

@ -0,0 +1,160 @@
from NametagConstants import *
import NametagGlobals
from otp.margins.ClickablePopup import ClickablePopup
from otp.otpbase import OTPGlobals
from pandac.PandaModules import *
from direct.interval.IntervalGlobal import *
class Nametag(ClickablePopup):
CName = 1
CSpeech = 2
CThought = 4
NAME_PADDING = 0.2
CHAT_ALPHA = 1.0
DEFAULT_CHAT_WORDWRAP = 10.0
IS_3D = False # 3D variants will set this to True.
def __init__(self):
if self.IS_3D:
ClickablePopup.__init__(self, NametagGlobals.camera)
else:
ClickablePopup.__init__(self)
self.contents = 0 # To be set by subclass.
self.innerNP = NodePath.anyPath(self).attachNewNode('nametag_contents')
self.wordWrap = 7.5
self.chatWordWrap = None
self.font = None
self.speechFont = None
self.name = ''
self.displayName = ''
self.qtColor = VBase4(1,1,1,1)
self.colorCode = CCNormal
self.avatar = None
self.icon = NodePath('icon')
self.frame = (0, 0, 0, 0)
self.nameFg = (0,0,0,1)
self.nameBg = (1,1,1,1)
self.chatFg = (0,0,0,1)
self.chatBg = (1,1,1,1)
self.chatString = ''
self.chatFlags = 0
def destroy(self):
ClickablePopup.destroy(self)
def setContents(self, contents):
self.contents = contents
self.update()
def setAvatar(self, avatar):
self.avatar = avatar
def setChatWordwrap(self, chatWordWrap):
self.chatWordWrap = chatWordWrap
def tick(self):
pass # Does nothing by default.
def clickStateChanged(self):
self.update(False)
def getButton(self):
cs = self.getClickState()
if self.buttons is None:
return None
elif cs in self.buttons:
return self.buttons[cs]
else:
return self.buttons.get(0)
def update(self, scale=True):
if self.colorCode in NAMETAG_COLORS:
cc = self.colorCode
else:
cc = CCNormal
self.nameFg, self.nameBg, self.chatFg, self.chatBg = NAMETAG_COLORS[cc][self.getClickState()]
self.innerNP.node().removeAllChildren()
if self.contents & self.CThought and self.chatFlags & CFThought:
balloon = self.showBalloon(self.getThoughtBalloon(), self.chatString)
elif self.contents & self.CSpeech and self.chatFlags&CFSpeech:
balloon = self.showBalloon(self.getSpeechBalloon(), self.chatString)
elif self.contents & self.CName and self.displayName:
self.showName()
return
else:
return
if scale and self.IS_3D:
balloon.setScale(0)
scaleLerp = Sequence(Wait(0.10), LerpScaleInterval(balloon, 0.2, VBase3(1, 1, 1), VBase3(0, 0, 0), blendType='easeInOut'))
scaleLerp.start()
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)
reversed = (self.IS_3D and (self.chatFlags&CFReversed))
balloon, frame = balloon.generate(text, self.speechFont, textColor=self.chatFg,
balloonColor=color,
wordWrap=self.chatWordWrap or \
self.DEFAULT_CHAT_WORDWRAP,
button=self.getButton(),
reversed=reversed)
balloon.reparentTo(self.innerNP)
self.frame = frame
return balloon
def showName(self):
if not self.font:
# If no font is set, we can't actually display a name yet...
return
# Create text node:
self.innerNP.attachNewNode(self.icon)
t = self.innerNP.attachNewNode(TextNode('name'), 1)
t.node().setFont(self.font)
t.node().setAlign(TextNode.ACenter)
t.node().setWordwrap(self.wordWrap)
t.node().setText(self.displayName)
t.node().setTextColor(self.nameFg)
t.setTransparency(self.nameFg[3] < 1.0)
width, height = t.node().getWidth(), t.node().getHeight()
# Put the actual written name a little in front of the nametag and
# disable depth write so the text appears nice and clear, free from
# z-fighting and bizarre artifacts. The text renders *after* the tag
# behind it, due to both being in the transparency bin,
# so there's really no problem with doing this.
t.setY(-0.05)
t.setAttrib(DepthWriteAttrib.make(0))
# Apply panel behind the text:
panel = NametagGlobals.nametagCardModel.copyTo(self.innerNP, 0)
panel.setPos((t.node().getLeft()+t.node().getRight())/2.0, 0,
(t.node().getTop()+t.node().getBottom())/2.0)
panel.setScale(width + self.NAME_PADDING, 1, height + self.NAME_PADDING)
panel.setColor(self.nameBg)
panel.setTransparency(self.nameBg[3] < 1.0)
self.frame = (t.node().getLeft()-self.NAME_PADDING/2.0,
t.node().getRight()+self.NAME_PADDING/2.0,
t.node().getBottom()-self.NAME_PADDING/2.0,
t.node().getTop()+self.NAME_PADDING/2.0)

113
otp/nametag/Nametag2d.py Normal file
View file

@ -0,0 +1,113 @@
from Nametag import *
from otp.margins.MarginPopup import *
from pandac.PandaModules import *
import math
class Nametag2d(Nametag, MarginPopup):
SCALE_2D = 0.25
CHAT_ALPHA = 0.5
ARROW_OFFSET = -1.0
ARROW_SCALE = 1.5
DEFAULT_CHAT_WORDWRAP = 8.0
def __init__(self):
Nametag.__init__(self)
MarginPopup.__init__(self)
self.contents = self.CName|self.CSpeech
self.chatWordWrap = 7.5
self.arrow = None
self.innerNP.setScale(self.SCALE_2D)
def showBalloon(self, balloon, text):
text = '%s: %s' % (self.name, text)
Nametag.showBalloon(self, balloon, text)
# Next, center the balloon in the cell:
balloon = NodePath.anyPath(self).find('*/balloon')
# Calculate the center of the TextNode.
text = balloon.find('**/+TextNode')
t = text.node()
left, right, bottom, top = t.getFrameActual()
center = self.innerNP.getRelativePoint(text,
((left+right)/2., 0, (bottom+top)/2.))
# Next translate the balloon along the inverse.
balloon.setPos(balloon, -center)
# Also translate the frame:
left, right, bottom, top = self.frame
self.frame = (left-center.getX(), right-center.getX(),
bottom-center.getZ(), top-center.getZ())
# When a balloon is active, we need to be somewhat higher-priority in the
# popup system:
self.setPriority(1)
# Remove our pointer arrow:
if self.arrow is not None:
self.arrow.removeNode()
self.arrow = None
def showName(self):
Nametag.showName(self)
# Revert our priority back to basic:
self.setPriority(0)
# Tack on an arrow:
t = self.innerNP.find('**/+TextNode')
arrowZ = self.ARROW_OFFSET + t.node().getBottom()
self.arrow = NametagGlobals.arrowModel.copyTo(self.innerNP)
self.arrow.setZ(arrowZ)
self.arrow.setScale(self.ARROW_SCALE)
self.arrow.setColor(ARROW_COLORS.get(self.colorCode, self.nameFg))
def update(self, scale=True):
Nametag.update(self, scale)
self.considerUpdateClickRegion()
def marginVisibilityChanged(self):
self.considerUpdateClickRegion()
def considerUpdateClickRegion(self):
# If we are onscreen, we update our click region:
if self.isDisplayed():
left, right, bottom, top = self.frame
self.updateClickRegion(left*self.SCALE_2D, right*self.SCALE_2D,
bottom*self.SCALE_2D, top*self.SCALE_2D)
else:
self.stashClickRegion()
def tick(self):
# Update the arrow's pointing.
if not self.isDisplayed() or self.arrow is None:
return # No arrow or not onscreen.
if self.avatar is None or self.avatar.isEmpty():
return # No avatar, can't be done.
# Get points needed in calculation:
cam = NametagGlobals.camera or base.cam
toon = NametagGlobals.toon or cam
# libotp calculates this using the offset from localToon->avatar, but
# the orientation from cam. Therefore, we duplicate it like so:
location = self.avatar.getPos(toon)
rotation = toon.getQuat(cam)
camSpacePos = rotation.xform(location)
arrowRadians = math.atan2(camSpacePos[0], camSpacePos[1])
arrowDegrees = arrowRadians/math.pi*180
self.arrow.setR(arrowDegrees - 90)
def getSpeechBalloon(self):
return NametagGlobals.speechBalloon2d
def getThoughtBalloon(self):
return NametagGlobals.thoughtBalloon2d

71
otp/nametag/Nametag3d.py Normal file
View file

@ -0,0 +1,71 @@
from Nametag import *
import NametagGlobals
from NametagConstants import *
from pandac.PandaModules import *
import math
class Nametag3d(Nametag):
WANT_DYNAMIC_SCALING = True
MAX_SCALE = 2.5
SCALING_FACTOR = 0.055
SCALING_MINDIST = 1
SCALING_MAXDIST = math.pow(MAX_SCALE / SCALING_FACTOR, 2)
BILLBOARD_OFFSET = 3.0
SHOULD_BILLBOARD = True
IS_3D = True
def __init__(self):
Nametag.__init__(self)
self.contents = self.CName|self.CSpeech|self.CThought
self.bbOffset = self.BILLBOARD_OFFSET
self._doBillboard()
def _doBillboard(self):
if self.SHOULD_BILLBOARD:
self.innerNP.setEffect(BillboardEffect.make(
Vec3(0,0,1),
True,
False,
self.bbOffset,
NodePath(), # Empty; look at scene camera
Point3(0,0,0)))
else:
self.bbOffset = 0.0
def setBillboardOffset(self, bbOffset):
self.bbOffset = bbOffset
self._doBillboard()
def tick(self):
if not self.WANT_DYNAMIC_SCALING:
scale = self.SCALING_FACTOR
else:
# Attempt to maintain the same on-screen size.
distance = self.innerNP.getPos(NametagGlobals.camera).length()
distance = max(min(distance, self.SCALING_MAXDIST), self.SCALING_MINDIST)
scale = math.sqrt(distance)*self.SCALING_FACTOR
self.innerNP.setScale(scale)
# As 3D nametags can move around on their own, we need to update the
# click frame constantly:
path = NodePath.anyPath(self)
if path.isHidden() or (path.getTop() != NametagGlobals.camera.getTop() and
path.getTop() != render2d):
self.stashClickRegion()
else:
left, right, bottom, top = self.frame
self.updateClickRegion(left*scale, right*scale,
bottom*scale, top*scale,
self.bbOffset)
def getSpeechBalloon(self):
return NametagGlobals.speechBalloon3d
def getThoughtBalloon(self):
return NametagGlobals.thoughtBalloon3d

View file

@ -0,0 +1,232 @@
CFNoQuitButton=256
CFPageButton=16
CFQuicktalker=4
CFQuitButton=32
CFReversed=64
CFSndOpenchat=128
CFSpeech=1
CFThought=2
CFTimeout=8
CCNormal = 0
CCNoChat = 1
CCNonPlayer = 2
CCSuit = 3
CCToonBuilding = 4
CCSuitBuilding = 5
CCHouseBuilding = 6
CCSpeedChat = 7
CCFreeChat = 8
CCAdmin = 9
NAMETAG_COLORS = {
CCNormal: (
# Normal FG BG
((0.3, 0.3, 0.7, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((0.3, 0.3, 0.7, 1.0), (0.2, 0.2, 0.2, 0.6), # Name
(1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((0.5, 0.5, 1.0, 1.0), (1.0, 1.0, 1.0, 1.0), # Name
(0.0, 0.6, 0.6, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((0.3, 0.3, 0.7, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
CCNoChat: (
# Normal FG BG
((0.8, 0.4, 0.0, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((1.0, 0.5, 0.5, 1.0), (0.2, 0.2, 0.2, 0.6), # Name
(1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((1.0, 0.5, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0), # Name
(0.0, 0.6, 0.6, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((0.8, 0.4, 0.0, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
CCNonPlayer: (
# Normal FG BG
((0.8, 0.4, 0.0, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((0.8, 0.4, 0.0, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((0.8, 0.4, 0.0, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((0.8, 0.4, 0.0, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
CCSuit: (
# Normal FG BG
((0.2, 0.2, 0.2, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((0.2, 0.2, 0.2, 1.0), (0.2, 0.2, 0.2, 0.6), # Name
(1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((0.4, 0.4, 0.4, 1.0), (1.0, 1.0, 1.0, 0.7), # Name
(0.0, 0.6, 0.6, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((0.2, 0.2, 0.2, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
CCSuitBuilding: (
# Normal FG BG
((0.5, 0.5, 0.5, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((0.5, 0.5, 0.5, 1.0), (0.2, 0.2, 0.2, 0.6), # Name
(1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((0.7, 0.7, 0.7, 1.0), (1.0, 1.0, 1.0, 0.7), # Name
(0.0, 0.6, 0.6, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((0.5, 0.5, 0.5, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
CCToonBuilding: (
# Normal FG BG
((0.2, 0.6, 0.9, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((0.2, 0.6, 0.9, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((0.2, 0.6, 0.9, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((0.2, 0.6, 0.9, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
CCHouseBuilding: (
# Normal FG BG
((0.2, 0.6, 0.9, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((0.2, 0.2, 0.5, 1.0), (0.2, 0.2, 0.2, 0.6), # Name
(1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((0.5, 0.5, 1.0, 1.0), (1.0, 1.0, 1.0, 1.0), # Name
(0.0, 0.6, 0.6, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((0.0, 0.6, 0.2, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
CCSpeedChat: (
# Normal FG BG
((0.0, 0.6, 0.2, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((0.0, 0.5, 0.0, 1.0), (0.5, 0.5, 0.5, 0.6), # Name
(1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((0.0, 0.7, 0.2, 1.0), (1.0, 1.0, 1.0, 0.7), # Name
(0.0, 0.6, 0.6, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((0.0, 0.6, 0.2, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
CCFreeChat: (
# Normal FG BG
((0.3, 0.3, 0.7, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((0.2, 0.2, 0.5, 1.0), (0.2, 0.2, 0.2, 0.6), # Name
(1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((0.5, 0.5, 1.0, 1.0), (1.0, 1.0, 1.0, 1.0), # Name
(0.0, 0.6, 0.6, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((0.3, 0.3, 0.7, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
CCAdmin: (
# Normal FG BG
((1.0, 0.35, 0.25, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Click FG BG
((1.0, 0.35, 0.25, 1.0), (0.2, 0.2, 0.2, 0.6), # Name
(1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Hover FG BG
((1.0, 0.5, 0.56, 1.0), (1.0, 1.0, 1.0, 1.0), # Name
(0.0, 0.6, 0.6, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
# Disable FG BG
((1.0, 0.35, 0.25, 1.0), (0.8, 0.8, 0.8, 0.5), # Name
(0.0, 0.0, 0.0, 1.0), (1.0, 1.0, 1.0, 1.0)), # Chat
),
}
ARROW_COLORS = {
CCSuit: (0.8, 0.4, 0.0, 1.0),
}
DEFAULT_WORDWRAPS = {
CCNormal: 7.5,
CCNoChat: 7.5,
CCNonPlayer: 7.5,
CCSuit: 7.5,
CCToonBuilding: 8.5,
CCSuitBuilding: 8.5,
CCHouseBuilding: 10.0,
CCSpeedChat: 7.5,
CCFreeChat: 7.5,
CCAdmin: 7.5
}
WTNormal = 0
WTQuickTalker = 1
WTSystem = 2
WTBattleSOS = 3
WTEmote = 4
WTToontownBoardingGroup = 5
WHISPER_COLORS = {
WTNormal: (
# Normal FG BG
((0.0, 0.0, 0.0, 1.0), (0.2, 0.6, 0.8, 0.6)),
# Click FG BG
((1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 0.8)),
# Hover FG BG
((0.0, 0.0, 0.0, 1.0), (0.2, 0.7, 0.9, 0.6)),
# Disable FG BG
((0.0, 0.0, 0.0, 1.0), (0.2, 0.7, 0.8, 0.6)),
),
WTQuickTalker: (
# Normal FG BG
((0.0, 0.0, 0.0, 1.0), (0.2, 0.6, 0.8, 0.6)),
# Click FG BG
((1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 0.8)),
# Hover FG BG
((0.0, 0.0, 0.0, 1.0), (0.2, 0.7, 0.9, 0.6)),
# Disable FG BG
((0.0, 0.0, 0.0, 1.0), (0.2, 0.7, 0.8, 0.6)),
),
WTSystem: (
# Normal FG BG
((0.0, 0.0, 0.0, 1.0), (0.8, 0.3, 0.6, 0.6)),
# Click FG BG
((1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 0.8)),
# Hover FG BG
((0.0, 0.0, 0.0, 1.0), (0.8, 0.4, 1.0, 0.6)),
# Disable FG BG
((0.0, 0.0, 0.0, 1.0), (0.8, 0.3, 0.6, 0.6)),
),
# TODO: WTBattleSOS
WTEmote: (
# Normal FG BG
((0.0, 0.0, 0.0, 1.0), (0.9, 0.5, 0.1, 0.6)),
# Click FG BG
((1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 0.8)),
# Hover FG BG
((0.0, 0.0, 0.0, 1.0), (0.9, 0.6, 0.2, 0.6)),
# Disable FG BG
((0.0, 0.0, 0.0, 1.0), (0.9, 0.6, 0.1, 0.6)),
),
# TODO: WTToontownBoardingGroup
}

View file

@ -0,0 +1,7 @@
from Nametag3d import *
class NametagFloat2d(Nametag3d):
WANT_DYNAMIC_SCALING = False
SCALING_FACTOR = 1.0
SHOULD_BILLBOARD = False
IS_3D = False

View file

@ -0,0 +1,7 @@
from Nametag3d import *
class NametagFloat3d(Nametag3d):
WANT_DYNAMIC_SCALING = False
SCALING_FACTOR = 1.0
SHOULD_BILLBOARD = True
IS_3D = False

View file

@ -0,0 +1,100 @@
camera = None
def setCamera(cam):
global camera
camera = cam
arrowModel = None
def setArrowModel(am):
global arrowModel
arrowModel = am
nametagCardModel = None
nametagCardDimensions = None
def setNametagCard(model, dimensions):
global nametagCardModel, nametagCardDimensions
nametagCardModel = model
nametagCardDimensions = dimensions
mouseWatcher = None
def setMouseWatcher(mw):
global mouseWatcher
mouseWatcher = mw
speechBalloon3d = None
def setSpeechBalloon3d(sb3d):
global speechBalloon3d
speechBalloon3d = sb3d
thoughtBalloon3d = None
def setThoughtBalloon3d(tb3d):
global thoughtBalloon3d
thoughtBalloon3d = tb3d
speechBalloon2d = None
def setSpeechBalloon2d(sb2d):
global speechBalloon2d
speechBalloon2d = sb2d
thoughtBalloon2d = None
def setThoughtBalloon2d(tb2d):
global thoughtBalloon2d
thoughtBalloon2d = tb2d
pageButtons = {}
def setPageButton(state, model):
pageButtons[state] = model
quitButtons = {}
def setQuitButton(state, model):
quitButtons[state] = model
rolloverSound = None
def setRolloverSound(ros):
global rolloverSound
rolloverSound = ros
clickSound = None
def setClickSound(cs):
global clickSound
clickSound = cs
toon = None
def setToon(t):
global toon
toon = t
masterArrowsOn = 0
def setMasterArrowsOn(mao):
global masterArrowsOn
masterArrowsOn = mao
masterNametagsActive = 0
def setMasterNametagsActive(mna):
global masterNametagsActive
masterNametagsActive = mna
min2dAlpha = 0.0
def setMin2dAlpha(m2a):
global min2dAlpha
min2dAlpha = m2a
def getMin2dAlpha():
global min2dAlpha
return min2dAlpha
max2dAlpha = 0.0
def setMax2dAlpha(m2a):
global max2dAlpha
max2dAlpha = m2a
def getMax2dAlpha():
global max2dAlpha
return max2dAlpha
onscreenChatForced = 0
def setOnscreenChatForced(ocf):
global onscreenChatForced
onscreenChatForced = ocf
def setGlobalNametagScale(s):
pass

321
otp/nametag/NametagGroup.py Normal file
View file

@ -0,0 +1,321 @@
from pandac.PandaModules import *
from NametagConstants import *
from Nametag3d import *
from Nametag2d import *
class NametagGroup:
CCNormal = CCNormal
CCNoChat = CCNoChat
CCNonPlayer = CCNonPlayer
CCSuit = CCSuit
CCToonBuilding = CCToonBuilding
CCSuitBuilding = CCSuitBuilding
CCHouseBuilding = CCHouseBuilding
CCSpeedChat = CCSpeedChat
CCFreeChat = CCFreeChat
CCAdmin = CCAdmin
CHAT_TIMEOUT_MAX = 12.0
CHAT_TIMEOUT_MIN = 4.0
CHAT_TIMEOUT_PROP = 0.5
def __init__(self):
self.nametag2d = Nametag2d()
self.nametag3d = Nametag3d()
self.icon = PandaNode('icon')
self.chatTimeoutTask = None
self.font = None
self.speechFont = None
self.name = ''
self.displayName = ''
self.wordWrap = None
self.qtColor = VBase4(1,1,1,1)
self.colorCode = CCNormal
self.avatar = None
self.active = True
self.chatPages = []
self.chatPage = 0
self.chatFlags = 0
self.objectCode = None
self.manager = None
self.nametags = []
self.addNametag(self.nametag2d)
self.addNametag(self.nametag3d)
self.visible3d = True # Is a 3D nametag visible, or do we need a 2D popup?
self.tickTask = taskMgr.add(self.__tickTask, self.getUniqueId(), sort=45)
self.stompTask = None
self.stompText = None
self.stompFlags = 0
def destroy(self):
taskMgr.remove(self.tickTask)
if self.manager is not None:
self.unmanage(self.manager)
for nametag in list(self.nametags):
self.removeNametag(nametag)
if self.stompTask:
self.stompTask.remove()
def getNametag2d(self):
return self.nametag2d
def getNametag3d(self):
return self.nametag3d
def getNameIcon(self):
return self.icon
def getNumChatPages(self):
if not self.chatFlags & (CFSpeech|CFThought):
return 0
return len(self.chatPages)
def setPageNumber(self, page):
self.chatPage = page
self.updateTags()
def getChatStomp(self):
return bool(self.stompTask)
def getChat(self):
if self.chatPage >= len(self.chatPages):
return ''
else:
return self.chatPages[self.chatPage]
def getStompText(self):
return self.stompText
def getStompDelay(self):
return 0.2
def getUniqueId(self):
return 'Nametag-%d' % id(self)
def hasButton(self):
return bool(self.getButtons())
def getButtons(self):
if self.getNumChatPages() < 2:
# Either only one page or no pages displayed. This means no button,
# unless the game code specifically requests one.
if self.chatFlags & CFQuitButton:
return NametagGlobals.quitButtons
elif self.chatFlags & CFPageButton:
return NametagGlobals.pageButtons
else:
return None
elif self.chatPage == self.getNumChatPages()-1:
# Last page of a multiple-page chat. This calls for a quit button,
# unless the game says otherwise.
if not self.chatFlags & CFNoQuitButton:
return NametagGlobals.quitButtons
else:
return None
else:
# Non-last page of a multiple-page chat. This calls for a page
# button, but only if the game requests it:
if self.chatFlags & CFPageButton:
return NametagGlobals.pageButtons
else:
return None
def setActive(self, active):
self.active = active
def isActive(self):
return self.active
def setAvatar(self, avatar):
self.avatar = avatar
def setFont(self, font):
self.font = font
self.updateTags()
def setSpeechFont(self, font):
self.speechFont = font
self.updateTags()
def setWordwrap(self, wrap):
self.wordWrap = wrap
self.updateTags()
def setColorCode(self, cc):
self.colorCode = cc
self.updateTags()
def setName(self, name):
self.name = name
self.updateTags()
def setDisplayName(self, name):
self.displayName = name
self.updateTags()
def setQtColor(self, color):
self.qtColor = color
self.updateTags()
def setChat(self, chatString, chatFlags):
if not self.chatFlags&CFSpeech:
# We aren't already displaying some chat. Therefore, we don't have
# to stomp.
self._setChat(chatString, chatFlags)
else:
# Stomp!
self.clearChat()
self.stompText = chatString
self.stompFlags = chatFlags
self.stompTask = taskMgr.doMethodLater(self.getStompDelay(), self.__updateStomp,
'ChatStomp-' + self.getUniqueId())
def _setChat(self, chatString, chatFlags):
if chatString:
self.chatPages = chatString.split('\x07')
self.chatFlags = chatFlags
else:
self.chatPages = []
self.chatFlags = 0
self.setPageNumber(0) # Calls updateTags() for us.
self._stopChatTimeout()
if chatFlags&CFTimeout:
self._startChatTimeout()
def __updateStomp(self, task):
self._setChat(self.stompText, self.stompFlags)
self.stompTask = None
def setContents(self, contents):
# This function is a little unique, it's meant to override contents on
# EXISTING nametags only:
for tag in self.nametags:
tag.setContents(contents)
def setObjectCode(self, objectCode):
self.objectCode = objectCode
def getObjectCode(self):
return self.objectCode
def _startChatTimeout(self):
length = len(self.getChat())
timeout = min(max(length*self.CHAT_TIMEOUT_PROP, self.CHAT_TIMEOUT_MIN), self.CHAT_TIMEOUT_MAX)
self.chatTimeoutTask = taskMgr.doMethodLater(timeout, self.__doChatTimeout,
'ChatTimeout-' + self.getUniqueId())
def __doChatTimeout(self, task):
self._setChat('', 0)
return task.done
def _stopChatTimeout(self):
if self.chatTimeoutTask:
taskMgr.remove(self.chatTimeoutTask)
def clearShadow(self):
pass
def clearChat(self):
self._setChat('', 0)
if self.stompTask:
self.stompTask.remove()
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
tag.qtColor = self.qtColor
tag.colorCode = self.colorCode
tag.chatString = self.getChat()
tag.buttons = self.getButtons()
tag.chatFlags = self.chatFlags
tag.avatar = self.avatar
tag.icon = self.icon
tag.update()
def __testVisible3D(self):
# We must determine if a 3D nametag is visible or not, since this
# affects the visibility state of 2D nametags.
# Next, we iterate over all of our nametags until we find a visible
# one:
for nametag in self.nametags:
if not isinstance(nametag, Nametag3d):
continue # It's not in the 3D system, disqualified.
if nametag.isOnScreen():
return True
# If we got here, none of the tags were a match...
return False
def __tickTask(self, task):
for nametag in self.nametags:
nametag.tick()
if (NametagGlobals.masterNametagsActive and self.active) or self.hasButton():
nametag.setClickRegionEvent(self.getUniqueId())
else:
nametag.setClickRegionEvent(None)
if NametagGlobals.onscreenChatForced and self.chatFlags & CFSpeech:
# Because we're *forcing* chat onscreen, we skip the visible3d test
# and go ahead and display it anyway.
visible3d = False
elif not NametagGlobals.masterArrowsOn and not self.chatFlags:
# We're forcing margins offscreen; therefore, we should pretend
# that the 3D nametag is always visible.
visible3d = True
else:
visible3d = self.__testVisible3D()
if visible3d ^ self.visible3d:
self.visible3d = visible3d
for nametag in self.nametags:
if isinstance(nametag, MarginPopup):
nametag.setVisible(not visible3d)
return task.cont
def updateTags(self):
for nametag in self.nametags:
self.updateNametag(nametag)
def addNametag(self, nametag):
self.nametags.append(nametag)
self.updateNametag(nametag)
if self.manager is not None and isinstance(nametag, MarginPopup):
nametag.manage(manager)
def removeNametag(self, nametag):
self.nametags.remove(nametag)
if self.manager is not None and isinstance(nametag, MarginPopup):
nametag.unmanage(manager)
nametag.destroy()
def manage(self, manager):
self.manager = manager
for tag in self.nametags:
if isinstance(tag, MarginPopup):
tag.manage(manager)
def unmanage(self, manager):
self.manager = None
for tag in self.nametags:
if isinstance(tag, MarginPopup):
tag.unmanage(manager)
tag.destroy()

View file

View file

@ -7,10 +7,10 @@ from BattleBase import *
import DistributedBattleBase
import SuitBattleGlobals
from otp.avatar import Emote
from toontown.chat.ChatGlobals import *
from toontown.distributed import DelayDelete
from toontown.nametag import NametagGlobals
from toontown.toonbase import ToontownBattleGlobals
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
class DistributedBattle(DistributedBattleBase.DistributedBattleBase):
@ -119,7 +119,7 @@ class DistributedBattle(DistributedBattleBase.DistributedBattleBase):
soundTrack = Wait(delay + faceoffTime)
mtrack = Parallel(suitTrack, toonTrack, soundTrack)
if self.hasLocalToon():
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
mtrack = Parallel(mtrack, camTrack)
done = Func(callback)
track = Sequence(mtrack, done, name=name)
@ -157,7 +157,7 @@ class DistributedBattle(DistributedBattleBase.DistributedBattleBase):
self.delayDeleteMembers()
Emote.globalEmote.disableAll(base.localAvatar, 'dbattle, enterReward')
if self.hasLocalToon():
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
if self.localToonActive() == 0:
self.removeInactiveLocalToon(base.localAvatar)
for toon in self.toons:
@ -188,7 +188,7 @@ class DistributedBattle(DistributedBattleBase.DistributedBattleBase):
self.ignore('resumeAfterReward')
self.movie.resetReward(finish=1)
self._removeMembersKeep()
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
Emote.globalEmote.releaseAll(base.localAvatar, 'dbattle, exitReward')
def enterResume(self, ts = 0):

View file

@ -20,7 +20,8 @@ from toontown.hood import ZoneUtil
from toontown.distributed import DelayDelete
from toontown.toon import TTEmote
from otp.avatar import Emote
from toontown.nametag import NametagGlobals
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
class DistributedBattleBase(DistributedNode.DistributedNode, BattleBase):
@ -1039,7 +1040,7 @@ class DistributedBattleBase(DistributedNode.DistributedNode, BattleBase):
self.notify.debug('enterLocalToonWaitForInput()')
camera.setPosHpr(self.camPos, self.camHpr)
base.camLens.setMinFov(self.camMenuFov/(4./3.))
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
self.townBattle.setState('Attack')
self.accept(self.localToonBattleEvent, self.__handleLocalToonBattleEvent)
@ -1205,8 +1206,7 @@ class DistributedBattleBase(DistributedNode.DistributedNode, BattleBase):
self.notify.debug('enterPlayMovie()')
self.delayDeleteMembers()
if self.hasLocalToon():
NametagGlobals.setWant2dNametags(False)
pass
NametagGlobals.setMasterArrowsOn(0)
if ToontownBattleGlobals.SkipMovie:
self.movie.play(ts, self.__handleMovieDone)
self.movie.finish()

View file

@ -10,9 +10,8 @@ import DistributedBattleBase
import MovieUtil
import SuitBattleGlobals
from otp.avatar import Emote
from toontown.chat.ChatGlobals import *
from toontown.nametag import NametagGlobals
from toontown.nametag.NametagGlobals import *
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
from toontown.suit import Suit
from toontown.suit import SuitDNA
from toontown.toon import TTEmote
@ -189,15 +188,14 @@ class DistributedBattleBldg(DistributedBattleBase.DistributedBattleBase):
self.notify.debug('exitReward()')
self.clearInterval(self.uniqueName('floorReward'))
self._removeMembersKeep()
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
for toon in self.toons:
toon.startSmooth()
def enterBuildingReward(self, ts):
self.delayDeleteMembers()
if self.hasLocalToon():
NametagGlobals.setWant2dNametags(False)
pass
NametagGlobals.setMasterArrowsOn(0)
self.movie.playReward(ts, self.uniqueName('building-reward'), self.__handleBuildingRewardDone, noSkip=True)
def __handleBuildingRewardDone(self):
@ -209,7 +207,7 @@ class DistributedBattleBldg(DistributedBattleBase.DistributedBattleBase):
def exitBuildingReward(self):
self.movie.resetReward(finish=1)
self._removeMembersKeep()
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
def enterResume(self, ts=0):
if self.hasLocalToon():

View file

@ -10,7 +10,8 @@ import DistributedBattleBase
import MovieUtil
import SuitBattleGlobals
from toontown.distributed import DelayDelete
from toontown.nametag import NametagGlobals
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
from toontown.suit import Suit
from toontown.toonbase import ToontownBattleGlobals
from toontown.toonbase import ToontownGlobals
@ -157,7 +158,7 @@ class DistributedBattleFinal(DistributedBattleBase.DistributedBattleBase):
self.notify.debug('exitReward()')
self.clearInterval(self.uniqueName('floorReward'), finish=1)
self._removeMembersKeep()
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
for toon in self.toons:
toon.startSmooth()

View file

@ -24,7 +24,6 @@ import MovieUtil
import PlayByPlayText
import RewardPanel
from SuitBattleGlobals import *
from toontown.chat.ChatGlobals import *
from toontown.distributed import DelayDelete
from toontown.toon import NPCToons
from toontown.toon import Toon
@ -32,7 +31,8 @@ from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownGlobals
from toontown.toonbase.ToontownBattleGlobals import *
from toontown.toontowngui import TTDialog
from toontown.nametag import NametagGlobals
from otp.nametag.NametagConstants import *
from otp.nametag.NametagGroup import *
camPos = Point3(14, 0, 10)
@ -342,7 +342,7 @@ class Movie(DirectObject.DirectObject):
self.tutorialTom.setDNA(dna)
self.tutorialTom.setName(TTLocalizer.NPCToonNames[20000])
self.tutorialTom.setPickable(0)
self.tutorialTom.setPlayerType(NametagGlobals.CCNonPlayer)
self.tutorialTom.setPlayerType(NametagGroup.CCNonPlayer)
self.tutorialTom.uniqueName = uniqueName
self.musicVolume = 0.9
music = base.cr.playGame.place.loader.battleMusic

View file

@ -10,7 +10,7 @@ from BattleSounds import *
import MovieCamera
import MovieNPCSOS
import MovieUtil
from toontown.chat.ChatGlobals import *
from otp.nametag.NametagConstants import *
from toontown.effects import Splash
from toontown.toon import NPCToons
from toontown.toonbase import TTLocalizer

View file

@ -7,8 +7,8 @@ from BattleProps import *
from BattleSounds import *
import MovieCamera
import MovieUtil
from toontown.chat.ChatGlobals import *
from toontown.nametag.NametagGlobals import *
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
from toontown.toon import NPCToons
from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownBattleGlobals

View file

@ -7,7 +7,7 @@ from BattleProps import *
from BattleSounds import *
import MovieCamera
import MovieUtil
from toontown.chat.ChatGlobals import *
from otp.nametag.NametagConstants import *
from toontown.pets import Pet, PetTricks
from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownBattleGlobals

View file

@ -3,8 +3,8 @@ from direct.interval.IntervalGlobal import *
from panda3d.core import *
import MovieCamera
from toontown.chat.ChatGlobals import *
from toontown.nametag.NametagGlobals import *
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
from toontown.toonbase import TTLocalizer

View file

@ -10,9 +10,8 @@ from BattleSounds import *
import MovieCamera
import MovieUtil
from SuitBattleGlobals import *
from toontown.chat.ChatGlobals import *
from toontown.nametag import NametagGlobals
from toontown.nametag.NametagGlobals import *
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
from toontown.suit.SuitDNA import *
from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownGlobals

View file

@ -6,7 +6,8 @@ import MovieCamera
from direct.directnotify import DirectNotifyGlobal
import types
notify = DirectNotifyGlobal.directNotify.newCategory('MovieToonVictory')
from toontown.nametag import NametagGlobals
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
def __findToonReward(rewards, toon):
for r in rewards:
@ -76,7 +77,7 @@ def doToonVictory(localToonActive, toons, rewardToonIds, rewardDicts, deathList,
track = Sequence()
if localToonActive == 1:
track.append(Func(rpanel.show))
track.append(Func(NametagGlobals.setForceOnscreenChat, True))
track.append(Func(NametagGlobals.setOnscreenChatForced, 1))
camTrack = Sequence()
endTrack = Sequence()
danceSound = globalBattleSoundCache.getSound('ENC_Win.ogg')
@ -121,7 +122,7 @@ def doToonVictory(localToonActive, toons, rewardToonIds, rewardDicts, deathList,
track.append(Func(skipper.destroy))
if localToonActive == 1:
track.append(Func(rpanel.hide))
track.append(Func(NametagGlobals.setForceOnscreenChat, False))
track.append(Func(NametagGlobals.setOnscreenChatForced, 0))
track.append(endTrack)
trackdur = track.getDuration()
soundTrack = SoundInterval(danceSound, duration=trackdur, loop=1)

View file

@ -6,8 +6,8 @@ from panda3d.core import *
import BoardingGroupShow
from toontown.building import BoardingPartyBase
from toontown.chat.ChatGlobals import *
from toontown.chat.WhisperPopup import *
from otp.nametag.NametagConstants import *
from otp.margins.WhisperPopup import *
from toontown.hood import ZoneUtil
from toontown.toon import BoardingGroupInviterPanels
from toontown.toon import GroupInvitee

View file

@ -13,8 +13,8 @@ from toontown.hood import ZoneUtil
from toontown.suit import Suit
from toontown.toonbase.ToonBaseGlobal import *
from toontown.toontowngui import TTDialog
from toontown.nametag.NametagGroup import NametagGroup
from toontown.nametag.Nametag import Nametag
from otp.nametag.NametagGroup import NametagGroup
from otp.nametag.Nametag import Nametag
class DistributedDoor(DistributedObject.DistributedObject, DelayDeletable):
@ -105,25 +105,23 @@ class DistributedDoor(DistributedObject.DistributedObject, DelayDeletable):
return
if self.nametag == None:
self.nametag = NametagGroup()
self.nametag.setNametag3d(None)
self.nametag.setFont(ToontownGlobals.getBuildingNametagFont())
if TTLocalizer.BuildingNametagShadow:
self.nametag.setShadow(*TTLocalizer.BuildingNametagShadow)
self.nametag.hideChat()
self.nametag.hideThought()
nametagColor = NametagGlobals.NametagColors[NametagGlobals.CCToonBuilding]
self.nametag.setNametagColor(nametagColor)
self.nametag.setActive(False)
self.nametag.setContents(Nametag.CName)
self.nametag.setColorCode(NametagGroup.CCToonBuilding)
self.nametag.setActive(0)
self.nametag.setAvatar(self.getDoorNodePath())
self.nametag.setObjectCode(self.block)
name = self.cr.playGame.dnaStore.getTitleFromBlockNumber(self.block)
self.nametag.setText(name)
self.nametag.setName(name)
self.nametag.manage(base.marginManager)
self.nametag.updateAll()
def clearNametag(self):
if self.nametag is not None:
self.nametag.unmanage(base.marginManager)
self.nametag.setAvatar(NodePath())
self.nametag.destroy()
self.nametag = None
def getTriggerName(self):

View file

@ -9,9 +9,9 @@ import DistributedElevator
from ElevatorConstants import *
from ElevatorUtils import *
from toontown.hood import ZoneUtil
from toontown.nametag import NametagGlobals
from toontown.nametag.Nametag import Nametag
from toontown.nametag.NametagGroup import NametagGroup
from otp.nametag.NametagGroup import NametagGroup
from otp.nametag.Nametag import Nametag
from otp.nametag.NametagConstants import *
from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownGlobals
@ -41,20 +41,17 @@ class DistributedElevatorExt(DistributedElevator.DistributedElevator):
self.nametag.setFont(ToontownGlobals.getBuildingNametagFont())
if TTLocalizer.BuildingNametagShadow:
self.nametag.setShadow(*TTLocalizer.BuildingNametagShadow)
self.nametag.hideChat()
self.nametag.hideThought()
nametagColor = NametagGlobals.NametagColors[NametagGlobals.CCSuitBuilding]
self.nametag.setNametagColor(nametagColor)
self.nametag.setActive(False)
self.nametag.setContents(Nametag.CName)
self.nametag.setColorCode(NametagGroup.CCSuitBuilding)
self.nametag.setActive(0)
self.nametag.setAvatar(self.getElevatorModel())
name = self.cr.playGame.dnaStore.getTitleFromBlockNumber(self.bldg.block)
if not name:
name = TTLocalizer.CogsInc
else:
name += TTLocalizer.CogsIncExt
self.nametag.setText(name)
self.nametag.setName(name)
self.nametag.manage(base.marginManager)
self.nametag.updateAll()
def clearNametag(self):
if self.nametag != None:

View file

@ -5,12 +5,11 @@ from panda3d.core import *
import DistributedAnimatedProp
from KnockKnockJokes import *
from toontown.chat.ChatGlobals import *
from toontown.distributed import DelayDelete
from toontown.nametag.NametagGlobals import *
from toontown.nametag.NametagGroup import NametagGroup
from toontown.toonbase import TTLocalizer
from toontown.toonbase import ToontownGlobals
from otp.nametag.NametagGroup import NametagGroup
from otp.nametag.NametagConstants import *
import random
class DistributedKnockKnockDoor(DistributedAnimatedProp.DistributedAnimatedProp):
@ -76,21 +75,19 @@ class DistributedKnockKnockDoor(DistributedAnimatedProp.DistributedAnimatedProp)
return
self.nametag = NametagGroup()
self.nametag.setAvatar(doorNP)
toonFont = ToontownGlobals.getToonFont()
self.nametag.setFont(toonFont)
self.nametag.setChatFont(toonFont)
self.nametag.setText(doorName)
self.nametag.setActive(False)
self.nametag.hideNametag()
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(6)
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.setChatText, TTLocalizer.DoorKnockKnock), Wait(d)), Func(avatar.setChatAbsolute, TTLocalizer.DoorWhosThere, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChatText, joke[0]), Wait(d), Func(avatar.setChatAbsolute, joke[0] + TTLocalizer.DoorWhoAppendix, CFSpeech | CFTimeout, openEnded=0), Wait(d), Func(self.nametag.setChatText, joke[1]))
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)))

View file

@ -15,7 +15,7 @@ from toontown.suit import Suit
from toontown.quest import QuestParser
from toontown.toon import DistributedNPCSpecialQuestGiver
from toontown.toonbase import TTLocalizer
from toontown.chat.ChatGlobals import CFSpeech
from otp.nametag.NametagConstants import CFSpeech
class DistributedTutorialInterior(DistributedObject.DistributedObject):
@ -145,8 +145,8 @@ class DistributedTutorialInterior(DistributedObject.DistributedObject):
suitDNA = SuitDNA.SuitDNA()
suitDNA.newSuit('f')
self.suit.setDNA(suitDNA)
self.suit.nametag.setNametag2d(None)
self.suit.nametag.setNametag3d(None)
self.suit.nametag3d.stash()
self.suit.nametag.destroy()
self.suit.loop('neutral')
self.suit.setPosHpr(-20, 8, 0, 0, 0, 0)
self.suit.reparentTo(self.interior)

View file

@ -9,7 +9,8 @@ import DistributedToonInterior
from otp.distributed.TelemetryLimiter import RotationLimitToH, TLGatherAllAvs
from toontown.hood import Place
from toontown.hood import ZoneUtil
from toontown.nametag import NametagGlobals
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
from toontown.toon import HealthForceAcknowledge
from toontown.toon import NPCForceAcknowledge
from toontown.toonbase import TTLocalizer
@ -92,7 +93,7 @@ class ToonInterior(Place.Place):
volume = requestStatus.get('musicVolume', 0.7)
base.playMusic(self.loader.activityMusic, looping=1, volume=volume)
self._telemLimiter = TLGatherAllAvs('ToonInterior', RotationLimitToH)
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
self.fsm.request(requestStatus['how'], [requestStatus])
def exit(self):
@ -100,7 +101,7 @@ class ToonInterior(Place.Place):
messenger.send('exitToonInterior')
self._telemLimiter.destroy()
del self._telemLimiter
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
self.loader.activityMusic.stop()
def setState(self, state):

View file

@ -14,8 +14,8 @@ from direct.actor import Actor
import random
from toontown.toon import DistributedToon
from direct.directnotify import DirectNotifyGlobal
from toontown.nametag import NametagGlobals
import CatalogChatBalloon
from otp.nametag.ChatBalloon import ChatBalloon
from otp.nametag import NametagGroup
NUM_CATALOG_ROWS = 3
NUM_CATALOG_COLS = 2
@ -971,13 +971,13 @@ class CatalogScreen(DirectFrame):
if not self.clarabelleChatBalloon:
self.clarabelleChatBalloon = loader.loadModel('phase_3/models/props/chatbox')
self.clarabelleChat = CatalogChatBalloon.CatalogChatBalloon(self.clarabelleChatBalloon)
self.clarabelleChat = ChatBalloon(self.clarabelleChatBalloon)
chatNode = self.clarabelleChat.generate(str, ToontownGlobals.getInterfaceFont())[0]
self.clarabelleChatNP = self.attachNewNode(chatNode.node(), 1000)
self.clarabelleChatNP.setScale(0.08)
self.clarabelleChatNP.setPos(0.7, 0, 0.6)
if timeout:
taskMgr.doMethodLater(timeout, self.clearClarabelleChat, 'clearClarabelleChat')

View file

@ -1,120 +0,0 @@
from panda3d.core import *
class ChatBalloon(NodePath):
TEXT_X_OFFSET = -0.04
TEXT_Y_OFFSET = -0.05
# Proportion of the Z offset based on the default line height, and the new
# line height:
TEXT_Z_OFFSET = -(4.0/33.0)
TEXT_MIN_WIDTH = 1.55
TEXT_MIN_HEIGHT = 1.1
TEXT_GLYPH_SCALE = 0.95
TEXT_GLYPH_SHIFT = -0.05
BALLOON_X_PADDING = 0.525
BALLOON_Z_PADDING = 0.5
BUTTON_SCALE = 6
BUTTON_SHIFT = (0, 0, 0.6)
def __init__(self, model, modelWidth, modelHeight, textNode,
foreground=VBase4(0, 0, 0, 1), background=VBase4(1, 1, 1, 1),
reversed=False, button=None):
NodePath.__init__(self, 'chatBalloon')
self.model = model
self.modelWidth = modelWidth
self.modelHeight = modelHeight
self.textNode = textNode
self.foreground = foreground
self.background = background
self.button = button
# Set the TextNode color:
self.textNode.setTextColor(self.foreground)
# Create a balloon:
self.balloon = self.model.copyTo(self)
self.balloon.setColor(self.background)
self.balloon.setTransparency(self.background[3] < 1)
# Attach the TextNode:
self.textNodePath = self.attachNewNode(self.textNode)
self.textNodePath.setTransparency(self.foreground[3] < 1)
self.textNodePath.setAttrib(DepthWriteAttrib.make(0))
# Resize the balloon as necessary:
middle = self.balloon.find('**/middle')
top = self.balloon.find('**/top')
self.textWidth = self.textNode.getWidth()
if self.textWidth < self.TEXT_MIN_WIDTH:
self.textWidth = self.TEXT_MIN_WIDTH
paddedWidth = self.textWidth + (self.BALLOON_X_PADDING*2)
self.balloon.setSx(paddedWidth / modelWidth)
self.textHeight = textNode.getHeight()
if self.textHeight < self.TEXT_MIN_HEIGHT:
self.textHeight = self.TEXT_MIN_HEIGHT
paddedHeight = self.textHeight + (self.BALLOON_Z_PADDING*2)
middle.setSz(paddedHeight - 1.5) # Compensate for the top, as well.
top.setZ(middle, 1)
if reversed:
self.balloon.setSx(-self.balloon.getSx())
self.balloon.setTwoSided(True) # Render the backface of the balloon.
self.width = paddedWidth
self.height = paddedHeight
# Position the TextNode:
self.center = self.balloon.getBounds().getCenter()
self.textNodePath.setPos(self.center)
self.textNodePath.setY(self.TEXT_Y_OFFSET)
self.textNodePath.setX(self.textNodePath, -(self.textWidth/2))
if self.textWidth == self.TEXT_MIN_WIDTH:
centerX = (self.TEXT_MIN_WIDTH-self.textNode.getWidth()) / 2.0
self.textNodePath.setX(self.textNodePath, centerX)
self.textNodePath.setZ(top, -self.BALLOON_Z_PADDING + self.TEXT_Z_OFFSET)
if self.textHeight == self.TEXT_MIN_HEIGHT:
centerZ = (ChatBalloon.TEXT_MIN_HEIGHT-self.textNode.getHeight()) / 2.0
self.textNodePath.setZ(self.textNodePath, -centerZ)
self.textNodePath.setX(self.textNodePath, self.TEXT_X_OFFSET)
# Add a button if one is given:
if self.button is not None:
self.buttonNodePath = button.copyTo(self)
self.buttonNodePath.setPos(self.textNodePath, self.textWidth, 0, -self.textHeight)
self.buttonNodePath.setPos(self.buttonNodePath, ChatBalloon.BUTTON_SHIFT)
self.buttonNodePath.setScale(ChatBalloon.BUTTON_SCALE)
else:
self.buttonNodePath = None
# Finally, enable anti-aliasing:
self.setAntialias(AntialiasAttrib.MMultisample)
def setForeground(self, foreground):
self.foreground = foreground
self.textNode.setTextColor(self.foreground)
def getForeground(self):
return self.foreground
def setBackground(self, background):
self.background = background
self.balloon.setColor(self.background)
def getBackground(self):
return self.background
def setButton(self, button):
if self.buttonNodePath is not None:
self.buttonNodePath.removeNode()
self.buttonNodePath = None
if button is not None:
self.buttonNodePath = button.copyTo(self)
self.buttonNodePath.setPos(self.textNodePath, self.textWidth, 0, -self.textHeight)
self.buttonNodePath.setPos(self.buttonNodePath, ChatBalloon.BUTTON_SHIFT)
self.buttonNodePath.setScale(ChatBalloon.BUTTON_SCALE)

View file

@ -1,48 +0,0 @@
CFSpeech = 1 << 0
CFThought = 1 << 1
CFQuicktalker = 1 << 2
CFTimeout = 1 << 3
CFPageButton = 1 << 4
CFQuitButton = 1 << 5
CFNoQuitButton = 1 << 6
CFReversed = 1 << 7
WTNormal = 0
WTSystem = 1
WTBattleSOS = 2
WTEmote = 3
WTToontownBoardingGroup = 4
# Foreground, background:
WhisperColors = {
WTNormal: (
((0.0, 0.0, 0.0, 1.0), (0.2, 0.6, 0.8, 0.6)), # Normal
((1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 0.8)), # Click
((0.0, 0.0, 0.0, 1.0), (0.2, 0.7, 0.9, 0.6)), # Rollover
((0.0, 0.0, 0.0, 1.0), (0.2, 0.7, 0.8, 0.6)) # Disabled
),
WTSystem: (
((0.0, 0.0, 0.0, 1.0), (0.8, 0.3, 0.6, 0.6)), # Normal
((1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 0.8)), # Click
((0.0, 0.0, 0.0, 1.0), (0.8, 0.4, 1.0, 0.6)), # Rollover
((0.0, 0.0, 0.0, 1.0), (0.8, 0.3, 0.6, 0.6)) # Disabled
),
WTEmote: (
((0.0, 0.0, 0.0, 1.0), (0.9, 0.5, 0.1, 0.6)), # Normal
((1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 0.8)), # Click
((0.0, 0.0, 0.0, 1.0), (0.9, 0.6, 0.2, 0.6)), # Rollover
((0.0, 0.0, 0.0, 1.0), (0.9, 0.6, 0.1, 0.6)), # Disabled
),
WTBattleSOS: (
((0.0, 0.0, 0.0, 1.0), (0.2, 0.6, 0.8, 0.6)), # Normal
((1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 0.8)), # Click
((0.0, 0.0, 0.0, 1.0), (0.2, 0.7, 0.9, 0.6)), # Rollover
((0.0, 0.0, 0.0, 1.0), (0.2, 0.7, 0.8, 0.6)) # Disabled
),
WTToontownBoardingGroup: (
((0.0, 0.0, 0.0, 1.0), (0.9, 0.5, 0.1, 0.6)), # Normal
((1.0, 0.5, 0.5, 1.0), (1.0, 1.0, 1.0, 0.8)), # Click
((0.0, 0.0, 0.0, 1.0), (0.9, 0.6, 0.2, 0.6)), # Rollover
((0.0, 0.0, 0.0, 1.0), (0.9, 0.6, 0.1, 0.6)) # Disabled
)
}

View file

@ -35,7 +35,7 @@ class ToontownChatManager(ChatManager.ChatManager):
ChatManager.ChatManager.__init__(self, cr, localAvatar)
self.chatInputSpeedChat = TTChatInputSpeedChat(self)
self.normalPos = Vec3(0.25, 0, -0.196)
self.whisperPos = Vec3(0, 0, -0.296)
self.whisperPos = Vec3(0.25, 0, -0.28)
self.speedChatPlusPos = Vec3(-0.35, 0, 0.71)
self.SCWhisperPos = Vec3(0, 0, 0)
self.chatInputWhiteList = TTChatInputWhiteList()

View file

@ -1,341 +0,0 @@
from panda3d.core import TextNode, PGButton, Point3
from toontown.chat import ChatGlobals
from toontown.chat.ChatBalloon import ChatBalloon
from toontown.margins import MarginGlobals
from toontown.margins.MarginVisible import MarginVisible
from toontown.nametag import NametagGlobals
from toontown.toontowngui.Clickable2d import Clickable2d
class WhisperQuitButton(Clickable2d):
CONTENTS_SCALE = 12
def __init__(self, whisperPopup):
Clickable2d.__init__(self, 'WhisperQuitButton')
self.whisperPopup = whisperPopup
self.contents.setScale(self.CONTENTS_SCALE)
self.contents.hide()
self.nodePath = None
self.update()
def destroy(self):
self.ignoreAll()
if self.nodePath is not None:
self.nodePath.removeNode()
self.nodePath = None
Clickable2d.destroy(self)
def getUniqueName(self):
return 'WhisperQuitButton-' + str(id(self))
def update(self):
if self.nodePath is not None:
self.nodePath.removeNode()
self.nodePath = None
self.contents.node().removeAllChildren()
quitButtonNode = NametagGlobals.quitButton[self.clickState]
self.nodePath = quitButtonNode.copyTo(self.contents)
def applyClickState(self, clickState):
if self.nodePath is not None:
self.nodePath.removeNode()
self.nodePath = None
quitButtonNode = NametagGlobals.quitButton[clickState]
self.nodePath = quitButtonNode.copyTo(self.contents)
def setClickState(self, clickState):
self.applyClickState(clickState)
if self.isHovering() or self.whisperPopup.isHovering():
self.contents.show()
elif self.clickState == PGButton.SDepressed:
self.contents.show()
else:
self.contents.hide()
Clickable2d.setClickState(self, clickState)
def enterDepressed(self):
base.playSfx(NametagGlobals.clickSound)
def enterRollover(self):
if self.lastClickState != PGButton.SDepressed:
base.playSfx(NametagGlobals.rolloverSound)
def updateClickRegion(self):
if self.nodePath is not None:
right = NametagGlobals.quitButtonWidth / 2.0
left = -right
top = NametagGlobals.quitButtonHeight / 2.0
bottom = -top
self.setClickRegionFrame(left, right, bottom, top)
class WhisperPopup(Clickable2d, MarginVisible):
CONTENTS_SCALE = 0.25
TEXT_MAX_ROWS = 6
TEXT_WORD_WRAP = 8
QUIT_BUTTON_SHIFT = (0.42, 0, 0.42)
WHISPER_TIMEOUT_MIN = 10
WHISPER_TIMEOUT_MAX = 20
def __init__(self, text, font, whisperType, timeout=None):
Clickable2d.__init__(self, 'WhisperPopup')
MarginVisible.__init__(self)
self.text = text
self.font = font
self.whisperType = whisperType
if timeout is None:
self.timeout = len(text) * 0.33
if self.timeout < self.WHISPER_TIMEOUT_MIN:
self.timeout = self.WHISPER_TIMEOUT_MIN
elif self.timeout > self.WHISPER_TIMEOUT_MAX:
self.timeout = self.WHISPER_TIMEOUT_MAX
else:
self.timeout = timeout
self.active = False
self.senderName = ''
self.fromId = 0
self.contents.setScale(self.CONTENTS_SCALE)
self.whisperColor = ChatGlobals.WhisperColors[self.whisperType]
self.textNode = TextNode('text')
self.textNode.setWordwrap(self.TEXT_WORD_WRAP)
self.textNode.setTextColor(self.whisperColor[PGButton.SInactive][0])
self.textNode.setFont(self.font)
self.textNode.setText(self.text)
self.chatBalloon = None
self.quitButton = None
self.timeoutTaskName = self.getUniqueName() + '-timeout'
self.timeoutTask = None
self.quitEvent = self.getUniqueName() + '-quit'
self.accept(self.quitEvent, self.destroy)
self.setPriority(MarginGlobals.MP_high)
self.setVisible(True)
self.update()
self.accept('MarginVisible-update', self.update)
def destroy(self):
self.ignoreAll()
if self.timeoutTask is not None:
taskMgr.remove(self.timeoutTask)
self.timeoutTask = None
if self.chatBalloon is not None:
self.chatBalloon.removeNode()
self.chatBalloon = None
if self.quitButton is not None:
self.quitButton.destroy()
self.quitButton = None
self.textNode = None
Clickable2d.destroy(self)
def getUniqueName(self):
return 'WhisperPopup-' + str(id(self))
def update(self):
if self.chatBalloon is not None:
self.chatBalloon.removeNode()
self.chatBalloon = None
if self.quitButton is not None:
self.quitButton.destroy()
self.quitButton = None
self.contents.node().removeAllChildren()
self.draw()
if self.cell is not None:
# We're in the margin display. Reposition our content, and update
# the click region:
self.reposition()
self.updateClickRegion()
else:
# We aren't in the margin display. Disable the click region if one
# is present:
if self.region is not None:
self.region.setActive(False)
def draw(self):
if self.isClickable():
foreground, background = self.whisperColor[self.clickState]
else:
foreground, background = self.whisperColor[PGButton.SInactive]
self.chatBalloon = ChatBalloon(
NametagGlobals.chatBalloon2dModel,
NametagGlobals.chatBalloon2dWidth,
NametagGlobals.chatBalloon2dHeight, self.textNode,
foreground=foreground, background=background
)
self.chatBalloon.reparentTo(self.contents)
# Calculate the center of the TextNode:
left, right, bottom, top = self.textNode.getFrameActual()
center = self.contents.getRelativePoint(
self.chatBalloon.textNodePath,
((left+right) / 2.0, 0, (bottom+top) / 2.0))
# Translate the chat balloon along the inverse:
self.chatBalloon.setPos(self.chatBalloon, -center)
# Draw the quit button:
self.quitButton = WhisperQuitButton(self)
quitButtonNodePath = self.contents.attachNewNode(self.quitButton)
# Move the quit button to the top right of the TextNode:
quitButtonNodePath.setPos(self.contents.getRelativePoint(
self.chatBalloon.textNodePath, (right, 0, top)))
# Apply the quit button shift:
quitButtonNodePath.setPos(quitButtonNodePath, self.QUIT_BUTTON_SHIFT)
# Allow the quit button to close this whisper:
self.quitButton.setClickEvent(self.quitEvent)
def manage(self, marginManager):
MarginVisible.manage(self, marginManager)
self.timeoutTask = taskMgr.doMethodLater(
self.timeout, self.unmanage, self.timeoutTaskName, [marginManager])
def unmanage(self, marginManager):
MarginVisible.unmanage(self, marginManager)
self.destroy()
def setClickable(self, senderName, fromId):
self.senderName = senderName
self.fromId = fromId
self.setClickEvent('clickedWhisper', extraArgs=[fromId])
self.setActive(True)
def applyClickState(self, clickState):
if self.chatBalloon is not None:
foreground, background = self.whisperColor[clickState]
self.chatBalloon.setForeground(foreground)
self.chatBalloon.setBackground(background)
def setClickState(self, clickState):
if self.isClickable():
self.applyClickState(clickState)
else:
self.applyClickState(PGButton.SInactive)
if self.isHovering() or self.quitButton.isHovering():
self.quitButton.contents.show()
elif self.quitButton.getClickState() == PGButton.SDepressed:
self.quitButton.contents.show()
else:
self.quitButton.contents.hide()
Clickable2d.setClickState(self, clickState)
def enterDepressed(self):
if self.isClickable():
base.playSfx(NametagGlobals.clickSound)
def enterRollover(self):
if self.isClickable() and (self.lastClickState != PGButton.SDepressed):
base.playSfx(NametagGlobals.rolloverSound)
def updateClickRegion(self):
if self.chatBalloon is not None:
right = self.chatBalloon.width / 2.0
left = -right
top = self.chatBalloon.height / 2.0
bottom = -top
self.setClickRegionFrame(left, right, bottom, top)
self.region.setActive(True)
else:
if self.region is not None:
self.region.setActive(False)
if self.quitButton is not None:
self.quitButton.updateClickRegion()
def marginVisibilityChanged(self):
if self.cell is not None:
# We're in the margin display. Reposition our content, and update
# the click region:
self.reposition()
self.updateClickRegion()
else:
# We aren't in the margin display. Disable the click region if one
# is present:
if self.region is not None:
self.region.setActive(False)
def reposition(self):
if self.contents is None:
return
origin = Point3()
self.contents.setPos(origin)
if self.chatBalloon is not None:
self.chatBalloon.removeNode()
self.chatBalloon = None
if self.quitButton is not None:
self.quitButton.destroy()
self.quitButton = None
self.contents.node().removeAllChildren()
if (self.cell in base.leftCells) or (self.cell in base.rightCells):
text = self.text.replace('\x01WLDisplay\x01', '').replace('\x02', '')
textWidth = self.textNode.calcWidth(text)
if (textWidth / self.TEXT_WORD_WRAP) > self.TEXT_MAX_ROWS:
self.textNode.setWordwrap(textWidth / (self.TEXT_MAX_ROWS-0.5))
else:
self.textNode.setWordwrap(self.TEXT_WORD_WRAP)
self.draw()
left, right, bottom, top = self.textNode.getFrameActual()
if self.cell in base.bottomCells:
# Move the origin to the bottom center of the chat balloon:
origin = self.contents.getRelativePoint(
self.chatBalloon.textNodePath, ((left+right) / 2.0, 0, bottom))
elif self.cell in base.leftCells:
# Move the origin to the left center of the chat balloon:
origin = self.contents.getRelativePoint(
self.chatBalloon.textNodePath, (left, 0, (bottom+top) / 2.0))
elif self.cell in base.rightCells:
# Move the origin to the right center of the chat balloon:
origin = self.contents.getRelativePoint(
self.chatBalloon.textNodePath, (right, 0, (bottom+top) / 2.0))
self.contents.setPos(self.contents, -origin)

View file

@ -87,13 +87,13 @@ class CogdoBarrelRoomIntro(CogdoGameMovie):
def start():
self.frame.show()
base.setCellsActive(base.bottomCells + base.leftCells + base.rightCells, 0)
base.setCellsAvailable(base.bottomCells + base.leftCells + base.rightCells, 0)
def end():
self._dialogueLabel.reparentTo(hidden)
self.toonHead.reparentTo(hidden)
self.frame.hide()
base.setCellsActive(base.bottomCells + base.leftCells + base.rightCells, 1)
base.setCellsAvailable(base.bottomCells + base.leftCells + base.rightCells, 1)
self._stopUpdateTask()
self._ival = Sequence(Func(start), Func(self.displayLine, dialogue), Wait(CogdoBarrelRoomConsts.BarrelRoomIntroTimeout), Func(end))

View file

@ -87,13 +87,13 @@ class CogdoElevatorMovie(CogdoGameMovie):
def start():
self.frame.show()
base.setCellsActive(base.bottomCells + base.leftCells + base.rightCells, 0)
base.setCellsAvailable(base.bottomCells + base.leftCells + base.rightCells, 0)
def end():
self._dialogueLabel.reparentTo(hidden)
self.toonHead.reparentTo(hidden)
self.frame.hide()
base.setCellsActive(base.bottomCells + base.leftCells + base.rightCells, 1)
base.setCellsAvailable(base.bottomCells + base.leftCells + base.rightCells, 1)
self._stopUpdateTask()
self._ival = Sequence(Func(start), Func(self.displayLine, dialogue), Wait(self.elevatorDuration), Func(end))

View file

@ -91,7 +91,7 @@ class CogdoExecutiveSuiteIntro(CogdoGameMovie):
def start():
self.frame.show()
base.setCellsActive(base.bottomCells + base.leftCells + base.rightCells, 0)
base.setCellsAvailable(base.bottomCells + base.leftCells + base.rightCells, 0)
def showShopOwner():
self._setCamTarget(self._shopOwner, -10, offset=Point3(0, 0, 5))
@ -100,7 +100,7 @@ class CogdoExecutiveSuiteIntro(CogdoGameMovie):
self._dialogueLabel.reparentTo(hidden)
self.toonHead.reparentTo(hidden)
self.frame.hide()
base.setCellsActive(base.bottomCells + base.leftCells + base.rightCells, 1)
base.setCellsAvailable(base.bottomCells + base.leftCells + base.rightCells, 1)
self._stopUpdateTask()
self._ival = Sequence(Func(start), Func(self.displayLine, dialogue), Func(showShopOwner), ParallelEndTogether(camera.posInterval(self.cameraMoveDuration, Point3(8, 0, 13), blendType='easeInOut'), camera.hprInterval(0.5, self._camHelperNode.getHpr(), blendType='easeInOut')), Wait(self.introDuration), Func(end))

View file

@ -87,8 +87,8 @@ class CogdoMazeGameIntro(CogdoGameMovie):
d = SuitDNA.SuitDNA()
d.newSuit(suitData['dnaName'])
bossSuit.setDNA(d)
bossSuit.nametag.setNametag2d(None)
bossSuit.nametag.setNametag3d(None)
bossSuit.nametag3d.stash()
bossSuit.nametag.destroy()
bossSuit.setScale(suitData['scale'])
bossSuit.loop('neutral')
bossSuit.reparentTo(render)

View file

@ -31,8 +31,7 @@ PAINTING_DICT = {'s': 'tt_m_ara_crg_paintingMoverShaker',
'm': 'tt_m_ara_crg_paintingMoverShaker',
'c': 'tt_m_ara_crg_paintingMoverShaker'}
from toontown.nametag.NametagGlobals import *
from toontown.chat.ChatGlobals import *
from otp.nametag.NametagConstants import *
class DistributedCogdoInterior(DistributedObject.DistributedObject):
id = 0

View file

@ -9,8 +9,8 @@ from toontown.toonbase import ToontownGlobals
from toontown.toonbase import ToontownBattleGlobals
from toontown.battle import BattlePlace
from toontown.suit import Suit
from toontown.nametag.NametagGlobals import *
from toontown.nametag import NametagGlobals
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
import math
class CogHQBossBattle(BattlePlace.BattlePlace):
@ -109,7 +109,7 @@ class CogHQBossBattle(BattlePlace.BattlePlace):
if self.bossCog:
self.bossCog.d_avatarEnter()
self._telemLimiter = TLGatherAllAvs('CogHQBossBattle', RotationLimitToH)
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
base.localAvatar.inventory.setRespectInvasions(0)
self.fsm.request(requestStatus['how'], [requestStatus])

View file

@ -5,7 +5,7 @@ from direct.fsm import State
from toontown.toonbase import ToontownGlobals
from panda3d.core import *
from otp.distributed.TelemetryLimiter import RotationLimitToH, TLGatherAllAvs
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
class CogHQExterior(BattlePlace.BattlePlace):
notify = DirectNotifyGlobal.directNotify.newCategory('CogHQExterior')
@ -69,7 +69,7 @@ class CogHQExterior(BattlePlace.BattlePlace):
self._telemLimiter = TLGatherAllAvs('CogHQExterior', RotationLimitToH)
self.accept('doorDoneEvent', self.handleDoorDoneEvent)
self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger)
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList)
how = requestStatus['how']
self.fsm.request(how, [requestStatus])

View file

@ -5,7 +5,6 @@ from direct.fsm import State
from direct.showbase import BulletinBoardWatcher
from panda3d.core import *
from otp.distributed.TelemetryLimiter import RotationLimitToH, TLGatherAllAvs
from toontown.nametag import NametagGlobals
from toontown.toon import Toon
from toontown.toonbase import ToontownGlobals
from toontown.hood import ZoneUtil
@ -14,7 +13,7 @@ from toontown.toontowngui import TTDialog
from toontown.toonbase import ToontownBattleGlobals
from toontown.coghq import DistributedCountryClub
from toontown.building import Elevator
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
import random
class CountryClubInterior(BattlePlace.BattlePlace):
@ -87,7 +86,7 @@ class CountryClubInterior(BattlePlace.BattlePlace):
self._telemLimiter = TLGatherAllAvs('CountryClubInterior', RotationLimitToH)
def commence(self = self):
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
self.fsm.request(requestStatus['how'], [requestStatus])
base.playMusic(self.music, looping=1, volume=0.8)
base.transitions.irisIn()
@ -107,7 +106,7 @@ class CountryClubInterior(BattlePlace.BattlePlace):
self.acceptOnce('localToonConfrontedCountryClubBoss', handleConfrontedBoss)
def exit(self):
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
bboard.remove(DistributedCountryClub.DistributedCountryClub.ReadyPost)
self._telemLimiter.destroy()
del self._telemLimiter

View file

@ -192,8 +192,8 @@ class DistributedBanquetTable(DistributedObject.DistributedObject, FSM.FSM, Banq
level -= 4
diner.dna.newSuitRandom(level=level, dept='c')
diner.setDNA(diner.dna)
diner.nametag.setNametag2d(None)
diner.nametag.setNametag3d(None)
diner.nametag3d.stash()
diner.nametag.destroy()
if self.useNewAnimations:
diner.loop('sit', fromFrame=i)
else:

View file

@ -11,7 +11,8 @@ from toontown.suit import SuitDNA
from direct.fsm import State
from direct.fsm import ClassicFSM, State
from toontown.toonbase import ToontownGlobals
from toontown.nametag import NametagGlobals
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
class DistributedBattleFactory(DistributedLevelBattle.DistributedLevelBattle):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedBattleFactory')
@ -29,7 +30,7 @@ class DistributedBattleFactory(DistributedLevelBattle.DistributedLevelBattle):
self.disableCollision()
self.delayDeleteMembers()
if self.hasLocalToon():
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
if self.bossBattle:
messenger.send('localToonConfrontedForeman')
self.movie.playReward(ts, self.uniqueName('building-reward'), self.__handleFactoryRewardDone, noSkip=True)
@ -45,4 +46,4 @@ class DistributedBattleFactory(DistributedLevelBattle.DistributedLevelBattle):
self.notify.info('exitFactoryReward()')
self.movie.resetReward(finish=1)
self._removeMembersKeep()
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)

View file

@ -10,8 +10,8 @@ from direct.task import Task
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import TTLocalizer
from otp.otpbase import OTPGlobals
from otp.nametag import NametagGlobals
import random
from toontown.nametag import NametagGlobals
class DistributedCashbotBossCrane(DistributedObject.DistributedObject, FSM.FSM):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedCashbotBossCrane')
@ -407,7 +407,7 @@ class DistributedCashbotBossCrane(DistributedObject.DistributedObject, FSM.FSM):
taskMgr.add(self.__watchControls, 'watchCraneControls')
taskMgr.doMethodLater(5, self.__displayCraneAdvice, self.craneAdviceName)
taskMgr.doMethodLater(10, self.__displayMagnetAdvice, self.magnetAdviceName)
NametagGlobals.setForceOnscreenChat(True)
NametagGlobals.setOnscreenChatForced(1)
self.arrowVert = 0
self.arrowHorz = 0
return
@ -428,7 +428,7 @@ class DistributedCashbotBossCrane(DistributedObject.DistributedObject, FSM.FSM):
self.ignore('InputState-turnRight')
self.arrowVert = 0
self.arrowHorz = 0
NametagGlobals.setForceOnscreenChat(False)
NametagGlobals.setOnscreenChatForced(0)
taskMgr.remove('watchCraneControls')
self.__setMoveSound(None)
return

View file

@ -5,7 +5,7 @@ from direct.fsm import ClassicFSM, State
from direct.fsm import State
from direct.interval.IntervalGlobal import *
from otp.avatar import Emote
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
from panda3d.core import *
from toontown.battle import SuitBattleGlobals
from toontown.battle.BattleBase import *
@ -31,7 +31,7 @@ class DistributedCountryClubBattle(DistributedLevelBattle.DistributedLevelBattle
self.disableCollision()
self.delayDeleteMembers()
if self.hasLocalToon():
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
if self.bossBattle:
messenger.send('localToonConfrontedCountryClubBoss')
self.movie.playReward(ts, self.uniqueName('building-reward'), self.__handleCountryClubRewardDone, noSkip=True)
@ -47,4 +47,4 @@ class DistributedCountryClubBattle(DistributedLevelBattle.DistributedLevelBattle
self.notify.debug('exitCountryClubReward()')
self.movie.resetReward(finish=1)
self._removeMembersKeep()
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)

View file

@ -9,8 +9,8 @@ import CountryClubRoomBase, CountryClubRoom
import FactoryEntityCreator
import CountryClubRoomSpecs
from otp.level import LevelSpec, LevelConstants
from otp.nametag.NametagConstants import *
from toontown.toonbase import TTLocalizer
from toontown.nametag.NametagGlobals import *
def getCountryClubRoomReadyPostName(doId):
return 'countryClubRoomReady-%s' % doId

View file

@ -13,9 +13,8 @@ from otp.level import LevelConstants
from toontown.toonbase import TTLocalizer
from toontown.coghq import FactoryCameraViews
from direct.controls.ControlManager import CollisionHandlerRayStart
from otp.nametag.NametagConstants import *
from otp.ai.MagicWordGlobal import *
from toontown.nametag.NametagGlobals import *
from toontown.chat.ChatGlobals import CFThought, CFTimeout
class DistributedFactory(DistributedLevel.DistributedLevel, FactoryBase.FactoryBase):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedFactory')

View file

@ -419,7 +419,7 @@ class DistributedGolfGreenGame(BattleBlocker.BattleBlocker):
self.isActive = 1
self.__setCamera()
self.spriteNode.show()
base.setCellsActive([base.bottomCells[1], base.bottomCells[2], base.bottomCells[3]], 0)
base.setCellsAvailable([base.bottomCells[1], base.bottomCells[2], base.bottomCells[3]], 0)
self.setupFlag = 1
def startBoard(self, board, attackPattern):
@ -557,7 +557,7 @@ class DistributedGolfGreenGame(BattleBlocker.BattleBlocker):
self.isActive = 0
if self.standbySprite:
self.standbySprite.nodeObj.hide()
base.setCellsActive([base.bottomCells[1], base.bottomCells[2], base.bottomCells[3]], 1)
base.setCellsAvailable([base.bottomCells[1], base.bottomCells[2], base.bottomCells[3]], 1)
self.sendUpdate('leaveGame', [])
return

View file

@ -7,7 +7,7 @@ from pandac.PandaModules import CollisionSphere, CollisionNode
from toontown.toonbase import ToontownGlobals
from toontown.estate import DistributedCannon
from toontown.estate import CannonGlobals
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
from direct.gui.DirectGui import *
from panda3d.core import *
from toontown.toon import NPCToons
@ -253,7 +253,7 @@ class DistributedLawbotCannon(DistributedObject.DistributedObject):
def __makeGui(self):
if self.madeGui:
return
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
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)
@ -297,7 +297,7 @@ class DistributedLawbotCannon(DistributedObject.DistributedObject):
if self.flashingLabel:
self.flashingLabel.finish()
self.flashingLabel = None
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
self.__disableAimInterface()
self.upButton.unbind(DGG.B1PRESS)
self.upButton.unbind(DGG.B1RELEASE)

View file

@ -9,9 +9,8 @@ from otp.avatar import Emote
from toontown.battle import DistributedBattle
from toontown.battle import SuitBattleGlobals
from toontown.battle.BattleBase import *
from toontown.chat.ChatGlobals import *
from toontown.nametag import NametagGlobals
from toontown.nametag.NametagGlobals import *
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
from toontown.suit import SuitDNA
from toontown.toon import TTEmote
from toontown.toonbase import ToontownGlobals
@ -179,7 +178,7 @@ class DistributedLevelBattle(DistributedBattle.DistributedBattle):
camTrack.append(Func(camera.lookAt, suit))
mtrack = Parallel(suitTrack, toonTrack)
if self.hasLocalToon():
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
mtrack = Parallel(mtrack, camTrack)
done = Func(callback)
track = Sequence(mtrack, done, name=name)
@ -229,6 +228,6 @@ class DistributedLevelBattle(DistributedBattle.DistributedBattle):
self.notify.info('exitReward()')
self.clearInterval(self.uniqueName('floorReward'))
self._removeMembersKeep()
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
for toon in self.toons:
toon.startSmooth()

View file

@ -11,7 +11,7 @@ from toontown.suit import SuitDNA
from direct.fsm import State
from direct.fsm import ClassicFSM, State
from toontown.toonbase import ToontownGlobals
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
class DistributedMintBattle(DistributedLevelBattle.DistributedLevelBattle):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedMintBattle')
@ -29,7 +29,7 @@ class DistributedMintBattle(DistributedLevelBattle.DistributedLevelBattle):
self.disableCollision()
self.delayDeleteMembers()
if self.hasLocalToon():
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
if self.bossBattle:
messenger.send('localToonConfrontedMintBoss')
self.movie.playReward(ts, self.uniqueName('building-reward'), self.__handleMintRewardDone, noSkip=True)
@ -45,4 +45,4 @@ class DistributedMintBattle(DistributedLevelBattle.DistributedLevelBattle):
self.notify.debug('exitMintReward()')
self.movie.resetReward(finish=1)
self._removeMembersKeep()
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)

View file

@ -9,7 +9,7 @@ import MintRoomBase, MintRoom
import MintRoomSpecs
from otp.level import DistributedLevel
from otp.level import LevelSpec, LevelConstants
from toontown.nametag.NametagGlobals import *
from otp.nametag.NametagConstants import *
from toontown.toonbase import TTLocalizer
from toontown.toonbase.ToontownGlobals import *

View file

@ -11,7 +11,7 @@ from toontown.suit import SuitDNA
from direct.fsm import State
from direct.fsm import ClassicFSM, State
from toontown.toonbase import ToontownGlobals
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
class DistributedStageBattle(DistributedLevelBattle.DistributedLevelBattle):
notify = DirectNotifyGlobal.directNotify.newCategory('DistributedStageBattle')
@ -29,7 +29,7 @@ class DistributedStageBattle(DistributedLevelBattle.DistributedLevelBattle):
self.disableCollision()
self.delayDeleteMembers()
if self.hasLocalToon():
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
if self.bossBattle:
messenger.send('localToonConfrontedStageBoss')
self.movie.playReward(ts, self.uniqueName('building-reward'), self.__handleStageRewardDone, noSkip=True)
@ -45,4 +45,4 @@ class DistributedStageBattle(DistributedLevelBattle.DistributedLevelBattle):
self.notify.debug('exitStageReward()')
self.movie.resetReward(finish=1)
self._removeMembersKeep()
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)

View file

@ -9,8 +9,8 @@ import StageRoomBase, StageRoom
import FactoryEntityCreator
import StageRoomSpecs
from otp.level import LevelSpec, LevelConstants
from otp.nametag.NametagConstants import *
from toontown.toonbase import TTLocalizer
from toontown.nametag.NametagGlobals import *
def getStageRoomReadyPostName(doId):
return 'stageRoomReady-%s' % doId

View file

@ -2,7 +2,7 @@ from direct.directnotify import DirectNotifyGlobal
from direct.fsm import ClassicFSM, State
from direct.fsm import State
from otp.distributed.TelemetryLimiter import RotationLimitToH, TLGatherAllAvs
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
from panda3d.core import *
from toontown.battle import BattlePlace
from toontown.building import Elevator
@ -93,7 +93,7 @@ class FactoryExterior(BattlePlace.BattlePlace):
self._telemLimiter = TLGatherAllAvs('FactoryExterior', RotationLimitToH)
self.accept('doorDoneEvent', self.handleDoorDoneEvent)
self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger)
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.nodeList)
how = requestStatus['how']
self.fsm.request(how, [requestStatus])

View file

@ -11,7 +11,8 @@ from toontown.toonbase import TTLocalizer
from toontown.toontowngui import TTDialog
from toontown.toonbase import ToontownBattleGlobals
from toontown.building import Elevator
from toontown.nametag import NametagGlobals
from otp.nametag.NametagConstants import *
from otp.nametag import NametagGlobals
class FactoryInterior(BattlePlace.BattlePlace):
notify = DirectNotifyGlobal.directNotify.newCategory('FactoryInterior')
@ -79,7 +80,7 @@ class FactoryInterior(BattlePlace.BattlePlace):
self._telemLimiter = TLGatherAllAvs('FactoryInterior', RotationLimitToH)
def commence(self = self):
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
self.fsm.request(requestStatus['how'], [requestStatus])
base.playMusic(self.music, looping=1, volume=0.8)
base.transitions.irisIn()
@ -100,7 +101,7 @@ class FactoryInterior(BattlePlace.BattlePlace):
self.acceptOnce('localToonConfrontedForeman', handleConfrontedForeman)
def exit(self):
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
self._telemLimiter.destroy()
del self._telemLimiter
if hasattr(base, 'factoryReady'):

View file

@ -12,7 +12,7 @@ from toontown.toonbase import TTLocalizer
from toontown.toontowngui import TTDialog
from toontown.toonbase import ToontownBattleGlobals
from toontown.coghq import DistributedMint
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
class MintInterior(BattlePlace.BattlePlace):
notify = DirectNotifyGlobal.directNotify.newCategory('MintInterior')
@ -80,7 +80,7 @@ class MintInterior(BattlePlace.BattlePlace):
self._telemLimiter = TLGatherAllAvs('MintInterior', RotationLimitToH)
def commence(self = self):
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
self.fsm.request(requestStatus['how'], [requestStatus])
base.playMusic(self.music, looping=1, volume=0.8)
base.transitions.irisIn()
@ -100,7 +100,7 @@ class MintInterior(BattlePlace.BattlePlace):
self.acceptOnce('localToonConfrontedMintBoss', handleConfrontedBoss)
def exit(self):
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
bboard.remove(DistributedMint.DistributedMint.ReadyPost)
self._telemLimiter.destroy()
del self._telemLimiter

View file

@ -13,7 +13,7 @@ from toontown.toontowngui import TTDialog
from toontown.toonbase import ToontownBattleGlobals
from toontown.coghq import DistributedStage
from toontown.building import Elevator
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
class StageInterior(BattlePlace.BattlePlace):
notify = DirectNotifyGlobal.directNotify.newCategory('StageInterior')
@ -82,7 +82,7 @@ class StageInterior(BattlePlace.BattlePlace):
base.cr.forbidCheesyEffects(1)
def commence(self = self):
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
self.fsm.request(requestStatus['how'], [requestStatus])
base.playMusic(self.music, looping=1, volume=0.8)
base.transitions.irisIn()
@ -102,7 +102,7 @@ class StageInterior(BattlePlace.BattlePlace):
self.acceptOnce('localToonConfrontedStageBoss', handleConfrontedBoss)
def exit(self):
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
self._telemLimiter.destroy()
del self._telemLimiter
bboard.remove(DistributedStage.DistributedStage.ReadyPost)

View file

@ -293,13 +293,13 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
def handleAvatarResponseMsg(self, avatarId, di):
self.cleanupWaitingForDatabase()
dclass = self.dclassesByName['DistributedToon']
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
loader.beginBulkLoad('localAvatarPlayGame', OTPLocalizer.CREnteringToontown, 400, 1, TTLocalizer.TIP_GENERAL, 0)
localAvatar = LocalToon.LocalToon(self)
localAvatar.dclass = dclass
base.localAvatar = localAvatar
__builtins__['localAvatar'] = base.localAvatar
NametagGlobals.setMe(base.localAvatar)
NametagGlobals.setToon(base.localAvatar)
localAvatar.doId = avatarId
self.localAvatarDoId = avatarId
parentId = None
@ -423,7 +423,7 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository):
self.notify.error('could not delete localAvatar, delayDeletes=%s' % (base.localAvatar.getDelayDeleteNames(),))
base.localAvatar.deleteOrDelay()
base.localAvatar.detectLeaks()
NametagGlobals.setMe(base.cam)
NametagGlobals.setToon(base.cam)
del base.localAvatar
del __builtins__['localAvatar']
base.localAvatarStyle = None

View file

@ -21,8 +21,8 @@ from direct.distributed import DistributedObject
from toontown.effects import Wake
from direct.controls.ControlManager import CollisionHandlerRayStart
from toontown.nametag.NametagFloat3d import NametagFloat3d
from toontown.nametag.Nametag import Nametag
from otp.nametag.NametagFloat3d import NametagFloat3d
from otp.nametag.Nametag import Nametag
LAND_TIME = 2
WORLD_SCALE = 2.0
@ -1239,19 +1239,19 @@ class DistributedCannon(DistributedObject.DistributedObject):
def __calcHitTreasures(self, trajectory):
estate = self.cr.doId2do.get(self.estateId)
self.hitTreasures = []
if estate:
'''if estate:
doIds = estate.flyingTreasureId
for id in doIds:
t = self.cr.doId2do.get(id)
if t:
pos = t.nodePath.getPos()
pos = t.pos
rad = 10.5
height = 10.0
t_impact = trajectory.checkCollisionWithCylinderSides(pos, rad, height)
if t_impact > 0:
self.hitTreasures.append([t_impact, t])
del estate
del estate'''
return None
def __shootTask(self, task):
@ -1580,4 +1580,3 @@ class DistributedCannon(DistributedObject.DistributedObject):
def turnOnBumperCollision(self, whatever = 0):
if self.bumperCol:
self.bumperCol.setCollideMask(ToontownGlobals.WallBitmask)

View file

@ -19,8 +19,8 @@ import HouseGlobals
from toontown.building import ToonInteriorColors
from direct.showbase.MessengerGlobal import messenger
from toontown.dna.DNAParser import *
from toontown.nametag.NametagGroup import NametagGroup
from toontown.nametag.Nametag import Nametag
from otp.nametag.NametagGroup import NametagGroup
from otp.nametag.Nametag import Nametag
class DistributedHouse(DistributedObject.DistributedObject):
notify = directNotify.newCategory('DistributedHouse')
@ -231,19 +231,16 @@ class DistributedHouse(DistributedObject.DistributedObject):
else:
houseName = TTLocalizer.AvatarsHouse % TTLocalizer.GetPossesive(self.name)
self.nametag = NametagGroup()
self.nametag.setNametag3d(None)
self.nametag.setFont(ToontownGlobals.getBuildingNametagFont())
if TTLocalizer.BuildingNametagShadow:
self.nametag.setShadow(*TTLocalizer.BuildingNametagShadow)
self.nametag.hideChat()
self.nametag.hideThought()
nametagColor = NametagGlobals.NametagColors[NametagGlobals.CCToonBuilding]
self.nametag.setNametagColor(nametagColor)
self.nametag.setActive(False)
self.nametag.setContents(Nametag.CName)
self.nametag.setColorCode(NametagGroup.CCHouseBuilding)
self.nametag.setActive(0)
self.nametag.setAvatar(self.house)
self.nametag.setText(houseName)
self.nametag.setObjectCode(self.doId)
self.nametag.setName(houseName)
self.nametag.manage(base.marginManager)
self.nametag.updateAll()
def unload(self):
self.notify.debug('unload')

View file

@ -155,12 +155,12 @@ class DistributedTarget(DistributedObject.DistributedObject):
def showTimer(self):
if base.localAvatar.animFSM.getCurrentState().getName() != 'ReadBook':
base.setCellsActive([base.rightCells[0]], 0)
base.setCellsAvailable([base.rightCells[0]], 0)
self.timer.show()
def hideTimer(self):
self.timer.hide()
base.setCellsActive([base.rightCells[0]], 1)
base.setCellsAvailable([base.rightCells[0]], 1)
def setPosition(self, x, y, z):
self.geom.setPos(x, y, z)

View file

@ -77,7 +77,7 @@ class House(Place.Place):
self.accept('doorDoneEvent', self.handleDoorDoneEvent)
self.accept('DistributedDoor_doorTrigger', self.handleDoorTrigger)
self._telemLimiter = TLGatherAllAvs('House', RotationLimitToH)
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
self.fsm.request(requestStatus['how'], [requestStatus])
def exit(self):
@ -87,7 +87,7 @@ class House(Place.Place):
self._telemLimiter.destroy()
del self._telemLimiter
messenger.send('exitHouse')
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
def setState(self, state):
if hasattr(self, 'fsm'):

View file

@ -9,7 +9,8 @@ from panda3d.core import *
from toontown.estate import DistributedToonStatuary
from toontown.estate import GardenGlobals
from toontown.estate import PlantingGUI
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
from otp.nametag.NametagGroup import *
from toontown.toon import DistributedToon
from toontown.toon import Toon
from toontown.toonbase import TTLocalizer
@ -96,20 +97,23 @@ class ToonStatueSelectionGUI(DirectFrame):
return test
def __makeFFlist(self):
playerAvatar = (base.localAvatar.doId, base.localAvatar.name, NametagGlobals.CCNonPlayer)
playerAvatar = (base.localAvatar.doId, base.localAvatar.name, CCNonPlayer)
self.ffList.append(playerAvatar)
self.dnaSelected = base.localAvatar.style
self.createPreviewToon(self.dnaSelected)
for familyMember in base.cr.avList:
if familyMember.id != base.localAvatar.doId:
newFF = (familyMember.id, familyMember.name, NametagGlobals.CCNonPlayer)
newFF = (familyMember.id, familyMember.name, CCNonPlayer)
self.ffList.append(newFF)
for friendId in base.localAvatar.friendsList:
handle = base.cr.identifyFriend(friendId)
if handle and not self.checkFamily(friendId):
if hasattr(handle, 'getName'):
newFF = (friendId, handle.getName(), NametagGlobals.getFriendColor(handle))
colorCode = CCSpeedChat
if flags & ToontownGlobals.FriendChat:
colorCode = CCFreeChat
newFF = (friendId, handle.getName(), colorCode)
self.ffList.append(newFF)
else:
self.notify.warning('Bad Handle for getName in makeFFlist')
@ -124,7 +128,7 @@ class ToonStatueSelectionGUI(DirectFrame):
self.scrollList.refresh()
def makeFamilyButton(self, familyId, familyName, colorCode):
fg = NametagGlobals.NametagColors[colorCode][3][0]
fg = NametagGlobals.getNameFg(colorCode, PGButton.SInactive)
return DirectButton(relief=None, text=familyName, text_scale=0.04, text_align=TextNode.ALeft, text_fg=fg, text1_bg=self.textDownColor, text2_bg=self.textRolloverColor, text3_fg=self.textDisabledColor, textMayChange=0, command=self.__chooseFriend, extraArgs=[familyId, familyName])
def __chooseFriend(self, friendId, friendName):

View file

@ -383,7 +383,7 @@ class ObjectManager(NodePath, DirectObject):
self.__updateDeleteButtons()
self.showAtticPicker()
base.localAvatar.laffMeter.stop()
base.setCellsActive(base.leftCells + [base.bottomCells[0]], 0)
base.setCellsAvailable(base.leftCells + [base.bottomCells[0]], 0)
if self.guiInterval:
self.guiInterval.finish()
self.guiInterval = self.furnitureGui.posHprScaleInterval(1.0, Point3(0.155, -0.6, -1.045), Vec3(0), Vec3(0.06), startPos=Point3(0.115, 0.0, -0.66), startHpr=Vec3(0), startScale=Vec3(0.04), blendType='easeInOut', name='lerpFurnitureButton')
@ -419,7 +419,7 @@ class ObjectManager(NodePath, DirectObject):
self.inTrashPicker = None
self.__cleanupVerifyDelete()
self.furnitureGui.hide()
base.setCellsActive(base.leftCells + [base.bottomCells[0]], 1)
base.setCellsAvailable(base.leftCells + [base.bottomCells[0]], 1)
base.localAvatar.laffMeter.start()
taskMgr.remove('recenterButtonFrameTask')
self.cleanupDialog()

View file

@ -14,7 +14,7 @@ from toontown.toonbase import ToontownGlobals
from toontown.toon import Toon
import FriendHandle
from otp.otpbase import OTPGlobals
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
class FriendsListManager:
notify = DirectNotifyGlobal.directNotify.newCategory('FriendsListManager')
@ -47,7 +47,7 @@ class FriendsListManager:
self.accept('openFriendsList', self.__openFriendsList)
self.accept('clickedNametag', self.__handleClickedNametag)
base.localAvatar.setFriendsListButtonActive(1)
NametagGlobals.setWantActiveNametags(True)
NametagGlobals.setMasterNametagsActive(1)
self.accept('gotoAvatar', self.__handleGotoAvatar)
self.accept('friendAvatar', self.__handleFriendAvatar)
self.accept('avatarDetails', self.__handleAvatarDetails)
@ -65,7 +65,7 @@ class FriendsListManager:
self.ignore('openFriendsList')
self.ignore('clickedNametag')
base.localAvatar.setFriendsListButtonActive(0)
NametagGlobals.setWantActiveNametags(False)
NametagGlobals.setMasterNametagsActive(0)
if self.avatarPanel:
self.avatarPanel.cleanup()
self.avatarPanel = None

View file

@ -4,7 +4,7 @@ from direct.fsm import StateData
from toontown.toon import ToonAvatarPanel
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import TTLocalizer
from toontown.nametag.NametagGlobals import *
from otp.nametag.NametagGroup import *
from otp.otpbase import OTPGlobals
FLPPets = 1
FLPOnline = 2
@ -270,10 +270,10 @@ class FriendsListPanel(DirectFrame, StateData.StateData):
friendButton.destroy()
del self.friends[friendId]
self.createButtons(petFriends, NametagColors[CCNonPlayer][0][0])
self.createButtons(admins, NametagColors[CCAdmin][0][0])
self.createButtons(trueFriends, NametagColors[CCNormal][0][0])
self.createButtons(friends, NametagColors[CCSpeedChat][0][0])
self.createButtons(petFriends, NAMETAG_COLORS[CCNonPlayer][0][0])
self.createButtons(admins, NAMETAG_COLORS[CCAdmin][0][0])
self.createButtons(trueFriends, NAMETAG_COLORS[CCNormal][0][0])
self.createButtons(friends, NAMETAG_COLORS[CCSpeedChat][0][0])
self.scrollList.index = self.listScrollIndex[self.panelType]
self.scrollList.refresh()

View file

@ -157,7 +157,7 @@ class DistributedGolfCourse(DistributedObject.DistributedObject, FSM, DelayDelet
else:
color += 1
base.setCellsActive(base.leftCells, 0)
base.setCellsAvailable(base.leftCells, 0)
else:
self.toonPanels = None
@ -201,7 +201,7 @@ class DistributedGolfCourse(DistributedObject.DistributedObject, FSM, DelayDelet
else:
self.notify.warning('GOLF COURSE: Attempting to clean up twice')
base.setCellsActive(base.leftCells, 1)
base.setCellsAvailable(base.leftCells, 1)
def onstage(self):
self.notify.debug('GOLF COURSE: onstage')

View file

@ -436,7 +436,7 @@ class Place(StateData.StateData, FriendsListManager.FriendsListManager):
self.fsm.request(out[requestStatus['how']], [requestStatus])
def enterDoorIn(self, requestStatus):
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
door = base.cr.doId2do.get(requestStatus['doorDoId'])
if not door is None:
door.readyToExit()
@ -444,7 +444,7 @@ class Place(StateData.StateData, FriendsListManager.FriendsListManager):
base.localAvatar.startQuestMap()
def exitDoorIn(self):
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
base.localAvatar.obscureMoveFurnitureButton(-1)
def enterDoorOut(self):
@ -600,7 +600,7 @@ class Place(StateData.StateData, FriendsListManager.FriendsListManager):
def _placeTeleportInPostZoneComplete(self, requestStatus):
teleportDebug(requestStatus, '_placeTeleportInPostZoneComplete(%s)' % (requestStatus,))
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
base.localAvatar.laffMeter.start()
base.localAvatar.startQuestMap()
base.localAvatar.reconsiderCheesyEffect()
@ -645,7 +645,7 @@ class Place(StateData.StateData, FriendsListManager.FriendsListManager):
def exitTeleportIn(self):
self.removeSetZoneCompleteCallback(self._tiToken)
self._tiToken = None
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
base.localAvatar.laffMeter.stop()
base.localAvatar.obscureMoveFurnitureButton(-1)
base.localAvatar.stopUpdateSmartCamera()

View file

@ -16,7 +16,7 @@ from MakeAToonGlobals import *
import MakeClothesGUI
import NameShop
from otp.avatar import Avatar
from toontown.chat.ChatGlobals import *
from otp.nametag.NametagConstants import *
from toontown.distributed.ToontownMsgTypes import *
from toontown.toon import LocalToon
from toontown.toon import Toon

View file

@ -1,40 +0,0 @@
from pandac.PandaModules import NodePath
class MarginCell(NodePath):
def __init__(self):
NodePath.__init__(self, 'cell')
self.active = False
self.content = None
self.contentNodePath = None
def setActive(self, active):
if not active:
self.setContent(None)
self.active = active
def getActive(self):
return self.active
def setContent(self, content):
if self.content is not None:
self.content.setCell(None)
self.content.marginVisibilityChanged()
self.content = None
if self.contentNodePath is not None:
self.contentNodePath.removeNode()
self.contentNodePath = None
if content is not None:
content.setLastCell(self)
content.setCell(self)
self.contentNodePath = self.attachNewNode(content)
content.marginVisibilityChanged()
self.content = content
def getContent(self):
return self.content

View file

@ -1,9 +0,0 @@
# Priorities:
MP_low = 0
MP_normal = 1
MP_high = 2
MP_urgent = 3
def updateMarginVisibles():
messenger.send('MarginVisible-update')

View file

@ -1,76 +0,0 @@
from pandac.PandaModules import PandaNode
import random
from toontown.margins.MarginCell import MarginCell
class MarginManager(PandaNode):
def __init__(self):
PandaNode.__init__(self, 'margins')
self.cells = set()
self.visibles = set()
def addCell(self, x, y, a2dMarker):
cell = MarginCell()
cell.reparentTo(a2dMarker)
cell.setPos(x, 0, y)
cell.setScale(0.2)
cell.setActive(True)
self.cells.add(cell)
self.reorganize()
return cell
def removeCell(self, cell):
if cell in self.cells:
self.cells.remove(cell)
self.reorganize()
def addVisible(self, visible):
self.visibles.add(visible)
self.reorganize()
def removeVisible(self, visible):
if visible in self.visibles:
self.visibles.remove(visible)
self.reorganize()
def getActiveCells(self):
return [cell for cell in self.cells if cell.getActive()]
def reorganize(self):
# First, get all of the active cells:
activeCells = self.getActiveCells()
# Next, get all of the visibles sorted by priority:
visibles = list(self.visibles)
visibles.sort(key=lambda visible: visible.getPriority(), reverse=True)
# We can only display so many visibles, so truncate them based on the
# number of active cells:
visibles = visibles[:len(activeCells)]
# Now, let's build a list of empty cells:
emptyCells = []
for cell in activeCells:
content = cell.getContent()
if content in visibles:
# This cell is already displaying something we want to see.
# Ignore it:
visibles.remove(content)
continue
elif content is not None:
# This cell isn't displaying anything interesting, so let's
# empty it:
cell.setContent(None)
emptyCells.append(cell)
# Assign the visibles to their cells:
for visible in visibles:
cell = visible.getLastCell()
if cell not in emptyCells:
cell = random.choice(emptyCells)
cell.setContent(visible)
emptyCells.remove(cell)

View file

@ -1,59 +0,0 @@
class MarginVisible:
def __init__(self):
self.marginManager = None
self.visible = False
self.priority = 0
self.lastCell = None
self.cell = None
def manage(self, marginManager):
if self.marginManager is not None:
self.unmanage(self.marginManager)
self.marginManager = marginManager
if self.visible:
self.marginManager.addVisible(self)
def unmanage(self, marginManager):
if marginManager != self.marginManager:
return
if self.marginManager is None:
return
if self.visible:
self.marginManager.removeVisible(self)
self.marginManager = None
def setVisible(self, visible):
if visible == self.visible:
return
self.visible = visible
if self.marginManager is not None:
if self.visible:
self.marginManager.addVisible(self)
else:
self.marginManager.removeVisible(self)
def getVisible(self):
return self.visible
def setPriority(self, priority):
self.priority = priority
if (self.marginManager is not None) and self.visible:
self.marginManager.reorganize()
def getPriority(self):
return self.priority
def setLastCell(self, cell):
self.lastCell = cell
def getLastCell(self):
return self.lastCell
def setCell(self, cell):
self.cell = cell
def getCell(self):
return self.cell
def marginVisibilityChanged(self):
pass # Inheritors should override this method.

View file

@ -1,7 +1,7 @@
from direct.directnotify import DirectNotifyGlobal
from panda3d.core import *
from toontown.nametag.NametagFloat3d import NametagFloat3d
from toontown.nametag.Nametag import Nametag
from otp.nametag.NametagFloat3d import NametagFloat3d
from otp.nametag.Nametag import Nametag
from toontown.toonbase.ToonBaseGlobal import *
from DistributedMinigame import *
from direct.distributed.ClockDelta import *
@ -198,7 +198,7 @@ class DistributedCannonGame(DistributedMinigame):
if av:
av.loop('neutral')
av.setPlayRate(1.0, 'run')
av.nametag.remove(head.tag)
av.nametag.removeNametag(head.tag)
head.delete()
del self.toonHeadDict
@ -345,11 +345,10 @@ class DistributedCannonGame(DistributedMinigame):
self.toonHeadDict[avId] = head
toon = self.getAvatar(avId)
tag = NametagFloat3d()
tag.hideNametag()
tag.update()
tag.setContents(Nametag.CSpeech | Nametag.CThought)
tag.setBillboardOffset(0)
tag.setAvatar(head)
toon.nametag.add(tag)
toon.nametag.addNametag(tag)
tagPath = head.attachNewNode(tag)
tagPath.setPos(0, 0, 1)
head.tag = tag

View file

@ -116,8 +116,8 @@ class DistributedCatchGame(DistributedMinigame):
d = SuitDNA.SuitDNA()
d.newSuit(type)
suit.setDNA(d)
suit.nametag.setNametag2d(None)
suit.nametag.setNametag3d(None)
suit.nametag3d.stash()
suit.nametag.destroy()
suit.pose('walk', 0)
self.suits.append(suit)

View file

@ -176,8 +176,8 @@ class DistributedCogThiefGame(DistributedMinigame):
pos = self.cogInfo[cogIndex]['pos']
suit.reparentTo(self.gameBoard)
suit.setPos(pos)
suit.nametag.setNametag2d(None)
suit.nametag.setNametag3d(None)
suit.nametag3d.stash()
suit.nametag.destroy()
for avId in self.avIdList:
self.toonHitTracks[avId] = Wait(0.1)

View file

@ -621,7 +621,7 @@ class DistributedMazeGame(DistributedMinigame):
self.scorePanels = []
self.goalBar.destroy()
del self.goalBar
base.setCellsActive(base.rightCells, 1)
base.setCellsAvailable(base.rightCells, 1)
for suit in self.suits:
suit.offstage()
@ -700,7 +700,7 @@ class DistributedMazeGame(DistributedMinigame):
self.goalBar.show()
self.goalBar['value'] = 0.0
base.setCellsActive(base.rightCells, 0)
base.setCellsAvailable(base.rightCells, 0)
self.__spawnUpdateSuitsTask()
orthoDrive = OrthoDrive(self.TOON_SPEED, maxFrameMove=self.MAX_FRAME_MOVE, customCollisionCallback=self.__doMazeCollisions, priority=1)
self.orthoWalk = OrthoWalk(orthoDrive, broadcast=not self.isSinglePlayer())

View file

@ -9,8 +9,7 @@ import string
import ArrowKeys
from DistributedMinigame import *
import PatternGameGlobals
from toontown.chat.ChatGlobals import *
from toontown.nametag.NametagGlobals import *
from otp.nametag.NametagConstants import *
from toontown.toon import NPCToons
from toontown.toon import ToonHead
from toontown.toonbase import TTLocalizer
@ -200,6 +199,7 @@ class DistributedPatternGame(DistributedMinigame):
camera.setPosHpr(0.0, -14.59, 10.56, 0.0, -16.39, 0.0)
base.camLens.setMinFov(24.66/(4./3.))
base.setBackgroundColor(Vec4(0.984, 0.984, 0.584, 1))
NametagGlobals.setGlobalNametagScale(0.6)
self.arrowKeys = ArrowKeys.ArrowKeys()
self.room.reparentTo(render)
self.room.setPosHpr(0.0, 18.39, -ToontownGlobals.FloorOffset, 0.0, 0.0, 0.0)
@ -244,7 +244,7 @@ class DistributedPatternGame(DistributedMinigame):
self.makeToonLookatCamera(self.blinky)
self.blinky.loop('neutral')
self.blinky.nametag.manage(base.marginManager)
self.blinky.nametag.getNametag3d().setChatWordWrap(8)
self.blinky.nametag.getNametag3d().setChatWordwrap(8)
self.arrowDict['m'] = [self.arrows.pop(), self.xs.pop()]
for k in xrange(0, 2):
self.arrowDict['m'][k].setBillboardAxis()
@ -262,6 +262,7 @@ class DistributedPatternGame(DistributedMinigame):
self.music.stop()
base.camLens.setMinFov(settings['fov']/(4./3.))
base.setBackgroundColor(ToontownGlobals.DefaultBackgroundColor)
NametagGlobals.setGlobalNametagScale(1.0)
self.arrowKeys.destroy()
del self.arrowKeys
self.room.reparentTo(hidden)

View file

@ -98,7 +98,7 @@ class DistributedTagGame(DistributedMinigame):
camera.setPosHpr(0, -24, 16, 0, -30, 0)
base.camLens.setFar(450.0)
base.transitions.irisIn(0.4)
NametagGlobals.setWant2dNametags(True)
NametagGlobals.setMasterArrowsOn(1)
DistributedSmoothNode.activateSmoothing(1, 1)
self.IT = None
@ -110,7 +110,7 @@ class DistributedTagGame(DistributedMinigame):
def offstage(self):
self.notify.debug('offstage')
DistributedSmoothNode.activateSmoothing(1, 0)
NametagGlobals.setWant2dNametags(False)
NametagGlobals.setMasterArrowsOn(0)
DistributedMinigame.offstage(self)
self.sky.reparentTo(hidden)
self.ground.reparentTo(hidden)
@ -162,7 +162,7 @@ class DistributedTagGame(DistributedMinigame):
scorePanel.reparentTo(base.a2dBottomRight)
self.scorePanels.append(scorePanel)
base.setCellsActive(base.rightCells, 0)
base.setCellsAvailable(base.rightCells, 0)
self.walkStateData.enter()
self.walkStateData.fsm.request('walking')
if base.localAvatar.isIt:
@ -195,7 +195,7 @@ class DistributedTagGame(DistributedMinigame):
panel.cleanup()
self.scorePanels = []
base.setCellsActive(base.rightCells, 1)
base.setCellsAvailable(base.rightCells, 1)
base.mouseInterfaceNode.setForwardSpeed(ToontownGlobals.ToonForwardSpeed)
base.mouseInterfaceNode.setRotateSpeed(ToontownGlobals.ToonRotateSpeed)
self.itPointer.reparentTo(hidden)

View file

@ -21,7 +21,7 @@ from toontown.effects import Ripples
from toontown.toonbase import TTLocalizer
import MinigamePowerMeter
from direct.task.Task import Task
from toontown.nametag import NametagGlobals
from otp.nametag import NametagGlobals
class DistributedTugOfWarGame(DistributedMinigame):
bgm = 'phase_4/audio/bgm/MG_tug_o_war.ogg'
@ -251,6 +251,7 @@ class DistributedTugOfWarGame(DistributedMinigame):
self.notify.debug('onstage')
DistributedMinigame.onstage(self)
self.lt = base.localAvatar
NametagGlobals.setGlobalNametagScale(1)
self.arrowKeys = ArrowKeys.ArrowKeys()
self.room.reparentTo(render)
self.room.setPosHpr(0.0, 18.39, -ToontownGlobals.FloorOffset, 0.0, 0.0, 0.0)
@ -294,6 +295,7 @@ class DistributedTugOfWarGame(DistributedMinigame):
self.setupTrack = None
base.camLens.setMinFov(settings['fov']/(4./3.))
base.camLens.setNearFar(ToontownGlobals.DefaultCameraNear, ToontownGlobals.DefaultCameraFar)
NametagGlobals.setGlobalNametagScale(1.0)
if self.arrowKeys:
self.arrowKeys.setPressHandlers(self.arrowKeys.NULL_HANDLERS)
self.arrowKeys.setReleaseHandlers(self.arrowKeys.NULL_HANDLERS)
@ -1020,8 +1022,8 @@ class DistributedTugOfWarGame(DistributedMinigame):
d = SuitDNA.SuitDNA()
d.newSuit(self.suitType)
self.suit.setDNA(d)
self.suit.nametag.setNametag2d(None)
self.suit.nametag.setNametag3d(None)
self.suit.nametag3d.stash()
self.suit.nametag.destroy()
self.suit.reparentTo(render)
self.suit.setPos(self.origSuitPosHpr[0])
self.suit.setHpr(self.origSuitPosHpr[1])

View file

@ -43,8 +43,8 @@ class MazeSuit(DirectObject):
d = SuitDNA.SuitDNA()
d.newSuit(suitDnaName)
self.suit.setDNA(d)
self.suit.nametag.setNametag2d(None)
self.suit.nametag.setNametag3d(None)
self.suit.nametag3d.stash()
self.suit.nametag.destroy()
if startTile is None:
defaultStartPos = MazeGameGlobals.SUIT_START_POSITIONS[self.serialNum]
self.startTile = (defaultStartPos[0] * self.maze.width, defaultStartPos[1] * self.maze.height)

View file

@ -6,8 +6,8 @@ from direct.task.Task import Task
import MinigameGlobals
from PurchaseBase import *
from toontown.distributed import DelayDelete
from toontown.nametag import NametagGlobals
from toontown.nametag.NametagFloat2d import *
from otp.nametag.NametagFloat2d import *
from otp.nametag import NametagGlobals
from toontown.toon import ToonHead
from toontown.toonbase import ToontownGlobals
from toontown.toonbase import ToontownTimer
@ -304,7 +304,7 @@ class Purchase(PurchaseBase):
floorNode = CollisionNode('collision_floor')
floorNode.addSolid(floor)
self.collisionFloor = render.attachNewNode(floorNode)
NametagGlobals.setForceOnscreenChat(True)
NametagGlobals.setOnscreenChatForced(1)
for index in xrange(len(self.ids)):
avId = self.ids[index]
if self.states[index] != PURCHASE_NO_CLIENT_STATE and self.states[index] != PURCHASE_DISCONNECTED_STATE and avId in base.cr.doId2do:
@ -511,7 +511,7 @@ class Purchase(PurchaseBase):
self.title.reparentTo(self.frame)
self.rewardDoubledJellybeanLabel.hide()
base.camLens.setMinFov(settings['fov']/(4./3.))
NametagGlobals.setForceOnscreenChat(False)
NametagGlobals.setOnscreenChatForced(0)
def _handleClientCleanup(self):
if hasattr(self, 'toonsKeep'):
@ -626,16 +626,13 @@ class PurchaseHeadFrame(DirectFrame):
self.headModel.setupHead(self.av.style, forGui=1)
self.headModel.reparentTo(self.head)
self.tag2Node = NametagFloat2d()
self.tag2Node.hideChat()
self.tag2Node.hideThought()
self.tag2Node.update()
self.av.nametag.add(self.tag2Node)
self.tag2Node.setContents(Nametag.CName)
self.av.nametag.addNametag(self.tag2Node)
self.tag2 = self.attachNewNode(self.tag2Node)
self.tag2.setPosHprScale(-0.22, 10.0, 0.12, 0, 0, 0, 0.046, 0.046, 0.046)
self.tag1Node = NametagFloat2d()
self.tag1Node.hideNametag()
self.tag1Node.update()
self.av.nametag.add(self.tag1Node)
self.tag1Node.setContents(Nametag.CSpeech | Nametag.CThought)
self.av.nametag.addNametag(self.tag1Node)
self.tag1 = self.attachNewNode(self.tag1Node)
self.tag1.setPosHprScale(-0.15, 0, -0.1, 0, 0, 0, 0.046, 0.046, 0.046)
self.hide()
@ -647,8 +644,8 @@ class PurchaseHeadFrame(DirectFrame):
del self.headModel
self.head.removeNode()
del self.head
self.av.nametag.remove(self.tag1Node)
self.av.nametag.remove(self.tag2Node)
self.av.nametag.removeNametag(self.tag1Node)
self.av.nametag.removeNametag(self.tag2Node)
self.tag1.removeNode()
self.tag2.removeNode()
del self.tag1

View file

@ -84,8 +84,8 @@ class TwoDEnemy(DirectObject):
self.suit.pose('walk', 0)
self.suitName = 'Enemy-%s' % self.index
self.suit.setName(self.suitName)
self.suit.nametag.setNametag2d(None)
self.suit.nametag.setNametag3d(None)
self.suit.nametag3d.stash()
self.suit.nametag.destroy()
suitPosAttribs = suitAttribs[1]
initX, initY, initZ = suitPosAttribs[0]
initPos = Point3(initX, initY, initZ)

View file

@ -1,308 +0,0 @@
from direct.task.Task import Task
from pandac.PandaModules import TextNode, VBase4
from direct.interval.IntervalGlobal import *
from toontown.chat.ChatBalloon import ChatBalloon
from toontown.nametag import NametagGlobals
class Nametag:
TEXT_WORD_WRAP = 8
TEXT_Y_OFFSET = -0.05
CHAT_TEXT_WORD_WRAP = 12
PANEL_X_PADDING = 0.2
PANEL_Z_PADDING = 0.2
CHAT_BALLOON_ALPHA = 1
def __init__(self):
self.avatar = None
self.panel = None
self.icon = None
self.chatBalloon = None
self.chatButton = NametagGlobals.noButton
self.chatReversed = False
self.font = None
self.chatFont = None
self.chatType = NametagGlobals.CHAT
self.chatBalloonType = NametagGlobals.CHAT_BALLOON
self.nametagColor = NametagGlobals.NametagColors[NametagGlobals.CCNormal]
self.chatColor = NametagGlobals.ChatColors[NametagGlobals.CCNormal]
self.speedChatColor = self.chatColor[0][1]
self.nametagHidden = False
self.chatHidden = False
self.thoughtHidden = False
# Create our TextNodes:
self.textNode = TextNode('text')
self.textNode.setWordwrap(self.TEXT_WORD_WRAP)
self.textNode.setAlign(TextNode.ACenter)
self.chatTextNode = TextNode('chatText')
self.chatTextNode.setWordwrap(self.CHAT_TEXT_WORD_WRAP)
self.chatTextNode.setGlyphScale(ChatBalloon.TEXT_GLYPH_SCALE)
self.chatTextNode.setGlyphShift(ChatBalloon.TEXT_GLYPH_SHIFT)
# Add the tick task:
self.tickTaskName = self.getUniqueName() + '-tick'
self.tickTask = taskMgr.add(self.tick, self.tickTaskName, sort=45)
def destroy(self):
if self.tickTask is not None:
taskMgr.remove(self.tickTask)
self.tickTask = None
self.chatTextNode = None
self.textNode = None
self.chatFont = None
self.font = None
self.chatButton = NametagGlobals.noButton
self.removeBalloon()
self.removeIcon()
self.removePanel()
self.avatar = None
def getUniqueName(self):
return 'Nametag-' + str(id(self))
def getChatBalloonModel(self):
pass # Inheritors should override this method.
def getChatBalloonWidth(self):
pass # Inheritors should override this method.
def getChatBalloonHeight(self):
pass # Inheritors should override this method.
def tick(self, task):
return Task.done # Inheritors should override this method.
def updateClickRegion(self):
pass # Inheritors should override this method.
def drawChatBalloon(self, model, modelWidth, modelHeight):
pass # Inheritors should override this method.
def drawNametag(self):
pass # Inheritors should override this method.
def setAvatar(self, avatar):
self.avatar = avatar
def getAvatar(self):
return self.avatar
def setIcon(self, icon):
self.icon = icon
def getIcon(self):
return self.icon
def setChatButton(self, chatButton):
self.chatButton = chatButton
def getChatButton(self):
return self.chatButton
def hasChatButton(self):
if (self.chatBalloonType == NametagGlobals.CHAT_BALLOON) and self.chatHidden:
return False
if (self.chatBalloonType == NametagGlobals.THOUGHT_BALLOON) and self.thoughtHidden:
return False
return self.chatButton != NametagGlobals.noButton
def setChatReversed(self, chatReversed):
self.chatReversed = chatReversed
def getChatReversed(self):
return self.chatReversed
def setFont(self, font):
self.font = font
if self.font is not None:
self.textNode.setFont(self.font)
self.update()
def getFont(self):
return self.font
def setChatFont(self, chatFont):
self.chatFont = chatFont
if self.chatFont is not None:
self.chatTextNode.setFont(self.chatFont)
self.update()
def getChatFont(self):
return self.chatFont
def setChatType(self, chatType):
self.chatType = chatType
def getChatType(self):
return self.chatType
def setChatBalloonType(self, chatBalloonType):
self.chatBalloonType = chatBalloonType
def getChatBalloonType(self):
return self.chatBalloonType
def setNametagColor(self, nametagColor):
self.nametagColor = nametagColor
def getNametagColor(self):
return self.nametagColor
def setChatColor(self, chatColor):
self.chatColor = chatColor
def getChatColor(self):
return self.chatColor
def setSpeedChatColor(self, speedChatColor):
self.speedChatColor = speedChatColor
def getSpeedChatColor(self):
return self.speedChatColor
def hideNametag(self):
self.nametagHidden = True
def showNametag(self):
self.nametagHidden = False
def hideChat(self):
self.chatHidden = True
def showChat(self):
self.chatHidden = False
def hideThought(self):
self.thoughtHidden = True
def showThought(self):
self.thoughtHidden = False
def applyClickState(self, clickState):
if self.chatBalloon is not None:
foreground, background = self.chatColor[clickState]
if self.chatType == NametagGlobals.SPEEDCHAT:
background = self.speedChatColor
if background[3] > self.CHAT_BALLOON_ALPHA:
background = VBase4(
background[0], background[1], background[2],
self.CHAT_BALLOON_ALPHA)
self.chatBalloon.setForeground(foreground)
self.chatBalloon.setBackground(background)
self.chatBalloon.setButton(self.chatButton[clickState])
elif self.panel is not None:
foreground, background = self.nametagColor[clickState]
self.setForeground(foreground)
self.setBackground(background)
def setText(self, text):
self.textNode.setText(text)
def getText(self):
try:
text = self.textNode.getText()
return text
except AttributeError:
return None
def setChatText(self, chatText):
self.chatTextNode.setText(chatText)
def getChatText(self):
try:
text = self.chatTextNode.getText()
return text
except AttributeError:
return None
def setWordWrap(self, wordWrap):
if wordWrap is None:
wordWrap = self.TEXT_WORD_WRAP
self.textNode.setWordwrap(wordWrap)
self.update()
def getWordWrap(self):
return self.textNode.getWordwrap()
def setChatWordWrap(self, chatWordWrap):
if (chatWordWrap is None) or (chatWordWrap > self.CHAT_TEXT_WORD_WRAP):
chatWordWrap = self.CHAT_TEXT_WORD_WRAP
self.chatTextNode.setWordwrap(chatWordWrap)
self.update()
def getChatWordWrap(self):
return self.chatTextNode.getWordwrap()
def setForeground(self, foreground):
self.textNode.setTextColor(foreground)
def setBackground(self, background):
if self.panel is not None:
self.panel.setColor(background)
def setShadow(self, shadow):
self.textNode.setShadow(shadow)
def getShadow(self):
return self.textNode.getShadow()
def clearShadow(self):
self.textNode.clearShadow()
def removeBalloon(self):
if self.chatBalloon:
self.chatBalloon.removeNode()
self.chatBalloon = None
def removePanel(self):
if self.panel:
self.panel.removeNode()
self.panel = None
def removeIcon(self):
if self.icon:
self.icon.removeAllChildren()
self.icon = None
def update(self):
self.removeBalloon()
self.removePanel()
if self.getChatText():
if self.chatBalloonType == NametagGlobals.CHAT_BALLOON:
if not self.chatHidden:
model = self.getChatBalloonModel()
modelWidth = self.getChatBalloonWidth()
modelHeight = self.getChatBalloonHeight()
self.drawChatBalloon(model, modelWidth, modelHeight)
return
elif self.chatBalloonType == NametagGlobals.THOUGHT_BALLOON:
if not self.thoughtHidden:
model = NametagGlobals.thoughtBalloonModel
modelWidth = NametagGlobals.thoughtBalloonWidth
modelHeight = NametagGlobals.thoughtBalloonHeight
self.drawChatBalloon(model, modelWidth, modelHeight)
return
if hasattr(self.avatar, 'ghostMode'):
if self.avatar.ghostMode == 2:
return
if self.getText() and (not self.nametagHidden):
self.drawNametag()

View file

@ -1,322 +0,0 @@
from direct.task.Task import Task
import math
from panda3d.core import PGButton, VBase4, DepthWriteAttrib, Point3
from direct.interval.IntervalGlobal import *
from toontown.chat.ChatBalloon import ChatBalloon
from toontown.margins import MarginGlobals
from toontown.margins.MarginVisible import MarginVisible
from toontown.nametag import NametagGlobals
from toontown.nametag.Nametag import Nametag
from toontown.toontowngui.Clickable2d import Clickable2d
class Nametag2d(Nametag, Clickable2d, MarginVisible):
CONTENTS_SCALE = 0.25
CHAT_TEXT_MAX_ROWS = 6
CHAT_TEXT_WORD_WRAP = 8
CHAT_BALLOON_ALPHA = 0.4
ARROW_OFFSET = -1.0
ARROW_SCALE = 1.5
def __init__(self):
Nametag.__init__(self)
Clickable2d.__init__(self, 'Nametag2d')
MarginVisible.__init__(self)
self.actualChatText = ''
self.arrow = None
self.textNodePath = None
self.contents.setScale(self.CONTENTS_SCALE)
self.hideThought()
self.accept('MarginVisible-update', self.update)
def destroy(self):
self.ignoreAll()
Nametag.destroy(self)
if self.textNodePath is not None:
self.textNodePath.removeNode()
self.textNodePath = None
if self.arrow is not None:
self.arrow.removeNode()
self.arrow = None
Clickable2d.destroy(self)
def getUniqueName(self):
return 'Nametag2d-' + str(id(self))
def getChatBalloonModel(self):
return NametagGlobals.chatBalloon2dModel
def getChatBalloonWidth(self):
return NametagGlobals.chatBalloon2dWidth
def getChatBalloonHeight(self):
return NametagGlobals.chatBalloon2dHeight
def setChatText(self, chatText):
self.actualChatText = chatText
Nametag.setChatText(self, chatText)
def updateClickRegion(self):
if self.chatBalloon is not None:
right = self.chatBalloon.width / 2.0
left = -right
top = self.chatBalloon.height / 2.0
bottom = -top
self.setClickRegionFrame(left, right, bottom, top)
self.region.setActive(True)
elif self.panel is not None:
centerX = (self.textNode.getLeft()+self.textNode.getRight()) / 2.0
centerY = (self.textNode.getBottom()+self.textNode.getTop()) / 2.0
left = centerX - (self.panelWidth/2.0)
right = centerX + (self.panelWidth/2.0)
bottom = centerY - (self.panelHeight/2.0)
top = centerY + (self.panelHeight/2.0)
self.setClickRegionFrame(left, right, bottom, top)
self.region.setActive(True)
else:
if self.region is not None:
self.region.setActive(False)
def isClickable(self):
if self.getChatText() and self.hasChatButton():
return True
return NametagGlobals.wantActiveNametags and Clickable2d.isClickable(self)
def setClickState(self, clickState):
if self.isClickable():
self.applyClickState(clickState)
else:
self.applyClickState(PGButton.SInactive)
Clickable2d.setClickState(self, clickState)
def enterDepressed(self):
if self.isClickable():
base.playSfx(NametagGlobals.clickSound)
def enterRollover(self):
if self.isClickable() and (self.lastClickState != PGButton.SDepressed):
base.playSfx(NametagGlobals.rolloverSound)
def update(self):
self.contents.node().removeAllChildren()
Nametag.update(self)
if self.cell is not None:
# We're in the margin display. Reposition our content, and update
# the click region:
self.reposition()
self.updateClickRegion()
else:
# We aren't in the margin display. Disable the click region if one
# is present:
if self.region is not None:
self.region.setActive(False)
def tick(self, task):
if (self.avatar is None) or self.avatar.isEmpty():
return Task.cont
if (self.cell is None) or (self.arrow is None):
return Task.cont
location = self.avatar.getPos(NametagGlobals.me)
rotation = NametagGlobals.me.getQuat(base.cam)
camSpacePos = rotation.xform(location)
arrowRadians = math.atan2(camSpacePos[0], camSpacePos[1])
arrowDegrees = (arrowRadians/math.pi) * 180
self.arrow.setR(arrowDegrees - 90)
return Task.cont
def drawChatBalloon(self, model, modelWidth, modelHeight):
if self.chatFont is None:
# We can't draw this without a font.
return
# Prefix the nametag text:
self.chatTextNode.setText(self.getText() + ': ' + self.actualChatText)
# Set our priority in the margin system:
self.setPriority(MarginGlobals.MP_normal)
if self.textNodePath is not None:
self.textNodePath.removeNode()
self.textNodePath = None
if self.arrow is not None:
self.arrow.removeNode()
self.arrow = None
if self.isClickable():
foreground, background = self.chatColor[self.clickState]
else:
foreground, background = self.chatColor[PGButton.SInactive]
if self.chatType == NametagGlobals.SPEEDCHAT:
background = self.speedChatColor
if background[3] > self.CHAT_BALLOON_ALPHA:
background = VBase4(
background[0], background[1], background[2],
self.CHAT_BALLOON_ALPHA)
self.chatBalloon = ChatBalloon(
model, modelWidth, modelHeight, self.chatTextNode,
foreground=foreground, background=background,
reversed=self.chatReversed,
button=self.chatButton[self.clickState])
self.chatBalloon.reparentTo(self.contents)
# Calculate the center of the TextNode:
left, right, bottom, top = self.chatTextNode.getFrameActual()
center = self.contents.getRelativePoint(
self.chatBalloon.textNodePath,
((left+right) / 2.0, 0, (bottom+top) / 2.0))
# Translate the chat balloon along the inverse:
self.chatBalloon.setPos(self.chatBalloon, -center)
def drawNametag(self):
# Set our priority in the margin system:
self.setPriority(MarginGlobals.MP_low)
if self.textNodePath is not None:
self.textNodePath.removeNode()
self.textNodePath = None
if self.arrow is not None:
self.arrow.removeNode()
self.arrow = None
if self.font is None:
# We can't draw this without a font.
return
# Attach the icon:
if self.icon is not None:
self.contents.attachNewNode(self.icon)
if self.isClickable():
foreground, background = self.nametagColor[self.clickState]
else:
foreground, background = self.nametagColor[PGButton.SInactive]
# Set the color of the TextNode:
self.textNode.setTextColor(foreground)
# Attach the TextNode:
self.textNodePath = self.contents.attachNewNode(self.textNode, 1)
self.textNodePath.setTransparency(foreground[3] < 1)
self.textNodePath.setAttrib(DepthWriteAttrib.make(0))
self.textNodePath.setY(self.TEXT_Y_OFFSET)
# Attach a panel behind the TextNode:
self.panel = NametagGlobals.cardModel.copyTo(self.contents, 0)
self.panel.setColor(background)
self.panel.setTransparency(background[3] < 1)
# Reposition the panel:
x = (self.textNode.getLeft()+self.textNode.getRight()) / 2.0
z = (self.textNode.getBottom()+self.textNode.getTop()) / 2.0
self.panel.setPos(x, 0, z)
# Resize the panel:
self.panelWidth = self.textNode.getWidth() + self.PANEL_X_PADDING
self.panelHeight = self.textNode.getHeight() + self.PANEL_Z_PADDING
self.panel.setScale(self.panelWidth, 1, self.panelHeight)
# Add an arrow:
self.arrow = NametagGlobals.arrowModel.copyTo(self.contents)
self.arrow.setZ(self.ARROW_OFFSET + self.textNode.getBottom())
self.arrow.setScale(self.ARROW_SCALE)
self.arrow.setColor(self.nametagColor[4] if len(self.nametagColor) >= 5 else self.nametagColor[0][0])
def marginVisibilityChanged(self):
if self.cell is not None:
# We're in the margin display. Reposition our content, and update
# the click region:
self.reposition()
self.updateClickRegion()
else:
# We aren't in the margin display. Disable the click region if one
# is present:
if self.region is not None:
self.region.setActive(False)
def reposition(self):
if self.contents is None:
return
origin = Point3()
self.contents.setPos(origin)
if self.chatBalloon is not None:
self.chatBalloon.removeNode()
self.chatBalloon = None
self.contents.node().removeAllChildren()
if (self.cell in base.leftCells) or (self.cell in base.rightCells):
text = self.getChatText().replace('\x01WLDisplay\x01', '').replace('\x02', '')
textWidth = self.chatTextNode.calcWidth(text)
if (textWidth / self.CHAT_TEXT_WORD_WRAP) > self.CHAT_TEXT_MAX_ROWS:
self.chatTextNode.setWordwrap(textWidth / (self.CHAT_TEXT_MAX_ROWS-0.5))
else:
self.chatTextNode.setWordwrap(self.CHAT_TEXT_WORD_WRAP)
model = self.getChatBalloonModel()
modelWidth = self.getChatBalloonWidth()
modelHeight = self.getChatBalloonHeight()
self.drawChatBalloon(model, modelWidth, modelHeight)
nodePath = self.chatBalloon.textNodePath
left, right, bottom, top = self.chatTextNode.getFrameActual()
left -= self.chatBalloon.BALLOON_X_PADDING
right += self.chatBalloon.BALLOON_X_PADDING
bottom -= self.chatBalloon.BALLOON_Z_PADDING
top += self.chatBalloon.BALLOON_Z_PADDING
elif self.panel is not None:
nodePath = self.textNodePath
left, right, bottom, top = self.textNode.getFrameActual()
left -= self.PANEL_X_PADDING
right += self.PANEL_X_PADDING
bottom -= self.PANEL_Z_PADDING
top += self.PANEL_Z_PADDING
# Compensate for the arrow:
bottom -= self.ARROW_SCALE
else:
return
if self.cell in base.bottomCells:
# Move the origin to the bottom center of the node path:
origin = self.contents.getRelativePoint(
nodePath, ((left+right) / 2.0, 0, bottom))
elif self.cell in base.leftCells:
# Move the origin to the left center of the node path:
origin = self.contents.getRelativePoint(
nodePath, (left, 0, (bottom+top) / 2.0))
elif self.cell in base.rightCells:
# Move the origin to the right center of the node path:
origin = self.contents.getRelativePoint(
nodePath, (right, 0, (bottom+top) / 2.0))
self.contents.setPos(self.contents, -origin)

View file

@ -1,185 +0,0 @@
from direct.task.Task import Task
import math
from panda3d.core import BillboardEffect, Vec3, Point3, PGButton, VBase4
from panda3d.core import DepthWriteAttrib
from direct.interval.IntervalGlobal import *
from toontown.chat.ChatBalloon import ChatBalloon
from toontown.nametag import NametagGlobals
from toontown.nametag.Nametag import Nametag
from toontown.toontowngui.Clickable3d import Clickable3d
class Nametag3d(Nametag, Clickable3d):
MAX_SCALE = 2.5
SCALING_FACTOR = 0.065
SCALING_MIN_DISTANCE = 1
SCALING_MAX_DISTANCE = math.pow(MAX_SCALE / SCALING_FACTOR, 2)
def __init__(self):
Nametag.__init__(self)
Clickable3d.__init__(self, 'Nametag3d')
self.distance = 0
self.billboardOffset = 3
self.doBillboardEffect()
def destroy(self):
self.ignoreAll()
Nametag.destroy(self)
Clickable3d.destroy(self)
def getUniqueName(self):
return 'Nametag3d-' + str(id(self))
def getChatBalloonModel(self):
return NametagGlobals.chatBalloon3dModel
def getChatBalloonWidth(self):
return NametagGlobals.chatBalloon3dWidth
def getChatBalloonHeight(self):
return NametagGlobals.chatBalloon3dHeight
def setBillboardOffset(self, billboardOffset):
self.billboardOffset = billboardOffset
self.doBillboardEffect()
def getBillboardOffset(self):
return self.billboardOffset
def doBillboardEffect(self):
billboardEffect = BillboardEffect.make(
Vec3(0, 0, 1), True, False, self.billboardOffset, base.cam,
Point3(0, 0, 0))
self.contents.setEffect(billboardEffect)
def updateClickRegion(self):
if self.chatBalloon is not None:
left = self.chatBalloon.center[0] - (self.chatBalloon.width/2)
right = left + self.chatBalloon.width
# Calculate the bottom of the region based on constants.
# 2.4 is the padded height of a single-line message:
bottom = NametagGlobals.chatBalloon3dHeight - 2.4
top = bottom + self.chatBalloon.height
self.setClickRegionFrame(left, right, bottom, top)
elif self.panel is not None:
centerX = (self.textNode.getLeft()+self.textNode.getRight()) / 2.0
centerY = (self.textNode.getBottom()+self.textNode.getTop()) / 2.0
left = centerX - (self.panelWidth/2.0)
right = centerX + (self.panelWidth/2.0)
bottom = centerY - (self.panelHeight/2.0)
top = centerY + (self.panelHeight/2.0)
self.setClickRegionFrame(left, right, bottom, top)
def isClickable(self):
if self.getChatText() and self.hasChatButton():
return True
return NametagGlobals.wantActiveNametags and Clickable3d.isClickable(self)
def setClickState(self, clickState):
if self.isClickable():
self.applyClickState(clickState)
else:
self.applyClickState(PGButton.SInactive)
Clickable3d.setClickState(self, clickState)
def enterDepressed(self):
if self.isClickable():
base.playSfx(NametagGlobals.clickSound)
def enterRollover(self):
if self.isClickable() and (self.lastClickState != PGButton.SDepressed):
base.playSfx(NametagGlobals.rolloverSound)
def removeContents(self):
if self.contents:
self.contents.node().removeAllChildren()
def update(self):
self.removeContents()
Nametag.update(self)
def tick(self, task):
distance = self.contents.getPos(base.cam).length()
if distance < self.SCALING_MIN_DISTANCE:
distance = self.SCALING_MIN_DISTANCE
elif distance > self.SCALING_MAX_DISTANCE:
distance = self.SCALING_MAX_DISTANCE
if distance != self.distance:
self.contents.setScale(math.sqrt(distance) * self.SCALING_FACTOR)
self.distance = distance
self.updateClickRegion()
return Task.cont
def drawChatBalloon(self, model, modelWidth, modelHeight):
if self.chatFont is None:
# We can't draw this without a font.
return
if self.isClickable():
foreground, background = self.chatColor[self.clickState]
else:
foreground, background = self.chatColor[PGButton.SInactive]
if self.chatType == NametagGlobals.SPEEDCHAT:
background = self.speedChatColor
if background[3] > self.CHAT_BALLOON_ALPHA:
background = VBase4(
background[0], background[1], background[2],
self.CHAT_BALLOON_ALPHA)
self.chatBalloon = ChatBalloon(
model, modelWidth, modelHeight, self.chatTextNode,
foreground=foreground, background=background,
reversed=self.chatReversed,
button=self.chatButton[self.clickState])
self.chatBalloon.reparentTo(self.contents)
scaleLerp = Sequence(LerpScaleInterval(self.chatBalloon, 0.2, VBase3(1, 1, 1), VBase3(0, 0, 0), blendType='easeInOut'))
scaleLerp.start()
def drawNametag(self):
if self.font is None:
# We can't draw this without a font.
return
# Attach the icon:
if self.icon is not None:
self.contents.attachNewNode(self.icon)
if self.isClickable():
foreground, background = self.nametagColor[self.clickState]
else:
foreground, background = self.nametagColor[PGButton.SInactive]
# Set the color of the TextNode:
self.textNode.setTextColor(foreground)
# Attach the TextNode:
textNodePath = self.contents.attachNewNode(self.textNode, 1)
textNodePath.setTransparency(foreground[3] < 1)
textNodePath.setAttrib(DepthWriteAttrib.make(0))
textNodePath.setY(self.TEXT_Y_OFFSET)
# Attach a panel behind the TextNode:
self.panel = NametagGlobals.cardModel.copyTo(self.contents, 0)
self.panel.setColor(background)
self.panel.setTransparency(background[3] < 1)
# Reposition the panel:
x = (self.textNode.getLeft()+self.textNode.getRight()) / 2.0
z = (self.textNode.getBottom()+self.textNode.getTop()) / 2.0
self.panel.setPos(x, 0, z)
# Resize the panel:
self.panelWidth = self.textNode.getWidth() + self.PANEL_X_PADDING
self.panelHeight = self.textNode.getHeight() + self.PANEL_Z_PADDING
self.panel.setScale(self.panelWidth, 1, self.panelHeight)

Some files were not shown because too many files have changed in this diff Show more