1
1
""" OpenLevelEditor Base Class - Drewcification 091420 """
2
2
3
+ import argparse
4
+ import asyncio
5
+ import builtins
6
+ import os
7
+ import pathlib
8
+ import sys
3
9
from direct .directnotify .DirectNotifyGlobal import directNotify
4
- from direct .showbase .ShowBase import ShowBase
5
10
from direct .gui .OnscreenText import OnscreenText
6
-
11
+ from direct . showbase . ShowBase import ShowBase
7
12
from panda3d .core import loadPrcFile , loadPrcFileData
8
-
9
13
from tkinter import Tk , messagebox
10
- from toontown .toonbase import ToontownGlobals
11
14
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
17
17
18
18
TOONTOWN_ONLINE = 0
19
19
TOONTOWN_REWRITTEN = 1
28
28
29
29
DEFAULT_SERVER = TOONTOWN_ONLINE
30
30
31
+ DEFAULT_SETTINGS = {
32
+ 'autosave-enabled' : True ,
33
+ 'autosave-interval' : 15 ,
34
+ 'autosave-max-files' : 10 ,
35
+ 'fps-meter-update-rate' : 0
36
+ }
31
37
32
38
class ToontownLevelEditor (ShowBase ):
33
39
notify = directNotify .newCategory ("Open Level Editor" )
@@ -44,18 +50,24 @@ def __init__(self):
44
50
if not os .path .exists (userfiles ):
45
51
pathlib .Path (userfiles ).mkdir (parents = True , exist_ok = True )
46
52
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
+
47
59
# Check for -e or -d launch options
48
60
parser = argparse .ArgumentParser (description = "Modes" )
49
61
parser .add_argument ("--experimental" , action = 'store_true' , help = "Enables experimental features" )
50
62
parser .add_argument ("--debug" , action = 'store_true' , help = "Enables debugging features" )
51
63
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" )
54
67
parser .add_argument ("--compiler" , nargs = "*" ,
55
68
help = "Specify which compiler to use (Only useful if your game uses a form of "
56
69
"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" )
59
71
60
72
parser .add_argument ("--server" , nargs = "*" , help = "Enables features exclusive to various Toontown projects" ,
61
73
default = 'online' )
@@ -151,21 +163,21 @@ def updateFrameRateMeter(self, task):
151
163
"""
152
164
fps = globalClock .getAverageFrameRate ()
153
165
154
- # Color is green by default
155
- color = (0 , 0.9 , 0 , 1 )
156
-
157
- # At or below 45 fps is yellow
158
166
if fps <= 45 :
167
+ # At or below 45 fps is yellow
159
168
color = (1 , 0.9 , 0 , 1 )
160
- # At or below 30 fps is red
161
169
elif fps <= 30 :
170
+ # At or below 30 fps is red
162
171
color = (1 , 0 , 0 , 1 )
172
+ else :
173
+ # Color is green by default
174
+ color = (0 , 0.9 , 0 , 1 )
163
175
164
176
text = f'{ round (fps , 1 )} FPS'
165
177
self .frameRateMeter .setText (text )
166
178
self .frameRateMeter .setFg (color )
167
-
168
- return task .cont
179
+ task . delayTime = settings [ 'fps-meter-update-rate' ] / 1000
180
+ return task .again
169
181
170
182
def __checkForFiles (self ):
171
183
# Make custom hood directory if it doesn't exist
@@ -194,7 +206,8 @@ def __createTk(self):
194
206
195
207
self .tkRoot = tkroot
196
208
197
- def __addCullBins (self ):
209
+ @staticmethod
210
+ def __addCullBins ():
198
211
cbm = CullBinManager .getGlobalPtr ()
199
212
cbm .addBin ('ground' , CullBinManager .BTUnsorted , 18 )
200
213
cbm .addBin ('shadow' , CullBinManager .BTBackToFront , 19 )
0 commit comments