From 27bd82aa364206c9566181de1e5eb0971936fd86 Mon Sep 17 00:00:00 2001 From: Open Toontown Date: Sat, 2 Nov 2019 20:25:58 -0400 Subject: [PATCH] general: more loading progress --- libotp/settings/Settings.py | 4 ++++ otp/avatar/Avatar.py | 2 +- otp/otpbase/PythonUtil.py | 21 +++++++++++++++++++++ toontown/shtiker/OptionsPage.py | 1 + toontown/toonbase/DisplayOptions.py | 3 ++- 5 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 otp/otpbase/PythonUtil.py diff --git a/libotp/settings/Settings.py b/libotp/settings/Settings.py index 4179d72..568fc4f 100644 --- a/libotp/settings/Settings.py +++ b/libotp/settings/Settings.py @@ -1,4 +1,8 @@ class Settings: + GL = 0 + DX7 = 1 + DX8 = 5 + @staticmethod def readSettings(): pass # todo diff --git a/otp/avatar/Avatar.py b/otp/avatar/Avatar.py index c77ce36..e82c2c3 100644 --- a/otp/avatar/Avatar.py +++ b/otp/avatar/Avatar.py @@ -9,7 +9,7 @@ from direct.distributed import ClockDelta from otp.avatar.ShadowCaster import ShadowCaster import random from otp.otpbase import OTPRender -from direct.showbase.PythonUtil import recordCreationStack +from otp.otpbase.PythonUtil import recordCreationStack teleportNotify = DirectNotifyGlobal.directNotify.newCategory('Teleport') teleportNotify.showTime = True if config.GetBool('want-teleport-debug', 1): diff --git a/otp/otpbase/PythonUtil.py b/otp/otpbase/PythonUtil.py new file mode 100644 index 0000000..758dcaf --- /dev/null +++ b/otp/otpbase/PythonUtil.py @@ -0,0 +1,21 @@ +# class 'decorator' that records the stack at the time of creation +# be careful with this, it creates a StackTrace, and that can take a +# lot of CPU +def recordCreationStack(cls): + if not hasattr(cls, '__init__'): + raise 'recordCreationStack: class \'%s\' must define __init__' % cls.__name__ + cls.__moved_init__ = cls.__init__ + def __recordCreationStack_init__(self, *args, **kArgs): + self._creationStackTrace = StackTrace(start=1) + return self.__moved_init__(*args, **kArgs) + def getCreationStackTrace(self): + return self._creationStackTrace + def getCreationStackTraceCompactStr(self): + return self._creationStackTrace.compact() + def printCreationStackTrace(self): + print self._creationStackTrace + cls.__init__ = __recordCreationStack_init__ + cls.getCreationStackTrace = getCreationStackTrace + cls.getCreationStackTraceCompactStr = getCreationStackTraceCompactStr + cls.printCreationStackTrace = printCreationStackTrace + return cls diff --git a/toontown/shtiker/OptionsPage.py b/toontown/shtiker/OptionsPage.py index 2c67999..a51d273 100644 --- a/toontown/shtiker/OptionsPage.py +++ b/toontown/shtiker/OptionsPage.py @@ -1,4 +1,5 @@ from pandac.PandaModules import * +from libotp import Settings import ShtikerPage from toontown.toontowngui import TTDialog from direct.gui.DirectGui import * diff --git a/toontown/toonbase/DisplayOptions.py b/toontown/toonbase/DisplayOptions.py index 2f577ab..7995265 100644 --- a/toontown/toonbase/DisplayOptions.py +++ b/toontown/toonbase/DisplayOptions.py @@ -3,7 +3,8 @@ import string import os import sys import datetime -from pandac.PandaModules import loadPrcFileData, Settings, WindowProperties +from pandac.PandaModules import loadPrcFileData, WindowProperties +from libotp import Settings from otp.otpgui import OTPDialog from otp.otpbase import OTPGlobals from otp.otpbase import OTPRender