diff --git a/direct/src/gui/DirectButton.py b/direct/src/gui/DirectButton.py index 32d95957c5..2866b04527 100644 --- a/direct/src/gui/DirectButton.py +++ b/direct/src/gui/DirectButton.py @@ -11,7 +11,7 @@ class DirectButton(DirectFrame): DirectButton(parent) - Create a DirectGuiWidget which responds to mouse clicks and execute a callback function if defined """ - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectFrame # A Direct Frame can have: # - A background texture (pass in path to image, or Texture Card) diff --git a/direct/src/gui/DirectCheckButton.py b/direct/src/gui/DirectCheckButton.py index 818930e016..dd9f3718b8 100644 --- a/direct/src/gui/DirectCheckButton.py +++ b/direct/src/gui/DirectCheckButton.py @@ -7,7 +7,7 @@ class DirectCheckButton(DirectButton): to mouse clicks by setting a state of on or off and execute a callback function (passing that state through) if defined """ - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectButton # A Direct Frame can have: # - A background texture (pass in path to image, or Texture Card) diff --git a/direct/src/gui/DirectDialog.py b/direct/src/gui/DirectDialog.py index 1cbfe5b91e..e0ae38c9ab 100644 --- a/direct/src/gui/DirectDialog.py +++ b/direct/src/gui/DirectDialog.py @@ -35,7 +35,7 @@ class DirectDialog(DirectFrame): AllDialogs = {} PanelIndex = 0 - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): """ DirectDialog(kw) @@ -331,7 +331,7 @@ class DirectDialog(DirectFrame): DirectFrame.destroy(self) class OkDialog(DirectDialog): - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectFrame optiondefs = ( # Define type of DirectGuiWidget @@ -344,7 +344,7 @@ class OkDialog(DirectDialog): self.initialiseoptions(OkDialog) class OkCancelDialog(DirectDialog): - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectFrame optiondefs = ( # Define type of DirectGuiWidget @@ -357,7 +357,7 @@ class OkCancelDialog(DirectDialog): self.initialiseoptions(OkCancelDialog) class YesNoDialog(DirectDialog): - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectFrame optiondefs = ( # Define type of DirectGuiWidget @@ -370,7 +370,7 @@ class YesNoDialog(DirectDialog): self.initialiseoptions(YesNoDialog) class YesNoCancelDialog(DirectDialog): - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectFrame optiondefs = ( # Define type of DirectGuiWidget @@ -384,7 +384,7 @@ class YesNoCancelDialog(DirectDialog): self.initialiseoptions(YesNoCancelDialog) class RetryCancelDialog(DirectDialog): - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectFrame optiondefs = ( # Define type of DirectGuiWidget diff --git a/direct/src/gui/DirectEntry.py b/direct/src/gui/DirectEntry.py index df015b8d60..1223e44229 100644 --- a/direct/src/gui/DirectEntry.py +++ b/direct/src/gui/DirectEntry.py @@ -10,7 +10,7 @@ class DirectEntry(DirectFrame): DirectEntry(parent) - Create a DirectGuiWidget which responds to keyboard buttons """ - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectFrame # A Direct Frame can have: # - A background texture (pass in path to image, or Texture Card) diff --git a/direct/src/gui/DirectFrame.py b/direct/src/gui/DirectFrame.py index 527028d691..5e503015ee 100644 --- a/direct/src/gui/DirectFrame.py +++ b/direct/src/gui/DirectFrame.py @@ -1,7 +1,7 @@ from DirectGuiBase import * class DirectFrame(DirectGuiWidget): - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectGuiWidget # A Direct Frame can have: # - A background texture (pass in path to image, or Texture Card) diff --git a/direct/src/gui/DirectGui.py b/direct/src/gui/DirectGui.py index 23e5b63cbb..20713845ce 100644 --- a/direct/src/gui/DirectGui.py +++ b/direct/src/gui/DirectGui.py @@ -3,10 +3,11 @@ from OnscreenText import * from OnscreenGeom import * from OnscreenImage import * +# MPG DirectStart should call this? # Set up default font -defaultFont = getDefaultFont() -if defaultFont: - PGItem.getTextNode().setFont(defaultFont) +#defaultFont = getDefaultFont() +#if defaultFont: +# PGItem.getTextNode().setFont(defaultFont) # Direct Gui Classes from DirectFrame import * diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index a99d76ed6f..40cfaf2668 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/direct/src/gui/DirectGuiBase.py @@ -652,7 +652,8 @@ class DirectGuiWidget(DirectGuiBase, NodePath): # Determine the default initial state for inactive (or # unclickable) components. If we are in edit mode, these are # actually clickable by default. - guiEdit = base.config.GetBool('direct-gui-edit', 0) + #guiEdit = base.config.GetBool('direct-gui-edit', 0) + guiEdit = config.GetBool('direct-gui-edit', 0) if guiEdit: inactiveInitState = NORMAL else: @@ -660,7 +661,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath): guiDict = {} - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Direct gui widgets are node paths # Direct gui widgets have: # - stateNodePaths (to hold visible representation of widget) @@ -712,6 +713,8 @@ class DirectGuiWidget(DirectGuiBase, NodePath): self.guiItem.setId(self['guiId']) self.guiId = self.guiItem.getId() # Attach button to parent and make that self + if (parent == None): + parent = aspect2d self.assign(parent.attachNewNode( self.guiItem, self['sortOrder'] ) ) # Update pose to initial values if self['pos']: diff --git a/direct/src/gui/DirectLabel.py b/direct/src/gui/DirectLabel.py index 6f1b2bac99..bbc08c95cf 100644 --- a/direct/src/gui/DirectLabel.py +++ b/direct/src/gui/DirectLabel.py @@ -5,7 +5,7 @@ class DirectLabel(DirectFrame): DirectLabel(parent) - Create a DirectGuiWidget which has multiple states. User explicitly chooses a state to display """ - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectFrame # A Direct Frame can have: # - A background texture (pass in path to image, or Texture Card) diff --git a/direct/src/gui/DirectOptionMenu.py b/direct/src/gui/DirectOptionMenu.py index b70b736c50..1798ad2e80 100644 --- a/direct/src/gui/DirectOptionMenu.py +++ b/direct/src/gui/DirectOptionMenu.py @@ -9,7 +9,7 @@ class DirectOptionMenu(DirectButton): To cancel the popup menu click anywhere on the screen outside of the popup menu. No command is executed in this case. """ - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectButton optiondefs = ( # List of items to display on the popup menu diff --git a/direct/src/gui/DirectScrolledList.py b/direct/src/gui/DirectScrolledList.py index bdc8873a06..4420fed9cc 100644 --- a/direct/src/gui/DirectScrolledList.py +++ b/direct/src/gui/DirectScrolledList.py @@ -4,7 +4,7 @@ import Task import types class DirectScrolledList(DirectFrame): - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): self.index = 0 self.forceHeight = None diff --git a/direct/src/gui/DirectWaitBar.py b/direct/src/gui/DirectWaitBar.py index 866b45656f..d9cf20200a 100644 --- a/direct/src/gui/DirectWaitBar.py +++ b/direct/src/gui/DirectWaitBar.py @@ -11,7 +11,7 @@ class DirectWaitBar(DirectFrame): DirectEntry(parent) - Create a DirectGuiWidget which responds to keyboard buttons """ - def __init__(self, parent = aspect2d, **kw): + def __init__(self, parent = None, **kw): # Inherits from DirectFrame # A Direct Frame can have: # - A background texture (pass in path to image, or Texture Card) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 3d0d60d649..9286702afa 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -1,10 +1,13 @@ - # This module redefines the builtin import function with one # that prints out every import it does in a hierarchical form # Annoying and very noisy, but sometimes useful #import VerboseImport from PandaModules import * + +# This needs to be available early for DirectGUI imports +__builtins__["config"] = ConfigConfigureGetConfigConfigShowbase + from DirectNotifyGlobal import * from MessengerGlobal import * from TaskManagerGlobal import * @@ -41,7 +44,8 @@ class ShowBase(DirectObject.DirectObject): def __init__(self): # Get the dconfig object - self.config = ConfigConfigureGetConfigConfigShowbase + #self.config = ConfigConfigureGetConfigConfigShowbase + self.config = config # Setup wantVerifyPdb as soon as reasonable: Verify.wantVerifyPdb = self.config.GetBool('want-verify-pdb', 0) @@ -240,7 +244,8 @@ class ShowBase(DirectObject.DirectObject): __builtins__["taskMgr"] = self.taskMgr __builtins__["eventMgr"] = self.eventMgr __builtins__["messenger"] = self.messenger - __builtins__["config"] = self.config + # Config needs to be defined before ShowBase is constructed + #__builtins__["config"] = self.config __builtins__["run"] = self.run __builtins__["ostream"] = Notify.out() __builtins__["directNotify"] = directNotify diff --git a/direct/src/showbase/ShowBaseGlobal.py b/direct/src/showbase/ShowBaseGlobal.py index de1740d92f..2b1e6be1fb 100644 --- a/direct/src/showbase/ShowBaseGlobal.py +++ b/direct/src/showbase/ShowBaseGlobal.py @@ -5,7 +5,10 @@ from ShowBase import * CollisionHandlerRayStart = 10.0 # This is a hack, it may be better to use a line instead of a ray. # Create the showbase instance -ShowBase() +# This should be created by the game specific "start" file +#ShowBase() +# Instead of creating a show base, assert that one has already been created +assert(base) # Set direct notify categories now that we have config directNotify.setDconfigLevels()