This commit is contained in:
John 2015-07-18 02:28:36 +03:00
parent 0be23c6abe
commit 95f67faab5
10 changed files with 11 additions and 238 deletions

View file

@ -27,24 +27,15 @@ def reconsiderAllUnderstandable():
for av in Avatar.ActiveAvatars:
av.considerUnderstandable()
class Avatar(Actor, ShadowCaster):
notify = directNotify.newCategory('Avatar')
ActiveAvatars = []
ManagesNametagAmbientLightChanged = False
def __init__(self, other = None):
self.name = ''
try:
self.Avatar_initialized
return
except:
self.Avatar_initialized = 1
Actor.__init__(self, None, None, other, flattenable=0, setFinal=1)
ShadowCaster.__init__(self)
self.__font = OTPGlobals.getInterfaceFont()
self.__speechFont = OTPGlobals.getInterfaceFont()
self.name = ''
self.soundChatBubble = None
self.avatarType = ''
self.nametagNodePath = None
@ -59,18 +50,11 @@ class Avatar(Actor, ShadowCaster):
self.nametag3d = self.attachNewNode('nametag3d')
self.nametag3d.setTag('cam', 'nametag')
self.nametag3d.setLightOff()
if self.ManagesNametagAmbientLightChanged:
self.acceptNametagAmbientLightChange()
OTPRender.renderReflection(False, self.nametag3d, 'otp_avatar_nametag', None)
self.getGeomNode().showThrough(OTPRender.ShadowCameraBitmask)
self.nametag3d.hide(OTPRender.ShadowCameraBitmask)
self.collTube = None
self.battleTube = None
self.scale = 1.0
self.nametagScale = 1.0
self.height = 0.0
self.battleTubeHeight = 0.0
self.battleTubeRadius = 0.0
self.style = None
self.understandable = 1
self.setPlayerType(NametagGroup.CCNormal)
@ -91,11 +75,8 @@ class Avatar(Actor, ShadowCaster):
except:
self.deleteNametag3d()
Actor.cleanup(self)
if self.ManagesNametagAmbientLightChanged:
self.ignoreNametagAmbientLightChange()
self.Avatar_deleted = 1
del self.__font
del self.__speechFont
del self.style
del self.soundChatBubble
self.nametag.destroy()
@ -104,12 +85,6 @@ class Avatar(Actor, ShadowCaster):
ShadowCaster.delete(self)
Actor.delete(self)
def acceptNametagAmbientLightChange(self):
self.accept('nametagAmbientLightChanged', self.nametagAmbientLightChanged)
def ignoreNametagAmbientLightChange(self):
self.ignore('nametagAmbientLightChanged')
def isLocal(self):
return 0
@ -177,13 +152,6 @@ class Avatar(Actor, ShadowCaster):
self.getGeomNode().setScale(scale)
self.setHeight(self.height)
def getNametagScale(self):
return self.nametagScale
def setNametagScale(self, scale):
self.nametagScale = scale
self.nametag3d.setScale(scale)
def adjustNametag3d(self, parentScale = 1.0):
self.nametag3d.setPos(0, 0, self.height + 0.5)
@ -197,8 +165,6 @@ class Avatar(Actor, ShadowCaster):
self.collTube.setPointB(0, 0, height - self.getRadius())
if self.collNodePath:
self.collNodePath.forceRecomputeBounds()
if self.battleTube:
self.battleTube.setPointB(0, 0, height - self.getRadius())
def getRadius(self):
return OTPGlobals.AvatarDefaultRadius
@ -245,13 +211,6 @@ class Avatar(Actor, ShadowCaster):
self.__font = font
self.nametag.setFont(font)
def getSpeechFont(self):
return self.__speechFont
def setSpeechFont(self, font):
self.__speechFont = font
self.nametag.setSpeechFont(font)
def getStyle(self):
return self.style
@ -349,9 +308,6 @@ class Avatar(Actor, ShadowCaster):
self.nametag.setChat(chatString, chatFlags)
self.playCurrentDialogue(dialogue, chatFlags, interrupt)
def setChatMuted(self, chatString, chatFlags, dialogue = None, interrupt = 1, quiet = 0):
pass
def displayTalk(self, chatString):
if not base.localAvatar.isIgnored(self.doId):
self.clearChat()
@ -364,11 +320,6 @@ class Avatar(Actor, ShadowCaster):
def clearChat(self):
self.nametag.clearChat()
def isInView(self):
pos = self.getPos(camera)
eyePos = Point3(pos[0], pos[1], pos[2] + self.getHeight())
return base.camNode.isInView(eyePos)
def getNameVisible(self):
return self.__nameVisible
@ -539,11 +490,6 @@ class Avatar(Actor, ShadowCaster):
cJoint.clearNetTransforms()
cJoint.addNetTransform(nametagNode)
def nametagAmbientLightChanged(self, newlight):
self.nametag3d.setLightOff()
if newlight:
self.nametag3d.setLight(newlight)
def deleteNametag3d(self):
if self.nametagNodePath:
self.nametagNodePath.removeNode()
@ -615,10 +561,5 @@ def target():
Returns the current Spellbook target.
"""
target = spellbook.getTarget()
print 'Called target.'
print 'Name: ' + target.getName()
doId = str(int(target.doId))
print 'doId: ', doId
accessLevel = str(int(target.getAdminAccess()))
print 'Access Level: ', accessLevel
return 'Target: %s-%d [%d]' % (target.getName(), int(target.doId), int(target.getAdminAccess()))
return 'Target: %s-%d [%d]' % (target.getName(), int(target.doId), int(target.getAdminAccess()))

View file

@ -7,7 +7,6 @@ import OTPGlobals, OTPRender, math
class OTPBase(ShowBase):
def __init__(self, windowType = None):
self.wantEnviroDR = False
ShowBase.__init__(self, windowType=windowType)
self.idTags = config.GetBool('want-id-tags', 0)
if not self.idTags:
@ -15,9 +14,6 @@ class OTPBase(ShowBase):
self.wantNametags = self.config.GetBool('want-nametags', 1)
self.wantDynamicShadows = 1
self.stereoEnabled = False
self.enviroDR = None
self.enviroCam = None
self.pixelZoomSetup = False
self.whiteList = None
if config.GetBool('want-whitelist', True):
@ -27,159 +23,12 @@ class OTPBase(ShowBase):
if config.GetBool('want-sequence-list', True):
self.whiteList.setSequenceList(SequenceListData.SEQUENCES)
if base.cam:
if self.wantEnviroDR:
base.cam.node().setCameraMask(OTPRender.MainCameraBitmask)
else:
base.cam.node().setCameraMask(OTPRender.MainCameraBitmask | OTPRender.EnviroCameraBitmask)
taskMgr.setupTaskChain('net')
def setTaskChainNetThreaded(self):
if base.config.GetBool('want-threaded-network', 0):
taskMgr.setupTaskChain('net', numThreads=1, frameBudget=0.001, threadPriority=TPLow)
def setTaskChainNetNonthreaded(self):
taskMgr.setupTaskChain('net', numThreads=0, frameBudget=-1)
def toggleStereo(self):
self.stereoEnabled = not self.stereoEnabled
if self.stereoEnabled:
if not base.win.isStereo():
base.win.setRedBlueStereo(True, ColorWriteAttrib.CRed, ColorWriteAttrib.CGreen | ColorWriteAttrib.CBlue)
if self.wantEnviroDR:
self.setupEnviroCamera()
return
mainDR = base.camNode.getDisplayRegion(0)
if self.stereoEnabled:
if not mainDR.isStereo():
base.win.removeDisplayRegion(mainDR)
mainDR = base.win.makeStereoDisplayRegion()
mainDR.getRightEye().setClearDepthActive(True)
mainDR.setCamera(base.cam)
elif mainDR.isStereo():
base.win.removeDisplayRegion(mainDR)
mainDR = base.win.makeMonoDisplayRegion()
mainDR.setCamera(base.cam)
def setupEnviroCamera(self):
clearColor = VBase4(0, 0, 0, 1)
if self.enviroDR:
clearColor = self.enviroDR.getClearColor()
self.win.removeDisplayRegion(self.enviroDR)
if not self.enviroCam:
self.enviroCam = self.cam.attachNewNode(Camera('enviroCam'))
mainDR = self.camNode.getDisplayRegion(0)
if self.stereoEnabled:
self.enviroDR = self.win.makeStereoDisplayRegion()
if not mainDR.isStereo():
self.win.removeDisplayRegion(mainDR)
mainDR = self.win.makeStereoDisplayRegion()
mainDR.setCamera(self.cam)
ml = mainDR.getLeftEye()
mr = mainDR.getRightEye()
el = self.enviroDR.getLeftEye()
er = self.enviroDR.getRightEye()
el.setSort(-8)
ml.setSort(-6)
er.setSort(-4)
er.setClearDepthActive(True)
mr.setSort(-2)
mr.setClearDepthActive(False)
else:
self.enviroDR = self.win.makeMonoDisplayRegion()
if mainDR.isStereo():
self.win.removeDisplayRegion(mainDR)
mainDR = self.win.makeMonoDisplayRegion()
mainDR.setCamera(self.cam)
self.enviroDR.setSort(-10)
self.enviroDR.setClearColor(clearColor)
self.win.setClearColor(clearColor)
self.enviroDR.setCamera(self.enviroCam)
self.enviroCamNode = self.enviroCam.node()
self.enviroCamNode.setLens(self.cam.node().getLens())
self.enviroCamNode.setCameraMask(OTPRender.EnviroCameraBitmask)
render.hide(OTPRender.EnviroCameraBitmask)
self.camList.append(self.enviroCam)
self.backgroundDrawable = self.enviroDR
self.enviroDR.setTextureReloadPriority(-10)
if self.pixelZoomSetup:
self.setupAutoPixelZoom()
def setupAutoPixelZoom(self):
self.win.setPixelZoom(1)
self.enviroDR.setPixelZoom(1)
if not self.stereoEnabled:
self.enviroDR.setClearColorActive(True)
self.enviroDR.setClearDepthActive(True)
self.win.setClearColorActive(False)
self.win.setClearDepthActive(False)
self.backgroundDrawable = self.enviroDR
else:
self.enviroDR.setClearColorActive(False)
self.enviroDR.setClearDepthActive(False)
self.enviroDR.getRightEye().setClearDepthActive(True)
self.win.setClearColorActive(True)
self.win.setClearDepthActive(True)
self.backgroundDrawable = self.win
self.pixelZoomSetup = True
self.targetPixelZoom = 1.0
self.pixelZoomTask = None
self.pixelZoomCamHistory = 2.0
self.pixelZoomCamMovedList = []
self.pixelZoomStarted = None
flag = self.config.GetBool('enable-pixel-zoom', True)
self.enablePixelZoom(flag)
return
def enablePixelZoom(self, flag):
if not self.backgroundDrawable.supportsPixelZoom():
flag = False
self.pixelZoomEnabled = flag
taskMgr.remove('chasePixelZoom')
if flag:
taskMgr.add(self.__chasePixelZoom, 'chasePixelZoom', priority=-52)
else:
self.backgroundDrawable.setPixelZoom(1)
def __chasePixelZoom(self, task):
now = globalClock.getFrameTime()
pos = base.cam.getNetTransform().getPos()
prevPos = base.cam.getNetPrevTransform().getPos()
d2 = (pos - prevPos).lengthSquared()
if d2:
d = math.sqrt(d2)
self.pixelZoomCamMovedList.append((now, d))
while self.pixelZoomCamMovedList and self.pixelZoomCamMovedList[0][0] < now - self.pixelZoomCamHistory:
del self.pixelZoomCamMovedList[0]
dist = sum(map(lambda pair: pair[1], self.pixelZoomCamMovedList))
speed = dist / self.pixelZoomCamHistory
if speed < 5:
self.backgroundDrawable.setPixelZoom(4)
self.pixelZoomStart = None
elif speed > 10:
if self.pixelZoomStart == None:
self.pixelZoomStart = now
elapsed = now - self.pixelZoomStart
if elapsed > 10:
self.backgroundDrawable.setPixelZoom(16)
elif elapsed > 5:
self.backgroundDrawable.setPixelZoom(8)
return task.cont
def getShardPopLimits(self):
return (100, 200, -1)
base.cam.node().setCameraMask(OTPRender.MainCameraBitmask)
taskMgr.setupTaskChain('net', numThreads=1, frameBudget=0.001, threadPriority=TPLow)
def getRepository(self):
return self.cr
def openMainWindow(self, *args, **kw):
result = ShowBase.openMainWindow(self, *args, **kw)
if result:
self.wantEnviroDR = not self.win.getGsg().isHardware() or config.GetBool('want-background-region', 1)
self.backgroundDrawable = self.win
return result
def run(self):
try:
taskMgr.run()

View file

@ -621,7 +621,7 @@ SuitFaceoffTaunts = {'b': ['Do you have a donation for me?',
'Would you like some hand-me-downs?',
'Let me show you some of my handiwork.',
'I think the handwriting is on the wall.',
"I'll gladly handle your gags for you"],
"I'll gladly handle your gags for you."],
'sc': ['I will make short work of you.',
"You're about to have money trouble.",
"You're about to be overcharged.",

View file

@ -4,7 +4,6 @@ ReflectionCameraBitmask = BitMask32.bit(1)
ShadowCameraBitmask = BitMask32.bit(2)
SkyReflectionCameraBitmask = BitMask32.bit(3)
GlowCameraBitmask = BitMask32.bit(4)
EnviroCameraBitmask = BitMask32.bit(5)
def setCameraBitmask(default, node_path, camera_bitmask, tag = None, tag_function = None, context = None):
if node_path:

View file

@ -110,8 +110,6 @@ class TTCodeRedemptionMgrAI(DistributedObjectAI):
self.air.writeServerEvent('suspicious', avId, 'Toon tried to redeem non-existent code %s' % code)
def requestCodeRedeem(self, avId, av, items):
count = self.getMailboxCount(items)
if len(av.mailboxContents) + len(av.onOrder) + len(av.onGiftOrder) + len(items) >= ToontownGlobals.MaxMailboxContents:
self.sendUpdateToAvatarId(avId, 'redeemCodeResult', [3])
return

View file

@ -34,7 +34,7 @@ class BossCog(Avatar.Avatar):
def __init__(self):
Avatar.Avatar.__init__(self)
self.setFont(ToontownGlobals.getSuitFont())
self.setSpeechFont(ToontownGlobals.getSuitFont())
self.nametag.setSpeechFont(ToontownGlobals.getSuitFont())
self.setPlayerType(NametagGroup.CCSuit)
self.setPickable(0)
self.doorA = None

View file

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

View file

@ -2056,10 +2056,6 @@ class DistributedToon(DistributedPlayer.DistributedPlayer, Toon.Toon, Distribute
def setChatAbsolute(self, chatString, chatFlags, dialogue = None, interrupt = 1, quiet = 0):
DistributedAvatar.DistributedAvatar.setChatAbsolute(self, chatString, chatFlags, dialogue, interrupt)
def setChatMuted(self, chatString, chatFlags, dialogue=None, interrupt=1, quiet=0):
self.nametag.setChat(chatString, chatFlags)
self.playCurrentDialogue(dialogue, chatFlags - CFSpeech, interrupt)
def displayTalk(self, chatString):
flags = CFSpeech | CFTimeout
if ChatUtil.isThought(chatString):

View file

@ -453,7 +453,7 @@ class Toon(Avatar.Avatar, ToonHead):
self.partyHat = None
self.setTag('pieCode', str(ToontownGlobals.PieCodeToon))
self.setFont(ToontownGlobals.getToonFont())
self.setSpeechFont(ToontownGlobals.getToonFont())
self.nametag.setSpeechFont(ToontownGlobals.getToonFont())
self.soundChatBubble = base.loadSfx('phase_3/audio/sfx/GUI_balloon_popup.ogg')
self.swimRunSfx = base.loadSfx('phase_4/audio/sfx/AV_footstep_runloop_water.ogg')
self.swimRunLooping = False
@ -2748,7 +2748,7 @@ class Toon(Avatar.Avatar, ToonHead):
self.suit.loop('neutral')
self.isDisguised = 1
self.setFont(ToontownGlobals.getSuitFont())
self.setSpeechFont(ToontownGlobals.getSuitFont())
self.nametag.setSpeechFont(ToontownGlobals.getSuitFont())
if setDisplayName:
if hasattr(base, 'idTags') and base.idTags:
name = self.getAvIdName()
@ -2782,7 +2782,7 @@ class Toon(Avatar.Avatar, ToonHead):
Emote.globalEmote.releaseAll(self)
self.isDisguised = 0
self.setFont(ToontownGlobals.getToonFont())
self.setSpeechFont(ToontownGlobals.getToonFont())
self.nametag.setSpeechFont(ToontownGlobals.getToonFont())
self.nametag.setWordwrap(None)
if hasattr(base, 'idTags') and base.idTags:
name = self.getAvIdName()

View file

@ -147,9 +147,6 @@ class ToonBase(OTPBase.OTPBase):
self.setCursorAndIcon()
return result
def windowEvent(self, win):
OTPBase.OTPBase.windowEvent(self, win)
def setCursorAndIcon(self):
tempdir = tempfile.mkdtemp()
atexit.register(shutil.rmtree, tempdir)
@ -419,13 +416,6 @@ class ToonBase(OTPBase.OTPBase):
self.cr.sendDisconnect()
sys.exit()
def getShardPopLimits(self):
return (
config.GetInt('shard-low-pop', ToontownGlobals.LOW_POP),
config.GetInt('shard-mid-pop', ToontownGlobals.MID_POP),
config.GetInt('shard-high-pop', ToontownGlobals.HIGH_POP)
)
def playMusic(self, music, looping = 0, interrupt = 1, volume = None, time = 0.0):
OTPBase.OTPBase.playMusic(self, music, looping, interrupt, volume, time)