11""" OpenLevelEditor Base Class - Drewcification 091420 """
22
3+ import argparse
4+ import asyncio
5+ import builtins
6+ import os
7+ import pathlib
8+ import sys
39from direct .directnotify .DirectNotifyGlobal import directNotify
4- from direct .showbase .ShowBase import ShowBase
510from direct .gui .OnscreenText import OnscreenText
6-
11+ from direct . showbase . ShowBase import ShowBase
712from panda3d .core import loadPrcFile , loadPrcFileData
8-
913from tkinter import Tk , messagebox
10- from toontown .toonbase import ToontownGlobals
1114
12- import asyncio
13- import argparse
14- import builtins
15- import os
16- import sys
15+ from ott .Settings import Settings
16+ from toontown .toonbase import ToontownGlobals
1717
1818TOONTOWN_ONLINE = 0
1919TOONTOWN_REWRITTEN = 1
2828
2929DEFAULT_SERVER = TOONTOWN_ONLINE
3030
31+ DEFAULT_SETTINGS = {
32+ 'autosave-enabled' : True ,
33+ 'autosave-interval' : 15 ,
34+ 'autosave-max-files' : 10 ,
35+ 'fps-meter-update-rate' : 0
36+ }
3137
3238class ToontownLevelEditor (ShowBase ):
3339 notify = directNotify .newCategory ("Open Level Editor" )
@@ -44,18 +50,24 @@ def __init__(self):
4450 if not os .path .exists (userfiles ):
4551 pathlib .Path (userfiles ).mkdir (parents = True , exist_ok = True )
4652
53+ builtins .settings = Settings (f'{ userfiles } /settings.json' )
54+
55+ for setting in DEFAULT_SETTINGS :
56+ if setting not in settings :
57+ settings [setting ] = DEFAULT_SETTINGS [setting ]
58+
4759 # Check for -e or -d launch options
4860 parser = argparse .ArgumentParser (description = "Modes" )
4961 parser .add_argument ("--experimental" , action = 'store_true' , help = "Enables experimental features" )
5062 parser .add_argument ("--debug" , action = 'store_true' , help = "Enables debugging features" )
5163 parser .add_argument ("--noupdate" , action = 'store_true' , help = "Disables Auto Updating" )
52- parser .add_argument ("--png" , action = 'store_true' , help = "Forces PNG resources mode, if this is not specified, "
53- "it will automatically determine the format" )
64+ parser .add_argument ("--png" , action = 'store_true' , help = "Forces PNG resources mode, if this is not "
65+ "specified, it will automatically determine the "
66+ "format" )
5467 parser .add_argument ("--compiler" , nargs = "*" ,
5568 help = "Specify which compiler to use (Only useful if your game uses a form of "
5669 "libpandadna.) Valid options are 'libpandadna', for games which use the "
57- "modern c++ version of libpandadna, and 'clash', "
58- "for Corporate Clash" )
70+ "modern c++ version of libpandadna, and 'clash', for Corporate Clash" )
5971
6072 parser .add_argument ("--server" , nargs = "*" , help = "Enables features exclusive to various Toontown projects" ,
6173 default = 'online' )
@@ -151,21 +163,21 @@ def updateFrameRateMeter(self, task):
151163 """
152164 fps = globalClock .getAverageFrameRate ()
153165
154- # Color is green by default
155- color = (0 , 0.9 , 0 , 1 )
156-
157- # At or below 45 fps is yellow
158166 if fps <= 45 :
167+ # At or below 45 fps is yellow
159168 color = (1 , 0.9 , 0 , 1 )
160- # At or below 30 fps is red
161169 elif fps <= 30 :
170+ # At or below 30 fps is red
162171 color = (1 , 0 , 0 , 1 )
172+ else :
173+ # Color is green by default
174+ color = (0 , 0.9 , 0 , 1 )
163175
164176 text = f'{ round (fps , 1 )} FPS'
165177 self .frameRateMeter .setText (text )
166178 self .frameRateMeter .setFg (color )
167-
168- return task .cont
179+ task . delayTime = settings [ 'fps-meter-update-rate' ] / 1000
180+ return task .again
169181
170182 def __checkForFiles (self ):
171183 # Make custom hood directory if it doesn't exist
@@ -194,7 +206,8 @@ def __createTk(self):
194206
195207 self .tkRoot = tkroot
196208
197- def __addCullBins (self ):
209+ @staticmethod
210+ def __addCullBins ():
198211 cbm = CullBinManager .getGlobalPtr ()
199212 cbm .addBin ('ground' , CullBinManager .BTUnsorted , 18 )
200213 cbm .addBin ('shadow' , CullBinManager .BTBackToFront , 19 )
0 commit comments