Browse Source

showbase: move run() and __dev__ to ShowBaseGlobal

Also remove ShowBaseGlobal notify category, it doesn't really add anything
rdb 7 years ago
parent
commit
0cf605ce7d
2 changed files with 9 additions and 8 deletions
  1. 3 5
      direct/src/showbase/ShowBase.py
  2. 6 3
      direct/src/showbase/ShowBaseGlobal.py

+ 3 - 5
direct/src/showbase/ShowBase.py

@@ -47,10 +47,6 @@ if __debug__:
     from . import OnScreenDebug
 from . import AppRunnerGlobal
 
-def legacyRun():
-    assert builtins.base.notify.warning("run() is deprecated, use base.run() instead")
-    builtins.base.run()
-
 @atexit.register
 def exitfunc():
     if getattr(builtins, 'base', None) is not None:
@@ -369,7 +365,6 @@ class ShowBase(DirectObject.DirectObject):
         builtins.bboard = self.bboard
         # Config needs to be defined before ShowBase is constructed
         #builtins.config = self.config
-        builtins.run = legacyRun
         builtins.ostream = Notify.out()
         builtins.directNotify = directNotify
         builtins.giveNotify = giveNotify
@@ -391,7 +386,9 @@ class ShowBase(DirectObject.DirectObject):
 
         # Now add this instance to the ShowBaseGlobal module scope.
         from . import ShowBaseGlobal
+        builtins.run = ShowBaseGlobal.run
         ShowBaseGlobal.base = self
+        ShowBaseGlobal.__dev__ = self.__dev__
 
         if self.__dev__:
             ShowBase.notify.debug('__dev__ == %s' % self.__dev__)
@@ -515,6 +512,7 @@ class ShowBase(DirectObject.DirectObject):
 
         # Remove the built-in base reference
         if getattr(builtins, 'base', None) is self:
+            del builtins.run
             del builtins.base
             del builtins.loader
             del builtins.taskMgr

+ 6 - 3
direct/src/showbase/ShowBaseGlobal.py

@@ -14,6 +14,7 @@ from panda3d.core import ConfigPageManager, ConfigVariableManager
 from panda3d.direct import get_config_showbase
 
 config = get_config_showbase()
+__dev__ = config.GetBool('want-dev', __debug__)
 
 vfs = VirtualFileSystem.getGlobalPtr()
 ostream = Notify.out()
@@ -25,6 +26,10 @@ pandaSystem = PandaSystem.getGlobalPtr()
 # Set direct notify categories now that we have config
 directNotify.setDconfigLevels()
 
+def run():
+    assert ShowBase.notify.warning("run() is deprecated, use base.run() instead")
+    base.run()
+
 def inspect(anObject):
     # Don't use a regular import, to prevent ModuleFinder from picking
     # it up as a dependency when building a .p3d package.
@@ -41,6 +46,4 @@ builtins.inspect = inspect
 
 # this also appears in AIBaseGlobal
 if (not __debug__) and __dev__:
-    notify = directNotify.newCategory('ShowBaseGlobal')
-    notify.error("You must set 'want-dev' to false in non-debug mode.")
-    del notify
+    ShowBase.notify.error("You must set 'want-dev' to false in non-debug mode.")