From 965708844c2447e5ac5c2d114fd988ed225a7dc8 Mon Sep 17 00:00:00 2001 From: John Cote Date: Tue, 2 Jun 2015 19:12:08 -0400 Subject: [PATCH] Bye bye content pack manager --- dependencies/config/general.prc | 4 - toontown/hood/DDHood.py | 16 +-- toontown/hood/OZHood.py | 15 +-- toontown/hood/ToonHood.py | 14 --- toontown/toonbase/ClientStart.py | 22 ---- toontown/toonbase/ContentPacksManager.py | 138 ----------------------- user/contentpacks/.gitignore | 3 - user/contentpacks/sort.yaml | 0 8 files changed, 2 insertions(+), 210 deletions(-) delete mode 100755 toontown/toonbase/ContentPacksManager.py delete mode 100644 user/contentpacks/.gitignore delete mode 100644 user/contentpacks/sort.yaml diff --git a/dependencies/config/general.prc b/dependencies/config/general.prc index fc2e3edc..f1030914 100644 --- a/dependencies/config/general.prc +++ b/dependencies/config/general.prc @@ -23,10 +23,6 @@ texture-anisotropic-degree 16 # Preferences: preferences-filename user/preferences.json -# Content packs: -content-packs-filepath user/contentpacks/ -content-packs-sort-filename sort.yaml - # Backups: backups-filepath dependencies/backups/ backups-extension .json diff --git a/toontown/hood/DDHood.py b/toontown/hood/DDHood.py index c9806c08..7e2a8602 100755 --- a/toontown/hood/DDHood.py +++ b/toontown/hood/DDHood.py @@ -1,11 +1,9 @@ from pandac.PandaModules import Vec4 - from toontown.safezone.DDSafeZoneLoader import DDSafeZoneLoader from toontown.town.DDTownLoader import DDTownLoader from toontown.toonbase import ToontownGlobals from toontown.hood.ToonHood import ToonHood - class DDHood(ToonHood): notify = directNotify.newCategory('DDHood') @@ -16,7 +14,7 @@ class DDHood(ToonHood): SKY_FILE = 'phase_3.5/models/props/BR_sky' SPOOKY_SKY_FILE = 'phase_3.5/models/props/BR_sky' TITLE_COLOR = (0.8, 0.6, 0.5, 1.0) - + underwaterColor = Vec4(0.0, 0.0, 0.6, 1.0) HOLIDAY_DNA = { ToontownGlobals.WINTER_DECORATIONS: ['phase_6/dna/winter_storage_DD.pdna'], ToontownGlobals.WACKY_WINTER_DECORATIONS: ['phase_6/dna/winter_storage_DD.pdna'], @@ -26,18 +24,6 @@ class DDHood(ToonHood): def __init__(self, parentFSM, doneEvent, dnaStore, hoodId): ToonHood.__init__(self, parentFSM, doneEvent, dnaStore, hoodId) - # Load content pack ambience settings: - ambience = contentPacksMgr.getAmbience('donalds-dock') - - color = ambience.get('underwater-color') - if color is not None: - try: - self.underwaterColor = Vec4(color['r'], color['g'], color['b'], color['a']) - except Exception, e: - raise ContentPackError(e) - elif self.underwaterColor is None: - self.underwaterColor = Vec4(0, 0, 0.6, 1) - def load(self): ToonHood.load(self) diff --git a/toontown/hood/OZHood.py b/toontown/hood/OZHood.py index 318234f1..5ddbedbd 100755 --- a/toontown/hood/OZHood.py +++ b/toontown/hood/OZHood.py @@ -1,10 +1,8 @@ from pandac.PandaModules import Vec4 - from toontown.safezone.OZSafeZoneLoader import OZSafeZoneLoader from toontown.toonbase import ToontownGlobals from toontown.hood.ToonHood import ToonHood - class OZHood(ToonHood): notify = directNotify.newCategory('OZHood') @@ -14,22 +12,11 @@ class OZHood(ToonHood): SKY_FILE = 'phase_3.5/models/props/TT_sky' SPOOKY_SKY_FILE = 'phase_3.5/models/props/BR_sky' TITLE_COLOR = (1.0, 0.5, 0.4, 1.0) + underwaterColor = Vec4(0.0, 0.0, 0.6, 1.0) def __init__(self, parentFSM, doneEvent, dnaStore, hoodId): ToonHood.__init__(self, parentFSM, doneEvent, dnaStore, hoodId) - # Load content pack ambience settings: - ambience = contentPacksMgr.getAmbience('outdoor-zone') - - color = ambience.get('underwater-color') - if color is not None: - try: - self.underwaterColor = Vec4(color['r'], color['g'], color['b'], color['a']) - except Exception, e: - raise ContentPackError(e) - elif self.underwaterColor is None: - self.underwaterColor = Vec4(0, 0, 0.6, 1) - def load(self): ToonHood.load(self) diff --git a/toontown/hood/ToonHood.py b/toontown/hood/ToonHood.py index ab11fca7..665bec4e 100755 --- a/toontown/hood/ToonHood.py +++ b/toontown/hood/ToonHood.py @@ -11,7 +11,6 @@ from toontown.cogdominium import CogdoInterior from toontown.toon.Toon import teleportDebug from toontown.hood import SkyUtil - class ToonHood(Hood): notify = directNotify.newCategory('ToonHood') @@ -22,7 +21,6 @@ class ToonHood(Hood): SKY_FILE = None SPOOKY_SKY_FILE = None TITLE_COLOR = None - HOLIDAY_DNA = {} def __init__(self, parentFSM, doneEvent, dnaStore, hoodId): @@ -54,18 +52,6 @@ class ToonHood(Hood): State.State('final', self.enterFinal, self.exitFinal, [])], 'start', 'final') self.fsm.enterInitialState() - # Load content pack ambience settings: - ambience = contentPacksMgr.getAmbience('general') - - color = ambience.get('underwater-color') - if color is not None: - try: - self.underwaterColor = Vec4(color['r'], color['g'], color['b'], color['a']) - except Exception, e: - raise ContentPackError(e) - else: - self.underwaterColor = None - # Until we cleanup Hood, we will need to define some variables self.id = self.ID self.storageDNAFile = self.STORAGE_DNA diff --git a/toontown/toonbase/ClientStart.py b/toontown/toonbase/ClientStart.py index 778f65e8..580cafde 100755 --- a/toontown/toonbase/ClientStart.py +++ b/toontown/toonbase/ClientStart.py @@ -103,28 +103,6 @@ loadPrcFileData('Settings: musicVol', 'audio-master-music-volume %s' % settings[ loadPrcFileData('Settings: sfxVol', 'audio-master-sfx-volume %s' % settings['sfxVol']) loadPrcFileData('Settings: loadDisplay', 'load-display %s' % settings['loadDisplay']) -import os - -from toontown.toonbase.ContentPacksManager import ContentPackError -from toontown.toonbase.ContentPacksManager import ContentPacksManager - - -contentPacksFilepath = ConfigVariableString( - 'content-packs-filepath', 'user/contentpacks/').getValue() -contentPacksSortFilename = ConfigVariableString( - 'content-packs-sort-filename', 'sort.yaml').getValue() -if not os.path.exists(contentPacksFilepath): - os.makedirs(contentPacksFilepath) -__builtin__.ContentPackError = ContentPackError -__builtin__.contentPacksMgr = ContentPacksManager( - filepath=contentPacksFilepath, sortFilename=contentPacksSortFilename) -contentPacksMgr.applyAll() - -languagePack = settings['language'].lower() + '.mf' - -if contentPacksMgr.isApplicable(languagePack): - contentPacksMgr.applyMultifile(languagePack) - import time import sys import random diff --git a/toontown/toonbase/ContentPacksManager.py b/toontown/toonbase/ContentPacksManager.py deleted file mode 100755 index d85e01a7..00000000 --- a/toontown/toonbase/ContentPacksManager.py +++ /dev/null @@ -1,138 +0,0 @@ -from direct.directnotify.DirectNotifyGlobal import directNotify -import fnmatch -import os -import yaml -from panda3d.core import Multifile, Filename, VirtualFileSystem - -APPLICABLE_FILE_PATTERNS = ('*.mf', 'ambience.yaml') -CONTENT_EXT_WHITELIST = ('.jpg', '.jpeg', '.rgb', '.png', '.ogg', '.ttf') - -class ContentPackError(Exception): - pass - -class ContentPacksManager: - notify = directNotify.newCategory('ContentPacksManager') - notify.setInfo(True) - - def __init__(self, filepath='user/contentpacks/', sortFilename='sort.yaml'): - self.filepath = filepath - self.sortFilename = os.path.join(self.filepath, sortFilename) - - if __debug__: - self.mountPoint = '../resources' - else: - self.mountPoint = '/' - - self.vfs = VirtualFileSystem.getGlobalPtr() - - self.sort = [] - self.ambience = {} - - def isApplicable(self, filename): - """ - Returns whether or not the specified file is applicable. - """ - # Does this file exist? - if not os.path.exists(filename): - return False - - # Does this file match one of the applicable file patterns? - basename = os.path.basename(filename) - for pattern in APPLICABLE_FILE_PATTERNS: - if fnmatch.fnmatch(basename, pattern): - return True - - return False - - def applyMultifile(self, filename): - """ - Apply the specified multifile. - """ - mf = Multifile() - mf.openReadWrite(Filename(filename)) - - # Discard content with non-whitelisted extensions: - for subfileName in mf.getSubfileNames(): - ext = os.path.splitext(subfileName)[1] - if ext not in CONTENT_EXT_WHITELIST: - mf.removeSubfile(subfileName) - - self.vfs.mount(mf, self.mountPoint, 0) - - def applyAmbience(self, filename): - """ - Apply the specified ambience configuration file. - """ - with open(os.path.join(self.filepath, filename), 'r') as f: - self.ambience.update(yaml.load(f) or {}) - - def apply(self, filename): - """ - Apply the specified content pack file. - """ - self.notify.info('Applying %s...' % filename) - basename = os.path.basename(filename) - if basename.endswith('.mf'): - self.applyMultifile(os.path.join(self.filepath, filename)) - elif basename == 'ambience.yaml': - self.applyAmbience(filename) - - def applyAll(self): - """ - Using the sort configuration, recursively apply all applicable content - pack files under the configured content packs directory. - """ - # First, read the sort configuration: - self.readSortConfig() - - # Next, apply the sorted files: - for filename in self.sort[:]: - if self.isApplicable(os.path.join(self.filepath, filename)): - self.apply(filename) - else: - self.notify.warning('Invalidating %s...' % filename) - self.sort.remove(filename) - - # Apply the non-sorted files: - for root, _, filenames in os.walk(self.filepath): - root = root[len(self.filepath):] - for filename in filenames: - filename = os.path.join(root, filename).replace('\\', '/') - - # Ensure this file isn't sorted: - if filename in self.sort: - continue - - # Ensure this file is applicable: - if not self.isApplicable(os.path.join(self.filepath, filename)): - continue - - # Apply this file, and add it to the sort configuration: - self.apply(filename) - self.sort.append(filename) - - # Finally, write the new sort configuration: - self.writeSortConfig() - - def readSortConfig(self): - """ - Read the sort configuration. - """ - if not os.path.exists(self.sortFilename): - return - with open(self.sortFilename, 'r') as f: - self.sort = yaml.load(f) or [] - - def writeSortConfig(self): - """ - Write the sort configuration to disk. - """ - with open(self.sortFilename, 'w') as f: - for filename in self.sort: - f.write('- %s\n' % filename) - - def getAmbience(self, group): - """ - Returns the ambience configurations for the specified group. - """ - return self.ambience.get(group, {}) diff --git a/user/contentpacks/.gitignore b/user/contentpacks/.gitignore deleted file mode 100644 index 848e0447..00000000 --- a/user/contentpacks/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -* -!.gitignore -!sort.yaml \ No newline at end of file diff --git a/user/contentpacks/sort.yaml b/user/contentpacks/sort.yaml deleted file mode 100644 index e69de29b..00000000