Removed avatar2d as default argument to avoid import order problem - avatar2d now gets filled in after ShowBase is constructed.

This commit is contained in:
Mike Goslin 2004-05-05 00:12:48 +00:00
parent fb79ed6314
commit 966e57d3be
13 changed files with 35 additions and 23 deletions

View File

@ -11,7 +11,7 @@ class DirectButton(DirectFrame):
DirectButton(parent) - Create a DirectGuiWidget which responds DirectButton(parent) - Create a DirectGuiWidget which responds
to mouse clicks and execute a callback function if defined 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 # Inherits from DirectFrame
# A Direct Frame can have: # A Direct Frame can have:
# - A background texture (pass in path to image, or Texture Card) # - A background texture (pass in path to image, or Texture Card)

View File

@ -7,7 +7,7 @@ class DirectCheckButton(DirectButton):
to mouse clicks by setting a state of on or off and execute a callback to mouse clicks by setting a state of on or off and execute a callback
function (passing that state through) if defined function (passing that state through) if defined
""" """
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectButton # Inherits from DirectButton
# A Direct Frame can have: # A Direct Frame can have:
# - A background texture (pass in path to image, or Texture Card) # - A background texture (pass in path to image, or Texture Card)

View File

@ -35,7 +35,7 @@ class DirectDialog(DirectFrame):
AllDialogs = {} AllDialogs = {}
PanelIndex = 0 PanelIndex = 0
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
""" """
DirectDialog(kw) DirectDialog(kw)
@ -331,7 +331,7 @@ class DirectDialog(DirectFrame):
DirectFrame.destroy(self) DirectFrame.destroy(self)
class OkDialog(DirectDialog): class OkDialog(DirectDialog):
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectFrame # Inherits from DirectFrame
optiondefs = ( optiondefs = (
# Define type of DirectGuiWidget # Define type of DirectGuiWidget
@ -344,7 +344,7 @@ class OkDialog(DirectDialog):
self.initialiseoptions(OkDialog) self.initialiseoptions(OkDialog)
class OkCancelDialog(DirectDialog): class OkCancelDialog(DirectDialog):
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectFrame # Inherits from DirectFrame
optiondefs = ( optiondefs = (
# Define type of DirectGuiWidget # Define type of DirectGuiWidget
@ -357,7 +357,7 @@ class OkCancelDialog(DirectDialog):
self.initialiseoptions(OkCancelDialog) self.initialiseoptions(OkCancelDialog)
class YesNoDialog(DirectDialog): class YesNoDialog(DirectDialog):
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectFrame # Inherits from DirectFrame
optiondefs = ( optiondefs = (
# Define type of DirectGuiWidget # Define type of DirectGuiWidget
@ -370,7 +370,7 @@ class YesNoDialog(DirectDialog):
self.initialiseoptions(YesNoDialog) self.initialiseoptions(YesNoDialog)
class YesNoCancelDialog(DirectDialog): class YesNoCancelDialog(DirectDialog):
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectFrame # Inherits from DirectFrame
optiondefs = ( optiondefs = (
# Define type of DirectGuiWidget # Define type of DirectGuiWidget
@ -384,7 +384,7 @@ class YesNoCancelDialog(DirectDialog):
self.initialiseoptions(YesNoCancelDialog) self.initialiseoptions(YesNoCancelDialog)
class RetryCancelDialog(DirectDialog): class RetryCancelDialog(DirectDialog):
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectFrame # Inherits from DirectFrame
optiondefs = ( optiondefs = (
# Define type of DirectGuiWidget # Define type of DirectGuiWidget

View File

@ -10,7 +10,7 @@ class DirectEntry(DirectFrame):
DirectEntry(parent) - Create a DirectGuiWidget which responds DirectEntry(parent) - Create a DirectGuiWidget which responds
to keyboard buttons to keyboard buttons
""" """
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectFrame # Inherits from DirectFrame
# A Direct Frame can have: # A Direct Frame can have:
# - A background texture (pass in path to image, or Texture Card) # - A background texture (pass in path to image, or Texture Card)

View File

@ -1,7 +1,7 @@
from DirectGuiBase import * from DirectGuiBase import *
class DirectFrame(DirectGuiWidget): class DirectFrame(DirectGuiWidget):
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectGuiWidget # Inherits from DirectGuiWidget
# A Direct Frame can have: # A Direct Frame can have:
# - A background texture (pass in path to image, or Texture Card) # - A background texture (pass in path to image, or Texture Card)

View File

@ -3,10 +3,11 @@ from OnscreenText import *
from OnscreenGeom import * from OnscreenGeom import *
from OnscreenImage import * from OnscreenImage import *
# MPG DirectStart should call this?
# Set up default font # Set up default font
defaultFont = getDefaultFont() #defaultFont = getDefaultFont()
if defaultFont: #if defaultFont:
PGItem.getTextNode().setFont(defaultFont) # PGItem.getTextNode().setFont(defaultFont)
# Direct Gui Classes # Direct Gui Classes
from DirectFrame import * from DirectFrame import *

View File

@ -652,7 +652,8 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
# Determine the default initial state for inactive (or # Determine the default initial state for inactive (or
# unclickable) components. If we are in edit mode, these are # unclickable) components. If we are in edit mode, these are
# actually clickable by default. # 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: if guiEdit:
inactiveInitState = NORMAL inactiveInitState = NORMAL
else: else:
@ -660,7 +661,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
guiDict = {} guiDict = {}
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Direct gui widgets are node paths # Direct gui widgets are node paths
# Direct gui widgets have: # Direct gui widgets have:
# - stateNodePaths (to hold visible representation of widget) # - stateNodePaths (to hold visible representation of widget)
@ -712,6 +713,8 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
self.guiItem.setId(self['guiId']) self.guiItem.setId(self['guiId'])
self.guiId = self.guiItem.getId() self.guiId = self.guiItem.getId()
# Attach button to parent and make that self # Attach button to parent and make that self
if (parent == None):
parent = aspect2d
self.assign(parent.attachNewNode( self.guiItem, self['sortOrder'] ) ) self.assign(parent.attachNewNode( self.guiItem, self['sortOrder'] ) )
# Update pose to initial values # Update pose to initial values
if self['pos']: if self['pos']:

View File

@ -5,7 +5,7 @@ class DirectLabel(DirectFrame):
DirectLabel(parent) - Create a DirectGuiWidget which has multiple DirectLabel(parent) - Create a DirectGuiWidget which has multiple
states. User explicitly chooses a state to display states. User explicitly chooses a state to display
""" """
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectFrame # Inherits from DirectFrame
# A Direct Frame can have: # A Direct Frame can have:
# - A background texture (pass in path to image, or Texture Card) # - A background texture (pass in path to image, or Texture Card)

View File

@ -9,7 +9,7 @@ class DirectOptionMenu(DirectButton):
To cancel the popup menu click anywhere on the screen outside of the To cancel the popup menu click anywhere on the screen outside of the
popup menu. No command is executed in this case. popup menu. No command is executed in this case.
""" """
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectButton # Inherits from DirectButton
optiondefs = ( optiondefs = (
# List of items to display on the popup menu # List of items to display on the popup menu

View File

@ -4,7 +4,7 @@ import Task
import types import types
class DirectScrolledList(DirectFrame): class DirectScrolledList(DirectFrame):
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
self.index = 0 self.index = 0
self.forceHeight = None self.forceHeight = None

View File

@ -11,7 +11,7 @@ class DirectWaitBar(DirectFrame):
DirectEntry(parent) - Create a DirectGuiWidget which responds DirectEntry(parent) - Create a DirectGuiWidget which responds
to keyboard buttons to keyboard buttons
""" """
def __init__(self, parent = aspect2d, **kw): def __init__(self, parent = None, **kw):
# Inherits from DirectFrame # Inherits from DirectFrame
# A Direct Frame can have: # A Direct Frame can have:
# - A background texture (pass in path to image, or Texture Card) # - A background texture (pass in path to image, or Texture Card)

View File

@ -1,10 +1,13 @@
# This module redefines the builtin import function with one # This module redefines the builtin import function with one
# that prints out every import it does in a hierarchical form # that prints out every import it does in a hierarchical form
# Annoying and very noisy, but sometimes useful # Annoying and very noisy, but sometimes useful
#import VerboseImport #import VerboseImport
from PandaModules import * from PandaModules import *
# This needs to be available early for DirectGUI imports
__builtins__["config"] = ConfigConfigureGetConfigConfigShowbase
from DirectNotifyGlobal import * from DirectNotifyGlobal import *
from MessengerGlobal import * from MessengerGlobal import *
from TaskManagerGlobal import * from TaskManagerGlobal import *
@ -41,7 +44,8 @@ class ShowBase(DirectObject.DirectObject):
def __init__(self): def __init__(self):
# Get the dconfig object # Get the dconfig object
self.config = ConfigConfigureGetConfigConfigShowbase #self.config = ConfigConfigureGetConfigConfigShowbase
self.config = config
# Setup wantVerifyPdb as soon as reasonable: # Setup wantVerifyPdb as soon as reasonable:
Verify.wantVerifyPdb = self.config.GetBool('want-verify-pdb', 0) Verify.wantVerifyPdb = self.config.GetBool('want-verify-pdb', 0)
@ -240,7 +244,8 @@ class ShowBase(DirectObject.DirectObject):
__builtins__["taskMgr"] = self.taskMgr __builtins__["taskMgr"] = self.taskMgr
__builtins__["eventMgr"] = self.eventMgr __builtins__["eventMgr"] = self.eventMgr
__builtins__["messenger"] = self.messenger __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__["run"] = self.run
__builtins__["ostream"] = Notify.out() __builtins__["ostream"] = Notify.out()
__builtins__["directNotify"] = directNotify __builtins__["directNotify"] = directNotify

View File

@ -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. CollisionHandlerRayStart = 10.0 # This is a hack, it may be better to use a line instead of a ray.
# Create the showbase instance # 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 # Set direct notify categories now that we have config
directNotify.setDconfigLevels() directNotify.setDconfigLevels()