diff --git a/astron/dclass/toon.dc b/astron/dclass/toon.dc index 9f3ba334..dd56cea7 100644 --- a/astron/dclass/toon.dc +++ b/astron/dclass/toon.dc @@ -287,7 +287,6 @@ from toontown.uberdog.DistributedMailManager/AI/UD import DistributedMailManager from toontown.uberdog.DistributedPartyManager/AI/UD import DistributedPartyManager/AI/UD from toontown.rpc.AwardManager/UD import AwardManager/UD from toontown.uberdog.DistributedCpuInfoMgr/AI/UD import DistributedCpuInfoMgr/AI/UD -from toontown.uberdog.DistributedInGameNewsMgr/AI/UD import DistributedInGameNewsMgr/AI/UD from toontown.coderedemption.TTCodeRedemptionMgr/AI import TTCodeRedemptionMgr/AI from toontown.distributed.NonRepeatableRandomSourceAI import NonRepeatableRandomSourceAI from toontown.distributed.NonRepeatableRandomSourceUD import NonRepeatableRandomSourceUD @@ -3277,12 +3276,6 @@ dclass NonRepeatableRandomSource : DistributedObject, NonRepeatableRandomSourceC randomSampleAck() airecv; }; -dclass DistributedInGameNewsMgr : DistributedObjectGlobal { - setLatestIssueStr(string) required broadcast ram; - inGameNewsMgrAIStartingUp(uint32, uint32); - newIssueUDtoAI(string) airecv; -}; - struct Friend { uint32 doId; diff --git a/otp/distributed/DCClassImports.py b/otp/distributed/DCClassImports.py index 4b26b95b..5e0e26e6 100644 --- a/otp/distributed/DCClassImports.py +++ b/otp/distributed/DCClassImports.py @@ -2,7 +2,7 @@ from pandac.PandaModules import * -hashVal = 2798365763L +hashVal = 1610389195 from toontown.coghq import DistributedCashbotBossSafe, DistributedCashbotBossCrane, DistributedBattleFactory, DistributedCashbotBossTreasure, DistributedCogHQDoor, DistributedSellbotHQDoor, DistributedFactoryElevatorExt, DistributedMintElevatorExt, DistributedLawOfficeElevatorExt, DistributedLawOfficeElevatorInt, LobbyManager, DistributedMegaCorp, DistributedFactory, DistributedLawOffice, DistributedLawOfficeFloor, DistributedLift, DistributedDoorEntity, DistributedSwitch, DistributedButton, DistributedTrigger, DistributedCrushableEntity, DistributedCrusherEntity, DistributedStomper, DistributedStomperPair, DistributedLaserField, DistributedGolfGreenGame, DistributedSecurityCamera, DistributedMover, DistributedElevatorMarker, DistributedBarrelBase, DistributedGagBarrel, DistributedBeanBarrel, DistributedHealBarrel, DistributedGrid, ActiveCell, DirectionalCell, CrusherCell, DistributedCrate, DistributedSinkingPlatform, BattleBlocker, DistributedMint, DistributedMintRoom, DistributedMintBattle, DistributedStage, DistributedStageRoom, DistributedStageBattle, DistributedLawbotBossGavel, DistributedLawbotCannon, DistributedLawbotChair, DistributedCogKart, DistributedCountryClub, DistributedCountryClubRoom, DistributedMoleField, DistributedCountryClubBattle, DistributedMaze, DistributedFoodBelt, DistributedBanquetTable, DistributedGolfSpot @@ -37,7 +37,6 @@ from toontown.catalog import CatalogManager, AccountDate from toontown.ai.DistributedHydrantZeroMgr import DistributedHydrantZeroMgr from toontown.rpc.AwardManager import AwardManager from toontown.parties import DistributedParty, DistributedPartyActivity, DistributedPartyTeamActivity, DistributedPartyCannon, DistributedPartyCannonActivity, DistributedPartyCatchActivity, DistributedPartyWinterCatchActivity, DistributedPartyCogActivity, DistributedPartyWinterCogActivity, DistributedPartyFireworksActivity, DistributedPartyDanceActivityBase, DistributedPartyDanceActivity, DistributedPartyDance20Activity, DistributedPartyValentineDanceActivity, DistributedPartyValentineDance20Activity, DistributedPartyTrampolineActivity, DistributedPartyValentineTrampolineActivity, DistributedPartyVictoryTrampolineActivity, DistributedPartyWinterTrampolineActivity, DistributedPartyTugOfWarActivity, DistributedPartyJukeboxActivityBase, DistributedPartyJukeboxActivity, DistributedPartyJukebox40Activity, DistributedPartyValentineJukeboxActivity, DistributedPartyValentineJukebox40Activity -from toontown.uberdog.DistributedInGameNewsMgr import DistributedInGameNewsMgr from toontown.coghq.InGameEditorDCImports import * from toontown.friends import TTPlayerFriendsManager, TTUFriendsManager from toontown.cogdominium import DistributedCogdoInterior, DistributedCogdoBattleBldg, DistributedCogdoElevatorExt, DistributedCogdoElevatorInt, DistributedCogdoBarrel, DistCogdoGame, DistCogdoLevelGame, DistCogdoBoardroomGame, DistCogdoCraneGame, DistCogdoMazeGame, DistCogdoFlyingGame, DistCogdoCrane, DistCogdoCraneMoneyBag, DistCogdoCraneCog diff --git a/otp/distributed/OTPClientRepository.py b/otp/distributed/OTPClientRepository.py index 9e9a17d8..80c2fcde 100644 --- a/otp/distributed/OTPClientRepository.py +++ b/otp/distributed/OTPClientRepository.py @@ -1170,7 +1170,6 @@ class OTPClientRepository(ClientRepositoryBase): jobMgr.TaskName, self.GarbageCollectTaskName, 'garbageCollectStates', - 'RedownloadNewsTask', TelemetryLimiter.TaskName] if extraTasks is not None: allowedTasks.extend(extraTasks) diff --git a/otp/distributed/OtpDoGlobals.py b/otp/distributed/OtpDoGlobals.py index 061d5749..f665ced4 100644 --- a/otp/distributed/OtpDoGlobals.py +++ b/otp/distributed/OtpDoGlobals.py @@ -45,7 +45,6 @@ OTP_DO_ID_TOONTOWN_RAT_MANAGER = 4692 OTP_DO_ID_STATUS_DATABASE = 4693 OTP_DO_ID_TOONTOWN_AWARD_MANAGER = 4694 OTP_DO_ID_TOONTOWN_CODE_REDEMPTION_MANAGER = 4695 -OTP_DO_ID_TOONTOWN_IN_GAME_NEWS_MANAGER = 4696 OTP_DO_ID_TOONTOWN_NON_REPEATABLE_RANDOM_SOURCE = 4697 OTP_DO_ID_AI_TRADE_AVATAR = 4698 OTP_DO_ID_TOONTOWN_WHITELIST_MANAGER = 4699 diff --git a/toontown/ai/ToontownAIMsgTypes.py b/toontown/ai/ToontownAIMsgTypes.py index 035dcc8c..682b8974 100644 --- a/toontown/ai/ToontownAIMsgTypes.py +++ b/toontown/ai/ToontownAIMsgTypes.py @@ -2,7 +2,6 @@ from otp.ai.AIMsgTypes import * TTAIMsgName2Id = {'DBSERVER_GET_ESTATE': 1040, 'DBSERVER_GET_ESTATE_RESP': 1041, 'PARTY_MANAGER_UD_TO_ALL_AI': 1042, - 'IN_GAME_NEWS_MANAGER_UD_TO_ALL_AI': 1043, 'WHITELIST_MANAGER_UD_TO_ALL_AI': 1044} TTAIMsgId2Names = invertDictLossless(TTAIMsgName2Id) globals().update(TTAIMsgName2Id) diff --git a/toontown/catalog/CatalogNotifyDialog.py b/toontown/catalog/CatalogNotifyDialog.py index c34037ba..7ff2627c 100644 --- a/toontown/catalog/CatalogNotifyDialog.py +++ b/toontown/catalog/CatalogNotifyDialog.py @@ -2,7 +2,6 @@ from toontown.toonbase import ToontownGlobals from toontown.toonbase import TTLocalizer from direct.gui.DirectGui import * from pandac.PandaModules import * -CatalogNotifyBaseXPos = -0.93 class CatalogNotifyDialog: notify = directNotify.newCategory('CatalogNotifyDialog') @@ -10,11 +9,7 @@ class CatalogNotifyDialog: def __init__(self, message): self.message = message self.messageIndex = 0 - framePosX = CatalogNotifyBaseXPos - from toontown.toon import LocalToon - if LocalToon.WantNewsPage: - framePosX += LocalToon.AdjustmentForNewsButton - self.frame = DirectFrame(relief=None, parent=base.a2dTopRight, sortOrder=DGG.BACKGROUND_SORT_INDEX - 2, image=DGG.getDefaultDialogGeom(), image_color=ToontownGlobals.GlobalDialogColor, image_scale=(1.2, 1.0, 0.4), text=message[0], text_wordwrap=16, text_scale=0.06, text_pos=(-0.1, 0.1), pos=(framePosX, 0, -0.22)) + self.frame = DirectFrame(relief=None, parent=base.a2dTopRight, sortOrder=DGG.BACKGROUND_SORT_INDEX - 2, image=DGG.getDefaultDialogGeom(), image_color=ToontownGlobals.GlobalDialogColor, image_scale=(1.2, 1.0, 0.4), text=message[0], text_wordwrap=16, text_scale=0.06, text_pos=(-0.1, 0.1), pos=(-0.93, 0, -0.22)) buttons = loader.loadModel('phase_3/models/gui/dialog_box_buttons_gui') cancelImageList = (buttons.find('**/CloseBtn_UP'), buttons.find('**/CloseBtn_DN'), buttons.find('**/CloseBtn_Rllvr')) okImageList = (buttons.find('**/ChtBx_OKBtn_UP'), buttons.find('**/ChtBx_OKBtn_DN'), buttons.find('**/ChtBx_OKBtn_Rllvr')) diff --git a/toontown/distributed/ToontownClientRepository.py b/toontown/distributed/ToontownClientRepository.py index 89917200..5751f6bc 100644 --- a/toontown/distributed/ToontownClientRepository.py +++ b/toontown/distributed/ToontownClientRepository.py @@ -85,7 +85,6 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): self.streetSign = None self.distributedDistrict = None self.partyManager = None - self.inGameNewsMgr = None self.toontownTimeManager = ToontownTimeManager.ToontownTimeManager() @@ -583,7 +582,7 @@ class ToontownClientRepository(OTPClientRepository.OTPClientRepository): else: self.notify.info('dumpAllSubShardObjects: defaultShard is %s' % localAvatar.defaultShard) - ignoredClasses = ('MagicWordManager', 'TimeManager', 'DistributedDistrict', 'FriendManager', 'NewsManager', 'ToontownMagicWordManager', 'WelcomeValleyManager', 'DistributedTrophyMgr', 'CatalogManager', 'DistributedBankMgr', 'EstateManager', 'RaceManager', 'SafeZoneManager', 'DeleteManager', 'TutorialManager', 'ToontownDistrict', 'DistributedDeliveryManager', 'DistributedPartyManager', 'AvatarFriendsManager', 'InGameNewsMgr', 'TTCodeRedemptionMgr') + ignoredClasses = ('MagicWordManager', 'TimeManager', 'DistributedDistrict', 'FriendManager', 'NewsManager', 'ToontownMagicWordManager', 'WelcomeValleyManager', 'DistributedTrophyMgr', 'CatalogManager', 'DistributedBankMgr', 'EstateManager', 'RaceManager', 'SafeZoneManager', 'DeleteManager', 'TutorialManager', 'ToontownDistrict', 'DistributedDeliveryManager', 'DistributedPartyManager', 'AvatarFriendsManager', 'TTCodeRedemptionMgr') messenger.send('clientCleanup') for avId, pad in self.__queryAvatarMap.items(): pad.delayDelete.destroy() diff --git a/toontown/shtiker/DirectNewsFrame.py b/toontown/shtiker/DirectNewsFrame.py deleted file mode 100644 index 612c246c..00000000 --- a/toontown/shtiker/DirectNewsFrame.py +++ /dev/null @@ -1,414 +0,0 @@ -import os -import time -import datetime -from pandac.PandaModules import Filename, DSearchPath, TextNode -from pandac.PandaModules import HTTPClient, Ramfile, DocumentSpec -from direct.showbase import DirectObject -from direct.gui.DirectGui import DirectFrame, DGG -from direct.directnotify import DirectNotifyGlobal -from direct.task.Task import Task -from direct.showbase import AppRunnerGlobal -from toontown.shtiker import IssueFrame -from toontown.shtiker import IssueFrameV2 -from toontown.toonbase import TTLocalizer - -class DirectNewsFrame(DirectObject.DirectObject): - TaskName = 'HtmlViewUpdateTask' - TaskChainName = 'RedownladTaskChain' - RedownloadTaskName = 'RedownloadNewsTask' - NewsBaseDir = config.GetString('news-base-dir', '/httpNews') - NewsStageDir = config.GetString('news-stage-dir', 'news') - FrameDimensions = (-1.30666637421, - 1.30666637421, - -0.751666665077, - 0.751666665077) - notify = DirectNotifyGlobal.directNotify.newCategory('DirectNewsFrame') - NewsIndexFilename = config.GetString('news-index-filename', 'http_news_index.txt') - NewsOverHttp = config.GetBool('news-over-http', True) - CacheIndexFilename = 'cache_index.txt' - SectionIdents = ['hom', - 'new', - 'evt', - 'tot', - 'att', - 'tnr'] - - def __init__(self, parent = aspect2d): - DirectObject.DirectObject.__init__(self) - self.accept('newsSnapshot', self.doSnapshot) - self.active = False - self.parent = parent - self.issues = [] - self.accept('newsChangeWeek', self.changeWeek) - self.curIssueIndex = 0 - self.strFilenames = None - self.redownloadingNews = False - self.startRedownload = datetime.datetime.now() - self.endRedownload = datetime.datetime.now() - self.load() - self.percentDownloaded = 0.0 - self.numIssuesExpected = 0 - self.needsParseNews = True - self.newsIndexEntries = [] - if self.NewsOverHttp: - self.redownloadNews() - self.accept('newIssueOut', self.handleNewIssueOut) - self.accept('clientCleanup', self.handleClientCleanup) - return - - def parseNewsContent(self): - if not self.needsParseNews: - return - self.needsParseNews = False - result = False - newsDir = self.findNewsDir() - if newsDir: - allHomeFiles = self.getAllHomeFilenames(newsDir) - self.notify.debug('len allHomeFiles = %s' % len(allHomeFiles)) - self.numIssuesExpected = len(allHomeFiles) - if allHomeFiles: - for myIssueIndex, oneHomeFile in enumerate(allHomeFiles): - if type(oneHomeFile) == type(''): - justFilename = oneHomeFile - else: - justFilename = oneHomeFile.getFilename().getBasename() - self.notify.debug('parseNewContent %s' % justFilename) - parts = justFilename.split('_') - dateStr = parts[3] - majorVer, minorVer = self.calcIssueVersion(dateStr) - if majorVer == 1: - oneIssue = IssueFrame.IssueFrame(self.backFrame, newsDir, dateStr, myIssueIndex, len(allHomeFiles), self.strFilenames) - elif majorVer == 2: - oneIssue = IssueFrameV2.IssueFrameV2(self.backFrame, newsDir, dateStr, myIssueIndex, len(allHomeFiles), self.strFilenames, self.newsIndexEntries) - else: - self.notify.warning('Dont know how to handle version %s, asuming v2' % majorVer) - oneIssue = IssueFrameV2.IssueFrameV2(self.backFrame, newsDir, dateStr, myIssueIndex, len(allHomeFiles), self.strFilenames, self.newsIndexEntries) - oneIssue.hide() - self.issues.append(oneIssue) - - if self.issues: - self.issues[-1].show() - self.curIssueIndex = len(self.issues) - 1 - result = True - if hasattr(base.cr, 'inGameNewsMgr') and base.cr.inGameNewsMgr: - self.createdTime = base.cr.inGameNewsMgr.getLatestIssue() - self.notify.debug('setting created time to latest issue %s' % self.createdTime) - else: - self.createdTime = base.cr.toontownTimeManager.getCurServerDateTime() - self.notify.debug('setting created time cur server time %s' % self.createdTime) - return result - - def getAllHomeFilenames(self, newsDir): - self.notify.debug('getAllHomeFilenames') - newsDirAsFile = vfs.getFile(Filename(newsDir)) - fileList = newsDirAsFile.scanDirectory() - fileNames = fileList.getFiles() - self.notify.debug('filenames=%s' % fileNames) - homeFileNames = set([]) - for name in fileNames: - self.notify.debug('processing %s' % name) - baseName = name.getFilename().getBasename() - self.notify.debug('baseName=%s' % baseName) - if 'hom1.' in baseName: - homeFileNames.add(name) - else: - self.notify.debug('hom1. not in baseName') - - if not homeFileNames: - self.notify.warning('couldnt find hom1. in %s' % fileNames) - self.setErrorMessage(TTLocalizer.NewsPageNoIssues) - return [] - - def fileCmp(fileA, fileB): - return fileA.getFilename().compareTo(fileB.getFilename()) - - homeFileNames = list(homeFileNames) - homeFileNames.sort(cmp=fileCmp) - self.notify.debug('returned homeFileNames=%s' % homeFileNames) - return homeFileNames - - def findNewsDir(self): - if self.NewsOverHttp: - return self.NewsStageDir - searchPath = DSearchPath() - if AppRunnerGlobal.appRunner: - searchPath.appendDirectory(Filename.expandFrom('$TT_3_5_ROOT/phase_3.5/models/news')) - else: - basePath = os.path.expandvars('$TTMODELS') or './ttmodels' - searchPath.appendDirectory(Filename.fromOsSpecific(basePath + '/built/' + self.NewsBaseDir)) - searchPath.appendDirectory(Filename(self.NewsBaseDir)) - pfile = Filename(self.NewsIndexFilename) - found = vfs.resolveFilename(pfile, searchPath) - if not found: - self.notify.warning('findNewsDir - no path: %s' % self.NewsIndexFilename) - self.setErrorMessage(TTLocalizer.NewsPageErrorDownloadingFile % self.NewsIndexFilename) - return None - self.notify.debug('found index file %s' % pfile) - realDir = pfile.getDirname() - return realDir - - def load(self): - self.loadBackground() - - def loadBackground(self): - upsellBackground = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_newsStatusBackground') - imageScaleX = self.FrameDimensions[1] - self.FrameDimensions[0] - imageScaleY = self.FrameDimensions[3] - self.FrameDimensions[2] - self.backFrame = DirectFrame(parent=self.parent, image=upsellBackground, image_scale=(imageScaleX, 1, imageScaleY), frameColor=(1, 1, 1, 0), frameSize=self.FrameDimensions, pos=(0, 0, 0), relief=DGG.FLAT, text=TTLocalizer.NewsPageDownloadingNews1, text_scale=0.06, text_pos=(0, -0.4)) - - def addDownloadingTextTask(self): - self.removeDownloadingTextTask() - task = taskMgr.doMethodLater(1, self.loadingTextTask, 'DirectNewsFrameDownloadingTextTask') - task.startTime = globalClock.getFrameTime() - self.loadingTextTask(task) - - def removeDownloadingTextTask(self): - taskMgr.remove('DirectNewsFrameDownloadingTextTask') - - def loadMainPage(self): - self.mainFrame = DirectFrame(parent=self.backFrame, frameSize=self.FrameDimensions, frameColor=(1, 0, 0, 1)) - - def activate(self): - if hasattr(self, 'createdTime') and self.createdTime < base.cr.inGameNewsMgr.getLatestIssue() and self.NewsOverHttp and not self.redownloadingNews: - self.redownloadNews() - else: - self.addDownloadingTextTask() - if self.needsParseNews and not self.redownloadingNews: - self.parseNewsContent() - self.active = True - - def deactivate(self): - self.removeDownloadingTextTask() - self.active = False - - def unload(self): - self.removeDownloadingTextTask() - result = taskMgr.remove(self.RedownloadTaskName) - self.ignore('newsSnapshot') - self.ignore('newsChangeWeek') - self.ignore('newIssueOut') - self.ignore('clientCleanup') - - def handleClientCleanup(self): - pass - - def doSnapshot(self): - pass - - def changeWeek(self, issueIndex): - if 0 <= issueIndex and issueIndex < len(self.issues): - self.issues[self.curIssueIndex].hide() - self.issues[issueIndex].show() - self.curIssueIndex = issueIndex - - def loadingTextTask(self, task): - timeIndex = int(globalClock.getFrameTime() - task.startTime) % 3 - timeStrs = (TTLocalizer.NewsPageDownloadingNews0, TTLocalizer.NewsPageDownloadingNews1, TTLocalizer.NewsPageDownloadingNews2) - textToDisplay = timeStrs[timeIndex] % int(self.percentDownloaded * 100) - if self.backFrame['text'] != textToDisplay: - if TTLocalizer.NewsPageDownloadingNewsSubstr in self.backFrame['text']: - self.backFrame['text'] = textToDisplay - return task.again - - def setErrorMessage(self, errText): - self.backFrame['text'] = errText - - def redownloadNews(self): - if self.redownloadingNews: - self.notify.warning('averting potential crash redownloadNews called twice, just returning') - return - self.percentDownloaded = 0.0 - self.notify.info('starting redownloadNews') - self.startRedownload = datetime.datetime.now() - self.redownloadingNews = True - self.addDownloadingTextTask() - for issue in self.issues: - issue.destroy() - - self.issues = [] - self.curIssueIndex = 0 - self.strFilenames = None - self.needsParseNews = True - self.newsUrl = self.getInGameNewsUrl() - self.newsDir = Filename(self.findNewsDir()) - Filename(self.newsDir + '/.').makeDir() - http = HTTPClient.getGlobalPtr() - self.url = self.newsUrl + self.NewsIndexFilename - self.ch = http.makeChannel(True) - self.ch.beginGetDocument(self.url) - self.rf = Ramfile() - self.ch.downloadToRam(self.rf) - taskMgr.remove(self.RedownloadTaskName) - taskMgr.add(self.downloadIndexTask, self.RedownloadTaskName) - return - - def downloadIndexTask(self, task): - if self.ch.run(): - return task.cont - if not self.ch.isValid(): - self.notify.warning('Unable to download %s' % self.url) - self.redownloadingNews = False - return task.done - self.newsFiles = [] - filename = self.rf.readline() - while filename: - filename = filename.strip() - if filename: - self.newsFiles.append(filename) - filename = self.rf.readline() - - del self.rf - self.newsFiles.sort() - self.newsIndexEntries = list(self.newsFiles) - self.notify.info('Server lists %s news files' % len(self.newsFiles)) - self.notify.debug('self.newsIndexEntries=%s' % self.newsIndexEntries) - self.readNewsCache() - for basename in os.listdir(self.newsDir.toOsSpecific()): - if basename != self.CacheIndexFilename and basename not in self.newsCache: - junk = Filename(self.newsDir, basename) - self.notify.info('Removing %s' % junk) - junk.unlink() - - self.nextNewsFile = 0 - return self.downloadNextFile(task) - - def downloadNextFile(self, task): - while self.nextNewsFile < len(self.newsFiles) and 'aaver' in self.newsFiles[self.nextNewsFile]: - self.nextNewsFile += 1 - - if self.nextNewsFile >= len(self.newsFiles): - self.notify.info('Done downloading news.') - self.percentDownloaded = 1 - del self.newsFiles - del self.nextNewsFile - del self.newsUrl - del self.newsDir - del self.ch - del self.url - if hasattr(self, 'filename'): - del self.filename - self.redownloadingNews = False - if self.active: - self.parseNewsContent() - return task.done - self.percentDownloaded = float(self.nextNewsFile) / float(len(self.newsFiles)) - self.filename = self.newsFiles[self.nextNewsFile] - self.nextNewsFile += 1 - self.url = self.newsUrl + self.filename - localFilename = Filename(self.newsDir, self.filename) - self.notify.info('testing for %s' % localFilename.getFullpath()) - doc = DocumentSpec(self.url) - if self.filename in self.newsCache: - size, date = self.newsCache[self.filename] - if date and localFilename.exists() and (size == 0 or localFilename.getFileSize() == size): - doc.setDate(date) - doc.setRequestMode(doc.RMNewer) - self.ch.beginGetDocument(doc) - self.ch.downloadToFile(localFilename) - taskMgr.remove(self.RedownloadTaskName) - taskMgr.add(self.downloadCurrentFileTask, self.RedownloadTaskName) - - def downloadCurrentFileTask(self, task): - if self.ch.run(): - return task.cont - if self.ch.getStatusCode() == 304: - self.notify.info('already cached: %s' % self.filename) - return self.downloadNextFile(task) - localFilename = Filename(self.newsDir, self.filename) - if not self.ch.isValid(): - self.notify.warning('Unable to download %s' % self.url) - localFilename.unlink() - if self.filename in self.newsCache: - del self.newsCache[self.filename] - self.saveNewsCache() - return self.downloadNextFile(task) - self.notify.info('downloaded %s' % self.filename) - size = self.ch.getFileSize() - doc = self.ch.getDocumentSpec() - date = '' - if doc.hasDate(): - date = doc.getDate().getString() - self.newsCache[self.filename] = (size, date) - self.saveNewsCache() - return self.downloadNextFile(task) - - def readNewsCache(self): - cacheIndexFilename = Filename(self.newsDir, self.CacheIndexFilename) - self.newsCache = {} - if cacheIndexFilename.isRegularFile(): - file = open(cacheIndexFilename.toOsSpecific(), 'r') - for line in file.readlines(): - line = line.strip() - keywords = line.split('\t') - if len(keywords) == 3: - filename, size, date = keywords - if filename in self.newsFiles: - try: - size = int(size) - except ValueError: - size = 0 - - self.newsCache[filename] = (size, date) - - def saveNewsCache(self): - cacheIndexFilename = Filename(self.newsDir, self.CacheIndexFilename) - try: - file = open(cacheIndexFilename.toOsSpecific(), 'w') - except IOError, e: - self.notify.warning('error opening news cache file %s: %s' % (cacheIndexFilename, str(e))) - return - - for filename, (size, date) in self.newsCache.items(): - print >> file, '%s\t%s\t%s' % (filename, size, date) - - def handleNewIssueOut(self): - if hasattr(self, 'createdTime') and base.cr.inGameNewsMgr.getLatestIssue() < self.createdTime: - self.createdTime = base.cr.inGameNewsMgr.getLatestIssue() - elif self.NewsOverHttp and not self.redownloadingNews: - if not self.active: - self.redownloadNews() - - def getInGameNewsUrl(self): - result = base.config.GetString('fallback-news-url', 'http://cdn.toontown.disney.go.com/toontown/en/gamenews/') - override = base.config.GetString('in-game-news-url', '') - if override: - self.notify.info('got an override url, using %s for in game news' % override) - result = override - else: - try: - launcherUrl = base.launcher.getValue('GAME_IN_GAME_NEWS_URL', '') - if launcherUrl: - result = launcherUrl - self.notify.info('got GAME_IN_GAME_NEWS_URL from launcher using %s' % result) - else: - self.notify.info('blank GAME_IN_GAME_NEWS_URL from launcher, using %s' % result) - except: - self.notify.warning('got exception getting GAME_IN_GAME_NEWS_URL from launcher, using %s' % result) - - return result - - def calcIssueVersion(self, dateStr): - majorVer = 1 - minorVer = 0 - for entry in self.newsIndexEntries: - if 'aaver' in entry and dateStr in entry: - parts = entry.split('_') - if len(parts) > 5: - try: - majorVer = int(parts[5]) - except: - self.notify.warning('could not int %s' % parts[5]) - - else: - self.notify.warning('expected more than 5 parts in %s' % entry) - if len(parts) > 6: - try: - minorVer = int(parts[6]) - except: - self.notify.warning('could not int %s' % parts[6]) - - else: - self.notify.warning('expected more than 6 parts in %s' % entry) - break - - return (majorVer, minorVer) diff --git a/toontown/shtiker/EventsPage.py b/toontown/shtiker/EventsPage.py index aa73d29c..3567b350 100644 --- a/toontown/shtiker/EventsPage.py +++ b/toontown/shtiker/EventsPage.py @@ -1,7 +1,7 @@ import urllib -from pandac.PandaModules import Vec4, Vec3, TextNode, PNMImage, StringStream, Texture, HTTPClient, DocumentSpec, Ramfile, Point3 +from pandac.PandaModules import Vec4, Vec3, TextNode from direct.task.Task import Task -from direct.gui.DirectGui import DirectFrame, DirectLabel, DirectButton, DirectScrolledList, DirectCheckButton, OnscreenText +from direct.gui.DirectGui import DirectFrame, DirectLabel, DirectButton, DirectScrolledList, DirectCheckButton from direct.gui import DirectGuiGlobals from direct.directnotify import DirectNotifyGlobal from otp.otpbase import OTPLocalizer @@ -18,15 +18,9 @@ import ShtikerPage EventsPage_Host = 0 EventsPage_Invited = 1 EventsPage_Calendar = 2 -EventsPage_News = 3 class EventsPage(ShtikerPage.ShtikerPage): notify = DirectNotifyGlobal.directNotify.newCategory('EventsPage') - UseNewsTab = base.config.GetBool('want-news-tab', 0) - DefaultNewsUrl = '/news/news_urls.txt' - NewsUrl = base.config.GetString('news-url', DefaultNewsUrl) - DownloadArticlesTaskName = 'downloadArticlesTask' - NonblockingDownload = base.config.GetBool('news-nonblocking', 1) def __init__(self): ShtikerPage.ShtikerPage.__init__(self) @@ -34,13 +28,7 @@ class EventsPage(ShtikerPage.ShtikerPage): self.setMode(self.mode) self.noTeleport = config.GetBool('Parties-page-disable', 0) self.isPrivate = True - self.gotRssFeed = False - self.gotArticles = False - self.newsList = None - self.articleTextList = None - self.articleIndexList = None self.hostedPartyInfo = None - self.downloadArticlesInProgress = False return def load(self): @@ -53,7 +41,6 @@ class EventsPage(ShtikerPage.ShtikerPage): self.loadHostingTab() self.loadInvitationsTab() self.loadCalendarTab() - self.loadNewsTab() self.titleLabel = DirectLabel(parent=self, relief=None, text=TTLocalizer.EventsPageHostTabTitle, text_scale=TTLocalizer.EPtitleLabel, textMayChange=True, pos=self.hostingGui.find('**/myNextParty_text_locator').getPos()) return @@ -63,21 +50,9 @@ class EventsPage(ShtikerPage.ShtikerPage): rolloverColor = (0.15, 0.82, 1.0, 1.0) diabledColor = (1.0, 0.98, 0.15, 1.0) gui = loader.loadModel('phase_3.5/models/gui/fishingBook') - self.hostTab = DirectButton(parent=self, relief=None, text=TTLocalizer.EventsPageHostTabName, text_scale=TTLocalizer.EPhostTab, text_align=TextNode.ACenter, text_pos=(0.12, 0.0), image=gui.find('**/tabs/polySurface1'), image_pos=(0.55, 1, -0.91), image_hpr=(0, 0, -90), image_scale=(0.033, 0.033, 0.035), image_color=normalColor, image1_color=clickColor, image2_color=rolloverColor, image3_color=diabledColor, text_fg=Vec4(0.2, 0.1, 0, 1), command=self.setMode, extraArgs=[EventsPage_Host], pos=(0.92, 0, 0.55)) - self.invitedTab = DirectButton(parent=self, relief=None, text=TTLocalizer.EventsPageInvitedTabName, text_scale=TTLocalizer.EPinvitedTab, text_pos=(0.12, 0.0), text_align=TextNode.ACenter, image=gui.find('**/tabs/polySurface2'), image_pos=(0.12, 1, -0.91), image_hpr=(0, 0, -90), image_scale=(0.033, 0.033, 0.035), image_color=normalColor, image1_color=clickColor, image2_color=rolloverColor, image3_color=diabledColor, text_fg=Vec4(0.2, 0.1, 0, 1), command=self.setMode, extraArgs=[EventsPage_Invited], pos=(0.92, 0, 0.1)) - self.calendarTab = DirectButton(parent=self, relief=None, text=TTLocalizer.EventsPageCalendarTabName, text_scale=TTLocalizer.EPcalendarTab, text_pos=(0.12, 0.0), text_align=TextNode.ACenter, image=gui.find('**/tabs/polySurface2'), image_pos=(0.12, 1, -0.91), image_hpr=(0, 0, -90), image_scale=(0.033, 0.033, 0.035), image_color=normalColor, image1_color=clickColor, image2_color=rolloverColor, image3_color=diabledColor, text_fg=Vec4(0.2, 0.1, 0, 1), command=self.setMode, extraArgs=[EventsPage_Calendar], pos=(0.92, 0, 0.1)) - self.newsTab = DirectButton(parent=self, relief=None, text=TTLocalizer.EventsPageNewsTabName, text_scale=TTLocalizer.EPnewsTab, text_pos=(0.12, 0.0), text_align=TextNode.ACenter, image=gui.find('**/tabs/polySurface2'), image_pos=(0.12, 1, -0.91), image_hpr=(0, 0, -90), image_scale=(0.033, 0.033, 0.035), image_color=normalColor, image1_color=clickColor, image2_color=rolloverColor, image3_color=diabledColor, text_fg=Vec4(0.2, 0.1, 0, 1), command=self.setMode, extraArgs=[EventsPage_News], pos=(0.92, 0, 0.1)) - self.newsTab.hide() - if self.UseNewsTab: - self.newsTab.show() - self.calendarTab.setPos(-0.75, 0, 0.775) - self.hostTab.setPos(-0.33, 0, 0.775) - self.invitedTab.setPos(0.09, 0, 0.775) - self.newsTab.setPos(0.51, 0, 0.775) - else: - self.calendarTab.setPos(-0.55, 0, 0.775) - self.hostTab.setPos(-0.13, 0, 0.775) - self.invitedTab.setPos(0.28, 0, 0.775) + self.hostTab = DirectButton(parent=self, relief=None, text=TTLocalizer.EventsPageHostTabName, text_scale=TTLocalizer.EPhostTab, text_align=TextNode.ACenter, text_pos=(0.12, 0.0), image=gui.find('**/tabs/polySurface1'), image_pos=(0.55, 1, -0.91), image_hpr=(0, 0, -90), image_scale=(0.033, 0.033, 0.035), image_color=normalColor, image1_color=clickColor, image2_color=rolloverColor, image3_color=diabledColor, text_fg=Vec4(0.2, 0.1, 0, 1), command=self.setMode, extraArgs=[EventsPage_Host], pos=(-0.13, 0, 0.775)) + self.invitedTab = DirectButton(parent=self, relief=None, text=TTLocalizer.EventsPageInvitedTabName, text_scale=TTLocalizer.EPinvitedTab, text_pos=(0.12, 0.0), text_align=TextNode.ACenter, image=gui.find('**/tabs/polySurface2'), image_pos=(0.12, 1, -0.91), image_hpr=(0, 0, -90), image_scale=(0.033, 0.033, 0.035), image_color=normalColor, image1_color=clickColor, image2_color=rolloverColor, image3_color=diabledColor, text_fg=Vec4(0.2, 0.1, 0, 1), command=self.setMode, extraArgs=[EventsPage_Invited], pos=(0.28, 0, 0.775)) + self.calendarTab = DirectButton(parent=self, relief=None, text=TTLocalizer.EventsPageCalendarTabName, text_scale=TTLocalizer.EPcalendarTab, text_pos=(0.12, 0.0), text_align=TextNode.ACenter, image=gui.find('**/tabs/polySurface2'), image_pos=(0.12, 1, -0.91), image_hpr=(0, 0, -90), image_scale=(0.033, 0.033, 0.035), image_color=normalColor, image1_color=clickColor, image2_color=rolloverColor, image3_color=diabledColor, text_fg=Vec4(0.2, 0.1, 0, 1), command=self.setMode, extraArgs=[EventsPage_Calendar], pos=(-0.55, 0, 0.775)) return def loadHostingTab(self): @@ -153,25 +128,6 @@ class EventsPage(ShtikerPage.ShtikerPage): self.toontownTimeGui = ServerTimeGui(self.calendarDisplay, pos) return - def loadNewsTab(self): - self.newsDisplay = self.attachNewNode('news') - newspaper = loader.loadModel('phase_4/models/parties/tt_m_gui_sbk_newspaper.bam') - self.newsFrame = DirectLabel(relief=None, parent=self.newsDisplay, pos=(0, 0, -0.1)) - newspaper.reparentTo(self.newsFrame) - self.createArticleTextList() - self.articleImage = None - self.newsStatusLabel = DirectLabel(text=TTLocalizer.EventsPageNewsDownloading, relief=None, text_scale=0.1, text_wordwrap=13, parent=self.newsFrame, pos=(0, 0, 0.275)) - self.createArticleIndexList() - titlePos = self.newsFrame.find('**/loc_toontimeTimes').getPos() - self.newsPaperTitle = DirectLabel(text=TTLocalizer.EventsPageNewsPaperTitle, relief=None, text_scale=(0.13, 0.25, 1), text_align=TextNode.ACenter, text_font=ToontownGlobals.getMinnieFont(), parent=self.newsFrame, pos=titlePos) - subLeftPos = self.newsFrame.find('**/loc_subheaderLf').getPos() - subRightPos = self.newsFrame.find('**/loc_subheaderRt').getPos() - self.subLeft = DirectLabel(text=TTLocalizer.EventsPageNewsLeftSubtitle, relief=None, text_scale=0.05, text_align=TextNode.ALeft, parent=self.newsFrame, pos=subLeftPos) - self.subRight = DirectLabel(text=TTLocalizer.EventsPageNewsRightSubtitle, relief=None, text_scale=0.05, text_align=TextNode.ARight, parent=self.newsFrame, pos=subRightPos) - if self.UseNewsTab: - self.downloadArticles() - return - def getGuestItem(self, name, inviteStatus): label = DirectLabel(relief=None, text=name, text_scale=0.045, text_align=TextNode.ALeft, textMayChange=True) dot = DirectFrame(relief=None, geom=self.hostingGui.find('**/questionMark'), pos=(0.5, 0.0, 0.01)) @@ -455,20 +411,6 @@ class EventsPage(ShtikerPage.ShtikerPage): del self.cancelPartyResultGui self.ignore(self.confirmCancelPartyEvent) self.ignore(self.cancelPartyResultGuiEvent) - if hasattr(self, 'rssFeed') and self.rssFeed: - self.rssFeed = None - if self.articleTextList: - self.articleTextList.removeAndDestroyAllItems() - self.articleTextList.destroy() - self.articleTextList = None - if self.articleIndexList: - self.articleIndexList.removeAndDestroyAllItems() - self.articleIndexList.destroy() - self.articleIndexList = None - if self.newsList: - self.newsList.removeAndDestroyAllItems() - self.newsList.destroy() - self.newsList = None self.avatar = None self.hostingCancelButton.destroy() del self.hostingCancelButton @@ -487,7 +429,6 @@ class EventsPage(ShtikerPage.ShtikerPage): self.calendarGuiMonth.destroy() self.toontownTimeGui.destroy() taskMgr.remove('EventsPageUpdateTask-doLater') - taskMgr.remove(self.DownloadArticlesTaskName) ShtikerPage.ShtikerPage.unload(self) return @@ -539,11 +480,9 @@ class EventsPage(ShtikerPage.ShtikerPage): self.hostTab['state'] = DirectGuiGlobals.DISABLED self.invitedTab['state'] = DirectGuiGlobals.NORMAL self.calendarTab['state'] = DirectGuiGlobals.NORMAL - self.newsTab['state'] = DirectGuiGlobals.NORMAL self.invitationDisplay.hide() self.hostedPartyDisplay.show() self.calendarDisplay.hide() - self.newsDisplay.hide() self.loadHostedPartyInfo() if self.hostedPartyInfo is None: self.titleLabel['text'] = TTLocalizer.EventsPageHostTabTitleNoParties @@ -554,38 +493,22 @@ class EventsPage(ShtikerPage.ShtikerPage): self.hostTab['state'] = DirectGuiGlobals.NORMAL self.invitedTab['state'] = DirectGuiGlobals.DISABLED self.calendarTab['state'] = DirectGuiGlobals.NORMAL - self.newsTab['state'] = DirectGuiGlobals.NORMAL self.hostedPartyDisplay.hide() self.invitationDisplay.show() self.calendarDisplay.hide() - self.newsDisplay.hide() self.loadInvitations() elif self.mode == EventsPage_Calendar: self.titleLabel['text'] = '' self.hostTab['state'] = DirectGuiGlobals.NORMAL self.invitedTab['state'] = DirectGuiGlobals.NORMAL self.calendarTab['state'] = DirectGuiGlobals.DISABLED - self.newsTab['state'] = DirectGuiGlobals.NORMAL self.hostedPartyDisplay.hide() self.invitationDisplay.hide() self.calendarDisplay.show() - self.newsDisplay.hide() if not self.calendarGuiMonth: curServerDate = base.cr.toontownTimeManager.getCurServerDateTime() self.calendarGuiMonth = CalendarGuiMonth(self.calendarDisplay, curServerDate, onlyFutureMonthsClickable=True) self.calendarGuiMonth.changeMonth(0) - elif self.mode == EventsPage_News: - self.titleLabel['text'] = '' - self.hostTab['state'] = DirectGuiGlobals.NORMAL - self.invitedTab['state'] = DirectGuiGlobals.NORMAL - self.calendarTab['state'] = DirectGuiGlobals.NORMAL - self.newsTab['state'] = DirectGuiGlobals.DISABLED - self.hostedPartyDisplay.hide() - self.invitationDisplay.hide() - self.calendarDisplay.hide() - if not self.gotRssFeed: - pass - self.newsDisplay.show() return def __setPublicPrivateButton(self): @@ -658,408 +581,4 @@ class EventsPage(ShtikerPage.ShtikerPage): self.cancelPartyResultGui.hide() def updateToontownTime(self): - self.toontownTimeGui.updateTime() - - def createArticleTextList(self): - bottomLeft = self.newsFrame.find('**/loc_textBoxBtmLf') - topRight = self.newsFrame.find('**/loc_textBoxTopRt') - topLeft = self.newsFrame.find('**/loc_textBoxTopLf') - self.notify.debug('bottomLeft=%s topRight=%s' % (bottomLeft.getPos(), topRight.getPos())) - buttonOffSet = 0.045 - selectedIndex = 0 - self.articleListXorigin = bottomLeft.getPos().getX() - self.articleListFrameSizeX = topRight.getPos().getX() - bottomLeft.getPos().getX() - self.articleListZorigin = bottomLeft.getPos().getZ() - self.articleListFrameSizeZ = topRight.getPos().getZ() - bottomLeft.getPos().getZ() - self.articleArrowButtonScale = 1.3 - self.articleItemFrameXorigin = bottomLeft.getPos().getX() - self.articleButtonXstart = self.articleItemFrameXorigin + 0.25 - - def makeButton(itemName, itemNum, *extraArgs): - - def buttonCommand(): - print itemName, itemNum - - return DirectLabel(text=itemName, relief=None, text_align=TextNode.ALeft, scale=0.06) - - itemHeight = 0.062 - topLeftStart = topLeft.getPos() - self.notify.debug('topLeft=%s topLeftStart=%s' % (topLeft.getPos(), topLeftStart)) - scrollTopUp = self.newsFrame.find('**/scrollTopUp') - scrollTopDown = self.newsFrame.find('**/scrollTopDown') - scrollTopHover = self.newsFrame.find('**/scrollTopHover') - scrollBtmUp = self.newsFrame.find('**/scrollBtmUp') - scrollBtmDown = self.newsFrame.find('**/scrollBtmDown') - scrollBtmHover = self.newsFrame.find('**/scrollBtmHover') - decButtonPos = scrollTopUp.getPos(topLeft) - incButtonPos = scrollBtmDown.getPos(topLeft) - self.notify.debug('scrollTopUp pos wrt topLeft %s' % decButtonPos) - self.notify.debug('scrollTopUp pos normal %s' % scrollTopUp.getPos()) - scrollTopUp.setPos(0, 0, 0) - scrollTopDown.setPos(0, 0, 0) - scrollTopHover.setPos(0, 0, 0) - scrollBtmUp.setPos(0, 0, 0) - scrollBtmDown.setPos(0, 0, 0) - scrollBtmHover.setPos(0, 0, 0) - self.numLinesInTextList = 13 - self.articleTextList = DirectScrolledList(parent=self.newsFrame, relief=None, pos=topLeftStart, incButton_image=(self.newsFrame.find('**/scrollBtmUp'), - self.newsFrame.find('**/scrollBtmDown'), - self.newsFrame.find('**/scrollBtmHover'), - self.newsFrame.find('**/scrollBtmUp')), incButton_relief=None, incButton_pos=incButtonPos, incButton_image3_color=(1.0, 1.0, 1.0, 0.1), decButton_image=(self.newsFrame.find('**/scrollTopUp'), - self.newsFrame.find('**/scrollTopDown'), - self.newsFrame.find('**/scrollTopHover'), - self.newsFrame.find('**/scrollTopUp')), decButton_relief=None, decButton_pos=decButtonPos, decButton_image3_color=(1.0, 1.0, 1.0, 0.1), text_scale=0.05, frameSize=(self.articleListXorigin, - self.articleListXorigin + self.articleListFrameSizeX, - self.articleListZorigin, - self.articleListZorigin + self.articleListFrameSizeZ), frameColor=(0.82, 0.8, 0.75, 1), borderWidth=(0.01, 0.01), numItemsVisible=self.numLinesInTextList, itemMakeFunction=makeButton, forceHeight=itemHeight) - oldParent = self.articleTextList.decButton.getParent() - self.newsFrame.find('**/scroll').hide() - return - - def createArticleIndexList(self): - self.articleIndexList = DirectScrolledList(parent=self.newsFrame, relief=None, pos=(0, 0, 0), incButton_image=(self.newsFrame.find('**/pageRtUp'), - self.newsFrame.find('**/pageRtUp'), - self.newsFrame.find('**/pageRtHover'), - None), incButton_relief=None, incButton_scale=1, decButton_image=(self.newsFrame.find('**/pageLfUp'), - self.newsFrame.find('**/pageLfUp'), - self.newsFrame.find('**/pageLfHover'), - None), decButton_relief=None, decButton_scale=1, text_scale=0.05, numItemsVisible=1) - self.newsFrame.find('**/pageRtUp').hide() - self.newsFrame.find('**/pageRtHover').hide() - self.newsFrame.find('**/pageLfUp').hide() - self.newsFrame.find('**/pageLfHover').hide() - self.articleIndexList['command'] = self.articleIndexChanged - return - - def articleIndexChanged(self): - if not self.articleIndexList['items']: - return - curArticleIndex = self.articleIndexList.getSelectedIndex() - if curArticleIndex in self.articleImages and curArticleIndex in self.articleText: - self.displayArticle(self.articleImages[curArticleIndex], self.articleText[curArticleIndex]) - - def getRssFeed(self): - if self.gotRssFeed: - return - self.rssFeed = feedparser.parse('http://www.wdwinfo.com/news/rss.xml') - feedText = [] - - def addFeedText(unicodeText, textSize = 0.03, color = (0, 0, 0, 1), feedText = feedText): - feedText.append(DirectLabel(relief=None, text=unicodeText, text_scale=textSize, text_align=TextNode.ALeft, text_fg=color, textMayChange=0, pos=(0, 0, 0))) - return - - addFeedText(self.rssFeed['channel']['title'], 0.06) - addFeedText(self.rssFeed['channel']['subtitle'], 0.04) - for entry in self.rssFeed['entries']: - addFeedText('') - addFeedText(entry['title'], 0.04, (0, 0, 1, 1)) - (addFeedText(entry['updated'], 0.025),) - addFeedText(entry['summary'], 0.035) - - self.feedText = feedText - self.createNewsList() - self.gotRssFeed = True - - def downloadArticles(self): - if self.gotArticles: - return - if not self.NonblockingDownload: - if not taskMgr.hasTaskNamed(self.DownloadArticlesTaskName): - taskMgr.doMethodLater(0.5, self.downloadArticlesTask, self.DownloadArticlesTaskName) - elif not self.downloadArticlesInProgress: - self.downloadArticlesNonblocking() - - def downloadArticlesTask(self, task): - self.articleImages = {} - self.articleText = {} - try: - urlfile = urllib.urlopen(self.getNewsUrl()) - except IOError: - self.notify.warning('Could not open %s' % self.getNewsUrl()) - self.newsStatusLabel['text'] = TTLocalizer.EventsPageNewsUnavailable - return - - urlStrings = urlfile.read() - urlfile.close() - urls = urlStrings.split('\r\n') - for index in xrange(len(urls) / 2): - imageUrl = urls[index * 2] - textUrl = urls[index * 2 + 1] - img = PNMImage() - self.articleImages[index] = img - try: - self.notify.info('opening %s' % imageUrl) - imageFile = urllib.urlopen(imageUrl) - data = imageFile.read() - img.read(StringStream(data)) - imageFile.close() - except IOError: - self.notify.warning('image url %d could not open %s' % (index, imageUrl)) - - text = '' - self.articleText[index] = text - try: - self.notify.info('opening %s' % textUrl) - textFile = urllib.urlopen(textUrl) - data = textFile.read() - data = data.replace('\\1', '\x01') - data = data.replace('\\2', '\x02') - data = data.replace('\r', ' ') - self.articleText[index] = data - textFile.close() - except IOError: - self.notify.warning('text url %d could not open %s' % (index, textUrl)) - - self.articleIndexList.addItem('') - - self.newsStatusLabel['text'] = '' - self.gotArticles = True - return task.done - - def displayArticle(self, img, articleText): - self.displayArticleImage(img) - self.displayArticleText(articleText) - - def displayArticleImage(self, img): - xSize = img.getXSize() - ySize = img.getYSize() - bottomLeft = self.newsFrame.find('**/loc_picture_BtmLf').getPos() - topRight = self.newsFrame.find('**/loc_picture_TopRt').getPos() - maxFrameXSize = topRight.getX() - bottomLeft.getX() - maxFrameYSize = topRight.getZ() - bottomLeft.getZ() - center = (bottomLeft + topRight) / 2.0 - maxAspectRatio = maxFrameXSize / maxFrameYSize - if ySize: - imgAspectRatio = float(xSize) / float(ySize) - else: - imgAspectRatio = maxAspectRatio - curXSize = maxFrameXSize - curYSize = maxFrameYSize - shrinkY = True - if imgAspectRatio > maxAspectRatio: - if xSize: - curYSize = maxFrameXSize * ySize / xSize - elif ySize: - curXSize = maxFrameYSize * xSize / ySize - shrinkY = False - minX = -curXSize / 2.0 - maxX = curXSize / 2.0 - minY = -curYSize / 2.0 - maxY = curYSize / 2.0 - webTexture = Texture('webTexture') - if img.isValid(): - webTexture.load(img) - else: - webTexture = None - if self.articleImage: - self.articleImage.destroy() - self.articleImage = DirectFrame(parent=self.newsFrame, relief=DirectGuiGlobals.FLAT, image=webTexture, image_scale=(curXSize / 2.0, 1, curYSize / 2.0), pos=center, frameSize=(minX, - maxX, - minY, - maxY)) - foo1 = Point3(0, 0, 0) - foo2 = Point3(0, 0, 0) - self.articleImage.calcTightBounds(foo1, foo2) - foo3 = self.articleImage.getBounds() - return - - def displayArticleText(self, articleText): - playaLabel = DirectLabel(parent=None, relief=None, text_align=TextNode.ALeft, text=articleText, text_scale=0.06, text_wordwrap=13.5) - playaLabel.hide() - textN = playaLabel.component(playaLabel.components()[0]) - if type(textN) == OnscreenText: - wrappedText = textN.textNode.getWordwrappedText() - items = wrappedText.split('\n') - self.articleTextList.removeAndDestroyAllItems() - for item in items: - self.articleTextList.addItem(item) - - if len(items) <= self.numLinesInTextList: - self.articleTextList.decButton.hide() - self.articleTextList.incButton.hide() - else: - self.articleTextList.decButton.show() - self.articleTextList.incButton.show() - playaLabel.destroy() - return - - def createNewsList(self): - buttonOffSet = 0.045 - if self.newsList: - self.newsList.removeAllItems() - self.newsList.destroy() - selectedIndex = 0 - self.newsListXorigin = -0.02 - self.newsListFrameSizeX = 1.55 - self.newsListZorigin = -0.95 - self.newsListFrameSizeZ = 1.02 - self.newsArrowButtonScale = 1.3 - self.newsItemFrameXorigin = -0.237 - self.newsButtonXstart = self.newsItemFrameXorigin + 0.725 - self.newsList = DirectScrolledList(parent=self.newsFrame, items=self.feedText, relief=None, pos=(-0.5, 0, 0.4), incButton_image=(self.scrollButtonGui.find('**/FndsLst_ScrollUp'), - self.scrollButtonGui.find('**/FndsLst_ScrollDN'), - self.scrollButtonGui.find('**/FndsLst_ScrollUp_Rllvr'), - self.scrollButtonGui.find('**/FndsLst_ScrollUp')), incButton_relief=None, incButton_scale=(self.newsArrowButtonScale, self.newsArrowButtonScale, -self.newsArrowButtonScale), incButton_pos=(self.newsButtonXstart, 0, self.newsListZorigin - buttonOffSet), incButton_image3_color=Vec4(1, 1, 1, 0.2), decButton_image=(self.scrollButtonGui.find('**/FndsLst_ScrollUp'), - self.scrollButtonGui.find('**/FndsLst_ScrollDN'), - self.scrollButtonGui.find('**/FndsLst_ScrollUp_Rllvr'), - self.scrollButtonGui.find('**/FndsLst_ScrollUp')), decButton_relief=None, decButton_scale=(self.newsArrowButtonScale, self.newsArrowButtonScale, self.newsArrowButtonScale), decButton_pos=(self.newsButtonXstart, 0, self.newsListZorigin + self.newsListFrameSizeZ + buttonOffSet), decButton_image3_color=Vec4(1, 1, 1, 0.2), itemFrame_pos=(self.newsItemFrameXorigin, 0, 0), itemFrame_scale=1.0, itemFrame_relief=DirectGuiGlobals.SUNKEN, itemFrame_frameSize=(self.newsListXorigin, - self.newsListXorigin + self.newsListFrameSizeX, - self.newsListZorigin, - self.newsListZorigin + self.newsListFrameSizeZ), itemFrame_frameColor=(0.82, 0.8, 0.75, 1), itemFrame_borderWidth=(0.01, 0.01), numItemsVisible=14) - self.newsList.scrollTo(selectedIndex) - return - - def downloadArticlesNonblocking(self): - self.notify.info('Starting download of news articles.') - self.articleImages = {} - self.articleText = {} - self.downloadArticlesInProgress = True - self.httpSession = HTTPClient() - self.nonBlock = self.httpSession.makeChannel(True) - newsUrl = self.getNewsUrl() - self.curUrlIndex = -1 - self.curArticleIndex = -1 - self.curDownloadIsJpg = True - self.downloadUrl(newsUrl) - - def downloadUrl(self, newsUrl): - if 'http:' in newsUrl: - self.getHttpUrl(newsUrl) - else: - self.getFileUrl(newsUrl) - - def doneGettingUrl(self, url, data, allOk): - self.notify.debug('doneGettingUrl %s %s %s' % (url, type(data), allOk)) - self.printCurFields() - if url == self.getNewsUrl(): - if allOk: - if type(data) == Ramfile: - self.urls = data.getData().split('\r\n') - else: - self.urls = data.split('\r\n') - else: - self.notify.warning('Could not open %s' % url) - self.newsStatusLabel['text'] = TTLocalizer.EventsPageNewsUnavailable - self.gotArticles = True - return - if self.urls: - self.subRight['text'] = self.urls[0] - self.urls = self.urls[1:] - self.curUrlIndex = 0 - self.curArticleIndex = 0 - self.curDownloadIsJpg = True - if self.curUrlIndex < len(self.urls): - url = self.urls[self.curUrlIndex] - self.downloadUrl(url) - else: - if self.curDownloadIsJpg: - img = PNMImage() - self.articleImages[self.curArticleIndex] = img - try: - if type(data) == Ramfile: - if allOk: - img.read(StringStream(data.getData())) - else: - img.read(StringStream(data)) - except: - self.notify.warning('image url %d could not read %s' % (self.curArticleIndex, url)) - - else: - text = '' - self.articleText[self.curArticleIndex] = text - if type(data) == Ramfile: - textData = data.getData() - else: - textData = data - textData = textData.replace('\\1', '\x01') - textData = textData.replace('\\2', '\x02') - textData = textData.replace('\r', ' ') - self.articleText[self.curArticleIndex] = textData - self.articleIndexList.addItem('') - if self.newsStatusLabel['text']: - self.newsStatusLabel['text'] = '' - self.incrementCurFields() - if self.downloadedAllArticles(): - self.notify.debug('we got everything') - else: - url = self.urls[self.curUrlIndex] - self.downloadUrl(url) - - def downloadedAllArticles(self): - maxArticles = len(self.urls) / 2 - result = False - if self.curArticleIndex >= maxArticles: - result = True - if self.curUrlIndex >= len(self.urls): - result = True - return result - - def incrementCurFields(self): - if self.curDownloadIsJpg: - self.curDownloadIsJpg = False - self.curUrlIndex += 1 - else: - self.curDownloadIsJpg = True - self.curUrlIndex += 1 - self.curArticleIndex += 1 - - def printCurFields(self): - self.notify.debug('curUrlIndex=%s curArticleIndex=%s curDownloadIsJpg=%s' % (self.curUrlIndex, self.curArticleIndex, self.curDownloadIsJpg)) - - def getFileUrl(self, fileUrl): - result = True - urlStrings = '' - try: - urlfile = urllib.urlopen(fileUrl) - urlStrings = urlfile.read() - urlfile.close() - except IOError: - self.notify.warning('Could not open %s' % fileUrl) - result = False - - self.doneGettingUrl(fileUrl, urlStrings, result) - - def getHttpUrl(self, httpUrl): - docSpec = DocumentSpec(httpUrl) - self.ramfile = Ramfile() - self.nonBlock.beginGetDocument(docSpec) - self.nonBlock.downloadToRam(self.ramfile) - self.startCheckingAsyncRequest(httpUrl) - - def startCheckingAsyncRequest(self, url): - taskMgr.remove(self.DownloadArticlesTaskName) - task = taskMgr.doMethodLater(0.5, self.pollDownloadTask, self.DownloadArticlesTaskName) - task.url = url - - def stopCheckingAsyncRequest(self): - taskMgr.remove(self.DownloadArticlesTaskName) - - def pollDownloadTask(self, task): - result = self.nonBlock.run() - if result == 0: - self.stopCheckingAsyncRequest() - allOk = False - if self.nonBlock.getStatusString() == 'OK': - allOk = True - else: - self.notify.warning('%s for %s' % (self.nonBlock.getStatusString(), task.url)) - self.doneGettingUrl(task.url, self.ramfile, allOk) - else: - return Task.again - - def getNewsUrl(self): - result = '' - if self.NewsUrl == self.DefaultNewsUrl: - serverAddress = base.cr.getServerAddress() - if 'test.toontown' in serverAddress.getServer(): - result = 'http://play.test.toontown.com' - elif 'ttown4' in serverAddress.getServer(): - result = 'http://ttown4.online.disney.com:1601' - elif 'qa.toontown' in serverAddress.getServer(): - result = 'http://play.qa.toontown.com' - else: - result = 'http://play.toontown.com' - result += self.NewsUrl - else: - result = self.NewsUrl - return result + self.toontownTimeGui.updateTime() \ No newline at end of file diff --git a/toontown/shtiker/HtmlView.py b/toontown/shtiker/HtmlView.py deleted file mode 100644 index ab300f6e..00000000 --- a/toontown/shtiker/HtmlView.py +++ /dev/null @@ -1,283 +0,0 @@ -import array, sys -from direct.showbase.DirectObject import DirectObject -from direct.task.Task import Task -from direct.directnotify import DirectNotifyGlobal -from pandac.PandaModules import Texture -from pandac.PandaModules import CardMaker -from pandac.PandaModules import NodePath -from pandac.PandaModules import Point3, Vec3, Vec4, VBase4D, Point2 -from pandac.PandaModules import PNMImage -from pandac.PandaModules import TextureStage -from pandac.PandaModules import Texture -from pandac.PandaModules import WindowProperties -from direct.interval.IntervalGlobal import * -from pandac.PandaModules import AwWebView -from pandac.PandaModules import AwWebCore -WEB_WIDTH_PIXELS = 784 -WEB_HEIGHT_PIXELS = 451 -WEB_WIDTH = 1024 -WEB_HEIGHT = 512 -WEB_HALF_WIDTH = WEB_WIDTH / 2 -WIN_WIDTH = 800 -WIN_HEIGHT = 600 -GlobalWebcore = None - -class HtmlView(DirectObject): - notify = DirectNotifyGlobal.directNotify.newCategory('HtmlView') - useHalfTexture = base.config.GetBool('news-half-texture', 0) - - def __init__(self, parent = aspect2d): - global GlobalWebcore - self.parent = parent - self.mx = 0 - self.my = 0 - self.htmlFile = 'index.html' - self.transparency = False - if GlobalWebcore: - pass - else: - GlobalWebcore = AwWebCore(AwWebCore.LOGVERBOSE, True, AwWebCore.PFBGRA) - GlobalWebcore.setBaseDirectory('.') - for errResponse in xrange(400, 600): - GlobalWebcore.setCustomResponsePage(errResponse, 'error.html') - - self.webView = GlobalWebcore.createWebView(WEB_WIDTH, WEB_HEIGHT, self.transparency, False, 70) - frameName = '' - inGameNewsUrl = self.getInGameNewsUrl() - self.imgBuffer = array.array('B') - for i in xrange(WEB_WIDTH * WEB_HEIGHT): - self.imgBuffer.append(0) - self.imgBuffer.append(0) - self.imgBuffer.append(0) - self.imgBuffer.append(255) - - if self.useHalfTexture: - self.leftBuffer = array.array('B') - for i in xrange(WEB_HALF_WIDTH * WEB_HEIGHT): - self.leftBuffer.append(0) - self.leftBuffer.append(0) - self.leftBuffer.append(0) - self.leftBuffer.append(255) - - self.rightBuffer = array.array('B') - for i in xrange(WEB_HALF_WIDTH * WEB_HEIGHT): - self.rightBuffer.append(0) - self.rightBuffer.append(0) - self.rightBuffer.append(0) - self.rightBuffer.append(255) - - self.setupTexture() - if self.useHalfTexture: - self.setupHalfTextures() - self.accept('mouse1', self.mouseDown, [AwWebView.LEFTMOUSEBTN]) - self.accept('mouse3', self.mouseDown, [AwWebView.RIGHTMOUSEBTN]) - self.accept('mouse1-up', self.mouseUp, [AwWebView.LEFTMOUSEBTN]) - self.accept('mouse3-up', self.mouseUp, [AwWebView.RIGHTMOUSEBTN]) - - def getInGameNewsUrl(self): - result = base.config.GetString('fallback-news-url', 'http://cdn.toontown.disney.go.com/toontown/en/gamenews/') - override = base.config.GetString('in-game-news-url', '') - if override: - self.notify.info('got an override url, using %s for in a game news' % override) - result = override - else: - try: - launcherUrl = base.launcher.getValue('GAME_IN_GAME_NEWS_URL', '') - if launcherUrl: - result = launcherUrl - self.notify.info('got GAME_IN_GAME_NEWS_URL from launcher using %s' % result) - else: - self.notify.info('blank GAME_IN_GAME_NEWS_URL from launcher, using %s' % result) - except: - self.notify.warning('got exception getting GAME_IN_GAME_NEWS_URL from launcher, using %s' % result) - - return result - - def setupTexture(self): - cm = CardMaker('quadMaker') - cm.setColor(1.0, 1.0, 1.0, 1.0) - aspect = base.camLens.getAspectRatio() - htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH) - htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT) - cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0) - bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1) - bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1) - cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1)) - card = cm.generate() - self.quad = NodePath(card) - self.quad.reparentTo(self.parent) - self.guiTex = Texture('guiTex') - self.guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba) - self.guiTex.setMinfilter(Texture.FTLinear) - self.guiTex.setKeepRamImage(True) - self.guiTex.makeRamImage() - self.guiTex.setWrapU(Texture.WMRepeat) - self.guiTex.setWrapV(Texture.WMRepeat) - ts = TextureStage('webTS') - self.quad.setTexture(ts, self.guiTex) - self.quad.setTexScale(ts, 1.0, -1.0) - self.quad.setTransparency(0) - self.quad.setTwoSided(True) - self.quad.setColor(1.0, 1.0, 1.0, 1.0) - self.calcMouseLimits() - - def setupHalfTextures(self): - self.setupLeftTexture() - self.setupRightTexture() - self.fullPnmImage = PNMImage(WEB_WIDTH, WEB_HEIGHT, 4) - self.leftPnmImage = PNMImage(WEB_HALF_WIDTH, WEB_HEIGHT, 4) - self.rightPnmImage = PNMImage(WEB_HALF_WIDTH, WEB_HEIGHT, 4) - - def setupLeftTexture(self): - cm = CardMaker('quadMaker') - cm.setColor(1.0, 1.0, 1.0, 1.0) - aspect = base.camLens.getAspectRatio() - htmlWidth = 2.0 * aspect * WEB_WIDTH / float(WIN_WIDTH) - htmlHeight = 2.0 * float(WEB_HEIGHT) / float(WIN_HEIGHT) - cm.setFrame(-htmlWidth / 2.0, 0, -htmlHeight / 2.0, htmlHeight / 2.0) - card = cm.generate() - self.leftQuad = NodePath(card) - self.leftQuad.reparentTo(self.parent) - self.leftGuiTex = Texture('guiTex') - self.leftGuiTex.setupTexture(Texture.TT2dTexture, WEB_HALF_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba) - self.leftGuiTex.setKeepRamImage(True) - self.leftGuiTex.makeRamImage() - self.leftGuiTex.setWrapU(Texture.WMClamp) - self.leftGuiTex.setWrapV(Texture.WMClamp) - ts = TextureStage('leftWebTS') - self.leftQuad.setTexture(ts, self.leftGuiTex) - self.leftQuad.setTexScale(ts, 1.0, -1.0) - self.leftQuad.setTransparency(0) - self.leftQuad.setTwoSided(True) - self.leftQuad.setColor(1.0, 1.0, 1.0, 1.0) - - def setupRightTexture(self): - cm = CardMaker('quadMaker') - cm.setColor(1.0, 1.0, 1.0, 1.0) - aspect = base.camLens.getAspectRatio() - htmlWidth = 2.0 * aspect * WEB_WIDTH / float(WIN_WIDTH) - htmlHeight = 2.0 * float(WEB_HEIGHT) / float(WIN_HEIGHT) - cm.setFrame(0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0) - card = cm.generate() - self.rightQuad = NodePath(card) - self.rightQuad.reparentTo(self.parent) - self.rightGuiTex = Texture('guiTex') - self.rightGuiTex.setupTexture(Texture.TT2dTexture, WEB_HALF_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba) - self.rightGuiTex.setKeepRamImage(True) - self.rightGuiTex.makeRamImage() - self.rightGuiTex.setWrapU(Texture.WMClamp) - self.rightGuiTex.setWrapV(Texture.WMClamp) - ts = TextureStage('rightWebTS') - self.rightQuad.setTexture(ts, self.rightGuiTex) - self.rightQuad.setTexScale(ts, 1.0, -1.0) - self.rightQuad.setTransparency(0) - self.rightQuad.setTwoSided(True) - self.rightQuad.setColor(1.0, 1.0, 1.0, 1.0) - - def calcMouseLimits(self): - ll = Point3() - ur = Point3() - self.quad.calcTightBounds(ll, ur) - self.notify.debug('ll=%s ur=%s' % (ll, ur)) - offset = self.quad.getPos(aspect2d) - self.notify.debug('offset = %s ' % offset) - ll.setZ(ll.getZ() + offset.getZ()) - ur.setZ(ur.getZ() + offset.getZ()) - self.notify.debug('new LL=%s, UR=%s' % (ll, ur)) - relPointll = self.quad.getRelativePoint(aspect2d, ll) - self.notify.debug('relPoint = %s' % relPointll) - self.mouseLL = (aspect2d.getScale()[0] * ll[0], aspect2d.getScale()[2] * ll[2]) - self.mouseUR = (aspect2d.getScale()[0] * ur[0], aspect2d.getScale()[2] * ur[2]) - self.notify.debug('original mouseLL=%s, mouseUR=%s' % (self.mouseLL, self.mouseUR)) - - def writeTex(self, filename = 'guiText.png'): - self.notify.debug('writing texture') - self.guiTex.generateRamMipmapImages() - self.guiTex.write(filename) - - def toggleRotation(self): - if self.interval.isPlaying(): - self.interval.finish() - else: - self.interval.loop() - - def mouseDown(self, button): - messenger.send('wakeup') - self.webView.injectMouseDown(button) - - def mouseUp(self, button): - self.webView.injectMouseUp(button) - - def reload(self): - pass - - def zoomIn(self): - self.webView.zoomIn() - - def zoomOut(self): - self.webView.zoomOut() - - def toggleTransparency(self): - self.transparency = not self.transparency - self.webView.setTransparent(self.transparency) - - def update(self, task): - if base.mouseWatcherNode.hasMouse(): - x, y = self._translateRelativeCoordinates(base.mouseWatcherNode.getMouseX(), base.mouseWatcherNode.getMouseY()) - if self.mx - x != 0 or self.my - y != 0: - self.webView.injectMouseMove(x, y) - self.mx, self.my = x, y - if self.webView.isDirty(): - self.webView.render(self.imgBuffer.buffer_info()[0], WEB_WIDTH * 4, 4) - Texture.setTexturesPower2(2) - textureBuffer = self.guiTex.modifyRamImage() - textureBuffer.setData(self.imgBuffer.tostring()) - if self.useHalfTexture: - self.guiTex.store(self.fullPnmImage) - self.leftPnmImage.copySubImage(self.fullPnmImage, 0, 0, 0, 0, WEB_HALF_WIDTH, WEB_HEIGHT) - self.rightPnmImage.copySubImage(self.fullPnmImage, 0, 0, WEB_HALF_WIDTH, 0, WEB_HALF_WIDTH, WEB_HEIGHT) - self.leftGuiTex.load(self.leftPnmImage) - self.rightGuiTex.load(self.rightPnmImage) - self.quad.hide() - Texture.setTexturesPower2(1) - GlobalWebcore.update() - return Task.cont - - def _translateRelativeCoordinates(self, x, y): - sx = int((x - self.mouseLL[0]) / (self.mouseUR[0] - self.mouseLL[0]) * WEB_WIDTH_PIXELS) - sy = WEB_HEIGHT_PIXELS - int((y - self.mouseLL[1]) / (self.mouseUR[1] - self.mouseLL[1]) * WEB_HEIGHT_PIXELS) - return (sx, sy) - - def unload(self): - self.ignoreAll() - self.webView.destroy() - self.webView = None - return - - def onCallback(self, name, args): - if name == 'requestFPS': - pass - - def onBeginNavigation(self, url, frameName): - pass - - def onBeginLoading(self, url, frameName, statusCode, mimeType): - pass - - def onFinishLoading(self): - self.notify.debug('finished loading') - - def onReceiveTitle(self, title, frameName): - pass - - def onChangeTooltip(self, tooltip): - pass - - def onChangeCursor(self, cursor): - pass - - def onChangeKeyboardFocus(self, isFocused): - pass - - def onChangeTargetURL(self, url): - pass diff --git a/toontown/shtiker/InGameNewsFrame.py b/toontown/shtiker/InGameNewsFrame.py deleted file mode 100644 index 44166d98..00000000 --- a/toontown/shtiker/InGameNewsFrame.py +++ /dev/null @@ -1,39 +0,0 @@ -import datetime -from toontown.shtiker import HtmlView - -class InGameNewsFrame(HtmlView.HtmlView): - TaskName = 'HtmlViewUpdateTask' - - def __init__(self, parent = aspect2d): - HtmlView.HtmlView.__init__(self, parent) - self.initialLoadDone = False - self.accept('newsSnapshot', self.doSnapshot) - - def activate(self): - self.quad.show() - self.calcMouseLimits() - if not self.initialLoadDone: - inGameNewsUrl = self.getInGameNewsUrl() - self.webView.loadURL2(inGameNewsUrl) - self.initialLoadDone = True - taskMgr.add(self.update, self.TaskName) - - def deactivate(self): - self.quad.hide() - taskMgr.remove(self.TaskName) - - def unload(self): - self.deactivate() - HtmlView.HtmlView.unload(self) - self.ignore('newsSnapshot') - - def doSnapshot(self): - curtime = datetime.datetime.now() - filename = 'news_snapshot_' + curtime.isoformat() - filename = filename.replace(':', '-') - filename = filename.replace('.', '-') - pngfilename = filename + '.png' - self.writeTex(pngfilename) - jpgfilename = filename + '.jpg' - self.writeTex(jpgfilename) - return jpgfilename diff --git a/toontown/shtiker/IssueFrame.py b/toontown/shtiker/IssueFrame.py deleted file mode 100644 index fd374783..00000000 --- a/toontown/shtiker/IssueFrame.py +++ /dev/null @@ -1,390 +0,0 @@ -import os -from pandac.PandaModules import VirtualFileSystem, Filename, DSearchPath -from pandac.PandaModules import Texture, CardMaker, PNMImage, TextureStage -from pandac.PandaModules import NodePath -from pandac.PandaModules import Point2 -from direct.showbase import DirectObject -from direct.gui.DirectGui import DirectFrame, DirectButton, DGG, DirectLabel -from direct.directnotify import DirectNotifyGlobal -from toontown.toonbase import TTLocalizer -from toontown.toonbase import ToontownGlobals -WEB_WIDTH_PIXELS = 784 -WEB_HEIGHT_PIXELS = 451 -WEB_WIDTH = 1024 -WEB_HEIGHT = 512 -WEB_HALF_WIDTH = WEB_WIDTH / 2 -WIN_WIDTH = 800 -WIN_HEIGHT = 600 - -class IssueFrame(DirectFrame): - NewsBaseDir = config.GetString('news-base-dir', '/httpNews') - FrameDimensions = (-1.30666637421, - 1.30666637421, - -0.751666665077, - 0.751666665077) - notify = DirectNotifyGlobal.directNotify.newCategory('IssueFrame') - ContentPattern = 'tt_i_art_%s_%s%d.jpg' - SectionIdents = ['hom', - 'new', - 'evt', - 'tot', - 'att', - 'tnr'] - - def __init__(self, parent, newsDir, dateStr, myIssueIndex, numIssues, strFilenames): - DirectFrame.__init__(self, frameColor=(1, 1, 1, 0), frameSize=self.FrameDimensions, relief=DGG.FLAT, parent=parent) - self.hide() - self.accept('newsSnapshot', self.doSnapshot) - self.parent = parent - self.newsDir = newsDir - self.dateStr = dateStr - self.myIssueIndex = myIssueIndex - self.numIssues = numIssues - self.strFilenames = strFilenames - self.sectionList = [] - self.sectionFrames = {} - self.flatSubsectionList = [] - self.parseNewsContent() - self.load() - self.curSection = 0 - self.curSubsection = 0 - - def parseNewsContent(self): - for section, ident in enumerate(self.SectionIdents): - subSectionList = [] - curSubSection = 0 - endSearch = False - while not endSearch: - justName = self.ContentPattern % (self.dateStr, ident, curSubSection + 1) - fullName = Filename(self.newsDir + '/' + justName) - if self.strFilenames: - if justName in self.strFilenames: - subSectionList.append(fullName) - self.flatSubsectionList.append((section, curSubSection)) - curSubSection += 1 - else: - endSearch = True - else: - theFile = vfs.getFile(Filename(fullName), status_only=1) - if theFile: - subSectionList.append(fullName) - self.flatSubsectionList.append((section, curSubSection)) - curSubSection += 1 - else: - endSearch = True - - if not subSectionList: - self.notify.warning('Could not load %s' % fullName) - subSectionList.append('error_' + str(fullName)) - self.flatSubsectionList.append((section, 0)) - self.sectionList.append(subSectionList) - - self.notify.debug('%s' % self.sectionList) - - def getPreviousTarget(self, section, subSection): - result = None - if (section, subSection) in self.flatSubsectionList: - index = self.flatSubsectionList.index((section, subSection)) - if index > 0: - result = self.flatSubsectionList[index - 1] - return result - - def getNextTarget(self, section, subSection): - result = None - if (section, subSection) in self.flatSubsectionList: - index = self.flatSubsectionList.index((section, subSection)) - if index < len(self.flatSubsectionList) - 1: - result = self.flatSubsectionList[index + 1] - return result - - def load(self): - self.gui = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_directNewsGui') - self.guiNav = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_directNewsGuiNav') - numPagesLoaded = 0 - totalNumberOfPages = len(self.flatSubsectionList) - for section, subSectionList in enumerate(self.sectionList): - self.notify.debug('loading section %d' % section) - self.sectionFrames[section] = {} - for subsection, fullFilename in enumerate(subSectionList): - self.notify.debug('loading subsection %d' % subsection) - newPage = self.createPage(section, subsection, fullFilename) - numPagesLoaded += 1 - self.sectionFrames[section][subsection] = newPage - - def createPage(self, section, subsection, fullFilename): - upsellBackground = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_newsStatusBackground') - imageScaleX = self.FrameDimensions[1] - self.FrameDimensions[0] - imageScaleY = self.FrameDimensions[3] - self.FrameDimensions[2] - pageFrame = DirectFrame(frameColor=(1, 1, 1, 0), frameSize=self.FrameDimensions, image=upsellBackground, image_scale=(imageScaleX, 1, imageScaleY), relief=DGG.FLAT, parent=self, text='', text_scale=0.06, text_pos=(0, -0.4)) - if 'error_' in str(fullFilename): - pageFrame['text'] = TTLocalizer.NewsPageErrorDownloadingFileCanStillRead % fullFilename[len('error_'):] - else: - quad = self.loadFlatQuad(fullFilename) - if quad: - quad.reparentTo(pageFrame) - else: - pageFrame['text'] = TTLocalizer.NewsPageErrorDownloadingFileCanStillRead % fullFilename - self.loadRightArrow(section, subsection, pageFrame) - self.loadLeftArrow(section, subsection, pageFrame) - if section == 0 and subsection == 0: - self.loadHomePageButtons(section, subsection, pageFrame) - else: - self.loadNavButtons(pageFrame) - pageFrame.hide() - return pageFrame - - def loadRightArrow(self, section, subsection, pageFrame): - nextTarget = self.getNextTarget(section, subsection) - position = (1.16, 0, -0.69) - xSize = 48 - desiredXSize = 22 - imageScale = float(desiredXSize) / xSize - if nextTarget: - image = self.gui.find('**/tt_i_art_btn_ArrowRight') - rollover = self.gui.find('**/tt_i_art_btn_ArrowRightRo') - rightArrow = DirectButton(relief=None, parent=pageFrame, command=self.gotoPage, extraArgs=(nextTarget[0], nextTarget[1]), image=(image, - image, - rollover, - image), pos=position, image_scale=imageScale) - return - - def loadLeftArrow(self, section, subsection, pageFrame): - prevTarget = self.getPreviousTarget(section, subsection) - position = (-1.16, 0, -0.69) - xSize = 48 - desiredXSize = 22 - imageScale = float(desiredXSize) / xSize - if prevTarget: - image = self.gui.find('**/tt_i_art_btn_ArrowLeft') - rollover = self.gui.find('**/tt_i_art_btn_ArrowLeftRo') - rightArrow = DirectButton(relief=None, parent=pageFrame, command=self.gotoPage, extraArgs=(prevTarget[0], prevTarget[1]), image=(image, - image, - rollover, - image), pos=position, image_scale=imageScale) - return - - def loadHomePageButtons(self, section, subsection, pageFrame): - buttonNames = ['', - 'tt_i_art_btn_HomNew', - 'tt_i_art_btn_HomEvt', - 'tt_i_art_btn_HomTot', - 'tt_i_art_btn_HomAsk', - 'tt_i_art_btn_HomTnr'] - rolloverButtonNames = [] - for name in buttonNames: - ro = name + 'Ro' - rolloverButtonNames.append(ro) - - positions = [(0, 0.0), - (-1.05333, 0, 0.29333), - (-1.05333, 0, 0.0666667), - (-1.05333, 0, -0.156667), - (-1.05333, 0, -0.383333), - (-1.05333, 0, -0.606667)] - xSize = 136 - desiredXSize = 69 - image_scale = float(desiredXSize) / xSize - image_scale *= float(69) / 70 - self.sectionBtns = [] - for section in xrange(1, len(self.SectionIdents)): - image = self.gui.find('**/%s' % buttonNames[section]) - rolloverImage = self.gui.find('**/%s' % rolloverButtonNames[section]) - if image.isEmpty(): - self.notify.error('cant find %s' % buttonNames[section]) - sectionBtn = DirectButton(relief=None, parent=pageFrame, image=(image, - image, - rolloverImage, - image), image_scale=image_scale, command=self.gotoPage, extraArgs=(section, 0), enableEdit=1, pos=positions[section]) - - readMorePos = (0.906666, 0, -0.19) - readImage = self.gui.find('**/tt_i_art_btn_ReadMore') - readRollover = self.gui.find('**/tt_i_art_btn_ReadMoreRo') - xSize = 228.0 - desiredXSize = 113.0 - imageScale = desiredXSize / xSize - readMoreBtn = DirectButton(relief=None, parent=pageFrame, image=(readImage, - readImage, - readRollover, - readImage), image_scale=imageScale, command=self.gotoPage, extraArgs=(1, 0), enableEdit=1, pos=readMorePos) - self.loadWeekNavButtons(pageFrame) - return - - def loadWeekNavButtons(self, pageFrame): - if self.numIssues <= 1: - return - if self.myIssueIndex == self.numIssues - 1: - weekStr = TTLocalizer.IssueFrameThisWeek - elif self.myIssueIndex == self.numIssues - 2: - weekStr = TTLocalizer.IssueFrameLastWeek - else: - weeksAgo = self.numIssues - self.myIssueIndex - 1 - weekStr = TTLocalizer.IssueFrameWeeksAgo % weeksAgo - prevImage = self.gui.find('**/tt_i_art_btn_ArchiveArrwLeftNormal') - prevImageRo = self.gui.find('**/tt_i_art_btn_ArchiveArrwLeftRo') - prevImageDisabled = self.gui.find('**/tt_i_art_btn_ArchiveArrwLeftDisabled') - actualY1 = 78.0 - desiredY1 = 42.0 - y1Scale = desiredY1 / actualY1 - prevWeekBtn = DirectButton(relief=None, parent=pageFrame, image=[prevImage, - prevImage, - prevImageRo, - prevImageDisabled], image_scale=y1Scale, command=self.changeWeek, extraArgs=(self.myIssueIndex - 1,), pos=(0.806666, 0, 0.62)) - if self.myIssueIndex == 0: - prevWeekBtn['state'] = DGG.DISABLED - nextImage = self.gui.find('**/tt_i_art_btn_ArchiveArrwRightNormal') - nextImageRo = self.gui.find('**/tt_i_art_btn_ArchiveArrwRightRo') - nextImageDisabled = self.gui.find('**/tt_i_art_btn_ArchiveArrwRightDisabled') - actualY2Scale = 63.0 - desiredY2Scale = 34.0 - y2Scale = desiredY2Scale / actualY2Scale - nextWeekBtn = DirectButton(relief=None, parent=pageFrame, image=[nextImage, - nextImage, - nextImageRo, - nextImageDisabled], image_scale=y2Scale, command=self.changeWeek, extraArgs=(self.myIssueIndex + 1,), pos=(1.16, 0, 0.623333)) - if self.myIssueIndex == self.numIssues - 1: - nextWeekBtn['state'] = DGG.DISABLED - actualX = 176.0 - desiredX = 89.0 - imageScale = desiredX / actualX - midImage = self.gui.find('**/tt_i_art_btn_ArchiveMiddle') - weekColor = (0.0 / 255.0, - 23.0 / 255.0, - 140.0 / 255.0, - 1.0) - weekLabel = DirectLabel(relief=None, image=midImage, image_scale=imageScale, parent=pageFrame, text=weekStr, text_font=ToontownGlobals.InterfaceFont, text_fg=weekColor, text_scale=0.043, text_pos=(0, -0.01, 0), pos=(0.983333, 0, 0.62)) - return - - def loadNavButtons(self, pageFrame): - buttonNames = ['tt_i_art_btn_NavHom', - 'tt_i_art_btn_NavNew', - 'tt_i_art_btn_NavEvt', - 'tt_i_art_btn_NavTot', - 'tt_i_art_btn_NavAtt', - 'tt_i_art_btn_NavTnr'] - rolloverButtonNames = [] - for name in buttonNames: - ro = name + 'Ro' - rolloverButtonNames.append(ro) - - xPos = 1.24667 - positions = [(xPos, 0, 0.623333), - (xPos, 0, 0.536663), - (xPos, 0, 0.45), - (xPos, 0, 0.36333), - (xPos, 0, 0.276667), - (xPos, 0, 0.19)] - xSize1 = 177 - desiredXSize1 = 90 - image_scale1 = float(desiredXSize1) / xSize1 - image_scale = 1 - xSize2 = 300 - desiredXSize2 = 152 - image_scale2 = float(desiredXSize2) / xSize2 - image_scale2 *= 30.0 / 30.0 - rolloverPositions = [(1.15, 0, 0.623333), - (1.15, 0, 0.533333), - (1.15, 0, 0.443333), - (1.045, 0, 0.353333), - (1.045, 0, 0.263334), - (1.045, 0, 0.173333)] - imageScales = [image_scale1, - image_scale1, - image_scale1, - image_scale2, - image_scale2, - image_scale2] - frameSizeAdj1 = 0.1 - frameSize1 = (-0.04 + frameSizeAdj1, - 0.04 + frameSizeAdj1, - -0.04, - 0.04) - frameSizeAdj2 = 0.21 - frameSize2 = (-0.04 + frameSizeAdj2, - 0.04 + frameSizeAdj2, - -0.04, - 0.04) - frameSizes = (frameSize1, - frameSize1, - frameSize1, - frameSize2, - frameSize2, - frameSize2) - self.sectionBtns = [] - for section in xrange(0, len(self.SectionIdents)): - image = self.guiNav.find('**/%s' % buttonNames[section]) - rolloverImage = self.guiNav.find('**/%s' % rolloverButtonNames[section]) - if image.isEmpty(): - self.notify.error('cant find %s' % buttonNames[section]) - sectionBtn = DirectButton(relief=None, parent=pageFrame, frameSize=frameSizes[section], image=(image, - rolloverImage, - rolloverImage, - image), image_scale=imageScales[section], command=self.gotoPage, extraArgs=(section, 0), enableEdit=1, pos=rolloverPositions[section]) - - return - - def gotoPage(self, section, subsection): - if base.config.GetBool('want-qa-regression', 0): - self.notify.info('QA-REGRESSION: INGAMENEWS: Goto Page') - self.sectionFrames[self.curSection][self.curSubsection].hide() - self.sectionFrames[section][subsection].show() - self.curSection = section - self.curSubsection = subsection - messenger.send('wakeup') - - def loadFlatQuad(self, fullFilename): - cm = CardMaker('cm-%s' % fullFilename) - cm.setColor(1.0, 1.0, 1.0, 1.0) - aspect = base.camLens.getAspectRatio() - htmlWidth = 2.0 * aspect * WEB_WIDTH_PIXELS / float(WIN_WIDTH) - htmlHeight = 2.0 * float(WEB_HEIGHT_PIXELS) / float(WIN_HEIGHT) - cm.setFrame(-htmlWidth / 2.0, htmlWidth / 2.0, -htmlHeight / 2.0, htmlHeight / 2.0) - bottomRightX = WEB_WIDTH_PIXELS / float(WEB_WIDTH + 1) - bottomRightY = WEB_HEIGHT_PIXELS / float(WEB_HEIGHT + 1) - cm.setUvRange(Point2(0, 1 - bottomRightY), Point2(bottomRightX, 1)) - card = cm.generate() - quad = NodePath(card) - jpgFile = PNMImage(WEB_WIDTH, WEB_HEIGHT) - smallerJpgFile = PNMImage() - readFile = smallerJpgFile.read(Filename(fullFilename)) - if readFile: - jpgFile.copySubImage(smallerJpgFile, 0, 0) - guiTex = Texture('guiTex') - guiTex.setupTexture(Texture.TT2dTexture, WEB_WIDTH, WEB_HEIGHT, 1, Texture.TUnsignedByte, Texture.FRgba) - guiTex.setMinfilter(Texture.FTLinear) - guiTex.load(jpgFile) - guiTex.setWrapU(Texture.WMClamp) - guiTex.setWrapV(Texture.WMClamp) - ts = TextureStage('webTS') - quad.setTexture(ts, guiTex) - quad.setTransparency(0) - quad.setTwoSided(True) - quad.setColor(1.0, 1.0, 1.0, 1.0) - result = quad - else: - result = None - Texture.setTexturesPower2(1) - return result - - def loadBackground(self): - self.backFrame = DirectFrame(parent=self, frameColor=(1, 1, 1, 1), frameSize=self.FrameDimensions, pos=(0, 0, 0), relief=None) - return - - def loadMainPage(self): - self.mainFrame = DirectFrame(parent=self, frameSize=self.FrameDimensions, frameColor=(1, 0, 0, 1)) - - def activate(self): - pass - - def deactivate(self): - pass - - def unload(self): - self.ignore('newsSnapshot') - - def doSnapshot(self): - pass - - def changeWeek(self, newIssueWeek): - if base.config.GetBool('want-qa-regression', 0): - self.notify.info('QA-REGRESSION: INGAMENEWS: Change Week') - messenger.send('newsChangeWeek', [newIssueWeek]) diff --git a/toontown/shtiker/IssueFrameV2.py b/toontown/shtiker/IssueFrameV2.py deleted file mode 100644 index 96fc51ca..00000000 --- a/toontown/shtiker/IssueFrameV2.py +++ /dev/null @@ -1,159 +0,0 @@ -from pandac.PandaModules import Filename -from direct.directnotify import DirectNotifyGlobal -from direct.gui.DirectGui import DGG, DirectFrame, DirectButton -from toontown.shtiker import IssueFrame - -class IssueFrameV2(IssueFrame.IssueFrame): - notify = DirectNotifyGlobal.directNotify.newCategory('IssueFrameV2') - SectionIdents = ['hom', - 'new', - 'evt', - 'tot', - 'att', - 'tnr', - 'ext'] - - def __init__(self, parent, newsDir, dateStr, myIssueIndex, numIssues, strFilenames, newsIndexEntries): - self.newsIndexEntries = newsIndexEntries - self.dateStr = dateStr - self.calcActualSectionsInThisIssue() - IssueFrame.IssueFrame.__init__(self, parent, newsDir, dateStr, myIssueIndex, numIssues, strFilenames) - self.notify.debug('version2 %s' % dateStr) - - def load(self): - self.guiNavV2 = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_directNewsGuiNavV2') - IssueFrame.IssueFrame.load(self) - - def calcActualSectionsInThisIssue(self): - self.actualSectionIdents = [] - for ident in self.SectionIdents: - identTest = self.dateStr + '_' + ident + '1' - if self.isSectionInIndex(identTest): - self.actualSectionIdents.append(ident) - - def isSectionInIndex(self, sectionIdent): - for name in self.newsIndexEntries: - if sectionIdent in name and self.dateStr in name: - return True - - return False - - def parseNewsContent(self): - existingSectionIndex = 0 - for section, ident in enumerate(self.SectionIdents): - subSectionList = [] - curSubSection = 0 - endSearch = False - while not endSearch: - justName = self.ContentPattern % (self.dateStr, ident, curSubSection + 1) - fullName = Filename(self.newsDir + '/' + justName) - if self.strFilenames: - if justName in self.strFilenames: - subSectionList.append(fullName) - self.flatSubsectionList.append((existingSectionIndex, curSubSection)) - curSubSection += 1 - else: - endSearch = True - else: - theFile = vfs.getFile(Filename(fullName), status_only=1) - if theFile: - subSectionList.append(fullName) - self.flatSubsectionList.append((existingSectionIndex, curSubSection)) - curSubSection += 1 - else: - if curSubSection == 0 and self.isSectionInIndex(ident): - self.notify.warning('could not find %s' % fullName) - subSectionList.append(fullName) - self.flatSubsectionList.append((existingSectionIndex, curSubSection)) - endSearch = True - - if not subSectionList: - pass - else: - self.sectionList.append(subSectionList) - existingSectionIndex += 1 - - self.notify.debug('IssueFrameV2 self.sectionList=%s' % self.sectionList) - - def loadHomePageButtons(self, section, subsection, pageFrame): - self.notify.debug('Doing nothing for loadNavButtons') - if section == 0 and subsection == 0: - self.loadNavButtons(pageFrame) - self.parentOfWeekNav = DirectFrame(frameColor=(1, 1, 1, 0), relief=DGG.FLAT, parent=pageFrame) - self.loadWeekNavButtons(self.parentOfWeekNav) - self.parentOfWeekNav.setPos(-1.94, 0, 0) - - def loadNavButtons(self, pageFrame): - identToButtonNames = {'hom': 'tt_i_art_btn_NavHom2', - 'new': 'tt_i_art_btn_NavNew2', - 'evt': 'tt_i_art_btn_NavEvt2', - 'tot': 'tt_i_art_btn_NavTot2', - 'att': 'tt_i_art_btn_NavAtt2', - 'tnr': 'tt_i_art_btn_NavTnr2', - 'ext': 'tt_i_art_btn_NavExt2'} - identToRolloverButtonNames = {'hom': 'tt_i_art_btn_NavHomRo2', - 'new': 'tt_i_art_btn_NavNewRo2', - 'evt': 'tt_i_art_btn_NavEvtRo2', - 'tot': 'tt_i_art_btn_NavTotRo2', - 'att': 'tt_i_art_btn_NavAttRo2', - 'tnr': 'tt_i_art_btn_NavTnrRo2', - 'ext': 'tt_i_art_btn_NavExtRo2'} - xPos = 1.24667 - positions = [(xPos, 0, 0.623333), - (xPos, 0, 0.536663), - (xPos, 0, 0.45), - (xPos, 0, 0.36333), - (xPos, 0, 0.276667), - (xPos, 0, 0.19), - (xPos, 0, 0.08)] - xSize1 = 177 - desiredXSize1 = 90 - image_scale1 = float(desiredXSize1) / xSize1 - image_scale = 1 - xSize2 = 300 - desiredXSize2 = 152 - image_scale2 = float(desiredXSize2) / xSize2 - image_scale2 *= 30.0 / 30.0 - rolloverPositions = [(1.045, 0, 0.623333), - (1.045, 0, 0.533333), - (1.045, 0, 0.443333), - (1.045, 0, 0.353333), - (1.045, 0, 0.263334), - (1.045, 0, 0.173333), - (1.045, 0, 0.09)] - imageScales = [image_scale2, - image_scale2, - image_scale2, - image_scale2, - image_scale2, - image_scale2, - image_scale2] - frameSizeAdj1 = 0.1 - frameSize1 = (-0.04 + frameSizeAdj1, - 0.04 + frameSizeAdj1, - -0.04, - 0.04) - frameSizeAdj2 = 0.21 - frameSize2 = (-0.04 + frameSizeAdj2, - 0.04 + frameSizeAdj2, - -0.04, - 0.04) - frameSizes = (frameSize2, - frameSize2, - frameSize2, - frameSize2, - frameSize2, - frameSize2, - frameSize2) - self.sectionBtns = [] - for section, ident in enumerate(self.actualSectionIdents): - image = self.guiNavV2.find('**/%s' % identToButtonNames[ident]) - rolloverImage = self.guiNavV2.find('**/%s' % identToRolloverButtonNames[ident]) - if image.isEmpty(): - self.notify.error('cant find %s' % identToButtonNames[ident]) - sectionBtn = DirectButton(relief=None, parent=pageFrame, frameSize=frameSizes[section], image=(image, - rolloverImage, - rolloverImage, - image), image_scale=imageScales[section], command=self.gotoPage, extraArgs=(section, 0), enableEdit=1, pos=rolloverPositions[section]) - - return diff --git a/toontown/shtiker/NewsPage.py b/toontown/shtiker/NewsPage.py deleted file mode 100644 index 9de768e2..00000000 --- a/toontown/shtiker/NewsPage.py +++ /dev/null @@ -1,82 +0,0 @@ -from direct.fsm import StateData -from direct.gui.DirectGui import DirectFrame -from direct.gui.DirectGui import DGG -from direct.gui.DirectGui import DirectLabel -from direct.directnotify import DirectNotifyGlobal -from toontown.toonbase import ToontownGlobals -from toontown.shtiker import ShtikerPage -from toontown.toonbase import TTLocalizer -UseDirectNewsFrame = config.GetBool('use-direct-news-frame', True) -HaveNewsFrame = True -if UseDirectNewsFrame: - from toontown.shtiker import DirectNewsFrame -else: - try: - from toontown.shtiker import InGameNewsFrame - except: - HaveNewsFrame = False - -class NewsPage(ShtikerPage.ShtikerPage): - notify = DirectNotifyGlobal.directNotify.newCategory('NewsPage') - - def __init__(self): - ShtikerPage.ShtikerPage.__init__(self) - - def load(self): - self.noNewsLabel = DirectLabel(parent=self, relief=None, text=TTLocalizer.NewsPageImportError, text_scale=0.12) - if HaveNewsFrame: - if UseDirectNewsFrame: - import datetime - start = datetime.datetime.now() - self.newsFrame = DirectNewsFrame.DirectNewsFrame(parent=self) - ending = datetime.datetime.now() - self.notify.info('time to load news = %s' % str(ending - start)) - else: - self.newsFrame = InGameNewsFrame.InGameNewsFrame(parent=self) - self.newsFrame.activate() - return - - def unload(self): - if HaveNewsFrame: - self.newsFrame.unload() - del self.newsFrame - - def clearPage(self): - pass - - def updatePage(self): - pass - - def enter(self): - self.updatePage() - ShtikerPage.ShtikerPage.enter(self) - if HaveNewsFrame: - if self.book: - self.book.prevArrow.hide() - self.book.disableAllPageTabs() - self.newsFrame.activate() - base.setCellsActive(base.leftCells, 0) - base.setCellsActive([base.rightCells[1]], 0) - localAvatar.book.bookCloseButton.hide() - localAvatar.setLastTimeReadNews(base.cr.toontownTimeManager.getCurServerDateTime()) - - def exit(self): - self.clearPage() - if self.book: - self.book.prevArrow.show() - self.book.enableAllPageTabs() - ShtikerPage.ShtikerPage.exit(self) - if HaveNewsFrame: - self.newsFrame.deactivate() - base.setCellsActive(base.leftCells, 1) - base.setCellsActive([base.rightCells[1]], 1) - if localAvatar.book.shouldBookButtonBeHidden(): - localAvatar.book.bookCloseButton.hide() - else: - localAvatar.book.bookCloseButton.show() - - def doSnapshot(self): - if HaveNewsFrame: - return self.newsFrame.doSnapshot() - else: - return 'No News Frame' diff --git a/toontown/shtiker/ShtikerBook.py b/toontown/shtiker/ShtikerBook.py index c01985ab..02e2d4ac 100644 --- a/toontown/shtiker/ShtikerBook.py +++ b/toontown/shtiker/ShtikerBook.py @@ -24,7 +24,6 @@ class ShtikerBook(DirectFrame, StateData.StateData): self.pageTabFrame = DirectFrame(parent=self, relief=None, pos=(0.93, 1, 0.575), scale=1.25) self.pageTabFrame.hide() self.currPageIndex = None - self.pageBeforeNews = None self.entered = 0 self.safeMode = 0 self.__obscured = 0 @@ -47,8 +46,7 @@ class ShtikerBook(DirectFrame, StateData.StateData): TTLocalizer.GolfPageTitle, TTLocalizer.PhotoPageTitle, TTLocalizer.EventsPageName, - TTLocalizer.AchievementsPageTitle, - TTLocalizer.NewsPageName] + TTLocalizer.AchievementsPageTitle] return def setSafeMode(self, setting): @@ -79,8 +77,6 @@ class ShtikerBook(DirectFrame, StateData.StateData): self.accept(ToontownGlobals.OptionsPageHotkey, self.__close) self.pageTabFrame.show() self.pages[self.currPageIndex].enter() - if hasattr(localAvatar, 'newsButtonMgr') and localAvatar.newsButtonMgr: - localAvatar.newsButtonMgr.hideNewIssueButton() def exit(self): if not self.entered: @@ -164,28 +160,12 @@ class ShtikerBook(DirectFrame, StateData.StateData): if pageName not in self.pageOrder: self.notify.error('Trying to add page %s in the ShtickerBook. Page not listed in the order.' % pageName) return - pageIndex = 0 - if len(self.pages): - newIndex = len(self.pages) - prevIndex = newIndex - 1 - if self.pages[prevIndex].pageName == TTLocalizer.NewsPageName: - self.pages.insert(prevIndex, page) - pageIndex = prevIndex - if self.currPageIndex >= pageIndex: - self.currPageIndex += 1 - else: - self.pages.append(page) - pageIndex = len(self.pages) - 1 - else: - self.pages.append(page) - pageIndex = len(self.pages) - 1 + self.pages.append(page) + pageIndex = len(self.pages) - 1 page.setBook(self) page.setPageName(pageName) page.reparentTo(self) self.addPageTab(page, pageIndex, pageName) - from toontown.shtiker import MapPage - if isinstance(page, MapPage.MapPage): - self.pageBeforeNews = page def addPageTab(self, page, pageIndex, pageName = 'Page'): tabIndex = len(self.pageTabs) @@ -196,8 +176,6 @@ class ShtikerBook(DirectFrame, StateData.StateData): self.setPage(page) if base.config.GetBool('want-qa-regression', 0): self.notify.info('QA-REGRESSION: SHTICKERBOOK: Browse tabs %s' % page.pageName) - localAvatar.newsButtonMgr.setGoingToNewsPageFromStickerBook(False) - localAvatar.newsButtonMgr.showAppropriateButton() yOffset = 0.07 * pageIndex iconGeom = None @@ -271,13 +249,7 @@ class ShtikerBook(DirectFrame, StateData.StateData): elif pageName == TTLocalizer.PhotoPageTitle: iconGeom = iconModels = loader.loadModel('phase_4/models/minigames/photogame_filmroll') iconScale = (1.9, 1.5, 1.5) - iconModels.detachNode() - elif pageName == TTLocalizer.NewsPageName: - iconModels = loader.loadModel('phase_3.5/models/gui/sos_textures') - iconGeom = iconModels.find('**/tt_t_gui_sbk_newsPageTab') iconModels.detachNode() - buttonPressedCommand = self.goToNewsPage - extraArgs = [page] if pageName == TTLocalizer.OptionsPageTitle: pageName = TTLocalizer.OptionsTabTitle pageTab = DirectButton(parent=self.pageTabFrame, relief=DGG.RAISED, frameSize=(-0.575, @@ -298,16 +270,8 @@ class ShtikerBook(DirectFrame, StateData.StateData): if enterPage: self.showPageArrows() page.enter() - from toontown.shtiker import NewsPage - if not isinstance(page, NewsPage.NewsPage): - self.pageBeforeNews = page return - def setPageBeforeNews(self, enterPage = True): - self.setPage(self.pageBeforeNews, enterPage) - self.accept(ToontownGlobals.StickerBookHotkey, self.__close) - self.accept(ToontownGlobals.OptionsPageHotkey, self.__close) - def setPageTabIndex(self, pageTabIndex): if self.currPageTabIndex is not None and pageTabIndex != self.currPageTabIndex: self.pageTabs[self.currPageTabIndex]['relief'] = DGG.RAISED @@ -333,12 +297,10 @@ class ShtikerBook(DirectFrame, StateData.StateData): def showButton(self): self.__shown = 1 self.__setButtonVisibility() - localAvatar.newsButtonMgr.showAppropriateButton() def hideButton(self): self.__shown = 0 self.__setButtonVisibility() - localAvatar.newsButtonMgr.request('Hidden') def __setButtonVisibility(self): if self.__isOpen: @@ -398,12 +360,7 @@ class ShtikerBook(DirectFrame, StateData.StateData): self.setPageTabIndex(self.currPageIndex) self.showPageArrows() page = self.pages[self.currPageIndex] - from toontown.shtiker import NewsPage - if isinstance(page, NewsPage.NewsPage): - self.goToNewsPage(page) - else: - page.enter() - self.pageBeforeNews = page + page.enter() def showPageArrows(self): if self.currPageIndex == len(self.pages) - 1: @@ -412,33 +369,14 @@ class ShtikerBook(DirectFrame, StateData.StateData): else: self.prevArrow.show() self.nextArrow.show() - self.__checkForNewsPage() + self.__checkForPage() if self.currPageIndex == 0: self.prevArrow.hide() self.nextArrow.show() - def __checkForNewsPage(self): - from toontown.shtiker import NewsPage - self.ignore('arrow_left') - self.ignore('arrow_right') - if isinstance(self.pages[self.currPageIndex], NewsPage.NewsPage): - self.ignore('arrow_left') - self.ignore('arrow_right') - else: - self.accept('arrow_right', self.__pageChange, [1]) - self.accept('arrow_left', self.__pageChange, [-1]) - - def goToNewsPage(self, page): - messenger.send('wakeup') - base.playSfx(self.pageSound) - localAvatar.newsButtonMgr.setGoingToNewsPageFromStickerBook(True) - localAvatar.newsButtonMgr.showAppropriateButton() - self.setPage(page) - if base.config.GetBool('want-qa-regression', 0): - self.notify.info('QA-REGRESSION: SHTICKERBOOK: Browse tabs %s' % page.pageName) - self.ignore(ToontownGlobals.StickerBookHotkey) - self.ignore(ToontownGlobals.OptionsPageHotkey) - localAvatar.newsButtonMgr.acceptEscapeKeyPress() + def __checkForPage(self): + self.accept('arrow_right', self.__pageChange, [1]) + self.accept('arrow_left', self.__pageChange, [-1]) def disableBookCloseButton(self): if self.bookCloseButton: diff --git a/toontown/toon/LocalToon.py b/toontown/toon/LocalToon.py index 980b8797..c15c1fa5 100644 --- a/toontown/toon/LocalToon.py +++ b/toontown/toon/LocalToon.py @@ -58,14 +58,8 @@ from toontown.toon.DistributedNPCToonBase import DistributedNPCToonBase from toontown.toonbase import TTLocalizer from toontown.toonbase import ToontownGlobals from toontown.toonbase.ToontownGlobals import * -from toontown.toontowngui import NewsPageButtonManager from toontown.friends.FriendHandle import FriendHandle - -WantNewsPage = base.config.GetBool('want-news-page', ToontownGlobals.DefaultWantNewsPageSetting) -if WantNewsPage: - from toontown.shtiker import NewsPage -AdjustmentForNewsButton = -0.275 ClaraBaseXPos = 0.12 if (__debug__): import pdb @@ -96,10 +90,7 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): friendsButtonNormal = friendsGui.find('**/FriendsBox_Closed') friendsButtonPressed = friendsGui.find('**/FriendsBox_Rollover') friendsButtonRollover = friendsGui.find('**/FriendsBox_Rollover') - newScale = oldScale = 0.8 - if WantNewsPage: - newScale = oldScale * ToontownGlobals.NewsPageScaleAdjust - self.bFriendsList = DirectButton(image=(friendsButtonNormal, friendsButtonPressed, friendsButtonRollover), relief=None, pos=(-0.141, 0, -0.125), parent=base.a2dTopRight, scale=newScale, text=('', TTLocalizer.FriendsListLabel, TTLocalizer.FriendsListLabel), text_scale=0.09, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.18), text_font=ToontownGlobals.getInterfaceFont(), command=self.sendFriendsListEvent) + self.bFriendsList = DirectButton(image=(friendsButtonNormal, friendsButtonPressed, friendsButtonRollover), relief=None, pos=(-0.141, 0, -0.125), parent=base.a2dTopRight, scale=0.8, text=('', TTLocalizer.FriendsListLabel, TTLocalizer.FriendsListLabel), text_scale=0.09, text_fg=Vec4(1, 1, 1, 1), text_shadow=Vec4(0, 0, 0, 1), text_pos=(0, -0.18), text_font=ToontownGlobals.getInterfaceFont(), command=self.sendFriendsListEvent) self.bFriendsList.hide() self.friendsListButtonActive = 0 self.friendsListButtonObscured = 0 @@ -169,7 +160,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): self.createSystemMsgAckGui() if not hasattr(base.cr, 'lastLoggedIn'): base.cr.lastLoggedIn = self.cr.toontownTimeManager.convertStrToToontownTime('') - self.setLastTimeReadNews(base.cr.lastLoggedIn) self.acceptingNewFriends = True self.acceptingNonFriendWhispers = True self.physControls.event.addAgainPattern('again%in') @@ -275,7 +265,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): if hasattr(self, 'purchaseButton'): self.purchaseButton.destroy() del self.purchaseButton - self.newsButtonMgr.request('Off') self.book.unload() del self.optionsPage del self.shardPage @@ -343,8 +332,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): return def initInterface(self): - self.newsButtonMgr = NewsPageButtonManager.NewsPageButtonManager() - self.newsButtonMgr.request('Hidden') self.book = ShtikerBook.ShtikerBook('bookDone') self.book.load() self.book.hideButton() @@ -391,8 +378,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): self.photoPage.load() self.book.addPage(self.photoPage, pageName=TTLocalizer.PhotoPageTitle) self.addEventsPage() - if WantNewsPage: - self.addNewsPage() self.book.setPage(self.mapPage, enterPage=False) self.laffMeter = LaffMeter.LaffMeter(self.style, self.hp, self.maxHp) self.laffMeter.setAvatar(self) @@ -1008,23 +993,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): if self.__furnitureGui: self.__furnitureGui.hide() - def clarabelleNewsPageCollision(self, show = True): - if self.__clarabelleButton == None: - return - claraXPos = ClaraBaseXPos - notifyXPos = CatalogNotifyDialog.CatalogNotifyBaseXPos - if show: - claraXPos += AdjustmentForNewsButton - notifyXPos += AdjustmentForNewsButton - newPos = (claraXPos - 0.1, 1.0, 0.45) - self.__clarabelleButton.setPos(newPos) - if self.__catalogNotifyDialog == None or self.__catalogNotifyDialog.frame == None: - return - notifyPos = self.__catalogNotifyDialog.frame.getPos() - notifyPos[0] = notifyXPos - self.__catalogNotifyDialog.frame.setPos(notifyPos) - return - def loadClarabelleGui(self): if self.__clarabelleButton: return @@ -1036,13 +1004,7 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): white = VBase4(1.0, 1.0, 1.0, 1.0) icon.setColor(white) claraXPos = ClaraBaseXPos - newScale = oldScale = 0.5 - newPos = (claraXPos, 1.0, -0.63) - if WantNewsPage: - claraXPos += AdjustmentForNewsButton - newScale = oldScale * ToontownGlobals.NewsPageScaleAdjust - newPos = (claraXPos - 0.1, 1.0, -0.63) - self.__clarabelleButton = DirectButton(relief=None, image=circle, text='', text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.1, text_pos=(-1.06, 1.06), text_font=ToontownGlobals.getInterfaceFont(), pos=newPos, scale=newScale, command=self.__handleClarabelleButton) + self.__clarabelleButton = DirectButton(relief=None, image=circle, text='', text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=0.1, text_pos=(-1.06, 1.06), text_font=ToontownGlobals.getInterfaceFont(), pos=(claraXPos, 1.0, -0.63), scale=0.5, command=self.__handleClarabelleButton) self.__clarabelleButton.reparentTo(base.a2dTopRight, DGG.BACKGROUND_SORT_INDEX - 1) button = self.__clarabelleButton.stateNodePath[0] self.__clarabelleFlash = Sequence(LerpColorInterval(button, 2, white, blendType='easeInOut'), LerpColorInterval(button, 2, rgba, blendType='easeInOut')) @@ -1058,8 +1020,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): self.__clarabelleButton['text'] = ['', TTLocalizer.CatalogNewCatalogButton, TTLocalizer.CatalogNewCatalogButton] if not self.mailboxNotify and not self.awardNotify and self.catalogNotify == ToontownGlobals.OldItems and (self.simpleMailNotify != ToontownGlobals.NoItems or self.inviteMailNotify != ToontownGlobals.NoItems): self.__clarabelleButton['text'] = ['', TTLocalizer.MailNewMailButton, TTLocalizer.MailNewMailButton] - if self.newsButtonMgr.isNewIssueButtonShown(): - self.clarabelleNewsPageCollision(True) self.__clarabelleButton.show() self.__clarabelleFlash.resume() @@ -1837,11 +1797,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): self.book.addPage(self.eventsPage, pageName=TTLocalizer.EventsPageName) return - def addNewsPage(self): - self.newsPage = NewsPage.NewsPage() - self.newsPage.load() - self.book.addPage(self.newsPage, pageName=TTLocalizer.NewsPageName) - def addTIPPage(self): self.tipPage = TIPPage.TIPPage() self.tipPage.load() @@ -1894,12 +1849,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): elif av: self.notify.warning('setSleepAutoReply from non-toon %s' % fromId) - def setLastTimeReadNews(self, newTime): - self.lastTimeReadNews = newTime - - def getLastTimeReadNews(self): - return self.lastTimeReadNews - def cheatCogdoMazeGame(self, kindOfCheat = 0): if base.config.GetBool('allow-cogdo-maze-suit-hit-cheat'): maze = base.cr.doFind('DistCogdoMazeGame') @@ -1916,17 +1865,6 @@ class LocalToon(DistributedToon.DistributedToon, LocalAvatar.LocalAvatar): else: self.sendUpdate('logSuspiciousEvent', ['cheatCogdoMazeGame']) - def isReadingNews(self): - result = False - if base.cr and base.cr.playGame and base.cr.playGame.getPlace() and hasattr(base.cr.playGame.getPlace(), 'fsm') and base.cr.playGame.getPlace().fsm: - fsm = base.cr.playGame.getPlace().fsm - curState = fsm.getCurrentState().getName() - if curState == 'stickerBook' and WantNewsPage: - if hasattr(self, 'newsPage'): - if self.book.isOnPage(self.newsPage): - result = True - return result - def doTeleportResponse(self, fromAvatar, toAvatar, avId, available, shardId, hoodId, zoneId, sendToId): self.d_teleportResponse(avId, available, shardId, hoodId, zoneId, sendToId) diff --git a/toontown/toonbase/TTLocalizerEnglish.py b/toontown/toonbase/TTLocalizerEnglish.py index 8291ba77..3db2fb71 100644 --- a/toontown/toonbase/TTLocalizerEnglish.py +++ b/toontown/toonbase/TTLocalizerEnglish.py @@ -4172,25 +4172,6 @@ EventsPageInvitedTabTitle = 'Party Invitations' EventsPageInvitedTabInvitationListTitle = 'Invitations' EventsPageInvitedTabActivityListTitle = 'Activities' EventsPageInvitedTabTime = '%s %s Toontown Time' -EventsPageNewsTabName = 'News' -EventsPageNewsTabTitle = 'News' -EventsPageNewsDownloading = 'Retrieving News...' -EventsPageNewsUnavailable = 'Chip and Dale played with the printing press. News not available.' -EventsPageNewsPaperTitle = 'TOONTOWN TIMES' -EventsPageNewsLeftSubtitle = 'Still only 1 Jellybean' -EventsPageNewsRightSubtitle = 'Established toon-thousand nine' -NewsPageName = 'News' -NewsPageImportError = 'Whoops! There is an issue loading the "Toon News ... for the Amused!" Please check back later.' -NewsPageDownloadingNewsSubstr = 'Stay Tooned, while we bring you the latest issue of the \n"Toon News ... for the Amused!"' -NewsPageDownloadingNews0 = NewsPageDownloadingNewsSubstr + ' %s%% Complete.' -NewsPageDownloadingNews1 = NewsPageDownloadingNewsSubstr + ' %s%% Complete..' -NewsPageDownloadingNews2 = NewsPageDownloadingNewsSubstr + ' %s%% Complete...' -NewsPageErrorDownloadingFile = 'Whoops! Page %s is missing from "Toon News ... for the Amused!" Please check back later.' -NewsPageErrorDownloadingFileCanStillRead = 'Whoops! Page %s \nis missing from the "Toon News ... for the Amused!" \nTurn the page to continue, while we work to get this page back.' -NewsPageNoIssues = 'Whoops! The "Toon News ... for the Amused!" has gone missing! \nStay Tooned ... while we work to bring the news back!' -IssueFrameThisWeek = 'this week' -IssueFrameLastWeek = 'last week' -IssueFrameWeeksAgo = '%d weeks ago' SelectedInvitationInformation = '%s is having a party on %s at %s Toontown Time.' PartyPlannerNextButton = 'Continue' PartyPlannerPreviousButton = 'Back' diff --git a/toontown/toonbase/TTLocalizerEnglishProperty.py b/toontown/toonbase/TTLocalizerEnglishProperty.py index 800e96d4..0c2b266c 100644 --- a/toontown/toonbase/TTLocalizerEnglishProperty.py +++ b/toontown/toonbase/TTLocalizerEnglishProperty.py @@ -218,7 +218,6 @@ EPtitleLabel = 0.12 EPhostTab = 0.07 EPinvitedTab = 0.07 EPcalendarTab = 0.07 -EPnewsTab = 0.07 EPhostingCancelButton = 0.04 EPhostingDateLabel = 0.05 EPpartyGoButton = 0.045 diff --git a/toontown/toonbase/ToontownGlobals.py b/toontown/toonbase/ToontownGlobals.py index c277dbec..8c52dd3c 100644 --- a/toontown/toonbase/ToontownGlobals.py +++ b/toontown/toonbase/ToontownGlobals.py @@ -1597,7 +1597,6 @@ DG = 5 BR = 6 OZ = 7 DL = 8 -DefaultWantNewsPageSetting = 0 gmMagicWordList = ['restock', 'restockUber', 'autoRestock', @@ -1614,7 +1613,6 @@ gmMagicWordList = ['restock', 'newSummons', 'who', 'who all'] -NewsPageScaleAdjust = 0.85 AnimPropTypes = Enum(('Unknown', 'Hydrant', 'Mailbox', diff --git a/toontown/toontowngui/NewsPageButtonManager.py b/toontown/toontowngui/NewsPageButtonManager.py deleted file mode 100644 index 6b0e0b9a..00000000 --- a/toontown/toontowngui/NewsPageButtonManager.py +++ /dev/null @@ -1,241 +0,0 @@ -from pandac.PandaModules import VBase4, VBase3 -from direct.fsm import FSM -from direct.directnotify import DirectNotifyGlobal -from direct.gui.DirectButton import DirectButton -from toontown.toonbase import ToontownGlobals -from direct.gui.DirectGui import * -from direct.interval.IntervalGlobal import * -from toontown.toonbase import TTLocalizer -from toontown.coghq import CogHQBossBattle - -class NewsPageButtonManager(FSM.FSM): - notify = DirectNotifyGlobal.directNotify.newCategory('NewsPageButtonManager') - - def __init__(self): - FSM.FSM.__init__(self, 'NewsPageButtonManager') - self.buttonsLoaded = False - self.clearGoingToNewsInfo() - self.__blinkIval = None - self.load() - return - - def load(self): - btnGui = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_newsBtnGui') - bookModel = loader.loadModel('phase_3.5/models/gui/tt_m_gui_ign_shtickerBook') - self.openNewNewsUp = btnGui.find('**/tt_t_gui_ign_new') - self.openNewNewsUpBlink = btnGui.find('**/tt_t_gui_ign_newBlink') - self.openNewNewsHover = btnGui.find('**/tt_t_gui_ign_newHover') - self.openOldNewsUp = btnGui.find('**/tt_t_gui_ign_oldNews') - self.openOldNewsHover = btnGui.find('**/tt_t_gui_ign_oldHover') - self.closeNewsUp = bookModel.find('**/tt_t_gui_sbk_newsPage1') - self.closeNewsHover = bookModel.find('**/tt_t_gui_sbk_newsPage2') - btnGui.removeNode() - bookModel.removeNode() - oldScale = 0.5 - newScale = 0.9 - shtickerBookScale = 0.305 - newPos = VBase3(0.914, 0, 0.862) - shtickerBookPos = VBase3(1.175, 0, -0.83) - textScale = 0.06 - self.newIssueButton = DirectButton(relief=None, sortOrder=DGG.BACKGROUND_SORT_INDEX - 1, image=(self.openNewNewsUp, self.openNewNewsHover, self.openNewNewsHover), text=('', TTLocalizer.EventsPageNewsTabName, TTLocalizer.EventsPageNewsTabName), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=textScale, text_font=ToontownGlobals.getInterfaceFont(), pos=newPos, scale=newScale, command=self.__handleGotoNewsButton) - self.gotoPrevPageButton = DirectButton(relief=None, image=(self.closeNewsUp, self.closeNewsHover, self.closeNewsHover), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=textScale, text_font=ToontownGlobals.getInterfaceFont(), pos=shtickerBookPos, scale=shtickerBookScale, command=self.__handleGotoPrevPageButton) - self.goto3dWorldButton = DirectButton(relief=None, image=(self.closeNewsUp, self.closeNewsHover, self.closeNewsHover), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 1), text_scale=textScale, text_font=ToontownGlobals.getInterfaceFont(), pos=shtickerBookPos, scale=shtickerBookScale, command=self.__handleGoto3dWorldButton) - self.hideNewIssueButton() - self.gotoPrevPageButton.hide() - self.goto3dWorldButton.hide() - self.accept('newIssueOut', self.handleNewIssueOut) - bounce1Pos = VBase3(newPos.getX(), newPos.getY(), newPos.getZ() + 0.022) - bounce2Pos = VBase3(newPos.getX(), newPos.getY(), newPos.getZ() + 0.015) - bounceIval = Sequence(LerpPosInterval(self.newIssueButton, 0.1, bounce1Pos, blendType='easeOut'), LerpPosInterval(self.newIssueButton, 0.1, newPos, blendType='easeIn'), LerpPosInterval(self.newIssueButton, 0.07, bounce2Pos, blendType='easeOut'), LerpPosInterval(self.newIssueButton, 0.07, newPos, blendType='easeIn')) - self.__blinkIval = Sequence(Func(self.__showOpenEyes), Wait(2), bounceIval, Wait(0.5), Func(self.__showClosedEyes), Wait(0.1), Func(self.__showOpenEyes), Wait(0.1), Func(self.__showClosedEyes), Wait(0.1)) - self.__blinkIval.loop() - self.__blinkIval.pause() - self.buttonsLoaded = True - return - - def __showOpenEyes(self): - self.newIssueButton['image'] = (self.openNewNewsUp, self.openNewNewsHover, self.openNewNewsHover) - - def __showClosedEyes(self): - self.newIssueButton['image'] = (self.openNewNewsUpBlink, self.openNewNewsHover, self.openNewNewsHover) - - def clearGoingToNewsInfo(self): - self.goingToNewsPageFrom3dWorld = False - self.setGoingToNewsPageFromStickerBook(False) - - def __handleGotoNewsButton(self): - currentState = base.localAvatar.animFSM.getCurrentState().getName() - if currentState == 'jumpAirborne': - return - from toontown.toon import LocalToon - if not LocalToon.WantNewsPage: - return - if base.cr and base.cr.playGame and base.cr.playGame.getPlace() and base.cr.playGame.getPlace().fsm: - fsm = base.cr.playGame.getPlace().fsm - curState = fsm.getCurrentState().getName() - if curState == 'walk': - if hasattr(localAvatar, 'newsPage'): - localAvatar.book.setPage(localAvatar.newsPage) - fsm.request('stickerBook') - self.goingToNewsPageFrom3dWorld = True - elif curState == 'stickerBook': - if hasattr(localAvatar, 'newsPage'): - fsm.request('stickerBook') - if hasattr(localAvatar, 'newsPage') and localAvatar.newsPage: - localAvatar.book.goToNewsPage(localAvatar.newsPage) - - def __handleGotoPrevPageButton(self): - self.clearGoingToNewsInfo() - localAvatar.book.setPageBeforeNews() - self.showAppropriateButton() - self.ignoreEscapeKeyPress() - - def __handleGoto3dWorldButton(self): - localAvatar.book.closeBook() - - def hideNewIssueButton(self): - if hasattr(self, 'newIssueButton') and self.newIssueButton: - self.newIssueButton.hide() - localAvatar.clarabelleNewsPageCollision(False) - - def __showNewIssueButton(self): - self.newIssueButton.show() - localAvatar.clarabelleNewsPageCollision(True) - - def hideAllButtons(self): - if not self.buttonsLoaded: - return - self.gotoPrevPageButton.hide() - self.goto3dWorldButton.hide() - self.hideNewIssueButton() - self.__blinkIval.pause() - - def isNewIssueButtonShown(self): - return False - - if localAvatar.getLastTimeReadNews() < base.cr.inGameNewsMgr.getLatestIssue(): - return True - return False - - def enterHidden(self): - self.hideAllButtons() - - def exitHidden(self): - pass - - def enterNormalWalk(self): - if not self.buttonsLoaded: - return - if localAvatar.getLastTimeReadNews() < base.cr.inGameNewsMgr.getLatestIssue(): - self.__showNewIssueButton() - self.__blinkIval.resume() - else: - self.hideNewIssueButton() - self.gotoPrevPageButton.hide() - self.goto3dWorldButton.hide() - - def exitNormalWalk(self): - if not self.buttonsLoaded: - return - self.hideAllButtons() - - def enterGotoWorld(self): - if not self.buttonsLoaded: - return - self.hideAllButtons() - self.goto3dWorldButton.show() - - def exitGotoWorld(self): - if not self.buttonsLoaded: - return - self.hideAllButtons() - localAvatar.book.setPageBeforeNews(enterPage=False) - self.clearGoingToNewsInfo() - - def enterPrevPage(self): - if not self.buttonsLoaded: - return - self.hideAllButtons() - self.gotoPrevPageButton.show() - - def exitPrevPage(self): - if not self.buttonsLoaded: - return - self.hideAllButtons() - - def showAppropriateButton(self): - self.notify.debugStateCall(self) - from toontown.toon import LocalToon - if not LocalToon.WantNewsPage: - return - if not self.buttonsLoaded: - return - if base.cr and base.cr.playGame and base.cr.playGame.getPlace() and hasattr(base.cr.playGame.getPlace(), 'fsm') and base.cr.playGame.getPlace().fsm: - fsm = base.cr.playGame.getPlace().fsm - curState = fsm.getCurrentState().getName() - book = localAvatar.book - if curState == 'walk': - if localAvatar.tutorialAck and not localAvatar.isDisguised and not isinstance(base.cr.playGame.getPlace(), CogHQBossBattle.CogHQBossBattle): - self.request('NormalWalk') - else: - self.request('Hidden') - elif curState == 'stickerBook': - if self.goingToNewsPageFrom3dWorld: - if localAvatar.tutorialAck: - self.request('GotoWorld') - else: - self.request('Hidden') - elif self.goingToNewsPageFromStickerBook or hasattr(localAvatar, 'newsPage') and localAvatar.book.isOnPage(localAvatar.newsPage): - if localAvatar.tutorialAck: - self.request('PrevPage') - else: - self.request('Hidden') - elif localAvatar.tutorialAck: - self.request('NormalWalk') - else: - self.request('Hidden') - - def setGoingToNewsPageFromStickerBook(self, newVal): - self.goingToNewsPageFromStickerBook = newVal - - def enterOff(self): - self.ignoreAll() - if not self.buttonsLoaded: - return - if self.__blinkIval: - self.__blinkIval.finish() - self.__blinkIval = None - self.newIssueButton.destroy() - self.gotoPrevPageButton.destroy() - self.goto3dWorldButton.destroy() - del self.openNewNewsUp - del self.openNewNewsUpBlink - del self.openNewNewsHover - del self.openOldNewsUp - del self.openOldNewsHover - del self.closeNewsUp - del self.closeNewsHover - return - - def exitOff(self): - self.notify.warning('Should not get here. NewsPageButtonManager.exitOff') - - def simulateEscapeKeyPress(self): - if self.goingToNewsPageFrom3dWorld: - self.__handleGoto3dWorldButton() - if self.goingToNewsPageFromStickerBook: - self.__handleGotoPrevPageButton() - - def handleNewIssueOut(self): - if localAvatar.isReadingNews(): - pass - else: - self.showAppropriateButton() - - def acceptEscapeKeyPress(self): - self.accept(ToontownGlobals.StickerBookHotkey, self.simulateEscapeKeyPress) - self.accept(ToontownGlobals.OptionsPageHotkey, self.simulateEscapeKeyPress) - - def ignoreEscapeKeyPress(self): - self.ignore(ToontownGlobals.StickerBookHotkey) - self.ignore(ToontownGlobals.OptionsPageHotkey) diff --git a/toontown/uberdog/DistributedInGameNewsMgr.py b/toontown/uberdog/DistributedInGameNewsMgr.py deleted file mode 100644 index 9fd0ed79..00000000 --- a/toontown/uberdog/DistributedInGameNewsMgr.py +++ /dev/null @@ -1,39 +0,0 @@ -import socket -import datetime -import os -from direct.distributed.DistributedObjectGlobal import DistributedObjectGlobal -from direct.distributed.DistributedObject import DistributedObject -from toontown.toonbase import ToontownGlobals - -class DistributedInGameNewsMgr(DistributedObject): - notify = directNotify.newCategory('InGameNewsMgr') - neverDisable = 1 - - def __init__(self, cr): - DistributedObject.__init__(self, cr) - base.cr.inGameNewsMgr = self - - def delete(self): - DistributedObject.delete(self) - self.cr.inGameNewsMgr = None - return - - def disable(self): - self.notify.debug("i'm disabling InGameNewsMgr rightnow.") - DistributedObject.disable(self) - - def generate(self): - self.notify.debug('BASE: generate') - DistributedObject.generate(self) - - def setLatestIssueStr(self, issueStr): - self.latestIssueStr = issueStr - self.latestIssue = base.cr.toontownTimeManager.convertUtcStrToToontownTime(issueStr) - messenger.send('newIssueOut') - self.notify.info('latestIssue=%s' % self.latestIssue) - - def getLatestIssueStr(self): - pass - - def getLatestIssue(self): - return self.latestIssue diff --git a/toontown/uberdog/DistributedInGameNewsMgrAI.py b/toontown/uberdog/DistributedInGameNewsMgrAI.py deleted file mode 100644 index 180d2484..00000000 --- a/toontown/uberdog/DistributedInGameNewsMgrAI.py +++ /dev/null @@ -1,15 +0,0 @@ -from direct.directnotify import DirectNotifyGlobal -from direct.distributed.DistributedObjectGlobalAI import DistributedObjectGlobalAI - -class DistributedInGameNewsMgrAI(DistributedObjectGlobalAI): - notify = DirectNotifyGlobal.directNotify.newCategory("DistributedInGameNewsMgrAI") - - def setLatestIssueStr(self, todo0): - pass - - def inGameNewsMgrAIStartingUp(self, todo0, todo1): - pass - - def newIssueUDtoAI(self, todo0): - pass - diff --git a/toontown/uberdog/DistributedInGameNewsMgrUD.py b/toontown/uberdog/DistributedInGameNewsMgrUD.py deleted file mode 100644 index 33da1c39..00000000 --- a/toontown/uberdog/DistributedInGameNewsMgrUD.py +++ /dev/null @@ -1,15 +0,0 @@ -from direct.directnotify import DirectNotifyGlobal -from direct.distributed.DistributedObjectGlobalUD import DistributedObjectGlobalUD - -class DistributedInGameNewsMgrUD(DistributedObjectGlobalUD): - notify = DirectNotifyGlobal.directNotify.newCategory("DistributedInGameNewsMgrUD") - - def setLatestIssueStr(self, todo0): - pass - - def inGameNewsMgrAIStartingUp(self, todo0, todo1): - pass - - def newIssueUDtoAI(self, todo0): - pass -