From 0412683301a7e6f75d08a7658da1c71b74409e48 Mon Sep 17 00:00:00 2001 From: Loudrob Date: Thu, 11 Jun 2015 08:35:04 -0400 Subject: [PATCH] Revert "Bye street signs" This reverts commit 64322c9768a9b0811ff91ccbde6bdfd1a7e050be. --- .../distributed/ToontownClientRepository.py | 12 +++- toontown/hood/StreetSign.py | 66 +++++++++++++++++++ toontown/town/Street.py | 32 ++++++++- 3 files changed, 108 insertions(+), 2 deletions(-) create mode 100644 toontown/hood/StreetSign.py diff --git a/toontown/distributed/ToontownClientRepository.py b/toontown/distributed/ToontownClientRepository.py index 92af1277..ba5b76f0 100755 --- a/toontown/distributed/ToontownClientRepository.py +++ b/toontown/distributed/ToontownClientRepository.py @@ -1,3 +1,5 @@ +import types +import time from direct.distributed.ClockDelta import * from direct.gui.DirectGui import * from pandac.PandaModules import * @@ -40,7 +42,11 @@ from toontown.makeatoon import TTPickANamePattern from toontown.parties import ToontownTimeManager from toontown.toon import Toon, DistributedToon from ToontownMsgTypes import * -import types, time, random, HoodMgr, PlayGame +import HoodMgr +import PlayGame +from toontown.hood import StreetSign +import random + class ToontownClientRepository(OTPClientRepository.OTPClientRepository): SupportTutorial = 1 @@ -69,6 +75,7 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): self.tutorialManager = None self.welcomeValleyManager = None self.newsManager = None + self.streetSign = None self.distributedDistrict = None self.partyManager = None self.lobbyManager = None @@ -80,6 +87,7 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): self.argManager = self.generateGlobalObject(OtpDoGlobals.OTP_DO_ID_TTS_ARG_MANAGER, 'ARGManager') + self.streetSign = None self.furnitureManager = None self.objectManager = None self.openAvatarPanels = set() @@ -402,6 +410,8 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): base.localAvatar.defaultZone, -1]) self._userLoggingOut = False + if not self.streetSign: + self.streetSign = StreetSign.StreetSign() return def exitPlayingGame(self): diff --git a/toontown/hood/StreetSign.py b/toontown/hood/StreetSign.py new file mode 100644 index 00000000..b37cb616 --- /dev/null +++ b/toontown/hood/StreetSign.py @@ -0,0 +1,66 @@ +import os +import shutil +import datetime +from pandac.PandaModules import * +from direct.directnotify import DirectNotifyGlobal +from direct.distributed import DistributedObject +from direct.showbase import AppRunnerGlobal +from toontown.toonbase import TTLocalizer + +class StreetSign(DistributedObject.DistributedObject): + RedownloadTaskName = 'RedownloadStreetSign' + StreetSignFileName = config.GetString('street-sign-filename', 'texture.jpg') + StreetSignBaseDir = config.GetString('street-sign-base-dir', 'sign') + StreetSignUrl = base.config.GetString('street-sign-url', 'http://cdn.toontown.disney.go.com/toontown/en/street-signs/img/') + notify = DirectNotifyGlobal.directNotify.newCategory('StreetSign') + + def __init__(self): + self.downloadingStreetSign = False + self.percentDownloaded = 0.0 + self.startDownload = datetime.datetime.now() + self.endDownload = datetime.datetime.now() + self.notify.info('Street sign url is %s' % self.StreetSignUrl) + #self.redownloadStreetSign() + + def replaceTexture(self): + searchPath = DSearchPath() + searchPath.appendDirectory(self.directory) + + def redownloadStreetSign(self): + self.precentDownload = 0.0 + self.startRedownload = datetime.datetime.now() + self.downloadingStreetSign = True + Filename(self.StreetSignBaseDir + '/.').makeDir() + http = HTTPClient.getGlobalPtr() + self.url = self.StreetSignUrl + self.StreetSignFileName + self.ch = http.makeChannel(True) + localFilename = Filename(self.StreetSignBaseDir, self.StreetSignFileName) + self.ch.getHeader(DocumentSpec(self.url)) + size = self.ch.getFileSize() + doc = self.ch.getDocumentSpec() + localSize = localFilename.getFileSize() + outOfDate = True + if size == localSize: + if doc.hasDate(): + date = doc.getDate() + localDate = HTTPDate(localFilename.getTimestamp()) + if localDate.compareTo(date) > 0: + outOfDate = False + self.notify.info('Street Sign is up to date') + if outOfDate and self.ch.isValid(): + self.ch.beginGetDocument(doc) + self.ch.downloadToFile(localFilename) + taskMgr.add(self.downloadStreetSignTask, self.RedownloadTaskName) + + def downloadStreetSignTask(self, task): + if self.ch.run(): + return task.cont + doc = self.ch.getDocumentSpec() + date = '' + if doc.hasDate(): + date = doc.getDate().getString() + if not self.ch.isValid(): + self.redownloadingStreetSign = False + return task.done + self.notify.info('Down downloading street sign') + return task.done diff --git a/toontown/town/Street.py b/toontown/town/Street.py index de080620..18fc9759 100755 --- a/toontown/town/Street.py +++ b/toontown/town/Street.py @@ -134,6 +134,7 @@ class Street(BattlePlace.BattlePlace): self.enterZone(requestStatus['zoneId']) self.tunnelOriginList = base.cr.hoodMgr.addLinkTunnelHooks(self, self.loader.nodeList, self.zoneId) self.fsm.request(requestStatus['how'], [requestStatus]) + self.replaceStreetSignTextures() return def exit(self, visibilityFlag = 1): @@ -367,4 +368,33 @@ class Street(BattlePlace.BattlePlace): self.halloweenLights += geom.findAllMatches('**/*lamp*') self.halloweenLights += geom.findAllMatches('**/prop_snow_tree*') for light in self.halloweenLights: - light.setColorScaleOff(1) \ No newline at end of file + light.setColorScaleOff(1) + + return + + def replaceStreetSignTextures(self): + if not hasattr(base.cr, 'playGame'): + return + place = base.cr.playGame.getPlace() + if place is None: + return + geom = base.cr.playGame.getPlace().loader.geom + signs = geom.findAllMatches('**/*tunnelAheadSign*;+s') + if signs.getNumPaths() > 0: + streetSign = base.cr.streetSign + signTexturePath = streetSign.StreetSignBaseDir + '/' + streetSign.StreetSignFileName + loaderTexturePath = Filename(str(signTexturePath)) + alphaPath = 'phase_4/maps/tt_t_ara_gen_tunnelAheadSign_a.rgb' + inDreamland = False + if place.zoneId and ZoneUtil.getCanonicalHoodId(place.zoneId) == ToontownGlobals.DonaldsDreamland: + inDreamland = True + alphaPath = 'phase_4/maps/tt_t_ara_gen_tunnelAheadSign_a.rgb' + if Filename(signTexturePath).exists(): + signTexture = loader.loadTexture(loaderTexturePath, alphaPath) + for sign in signs: + if Filename(signTexturePath).exists(): + sign.setTexture(signTexture, 1) + if inDreamland: + sign.setColorScale(0.525, 0.525, 0.525, 1) + + return \ No newline at end of file