start getting rid of DeprecationWarnings

This commit is contained in:
Open Toontown 2022-01-19 00:40:24 -05:00
parent 6bd6ec9212
commit b8d5827496
6 changed files with 64 additions and 76 deletions

View file

@ -88,7 +88,7 @@ class LauncherBase(DirectObject):
self.setRegistry(self.GameLogFilenameKey, logfile) self.setRegistry(self.GameLogFilenameKey, logfile)
self.showPhase = 3.5 self.showPhase = 3.5
self.currentPhase = 4 self.currentPhase = 4
serverVersion = launcherConfig.GetString('server-version', 'no_version_set') serverVersion = ConfigVariableString('server-version', 'no_version_set').value
if serverVersion == 'no_version_set': if serverVersion == 'no_version_set':
self.setPandaErrorCode(10) self.setPandaErrorCode(10)
self.notify.info('Aborting, config did not load!') self.notify.info('Aborting, config did not load!')

View file

@ -1,5 +1,5 @@
from direct.showbase.ShowBase import ShowBase from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import Camera, TPLow, VBase4, ColorWriteAttrib, Filename, getModelPath, NodePath from panda3d.core import Camera, TPLow, VBase4, ColorWriteAttrib, Filename, getModelPath, NodePath, ConfigVariableBool, ConfigVariableDouble
from . import OTPRender from . import OTPRender
import time import time
import math import math
@ -10,22 +10,22 @@ class OTPBase(ShowBase):
def __init__(self, windowType = None): def __init__(self, windowType = None):
self.wantEnviroDR = False self.wantEnviroDR = False
ShowBase.__init__(self, windowType=windowType) ShowBase.__init__(self, windowType=windowType)
__builtins__['__astron__'] = self.config.GetBool('astron-support', 1) __builtins__['__astron__'] = ConfigVariableBool('astron-support', 1).value
__builtins__['__execWarnings__'] = self.config.GetBool('want-exec-warnings', 0) __builtins__['__execWarnings__'] = ConfigVariableBool('want-exec-warnings', 0).value
OTPBase.notify.info('__astron__ == %s' % __astron__) OTPBase.notify.info('__astron__ == %s' % __astron__)
if config.GetBool('want-phase-checker', 0): if ConfigVariableBool('want-phase-checker', 0).value:
from direct.showbase import Loader from direct.showbase import Loader
Loader.phaseChecker = self.loaderPhaseChecker Loader.phaseChecker = self.loaderPhaseChecker
self.errorAccumulatorBuffer = '' self.errorAccumulatorBuffer = ''
taskMgr.add(self.delayedErrorCheck, 'delayedErrorCheck', priority=10000) taskMgr.add(self.delayedErrorCheck, 'delayedErrorCheck', priority=10000)
self.idTags = config.GetBool('want-id-tags', 0) self.idTags = ConfigVariableBool('want-id-tags', 0).value
if not self.idTags: if not self.idTags:
del self.idTags del self.idTags
self.wantNametags = self.config.GetBool('want-nametags', 1) self.wantNametags = ConfigVariableBool('want-nametags', 1).value
self.slowCloseShard = self.config.GetBool('slow-close-shard', 0) self.slowCloseShard = ConfigVariableBool('slow-close-shard', 0).value
self.slowCloseShardDelay = self.config.GetFloat('slow-close-shard-delay', 10.0) self.slowCloseShardDelay = ConfigVariableDouble('slow-close-shard-delay', 10.0).value
self.fillShardsToIdealPop = self.config.GetBool('fill-shards-to-ideal-pop', 1) self.fillShardsToIdealPop = ConfigVariableBool('fill-shards-to-ideal-pop', 1).value
self.logPrivateInfo = self.config.GetBool('log-private-info', __dev__) self.logPrivateInfo = ConfigVariableBool('log-private-info', __dev__).value
self.wantDynamicShadows = 1 self.wantDynamicShadows = 1
self.stereoEnabled = False self.stereoEnabled = False
self.enviroDR = None self.enviroDR = None
@ -227,7 +227,7 @@ class OTPBase(ShowBase):
def openMainWindow(self, *args, **kw): def openMainWindow(self, *args, **kw):
result = ShowBase.openMainWindow(self, *args, **kw) result = ShowBase.openMainWindow(self, *args, **kw)
if result: if result:
self.wantEnviroDR = not self.win.getGsg().isHardware() or config.GetBool('want-background-region', 1) self.wantEnviroDR = not self.win.getGsg().isHardware() or ConfigVariableBool('want-background-region', 1).value
self.backgroundDrawable = self.win self.backgroundDrawable = self.win
return result return result

View file

@ -1,13 +1,7 @@
from panda3d.core import * from panda3d.core import *
from direct.showbase import DConfig
import string language = ConfigVariableString('language', 'english').value
import types checkLanguage = ConfigVariableBool('check-language', 0).value
try:
language = DConfig.GetString('language', 'english')
checkLanguage = DConfig.GetBool('check-language', 0)
except:
language = simbase.config.GetString('language', 'english')
checkLanguage = simbase.config.GetBool('check-language', 0)
def getLanguage(): def getLanguage():
return language return language

View file

@ -1,6 +1,6 @@
import os import os
from direct.showbase.EventManagerGlobal import * from direct.showbase.EventManagerGlobal import *
from pandac.PandaModules import * from panda3d.core import *
from otp.launcher.LauncherBase import LauncherBase from otp.launcher.LauncherBase import LauncherBase
from toontown.toonbase import TTLocalizer from toontown.toonbase import TTLocalizer
@ -12,7 +12,7 @@ class QuickLauncher(LauncherBase):
print('Running: ToontownQuickLauncher') print('Running: ToontownQuickLauncher')
self.toontownBlueKey = 'TOONTOWN_BLUE' self.toontownBlueKey = 'TOONTOWN_BLUE'
LauncherBase.__init__(self) LauncherBase.__init__(self)
self.useTTSpecificLogin = config.GetBool('tt-specific-login', 0) self.useTTSpecificLogin = ConfigVariableBool('tt-specific-login', 0).value
if self.useTTSpecificLogin: if self.useTTSpecificLogin:
self.toontownPlayTokenKey = 'LOGIN_TOKEN' self.toontownPlayTokenKey = 'LOGIN_TOKEN'
else: else:

View file

@ -1,13 +1,7 @@
from panda3d.core import * from panda3d.core import *
from direct.showbase import DConfig
import string language = ConfigVariableString('language', 'english').value
import types checkLanguage = ConfigVariableBool('check-language', 0).value
try:
language = DConfig.GetString('language', 'english')
checkLanguage = DConfig.GetBool('check-language', 0)
except:
language = simbase.config.GetString('language', 'english')
checkLanguage = simbase.config.GetBool('check-language', 0)
def getLanguage(): def getLanguage():
return language return language

View file

@ -8,7 +8,7 @@ from direct.directnotify import DirectNotifyGlobal
from . import ToontownLoader from . import ToontownLoader
from direct.gui import DirectGuiGlobals from direct.gui import DirectGuiGlobals
from direct.gui.DirectGui import * from direct.gui.DirectGui import *
from pandac.PandaModules import * from panda3d.core import *
from panda3d.otp import * from panda3d.otp import *
import sys import sys
import os import os
@ -23,7 +23,7 @@ class ToonBase(OTPBase.OTPBase):
def __init__(self): def __init__(self):
self.settings = Settings() self.settings = Settings()
if not config.GetInt('ignore-user-options', 0): if not ConfigVariableInt('ignore-user-options', 0).value:
self.settings.readSettings() self.settings.readSettings()
mode = not self.settings.getSetting('windowed-mode', True) mode = not self.settings.getSetting('windowed-mode', True)
music = self.settings.getSetting('music', True) music = self.settings.getSetting('music', True)
@ -49,8 +49,8 @@ class ToonBase(OTPBase.OTPBase):
sys.exit(1) sys.exit(1)
self.disableShowbaseMouse() self.disableShowbaseMouse()
base.debugRunningMultiplier /= OTPGlobals.ToonSpeedFactor base.debugRunningMultiplier /= OTPGlobals.ToonSpeedFactor
self.toonChatSounds = self.config.GetBool('toon-chat-sounds', 1) self.toonChatSounds = ConfigVariableBool('toon-chat-sounds', 1).value
self.placeBeforeObjects = config.GetBool('place-before-objects', 1) self.placeBeforeObjects = ConfigVariableBool('place-before-objects', 1).value
self.endlessQuietZone = False self.endlessQuietZone = False
self.wantDynamicShadows = 0 self.wantDynamicShadows = 0
self.exitErrorCode = 0 self.exitErrorCode = 0
@ -72,7 +72,7 @@ class ToonBase(OTPBase.OTPBase):
if 'launcher' in __builtins__ and launcher: if 'launcher' in __builtins__ and launcher:
launcher.setPandaErrorCode(11) launcher.setPandaErrorCode(11)
globalClock.setMaxDt(0.2) globalClock.setMaxDt(0.2)
if self.config.GetBool('want-particles', 1) == 1: if ConfigVariableBool('want-particles', 1).value == 1:
self.notify.debug('Enabling particles') self.notify.debug('Enabling particles')
self.enableParticles() self.enableParticles()
self.accept(ToontownGlobals.ScreenshotHotkey, self.takeScreenShot) self.accept(ToontownGlobals.ScreenshotHotkey, self.takeScreenShot)
@ -83,51 +83,51 @@ class ToonBase(OTPBase.OTPBase):
oldLoader.destroy() oldLoader.destroy()
self.accept('PandaPaused', self.disableAllAudio) self.accept('PandaPaused', self.disableAllAudio)
self.accept('PandaRestarted', self.enableAllAudio) self.accept('PandaRestarted', self.enableAllAudio)
self.friendMode = self.config.GetBool('switchboard-friends', 0) self.friendMode = ConfigVariableBool('switchboard-friends', 0).value
self.wantPets = self.config.GetBool('want-pets', 1) self.wantPets = ConfigVariableBool('want-pets', 1).value
self.wantBingo = self.config.GetBool('want-fish-bingo', 1) self.wantBingo = ConfigVariableBool('want-fish-bingo', 1).value
self.wantKarts = self.config.GetBool('want-karts', 1) self.wantKarts = ConfigVariableBool('want-karts', 1).value
self.wantNewSpecies = self.config.GetBool('want-new-species', 0) self.wantNewSpecies = ConfigVariableBool('want-new-species', 0).value
self.inactivityTimeout = self.config.GetFloat('inactivity-timeout', ToontownGlobals.KeyboardTimeout) self.inactivityTimeout = ConfigVariableDouble('inactivity-timeout', ToontownGlobals.KeyboardTimeout).value
if self.inactivityTimeout: if self.inactivityTimeout:
self.notify.debug('Enabling Panda timeout: %s' % self.inactivityTimeout) self.notify.debug('Enabling Panda timeout: %s' % self.inactivityTimeout)
self.mouseWatcherNode.setInactivityTimeout(self.inactivityTimeout) self.mouseWatcherNode.setInactivityTimeout(self.inactivityTimeout)
self.randomMinigameAbort = self.config.GetBool('random-minigame-abort', 0) self.randomMinigameAbort = ConfigVariableBool('random-minigame-abort', 0).value
self.randomMinigameDisconnect = self.config.GetBool('random-minigame-disconnect', 0) self.randomMinigameDisconnect = ConfigVariableBool('random-minigame-disconnect', 0).value
self.randomMinigameNetworkPlugPull = self.config.GetBool('random-minigame-netplugpull', 0) self.randomMinigameNetworkPlugPull = ConfigVariableBool('random-minigame-netplugpull', 0).value
self.autoPlayAgain = self.config.GetBool('auto-play-again', 0) self.autoPlayAgain = ConfigVariableBool('auto-play-again', 0).value
self.skipMinigameReward = self.config.GetBool('skip-minigame-reward', 0) self.skipMinigameReward = ConfigVariableBool('skip-minigame-reward', 0).value
self.wantMinigameDifficulty = self.config.GetBool('want-minigame-difficulty', 0) self.wantMinigameDifficulty = ConfigVariableBool('want-minigame-difficulty', 0).value
self.minigameDifficulty = self.config.GetFloat('minigame-difficulty', -1.0) self.minigameDifficulty = ConfigVariableDouble('minigame-difficulty', -1.0).value
if self.minigameDifficulty == -1.0: if self.minigameDifficulty == -1.0:
del self.minigameDifficulty del self.minigameDifficulty
self.minigameSafezoneId = self.config.GetInt('minigame-safezone-id', -1) self.minigameSafezoneId = ConfigVariableInt('minigame-safezone-id', -1).value
if self.minigameSafezoneId == -1: if self.minigameSafezoneId == -1:
del self.minigameSafezoneId del self.minigameSafezoneId
cogdoGameSafezoneId = self.config.GetInt('cogdo-game-safezone-id', -1) cogdoGameSafezoneId = ConfigVariableInt('cogdo-game-safezone-id', -1).value
cogdoGameDifficulty = self.config.GetFloat('cogdo-game-difficulty', -1) cogdoGameDifficulty = ConfigVariableDouble('cogdo-game-difficulty', -1).value
if cogdoGameDifficulty != -1: if cogdoGameDifficulty != -1:
self.cogdoGameDifficulty = cogdoGameDifficulty self.cogdoGameDifficulty = cogdoGameDifficulty
if cogdoGameSafezoneId != -1: if cogdoGameSafezoneId != -1:
self.cogdoGameSafezoneId = cogdoGameSafezoneId self.cogdoGameSafezoneId = cogdoGameSafezoneId
ToontownBattleGlobals.SkipMovie = self.config.GetBool('skip-battle-movies', 0) ToontownBattleGlobals.SkipMovie = ConfigVariableBool('skip-battle-movies', 0).value
self.creditCardUpFront = self.config.GetInt('credit-card-up-front', -1) self.creditCardUpFront = ConfigVariableInt('credit-card-up-front', -1).value
if self.creditCardUpFront == -1: if self.creditCardUpFront == -1:
del self.creditCardUpFront del self.creditCardUpFront
else: else:
self.creditCardUpFront = self.creditCardUpFront != 0 self.creditCardUpFront = self.creditCardUpFront != 0
self.housingEnabled = self.config.GetBool('want-housing', 1) self.housingEnabled = ConfigVariableBool('want-housing', 1).value
self.cannonsEnabled = self.config.GetBool('estate-cannons', 0) self.cannonsEnabled = ConfigVariableBool('estate-cannons', 0).value
self.fireworksEnabled = self.config.GetBool('estate-fireworks', 0) self.fireworksEnabled = ConfigVariableBool('estate-fireworks', 0).value
self.dayNightEnabled = self.config.GetBool('estate-day-night', 0) self.dayNightEnabled = ConfigVariableBool('estate-day-night', 0).value
self.cloudPlatformsEnabled = self.config.GetBool('estate-clouds', 0) self.cloudPlatformsEnabled = ConfigVariableBool('estate-clouds', 0).value
self.greySpacing = self.config.GetBool('allow-greyspacing', 0) self.greySpacing = ConfigVariableBool('allow-greyspacing', 0).value
self.goonsEnabled = self.config.GetBool('estate-goon', 0) self.goonsEnabled = ConfigVariableBool('estate-goon', 0).value
self.restrictTrialers = self.config.GetBool('restrict-trialers', 1) self.restrictTrialers = ConfigVariableBool('restrict-trialers', 1).value
self.roamingTrialers = self.config.GetBool('roaming-trialers', 1) self.roamingTrialers = ConfigVariableBool('roaming-trialers', 1).value
self.slowQuietZone = self.config.GetBool('slow-quiet-zone', 0) self.slowQuietZone = ConfigVariableBool('slow-quiet-zone', 0).value
self.slowQuietZoneDelay = self.config.GetFloat('slow-quiet-zone-delay', 5) self.slowQuietZoneDelay = ConfigVariableDouble('slow-quiet-zone-delay', 5).value
self.killInterestResponse = self.config.GetBool('kill-interest-response', 0) self.killInterestResponse = ConfigVariableBool('kill-interest-response', 0).value
tpMgr = TextPropertiesManager.getGlobalPtr() tpMgr = TextPropertiesManager.getGlobalPtr()
WLDisplay = TextProperties() WLDisplay = TextProperties()
WLDisplay.setSlant(0.3) WLDisplay.setSlant(0.3)
@ -151,7 +151,7 @@ class ToonBase(OTPBase.OTPBase):
def windowEvent(self, win): def windowEvent(self, win):
OTPBase.OTPBase.windowEvent(self, win) OTPBase.OTPBase.windowEvent(self, win)
if not config.GetInt('keep-aspect-ratio', 0): if not ConfigVariableInt('keep-aspect-ratio', 0).value:
return return
x = max(1, win.getXSize()) x = max(1, win.getXSize())
y = max(1, win.getYSize()) y = max(1, win.getYSize())
@ -215,7 +215,7 @@ class ToonBase(OTPBase.OTPBase):
self.screenshot(namePrefix=namePrefix) self.screenshot(namePrefix=namePrefix)
self.lastScreenShotTime = globalClock.getRealTime() self.lastScreenShotTime = globalClock.getRealTime()
return return
coordOnScreen = self.config.GetBool('screenshot-coords', 0) coordOnScreen = ConfigVariableBool('screenshot-coords', 0).value
self.localAvatar.stopThisFrame = 1 self.localAvatar.stopThisFrame = 1
ctext = self.localAvatar.getAvPosStr() ctext = self.localAvatar.getAvPosStr()
self.screenshotStr = '' self.screenshotStr = ''
@ -298,7 +298,7 @@ class ToonBase(OTPBase.OTPBase):
self.cleanupDownloadWatcher() self.cleanupDownloadWatcher()
else: else:
self.acceptOnce('launcherAllPhasesComplete', self.cleanupDownloadWatcher) self.acceptOnce('launcherAllPhasesComplete', self.cleanupDownloadWatcher)
gameServer = base.config.GetString('game-server', '') gameServer = ConfigVariableString('game-server', '').value
if gameServer: if gameServer:
self.notify.info('Using game-server from Configrc: %s ' % gameServer) self.notify.info('Using game-server from Configrc: %s ' % gameServer)
elif launcherServer: elif launcherServer:
@ -306,18 +306,18 @@ class ToonBase(OTPBase.OTPBase):
self.notify.info('Using gameServer from launcher: %s ' % gameServer) self.notify.info('Using gameServer from launcher: %s ' % gameServer)
else: else:
gameServer = '127.0.0.1' gameServer = '127.0.0.1'
serverPort = base.config.GetInt('server-port', 7198) serverPort = ConfigVariableInt('server-port', 7198).value
serverList = [] serverList = []
for name in gameServer.split(';'): for name in gameServer.split(';'):
url = URLSpec(name, 1) url = URLSpec(name, 1)
if config.GetBool('server-want-ssl', False): if ConfigVariableBool('server-want-ssl', False).value:
url.setScheme('s') url.setScheme('s')
if not url.hasPort(): if not url.hasPort():
url.setPort(serverPort) url.setPort(serverPort)
serverList.append(url) serverList.append(url)
if len(serverList) == 1: if len(serverList) == 1:
failover = base.config.GetString('server-failover', '') failover = ConfigVariableString('server-failover', '').value
serverURL = serverList[0] serverURL = serverList[0]
for arg in failover.split(): for arg in failover.split():
try: try:
@ -387,11 +387,11 @@ class ToonBase(OTPBase.OTPBase):
def getShardPopLimits(self): def getShardPopLimits(self):
if self.cr.productName == 'JP': if self.cr.productName == 'JP':
return (config.GetInt('shard-low-pop', ToontownGlobals.LOW_POP_JP), config.GetInt('shard-mid-pop', ToontownGlobals.MID_POP_JP), config.GetInt('shard-high-pop', ToontownGlobals.HIGH_POP_JP)) return (ConfigVariableInt('shard-low-pop', ToontownGlobals.LOW_POP_JP).value, ConfigVariableInt('shard-mid-pop', ToontownGlobals.MID_POP_JP).value, ConfigVariableInt('shard-high-pop', ToontownGlobals.HIGH_POP_JP).value)
elif self.cr.productName in ['BR', 'FR']: elif self.cr.productName in ['BR', 'FR']:
return (config.GetInt('shard-low-pop', ToontownGlobals.LOW_POP_INTL), config.GetInt('shard-mid-pop', ToontownGlobals.MID_POP_INTL), config.GetInt('shard-high-pop', ToontownGlobals.HIGH_POP_INTL)) return (ConfigVariableInt('shard-low-pop', ToontownGlobals.LOW_POP_INTL).value, ConfigVariableInt('shard-mid-pop', ToontownGlobals.MID_POP_INTL).value, ConfigVariableInt('shard-high-pop', ToontownGlobals.HIGH_POP_INTL).value)
else: else:
return (config.GetInt('shard-low-pop', ToontownGlobals.LOW_POP), config.GetInt('shard-mid-pop', ToontownGlobals.MID_POP), config.GetInt('shard-high-pop', ToontownGlobals.HIGH_POP)) return (ConfigVariableInt('shard-low-pop', ToontownGlobals.LOW_POP).value, ConfigVariableInt('shard-mid-pop', ToontownGlobals.MID_POP).value, ConfigVariableInt('shard-high-pop', ToontownGlobals.HIGH_POP).value)
def playMusic(self, music, looping = 0, interrupt = 1, volume = None, time = 0.0): def playMusic(self, music, looping = 0, interrupt = 1, volume = None, time = 0.0):
OTPBase.OTPBase.playMusic(self, music, looping, interrupt, volume, time) OTPBase.OTPBase.playMusic(self, music, looping, interrupt, volume, time)