|
|
@@ -101,19 +101,21 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
including this instance itself (under the name ``base``).
|
|
|
"""
|
|
|
|
|
|
+ from . import ShowBaseGlobal
|
|
|
+
|
|
|
#: Set if the want-dev Config.prc variable is enabled. By default, it
|
|
|
#: is set to True except when using Python with the -O flag.
|
|
|
- self.__dev__ = self.config.GetBool('want-dev', __debug__)
|
|
|
+ self.__dev__ = ShowBaseGlobal.__dev__
|
|
|
builtins.__dev__ = self.__dev__
|
|
|
|
|
|
- logStackDump = (self.config.GetBool('log-stack-dump', False) or
|
|
|
- self.config.GetBool('client-log-stack-dump', False))
|
|
|
- uploadStackDump = self.config.GetBool('upload-stack-dump', False)
|
|
|
+ logStackDump = (ConfigVariableBool('log-stack-dump', False).value or
|
|
|
+ ConfigVariableBool('client-log-stack-dump', False).value)
|
|
|
+ uploadStackDump = ConfigVariableBool('upload-stack-dump', False).value
|
|
|
if logStackDump or uploadStackDump:
|
|
|
ExceptionVarDump.install(logStackDump, uploadStackDump)
|
|
|
|
|
|
if __debug__:
|
|
|
- self.__autoGarbageLogging = self.__dev__ and self.config.GetBool('auto-garbage-logging', False)
|
|
|
+ self.__autoGarbageLogging = self.__dev__ and ConfigVariableBool('auto-garbage-logging', False)
|
|
|
|
|
|
#: The directory containing the main Python file of this application.
|
|
|
self.mainDir = ExecutionEnvironment.getEnvironmentVariable("MAIN_DIR")
|
|
|
@@ -128,9 +130,12 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.debugRunningMultiplier = 4
|
|
|
|
|
|
# [gjeon] to disable sticky keys
|
|
|
- if self.config.GetBool('disable-sticky-keys', 0):
|
|
|
+ if ConfigVariableBool('disable-sticky-keys', False):
|
|
|
storeAccessibilityShortcutKeys()
|
|
|
allowAccessibilityShortcutKeys(False)
|
|
|
+ self.__disabledStickyKeys = True
|
|
|
+ else:
|
|
|
+ self.__disabledStickyKeys = False
|
|
|
|
|
|
self.printEnvDebugInfo()
|
|
|
vfs = VirtualFileSystem.getGlobalPtr()
|
|
|
@@ -140,18 +145,18 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.__deadInputs = 0
|
|
|
|
|
|
# Store dconfig variables
|
|
|
- self.sfxActive = self.config.GetBool('audio-sfx-active', 1)
|
|
|
- self.musicActive = self.config.GetBool('audio-music-active', 1)
|
|
|
- self.wantFog = self.config.GetBool('want-fog', 1)
|
|
|
- self.wantRender2dp = self.config.GetBool('want-render2dp', 1)
|
|
|
+ self.sfxActive = ConfigVariableBool('audio-sfx-active', True).value
|
|
|
+ self.musicActive = ConfigVariableBool('audio-music-active', True).value
|
|
|
+ self.wantFog = ConfigVariableBool('want-fog', True).value
|
|
|
+ self.wantRender2dp = ConfigVariableBool('want-render2dp', True).value
|
|
|
|
|
|
- self.screenshotExtension = self.config.GetString('screenshot-extension', 'jpg')
|
|
|
+ self.screenshotExtension = ConfigVariableString('screenshot-extension', 'jpg').value
|
|
|
self.musicManager = None
|
|
|
self.musicManagerIsValid = None
|
|
|
self.sfxManagerList = []
|
|
|
self.sfxManagerIsValidList = []
|
|
|
|
|
|
- self.wantStats = self.config.GetBool('want-pstats', 0)
|
|
|
+ self.wantStats = ConfigVariableBool('want-pstats', False).value
|
|
|
self.wantTk = False
|
|
|
self.wantWx = False
|
|
|
self.wantDirect = False
|
|
|
@@ -178,7 +183,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
# If the aspect ratio is 0 or None, it means to infer the
|
|
|
# aspect ratio from the window size.
|
|
|
# If you need to know the actual aspect ratio call base.getAspectRatio()
|
|
|
- self.__configAspectRatio = ConfigVariableDouble('aspect-ratio', 0).getValue()
|
|
|
+ self.__configAspectRatio = ConfigVariableDouble('aspect-ratio', 0).value
|
|
|
# This variable is used to see if the aspect ratio has changed when
|
|
|
# we get a window-event.
|
|
|
self.__oldAspectRatio = None
|
|
|
@@ -188,8 +193,8 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
#: be 'onscreen' (the default), 'offscreen' or 'none'.
|
|
|
self.windowType = windowType
|
|
|
if self.windowType is None:
|
|
|
- self.windowType = self.config.GetString('window-type', 'onscreen')
|
|
|
- self.requireWindow = self.config.GetBool('require-window', 1)
|
|
|
+ self.windowType = ConfigVariableString('window-type', 'onscreen').value
|
|
|
+ self.requireWindow = ConfigVariableBool('require-window', True).value
|
|
|
|
|
|
#: This is the main, or only window; see `winList` for a list of *all* windows.
|
|
|
self.win = None
|
|
|
@@ -262,11 +267,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.clusterSyncFlag = clusterSyncFlag
|
|
|
except NameError:
|
|
|
# Has the clusterSyncFlag been set via a config variable
|
|
|
- self.clusterSyncFlag = self.config.GetBool('cluster-sync', 0)
|
|
|
+ self.clusterSyncFlag = ConfigVariableBool('cluster-sync', False)
|
|
|
|
|
|
# We've already created aspect2d in ShowBaseGlobal, for the
|
|
|
# benefit of creating DirectGui elements before ShowBase.
|
|
|
- from . import ShowBaseGlobal
|
|
|
self.hidden = ShowBaseGlobal.hidden
|
|
|
|
|
|
#: The global :class:`~panda3d.core.GraphicsEngine`, as returned by
|
|
|
@@ -298,14 +302,14 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
# Maybe create a RecorderController to record and/or play back
|
|
|
# the user session.
|
|
|
self.recorder = None
|
|
|
- playbackSession = self.config.GetString('playback-session', '')
|
|
|
- recordSession = self.config.GetString('record-session', '')
|
|
|
- if playbackSession:
|
|
|
+ playbackSession = ConfigVariableFilename('playback-session', '')
|
|
|
+ recordSession = ConfigVariableFilename('record-session', '')
|
|
|
+ if not playbackSession.empty():
|
|
|
self.recorder = RecorderController()
|
|
|
- self.recorder.beginPlayback(Filename.fromOsSpecific(playbackSession))
|
|
|
- elif recordSession:
|
|
|
+ self.recorder.beginPlayback(playbackSession.value)
|
|
|
+ elif not recordSession.empty():
|
|
|
self.recorder = RecorderController()
|
|
|
- self.recorder.beginRecord(Filename.fromOsSpecific(recordSession))
|
|
|
+ self.recorder.beginRecord(recordSession.value)
|
|
|
|
|
|
if self.recorder:
|
|
|
# If we're either playing back or recording, pass the
|
|
|
@@ -319,19 +323,19 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
|
|
|
# For some reason, wx needs to be initialized before the graphics window
|
|
|
if sys.platform == "darwin":
|
|
|
- if self.config.GetBool("want-wx", 0):
|
|
|
+ if ConfigVariableBool("want-wx", False):
|
|
|
wx = importlib.import_module('wx')
|
|
|
self.wxApp = wx.App()
|
|
|
|
|
|
# Same goes for Tk, which uses a conflicting NSApplication
|
|
|
- if self.config.GetBool("want-tk", 0):
|
|
|
+ if ConfigVariableBool("want-tk", False):
|
|
|
Pmw = importlib.import_module('Pmw')
|
|
|
self.tkRoot = Pmw.initialise()
|
|
|
|
|
|
# Open the default rendering window.
|
|
|
if self.windowType != 'none':
|
|
|
props = WindowProperties.getDefault()
|
|
|
- if self.config.GetBool('read-raw-mice', 0):
|
|
|
+ if ConfigVariableBool('read-raw-mice', False):
|
|
|
props.setRawMice(1)
|
|
|
self.openDefaultWindow(startDirect = False, props=props)
|
|
|
|
|
|
@@ -398,18 +402,18 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
# - pcalt-# (# is CPU number, 0-based)
|
|
|
# - client-cpu-affinity config
|
|
|
# - auto-single-cpu-affinity config
|
|
|
- affinityMask = self.config.GetInt('client-cpu-affinity-mask', -1)
|
|
|
+ affinityMask = ConfigVariableInt('client-cpu-affinity-mask', -1).value
|
|
|
if affinityMask != -1:
|
|
|
TrueClock.getGlobalPtr().setCpuAffinity(affinityMask)
|
|
|
else:
|
|
|
# this is useful on machines that perform better with each process
|
|
|
# assigned to a single CPU
|
|
|
- autoAffinity = self.config.GetBool('auto-single-cpu-affinity', 0)
|
|
|
+ autoAffinity = ConfigVariableBool('auto-single-cpu-affinity', False).value
|
|
|
affinity = None
|
|
|
if autoAffinity and hasattr(builtins, 'clientIndex'):
|
|
|
affinity = abs(int(builtins.clientIndex))
|
|
|
else:
|
|
|
- affinity = self.config.GetInt('client-cpu-affinity', -1)
|
|
|
+ affinity = ConfigVariableInt('client-cpu-affinity', -1).value
|
|
|
if (affinity in (None, -1)) and autoAffinity:
|
|
|
affinity = 0
|
|
|
if affinity not in (None, -1):
|
|
|
@@ -467,13 +471,13 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
|
|
|
self.createBaseAudioManagers()
|
|
|
|
|
|
- if self.__dev__ and self.config.GetBool('track-gui-items', False):
|
|
|
+ if self.__dev__ and ConfigVariableBool('track-gui-items', False):
|
|
|
# dict of guiId to gui item, for tracking down leaks
|
|
|
if not hasattr(ShowBase, 'guiItems'):
|
|
|
ShowBase.guiItems = {}
|
|
|
|
|
|
# optionally restore the default gui sounds from 1.7.2 and earlier
|
|
|
- if ConfigVariableBool('orig-gui-sounds', False).getValue():
|
|
|
+ if ConfigVariableBool('orig-gui-sounds', False).value:
|
|
|
from direct.gui import DirectGuiGlobals as DGG
|
|
|
DGG.setDefaultClickSound(self.loader.loadSfx("audio/sfx/GUI_click.wav"))
|
|
|
DGG.setDefaultRolloverSound(self.loader.loadSfx("audio/sfx/GUI_rollover.wav"))
|
|
|
@@ -495,18 +499,15 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.setupWindowControls()
|
|
|
|
|
|
# Client sleep
|
|
|
- sleepTime = self.config.GetFloat('client-sleep', 0.0)
|
|
|
+ sleepTime = ConfigVariableDouble('client-sleep', 0.0)
|
|
|
self.clientSleep = 0.0
|
|
|
- self.setSleep(sleepTime)
|
|
|
+ self.setSleep(sleepTime.value)
|
|
|
|
|
|
# Extra sleep for running 4+ clients on a single machine
|
|
|
# adds a sleep right after the main render in igloop
|
|
|
# tends to even out the frame rate and keeps it from going
|
|
|
# to zero in the out of focus windows
|
|
|
- if self.config.GetBool('multi-sleep', 0):
|
|
|
- self.multiClientSleep = 1
|
|
|
- else:
|
|
|
- self.multiClientSleep = 0
|
|
|
+ self.multiClientSleep = ConfigVariableBool('multi-sleep', False)
|
|
|
|
|
|
#: Utility for viewing offscreen buffers, see :mod:`.BufferViewer`.
|
|
|
self.bufferViewer = BufferViewer(self.win, self.render2dp if self.wantRender2dp else self.render2d)
|
|
|
@@ -515,7 +516,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
if fStartDirect: # [gjeon] if this is False let them start direct manually
|
|
|
self.__doStartDirect()
|
|
|
|
|
|
- if self.config.GetBool('show-tex-mem', False):
|
|
|
+ if ConfigVariableBool('show-tex-mem', False):
|
|
|
if not self.texmem or self.texmem.cleanedUp:
|
|
|
self.toggleTexMem()
|
|
|
|
|
|
@@ -543,10 +544,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
except ImportError:
|
|
|
return
|
|
|
|
|
|
- profile.Profile.bias = float(self.config.GetString("profile-bias","0"))
|
|
|
+ profile.Profile.bias = ConfigVariableDouble("profile-bias", 0.0).value
|
|
|
|
|
|
def f8(x):
|
|
|
- return ("%" + "8.%df" % self.config.GetInt("profile-decimals", 3)) % x
|
|
|
+ return ("%" + "8.%df" % ConfigVariableInt("profile-decimals", 3)) % x
|
|
|
pstats.f8 = f8
|
|
|
|
|
|
# temp; see ToonBase.py
|
|
|
@@ -558,7 +559,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
in. Stuff like the model paths and other paths. Feel free to
|
|
|
add stuff to this.
|
|
|
"""
|
|
|
- if self.config.GetBool('want-env-debug-info', 0):
|
|
|
+ if ConfigVariableBool('want-env-debug-info', False):
|
|
|
print("\n\nEnvironment Debug Info {")
|
|
|
print("* model path:")
|
|
|
print(getModelPath())
|
|
|
@@ -593,8 +594,9 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.aspect2d.reparent_to(self.render2d)
|
|
|
|
|
|
# [gjeon] restore sticky key settings
|
|
|
- if self.config.GetBool('disable-sticky-keys', 0):
|
|
|
+ if self.__disabledStickyKeys:
|
|
|
allowAccessibilityShortcutKeys(True)
|
|
|
+ self.__disabledStickyKeys = False
|
|
|
|
|
|
self.ignoreAll()
|
|
|
self.shutdown()
|
|
|
@@ -1076,16 +1078,10 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.win.setClearStencilActive(oldClearStencilActive)
|
|
|
self.win.setClearStencil(oldClearStencil)
|
|
|
|
|
|
- flag = self.config.GetBool('show-frame-rate-meter', False)
|
|
|
- if self.appRunner is not None and self.appRunner.allowPythonDev:
|
|
|
- # In an allow_python_dev p3d application, we always
|
|
|
- # start up with the frame rate meter enabled, to
|
|
|
- # provide a visual reminder that this flag has been
|
|
|
- # set.
|
|
|
- flag = True
|
|
|
- self.setFrameRateMeter(flag)
|
|
|
- flag = self.config.GetBool('show-scene-graph-analyzer-meter', False)
|
|
|
- self.setSceneGraphAnalyzerMeter(flag)
|
|
|
+ flag = ConfigVariableBool('show-frame-rate-meter', False)
|
|
|
+ self.setFrameRateMeter(flag.value)
|
|
|
+ flag = ConfigVariableBool('show-scene-graph-analyzer-meter', False)
|
|
|
+ self.setSceneGraphAnalyzerMeter(flag.value)
|
|
|
return success
|
|
|
|
|
|
def setSleep(self, amount):
|
|
|
@@ -2240,7 +2236,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
# between collisionLoop and igLoop
|
|
|
self.taskMgr.add(self.__collisionLoop, 'collisionLoop', sort = 30)
|
|
|
|
|
|
- if ConfigVariableBool('garbage-collect-states').getValue():
|
|
|
+ if ConfigVariableBool('garbage-collect-states').value:
|
|
|
self.taskMgr.add(self.__garbageCollectStates, 'garbageCollectStates', sort = 46)
|
|
|
# give the igLoop task a reasonably "late" sort,
|
|
|
# so that it will get run after most tasks
|
|
|
@@ -2508,7 +2504,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
# Make the spots round, so there's less static in the display.
|
|
|
# This forces software point generation on many drivers, so
|
|
|
# it's not on by default.
|
|
|
- if self.config.GetBool('round-show-vertices', False):
|
|
|
+ if ConfigVariableBool('round-show-vertices', False):
|
|
|
spot = PNMImage(256, 256, 1)
|
|
|
spot.renderSpot((1, 1, 1, 1), (0, 0, 0, 0), 0.8, 1)
|
|
|
tex = Texture('spot')
|
|
|
@@ -3134,7 +3130,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
# Set a timer to run the Panda frame 60 times per second.
|
|
|
wxFrameRate = ConfigVariableDouble('wx-frame-rate', 60.0)
|
|
|
self.wxTimer = wx.Timer(self.wxApp)
|
|
|
- self.wxTimer.Start(1000.0 / wxFrameRate.getValue())
|
|
|
+ self.wxTimer.Start(1000.0 / wxFrameRate.value)
|
|
|
self.wxApp.Bind(wx.EVT_TIMER, self.__wxTimerCallback)
|
|
|
|
|
|
# wx is now the main loop, not us any more.
|
|
|
@@ -3221,7 +3217,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
|
|
|
# Set a timer to run the Panda frame 60 times per second.
|
|
|
tkFrameRate = ConfigVariableDouble('tk-frame-rate', 60.0)
|
|
|
- self.tkDelay = int(1000.0 / tkFrameRate.getValue())
|
|
|
+ self.tkDelay = int(1000.0 / tkFrameRate.value)
|
|
|
self.tkRoot.after(self.tkDelay, self.__tkTimerCallback)
|
|
|
|
|
|
# wx is now the main loop, not us any more.
|
|
|
@@ -3301,11 +3297,11 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.__directStarted = False
|
|
|
|
|
|
# Start Tk, Wx and DIRECT if specified by Config.prc
|
|
|
- fTk = self.config.GetBool('want-tk', 0)
|
|
|
- fWx = self.config.GetBool('want-wx', 0)
|
|
|
+ fTk = ConfigVariableBool('want-tk', False).value
|
|
|
+ fWx = ConfigVariableBool('want-wx', False).value
|
|
|
# Start DIRECT if specified in Config.prc or in cluster mode
|
|
|
- fDirect = (self.config.GetBool('want-directtools', 0) or
|
|
|
- (self.config.GetString("cluster-mode", '') != ''))
|
|
|
+ fDirect = (ConfigVariableBool('want-directtools', 0).value or
|
|
|
+ (not ConfigVariableString("cluster-mode", '').empty()))
|
|
|
# Set fWantTk to 0 to avoid starting Tk with this call
|
|
|
self.startDirect(fWantDirect = fDirect, fWantTk = fTk, fWantWx = fWx)
|
|
|
|