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
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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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 *

View File

@ -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']:

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

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.
# 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()