diff --git a/direct/__init__.py b/direct/__init__.py new file mode 100644 index 0000000000..12ae7c6cb0 --- /dev/null +++ b/direct/__init__.py @@ -0,0 +1,45 @@ +"""This file defines the path to the Python files within this package. +There are two cases: + +(1) This is a source tree being run interactively by a developer, in + which case the Python files are found in package/src/*/*.py. This + case also breaks down into two sub-cases: (1a) we are using the + ctattach tools, in which case we should look for the files in the + actual source directory according to the ctattach variables, or + (1b) we are not using the ctattach tools, in which case the files + are right where we expect them to be. + +(2) This is an installed tree being run by an end-user, in which case + the Python files are found in package/*/*.py. In this case, this + file doesn't really need to be installed; an empty __init__.py + file to define the package would serve just as well. But the file + is crafted so that it will do no harm if it is installed. +""" + +package = 'DIRECT' + +import os + +if os.getenv('CTPROJS'): + # Ok, this is case (1a): we are using the ctattach tools, are + # therefore will expect to find the source files in + # $(package)/src/*/*.py. Completely replace the search path with + # this path. + tree = os.getenv(package) + + if not tree: + raise StandardError, 'CTPROJS is defined, but $%s is not defined!' % (package) + __path__[0] = os.path.join(tree, 'src') + +else: + # We are not using the ctattach tools. + srcDir = os.path.join(__path__[0], 'src') + if os.path.isdir(srcDir): + # The source directory exists; therefore, we are in case (1b). + __path__[0] = srcDir + + else: + # The source directory does not exist, so we must be in case + # (2). Leave well enough alone. + pass + diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py index 85c8302af7..676b6c29a9 100644 --- a/direct/src/actor/Actor.py +++ b/direct/src/actor/Actor.py @@ -1,7 +1,7 @@ """Actor module: contains the Actor class""" -from PandaObject import * -import LODNode +from direct.showbase.PandaObject import * +from pandac import LODNode import types class Actor(PandaObject, NodePath): @@ -935,8 +935,8 @@ class Actor(PandaObject, NodePath): # actions def animPanel(self): - import TkGlobal - import AnimPanel + from direct.showbase import TkGlobal + from direct.tkpanels import AnimPanel return AnimPanel.AnimPanel(self) def stop(self, animName=None, partName=None): @@ -1369,6 +1369,6 @@ class Actor(PandaObject, NodePath): [other.__animControlDict[lodName][partName][animName][0], None] def actorInterval(self, *args, **kw): - import ActorInterval + from direct.interval import ActorInterval return ActorInterval.ActorInterval(self, *args, **kw) diff --git a/direct/src/actor/DistributedActor.py b/direct/src/actor/DistributedActor.py index d381177cdc..c51b130a6d 100644 --- a/direct/src/actor/DistributedActor.py +++ b/direct/src/actor/DistributedActor.py @@ -1,6 +1,6 @@ """DistributedActor module: contains the DistributedActor class""" -import DistributedNode +from direct.distributed import DistributedNode import Actor class DistributedActor(DistributedNode.DistributedNode, Actor.Actor): diff --git a/direct/src/actor/__init__.py b/direct/src/actor/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/cluster/ClusterClient.py b/direct/src/cluster/ClusterClient.py index d167f660e5..6eccf6a7d2 100644 --- a/direct/src/cluster/ClusterClient.py +++ b/direct/src/cluster/ClusterClient.py @@ -1,11 +1,11 @@ """ClusterClient: Master for mutli-piping or PC clusters. """ -from PandaModules import * +from pandac.PandaModules import * from ClusterMsgs import * from ClusterConfig import * -import DirectNotifyGlobal -import DirectObject -import Task +from direct.directnotify import DirectNotifyGlobal +from direct.showbase import DirectObject +from direct.task import Task import os class ClusterClient(DirectObject.DirectObject): diff --git a/direct/src/cluster/ClusterConfig.py b/direct/src/cluster/ClusterConfig.py index 4ea9557c02..c68c76043b 100644 --- a/direct/src/cluster/ClusterConfig.py +++ b/direct/src/cluster/ClusterConfig.py @@ -1,4 +1,4 @@ -from PandaObject import * +from direct.showbase.PandaObject import * from ClusterClient import * import string diff --git a/direct/src/cluster/ClusterMsgs.py b/direct/src/cluster/ClusterMsgs.py index 1138d5d037..90bd86c34d 100644 --- a/direct/src/cluster/ClusterMsgs.py +++ b/direct/src/cluster/ClusterMsgs.py @@ -3,9 +3,9 @@ # This module is intended to supply routines and dataformats common to # both ClusterClient and ClusterServer. -from PandaModules import * -from PyDatagram import PyDatagram -from PyDatagramIterator import PyDatagramIterator +from pandac.PandaModules import * +from direct.distributed.PyDatagram import PyDatagram +from direct.distributed.PyDatagramIterator import PyDatagramIterator import time #these are the types of messages that are currently supported. diff --git a/direct/src/cluster/ClusterServer.py b/direct/src/cluster/ClusterServer.py index 3caa4f46c6..62725ee3df 100644 --- a/direct/src/cluster/ClusterServer.py +++ b/direct/src/cluster/ClusterServer.py @@ -1,9 +1,9 @@ -from PandaModules import * +from pandac.PandaModules import * from ClusterMsgs import * -from MsgTypes import * -import DirectNotifyGlobal -import DirectObject -import Task +from direct.distributed.MsgTypes import * +from direct.directnotify import DirectNotifyGlobal +from direct.showbase import DirectObject +from direct.task import Task # NOTE: This assumes the following variables are set via bootstrap command line # arguments on server startup: diff --git a/direct/src/cluster/__init__.py b/direct/src/cluster/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index 3ffe931924..ab7d62c25e 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -19,7 +19,6 @@ #include "dcField.h" #include "hashGenerator.h" #include "dcmsgtypes.h" -#include "notify.h" //////////////////////////////////////////////////////////////////// // Function: DCField::get_number diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index 9ac2529f9d..c5f8edcf0b 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -85,6 +85,8 @@ dc_cleanup_parser() { %type dclass_name %type atomic_name %type type_token +%type import_identifier +%type slash_identifier %% @@ -120,12 +122,28 @@ dclass_name: } ; +slash_identifier: + IDENTIFIER + | slash_identifier '/' IDENTIFIER +{ + $$ = $1 + string("/") + $3; +} + ; + +import_identifier: + slash_identifier + | import_identifier '.' slash_identifier +{ + $$ = $1 + string(".") + $3; +} + ; + import: - KW_IMPORT IDENTIFIER + KW_IMPORT import_identifier { dc_file->add_import_module($2); } - | KW_FROM IDENTIFIER KW_IMPORT + | KW_FROM import_identifier KW_IMPORT { dc_file->add_import_module($2); } @@ -141,11 +159,11 @@ import_symbol_list_or_star: ; import_symbol_list: - IDENTIFIER + slash_identifier { dc_file->add_import_symbol($1); } - | import_symbol_list ',' IDENTIFIER + | import_symbol_list ',' slash_identifier { dc_file->add_import_symbol($3); } diff --git a/direct/src/directbase/DirectStart.py b/direct/src/directbase/DirectStart.py index b6240ad0bd..6e2f27c7e7 100644 --- a/direct/src/directbase/DirectStart.py +++ b/direct/src/directbase/DirectStart.py @@ -1,4 +1,4 @@ print 'DirectStart: Starting the game.' -import ShowBase +from direct.showbase import ShowBase ShowBase.ShowBase() diff --git a/direct/src/directbase/__init__.py b/direct/src/directbase/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/directdevices/DirectDeviceManager.py b/direct/src/directdevices/DirectDeviceManager.py index 4544ee53aa..53d0d61ced 100644 --- a/direct/src/directdevices/DirectDeviceManager.py +++ b/direct/src/directdevices/DirectDeviceManager.py @@ -1,7 +1,7 @@ """ Class used to create and control vrpn devices """ -from DirectObject import * -from PandaModules import * +from direct.showbase.DirectObject import * +from pandac.PandaModules import * ANALOG_MIN = -0.95 ANALOG_MAX = 0.95 diff --git a/direct/src/directdevices/DirectFastrak.py b/direct/src/directdevices/DirectFastrak.py index 04d76268d0..72ebc44063 100644 --- a/direct/src/directdevices/DirectFastrak.py +++ b/direct/src/directdevices/DirectFastrak.py @@ -1,9 +1,9 @@ """ Class used to create and control radamec device """ from math import * -from PandaObject import * +from direct.showbase.PandaObject import * from DirectDeviceManager import * -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal """ TODO: diff --git a/direct/src/directdevices/DirectJoybox.py b/direct/src/directdevices/DirectJoybox.py index 0874bd341f..1f0ab42068 100644 --- a/direct/src/directdevices/DirectJoybox.py +++ b/direct/src/directdevices/DirectJoybox.py @@ -1,9 +1,9 @@ """ Class used to create and control joybox device """ -from PandaObject import * +from direct.showbase.PandaObject import * from DirectDeviceManager import * -from DirectUtil import * -import OnscreenText -import Task +from direct.directtools.DirectUtil import * +from direct.gui import OnscreenText +from direct.task import Task """ TODO: diff --git a/direct/src/directdevices/DirectRadamec.py b/direct/src/directdevices/DirectRadamec.py index d68acca663..7fc58438cc 100644 --- a/direct/src/directdevices/DirectRadamec.py +++ b/direct/src/directdevices/DirectRadamec.py @@ -1,9 +1,9 @@ """ Class used to create and control radamec device """ from math import * -from PandaObject import * +from direct.showbase.PandaObject import * from DirectDeviceManager import * -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal """ diff --git a/direct/src/directdevices/__init__.py b/direct/src/directdevices/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/directnotify/DirectNotify.py b/direct/src/directnotify/DirectNotify.py index 6dc0d728a5..1b04958078 100644 --- a/direct/src/directnotify/DirectNotify.py +++ b/direct/src/directnotify/DirectNotify.py @@ -102,5 +102,5 @@ class DirectNotify: self.setDconfigLevel(categoryName) def popupControls(self, tl = None): - import NotifyPanel + from direct.tkpanels import NotifyPanel NotifyPanel.NotifyPanel(self, tl) diff --git a/direct/src/directnotify/Notifier.py b/direct/src/directnotify/Notifier.py index 5c54b61444..7ed5ae6144 100644 --- a/direct/src/directnotify/Notifier.py +++ b/direct/src/directnotify/Notifier.py @@ -2,7 +2,7 @@ for the programmer/user""" from LoggerGlobal import * -import PythonUtil +from direct.showbase import PythonUtil import time class Notifier: @@ -41,7 +41,7 @@ class Notifier: delta = int(round(delta)) Notifier.serverDelta = delta + time.timezone - timezone - import NotifyCategory + from pandac import NotifyCategory NotifyCategory.NotifyCategory.setServerDelta(self.serverDelta) self.info("Notify clock adjusted by %s (and timezone adjusted by %s hours) to synchronize with server." % (PythonUtil.formatElapsedSeconds(delta), (time.timezone - timezone) / 3600)) @@ -71,7 +71,7 @@ class Notifier: # Severity funcs def setSeverity(self, severity): - import NotifySeverity + from pandac import NotifySeverity if severity >= NotifySeverity.NSError: self.setWarning(0) self.setInfo(0) @@ -90,7 +90,7 @@ class Notifier: self.setDebug(1) def getSeverity(self): - import NotifySeverity + from pandac import NotifySeverity if self.getDebug(): return NotifySeverity.NSDebug elif self.getInfo(): diff --git a/direct/src/directnotify/__init__.py b/direct/src/directnotify/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/directscripts/__init__.py b/direct/src/directscripts/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/directtools/DirectCameraControl.py b/direct/src/directtools/DirectCameraControl.py index cd071ea25a..f2876f627b 100644 --- a/direct/src/directtools/DirectCameraControl.py +++ b/direct/src/directtools/DirectCameraControl.py @@ -1,8 +1,8 @@ -from PandaObject import * +from direct.showbase.PandaObject import * from DirectUtil import * from DirectGeometry import * from DirectGlobals import * -import Task +from direct.task import Task CAM_MOVE_DURATION = 1.2 COA_MARKER_SF = 0.0075 diff --git a/direct/src/directtools/DirectGeometry.py b/direct/src/directtools/DirectGeometry.py index 12dce2649c..7ee9666a53 100644 --- a/direct/src/directtools/DirectGeometry.py +++ b/direct/src/directtools/DirectGeometry.py @@ -1,5 +1,5 @@ -from PandaModules import * -from PandaObject import * +from pandac.PandaModules import * +from direct.showbase.PandaObject import * from DirectGlobals import * from DirectUtil import * import math diff --git a/direct/src/directtools/DirectGlobals.py b/direct/src/directtools/DirectGlobals.py index 46cde86260..0940f59fe1 100644 --- a/direct/src/directtools/DirectGlobals.py +++ b/direct/src/directtools/DirectGlobals.py @@ -1,4 +1,4 @@ -from PandaModules import Vec3, Point3 +from pandac.PandaModules import Vec3, Point3 UNPICKABLE = ['x-disc-visible', 'y-disc-visible', 'z-disc-visible', 'GridBack', 'unpickable'] diff --git a/direct/src/directtools/DirectGrid.py b/direct/src/directtools/DirectGrid.py index c4774a5fc7..6518c9bf70 100644 --- a/direct/src/directtools/DirectGrid.py +++ b/direct/src/directtools/DirectGrid.py @@ -1,4 +1,4 @@ -from PandaObject import * +from direct.showbase.PandaObject import * from DirectUtil import * from DirectGeometry import * diff --git a/direct/src/directtools/DirectLights.py b/direct/src/directtools/DirectLights.py index d5ded77ac7..eb0cc689c2 100644 --- a/direct/src/directtools/DirectLights.py +++ b/direct/src/directtools/DirectLights.py @@ -1,4 +1,4 @@ -from PandaObject import * +from direct.showbase.PandaObject import * from string import lower class DirectLight(NodePath): diff --git a/direct/src/directtools/DirectManipulation.py b/direct/src/directtools/DirectManipulation.py index 83ee48f619..b08cefb4ed 100644 --- a/direct/src/directtools/DirectManipulation.py +++ b/direct/src/directtools/DirectManipulation.py @@ -1,8 +1,8 @@ -from PandaObject import * +from direct.showbase.PandaObject import * from DirectGlobals import * from DirectUtil import * from DirectGeometry import * -import Task +from direct.task import Task class DirectManipulationControl(PandaObject): def __init__(self): diff --git a/direct/src/directtools/DirectSelection.py b/direct/src/directtools/DirectSelection.py index 0f72bb7437..f200d87a9f 100644 --- a/direct/src/directtools/DirectSelection.py +++ b/direct/src/directtools/DirectSelection.py @@ -1,4 +1,4 @@ -from PandaObject import * +from direct.showbase.PandaObject import * from DirectGlobals import * from DirectUtil import * from DirectGeometry import * diff --git a/direct/src/directtools/DirectSession.py b/direct/src/directtools/DirectSession.py index 2f9a3b323e..7d13b6bcba 100644 --- a/direct/src/directtools/DirectSession.py +++ b/direct/src/directtools/DirectSession.py @@ -1,4 +1,4 @@ -from PandaObject import * +from direct.showbase.PandaObject import * from DirectGlobals import * from DirectUtil import* from DirectCameraControl import * @@ -7,15 +7,15 @@ from DirectSelection import * from DirectGrid import * from DirectGeometry import * from DirectLights import * -from ClusterClient import * -from ClusterServer import * -import Placer -import Slider -import SceneGraphExplorer -import OnscreenText +from direct.cluster.ClusterClient import * +from direct.cluster.ClusterServer import * +from direct.tkpanels import Placer +from direct.tkwidgets import Slider +from direct.tkwidgets import SceneGraphExplorer +from direct.gui import OnscreenText import types import string -import Loader +from direct.showbase import Loader class DirectSession(PandaObject): @@ -84,20 +84,20 @@ class DirectSession(PandaObject): self.radamec = None self.fastrak = [] if base.config.GetBool('want-vrpn', 0): - import DirectDeviceManager + from direct.directdevices import DirectDeviceManager self.deviceManager = DirectDeviceManager.DirectDeviceManager() # Automatically create any devices specified in config file joybox = base.config.GetString('vrpn-joybox-device', '') radamec = base.config.GetString('vrpn-radamec-device', '') fastrak = base.config.GetString('vrpn-fastrak-device', '') if joybox: - import DirectJoybox + from direct.directdevices import DirectJoybox self.joybox = DirectJoybox.DirectJoybox(joybox) if radamec: - import DirectRadamec + from direct.directdevices import DirectRadamec self.radamec = DirectRadamec.DirectRadamec(radamec) if fastrak: - import DirectFastrak + from direct.directdevices import DirectFastrak # parse string into format device:N where N is the sensor name fastrak = string.split(fastrak) for i in range(len(fastrak))[1:]: @@ -170,8 +170,8 @@ class DirectSession(PandaObject): ] if base.wantTk: - import TkGlobal - import DirectSessionPanel + from direct.showbase import TkGlobal + from direct.tkpanels import DirectSessionPanel self.panel = DirectSessionPanel.DirectSessionPanel(parent = tkroot) try: # Has the clusterMode been set externally (i.e. via the diff --git a/direct/src/directtools/DirectUtil.py b/direct/src/directtools/DirectUtil.py index 85788cb85b..98ae7f62c9 100644 --- a/direct/src/directtools/DirectUtil.py +++ b/direct/src/directtools/DirectUtil.py @@ -1,4 +1,4 @@ -from PandaObject import * +from direct.showbase.PandaObject import * from DirectGlobals import * # Routines to adjust values diff --git a/direct/src/directtools/__init__.py b/direct/src/directtools/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/directutil/DistributedLargeBlobSender.py b/direct/src/directutil/DistributedLargeBlobSender.py index 6cad983984..bed96cc643 100755 --- a/direct/src/directutil/DistributedLargeBlobSender.py +++ b/direct/src/directutil/DistributedLargeBlobSender.py @@ -1,7 +1,7 @@ """DistributedLargeBlobSender module: contains the DistributedLargeBlobSender class""" -import DistributedObject -import DirectNotifyGlobal +from direct.distributed import DistributedObject +from direct.directnotify import DirectNotifyGlobal import LargeBlobSenderConsts class DistributedLargeBlobSender(DistributedObject.DistributedObject): diff --git a/direct/src/directutil/DistributedLargeBlobSenderAI.py b/direct/src/directutil/DistributedLargeBlobSenderAI.py index dbb82a4ee9..a0212de8e5 100755 --- a/direct/src/directutil/DistributedLargeBlobSenderAI.py +++ b/direct/src/directutil/DistributedLargeBlobSenderAI.py @@ -1,7 +1,7 @@ """DistributedLargeBlobSenderAI module: contains the DistributedLargeBlobSenderAI class""" -import DistributedObjectAI -import DirectNotifyGlobal +from direct.distributed import DistributedObjectAI +from direct.directnotify import DirectNotifyGlobal import LargeBlobSenderConsts class DistributedLargeBlobSenderAI(DistributedObjectAI.DistributedObjectAI): diff --git a/direct/src/directutil/Mopath.py b/direct/src/directutil/Mopath.py index 008577541b..f6b206b0b8 100644 --- a/direct/src/directutil/Mopath.py +++ b/direct/src/directutil/Mopath.py @@ -1,7 +1,7 @@ -from PandaObject import * -from DirectGeometry import * +from direct.showbase.PandaObject import * +from direct.directtools.DirectGeometry import * -import NodePath +from pandac import NodePath class Mopath(PandaObject): diff --git a/direct/src/directutil/__init__.py b/direct/src/directutil/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/distributed/CRCache.py b/direct/src/distributed/CRCache.py index 340b6fc0a7..c2771fc8ae 100644 --- a/direct/src/distributed/CRCache.py +++ b/direct/src/distributed/CRCache.py @@ -1,6 +1,6 @@ """CRCache module: contains the CRCache class""" -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import DistributedObject class CRCache: @@ -86,7 +86,7 @@ class CRCache: def checkCache(self): # For debugging; this verifies that the cache is sensible and # returns true if so. - from PandaModules import NodePath + from pandac.PandaModules import NodePath for obj in self.dict.values(): if isinstance(obj, NodePath): assert(not obj.isEmpty() and obj.getTopNode() != render.node()) diff --git a/direct/src/distributed/ClientRepository.py b/direct/src/distributed/ClientRepository.py index e8e7004a69..4dfd22692c 100644 --- a/direct/src/distributed/ClientRepository.py +++ b/direct/src/distributed/ClientRepository.py @@ -1,12 +1,12 @@ """ClientRepository module: contains the ClientRepository class""" -from PandaModules import * +from pandac.PandaModules import * from MsgTypes import * -import Task -import DirectNotifyGlobal +from direct.task import Task +from direct.directnotify import DirectNotifyGlobal import CRCache import ConnectionRepository -import PythonUtil +from direct.showbase import PythonUtil import ParentMgr import RelatedObjectMgr import time diff --git a/direct/src/distributed/ClockDelta.py b/direct/src/distributed/ClockDelta.py index a1d1376342..89d406d6cb 100644 --- a/direct/src/distributed/ClockDelta.py +++ b/direct/src/distributed/ClockDelta.py @@ -1,9 +1,9 @@ # ClockDelta provides the ability to use clock synchronization for # distributed objects -from PandaModules import * -import DirectNotifyGlobal -import DirectObject +from pandac.PandaModules import * +from direct.directnotify import DirectNotifyGlobal +from direct.showbase import DirectObject import math # The following two parameters, NetworkTimeBits and diff --git a/direct/src/distributed/ConnectionRepository.py b/direct/src/distributed/ConnectionRepository.py index ad1b90d65f..1603ceb5d9 100644 --- a/direct/src/distributed/ConnectionRepository.py +++ b/direct/src/distributed/ConnectionRepository.py @@ -1,11 +1,12 @@ -from PandaModules import * -import Task -import DirectNotifyGlobal -import DirectObject +from pandac.PandaModules import * +from direct.task import Task +from direct.directnotify import DirectNotifyGlobal +from direct.showbase import DirectObject from PyDatagram import PyDatagram from PyDatagramIterator import PyDatagramIterator import types +import imp class ConnectionRepository(DirectObject.DirectObject, CConnectionRepository): """ @@ -52,6 +53,10 @@ class ConnectionRepository(DirectObject.DirectObject, CConnectionRepository): self.recorder = None + # This is the string that is appended to symbols read from the + # DC file. The AIRepository will redefine this to 'AI'. + self.dcSuffix = '' + def readDCFile(self, dcFileNames = None): """ Reads in the dc files listed in dcFileNames, or if @@ -79,43 +84,33 @@ class ConnectionRepository(DirectObject.DirectObject, CConnectionRepository): # Now import all of the modules required by the DC file. for n in range(dcFile.getNumImportModules()): moduleName = dcFile.getImportModule(n) - moduleName = self.mangleDCName(moduleName) - module = __import__(moduleName, globals(), locals()) + # Maybe the module name is represented as "moduleName/AI". + suffix = moduleName.split('/') + moduleName = suffix[0] + if self.dcSuffix and self.dcSuffix in suffix[1:]: + moduleName += self.dcSuffix - if dcFile.getNumImportSymbols(n) > 0: - # "from moduleName import symbolName, symbolName, ..." - # Copy just the named symbols into the dictionary. - for i in range(dcFile.getNumImportSymbols(n)): - symbolName = dcFile.getImportSymbol(n, i) - if symbolName == '*': - # Get all symbols. - dcImports.update(module.__dict__) - else: - mangledName = self.mangleName(symbolName) - gotAny = 0 - if hasattr(module, symbolName): - dcImports[symbolName] = getattr(module, symbolName) - gotAny = 1 - if hasattr(module, mangledName): - dcImports[mangledName] = getattr(module, mangledName) - gotAny = 1 - - if not gotAny: - self.notify.error("Symbol %s not found in module %s." % ( - symbolName, moduleName)) - else: - # "import moduleName" - # Copy the module itself into the dictionary. - dcImports[moduleName] = module + importSymbols = [] + for i in range(dcFile.getNumImportSymbols(n)): + symbolName = dcFile.getImportSymbol(n, i) + + # Maybe the symbol name is represented as "symbolName/AI". + suffix = symbolName.split('/') + symbolName = suffix[0] + if self.dcSuffix and self.dcSuffix in suffix[1:]: + symbolName += self.dcSuffix + + importSymbols.append(symbolName) + + self.importModule(dcImports, moduleName, importSymbols) # Now get the class definition for the classes named in the DC # file. for i in range(dcFile.getNumClasses()): dclass = dcFile.getClass(i) number = dclass.getNumber() - className = dclass.getName() - className = self.mangleDCName(className) + className = dclass.getName() + self.dcSuffix # Does the class have a definition defined in the newly # imported namespace? @@ -136,14 +131,38 @@ class ConnectionRepository(DirectObject.DirectObject, CConnectionRepository): self.dclassesByName[className] = dclass self.dclassesByNumber[number] = dclass - def mangleDCName(self, name): - """ This is provided as a hook so that derived classes - (e.g. the AIRepository) can rename symbols from the .dc file - according to the conventions associated with this particular - repository (e.g., an AIRepository appends 'AI' to class and - module names).""" - - return name + def importModule(self, dcImports, moduleName, importSymbols): + """ Imports the indicated moduleName and all of its symbols + into the current namespace. This more-or-less reimplements + the Python import command. """ + + module = __import__(moduleName, globals(), locals(), importSymbols) + + if importSymbols: + # "from moduleName import symbolName, symbolName, ..." + # Copy just the named symbols into the dictionary. + if importSymbols == ['*']: + # "from moduleName import *" + if hasattr(module, "__all__"): + importSymbols = module.__all__ + else: + importSymbols = module.__dict__.keys() + + for symbolName in importSymbols: + if hasattr(module, symbolName): + dcImports[symbolName] = getattr(module, symbolName) + + else: + raise StandardError, 'Symbol %s not defined in module %s.' % (symbolName, moduleName) + + else: + # "import moduleName" + + # Copy the root module name into the dictionary. + + # Follow the dotted chain down to the actual module. + components = moduleName.split('.') + dcImports[components[0]] = module def connect(self, serverList, successCallback = None, successArgs = [], diff --git a/direct/src/distributed/DistributedNode.py b/direct/src/distributed/DistributedNode.py index 66bea19269..e288fafed4 100644 --- a/direct/src/distributed/DistributedNode.py +++ b/direct/src/distributed/DistributedNode.py @@ -1,9 +1,9 @@ """DistributedNode module: contains the DistributedNode class""" -from ShowBaseGlobal import * -from PandaModules import NodePath +from direct.showbase.ShowBaseGlobal import * +from pandac.PandaModules import NodePath import DistributedObject -import Task +from direct.task import Task import types class DistributedNode(DistributedObject.DistributedObject, NodePath): diff --git a/direct/src/distributed/DistributedNodeAI.py b/direct/src/distributed/DistributedNodeAI.py index e2a8082be5..4e1a2a9093 100644 --- a/direct/src/distributed/DistributedNodeAI.py +++ b/direct/src/distributed/DistributedNodeAI.py @@ -1,6 +1,6 @@ -from AIBaseGlobal import * -from PandaModules import NodePath -import DistributedObjectAI +from otp.ai.AIBaseGlobal import * +from pandac.PandaModules import NodePath +from direct.distributed import DistributedObjectAI class DistributedNodeAI(DistributedObjectAI.DistributedObjectAI, NodePath): def __init__(self, air, name=None): diff --git a/direct/src/distributed/DistributedObject.py b/direct/src/distributed/DistributedObject.py index 702c87ac0b..019cc1486d 100644 --- a/direct/src/distributed/DistributedObject.py +++ b/direct/src/distributed/DistributedObject.py @@ -1,7 +1,7 @@ """DistributedObject module: contains the DistributedObject class""" -from PandaObject import * -from DirectNotifyGlobal import * +from direct.showbase.PandaObject import * +from direct.directnotify.DirectNotifyGlobal import * from PyDatagram import PyDatagram from PyDatagramIterator import PyDatagramIterator diff --git a/direct/src/distributed/DistributedObjectAI.py b/direct/src/distributed/DistributedObjectAI.py new file mode 100644 index 0000000000..30bb69561b --- /dev/null +++ b/direct/src/distributed/DistributedObjectAI.py @@ -0,0 +1,272 @@ +"""DistributedObjectAI module: contains the DistributedObjectAI class""" + +from direct.directnotify.DirectNotifyGlobal import * +from direct.showbase import PythonUtil +from direct.showbase import DirectObject +from pandac.PandaModules import * +from PyDatagram import PyDatagram +from PyDatagramIterator import PyDatagramIterator + +class DistributedObjectAI(DirectObject.DirectObject): + """Distributed Object class:""" + + notify = directNotify.newCategory("DistributedObjectAI") + + def __init__(self, air): + try: + self.DistributedObjectAI_initialized + except: + self.DistributedObjectAI_initialized = 1 + # Record the repository + self.air = air + # Record our distributed class + className = self.__class__.__name__ + self.dclass = self.air.dclassesByName[className] + # init doId pre-allocated flag + self.__preallocDoId = 0 + + # These are used to implement beginBarrier(). + self.__nextBarrierContext = 0 + self.__barriers = {} + + # Uncomment if you want to debug DO leaks + #def __del__(self): + # """ + # For debugging purposes, this just prints out what got deleted + # """ + # print ("Destructing: " + self.__class__.__name__) + + def delete(self): + """ + Inheritors should redefine this to take appropriate action on delete + Note that this may be called multiple times if a class inherits + from DistributedObjectAI more than once. + """ + # prevent this code from executing multiple times + if self.air is not None: + # self.doId may not exist. The __dict__ syntax works around that. + assert(self.notify.debug('delete(): %s' % (self.__dict__.get("doId")))) + # Clean up all the pending barriers. + for barrier in self.__barriers.values(): + barrier.cleanup() + self.__barriers = {} + + if not hasattr(self, "doNotDeallocateChannel"): + if self.air: + self.air.deallocateChannel(self.doId) + self.air = None + del self.zoneId + + def isDeleted(self): + """ + Returns true if the object has been deleted, + or if it is brand new and hasn't yet been generated. + """ + return (self.air == None) + + def isGenerated(self): + """ + Returns true if the object has been generated + """ + return hasattr(self, 'zoneId') + + def getDoId(self): + """ + Return the distributed object id + """ + return self.doId + + def preAllocateDoId(self): + """ + objects that need to have a doId before they are generated + can call this to pre-allocate a doId for the object + """ + assert not self.__preallocDoId + self.doId = self.air.allocateChannel() + self.__preallocDoId = 1 + + def updateRequiredFields(self, dclass, di): + dclass.receiveUpdateBroadcastRequired(self, di) + + def updateAllRequiredFields(self, dclass, di): + dclass.receiveUpdateAllRequired(self, di) + + def updateRequiredOtherFields(self, dclass, di): + dclass.receiveUpdateBroadcastRequired(self, di) + dclass.receiveUpdateOther(self, di) + + def updateAllRequiredOtherFields(self, dclass, di): + dclass.receiveUpdateAllRequired(self, di) + dclass.receiveUpdateOther(self, di) + + def getZoneChangeEvent(self): + return 'DOChangeZone-%s' % self.doId + + def handleZoneChange(self, newZoneId, oldZoneId): + assert oldZoneId == self.zoneId + self.zoneId = newZoneId + self.air.changeDOZoneInTables(self, newZoneId, oldZoneId) + messenger.send(self.getZoneChangeEvent(), [newZoneId, oldZoneId]) + + def sendUpdate(self, fieldName, args = []): + if self.air: + self.air.sendUpdate(self, fieldName, args) + + def sendUpdateToAvatarId(self, avId, fieldName, args): + channelId = avId + 1 + self.sendUpdateToChannel(channelId, fieldName, args) + + def sendUpdateToChannel(self, channelId, fieldName, args): + if self.air: + self.air.sendUpdateToChannel(self, channelId, fieldName, args) + + def generateWithRequired(self, zoneId, optionalFields=[]): + # have we already allocated a doId? + if self.__preallocDoId: + self.__preallocDoId = 0 + return self.generateWithRequiredAndId( + self.doId, zoneId, optionalFields) + + # The repository is the one that really does the work + self.air.generateWithRequired(self, zoneId, optionalFields) + self.zoneId = zoneId + self.generate() + + # this is a special generate used for estates, or anything else that + # needs to have a hard coded doId as assigned by the server + def generateWithRequiredAndId(self, doId, zoneId, optionalFields=[]): + # have we already allocated a doId? + if self.__preallocDoId: + self.__preallocDoId = 0 + assert doId == self.doId + + # The repository is the one that really does the work + self.air.generateWithRequiredAndId(self, doId, zoneId, optionalFields) + self.zoneId = zoneId + self.generate() + + def generate(self): + # Inheritors should put functions that require self.zoneId or + # other networked info in this function. + assert(self.notify.debug('generate(): %s' % (self.doId))) + pass + + def sendGenerateWithRequired(self, repository, zoneId, optionalFields=[]): + # Make the dclass do the hard work + dg = self.dclass.aiFormatGenerate(self, self.doId, zoneId, + repository.districtId, + repository.ourChannel, + optionalFields) + repository.send(dg) + self.zoneId = zoneId + + def initFromServerResponse(self, valDict): + # This is a special method used for estates, etc., which get + # their fields set from the database indirectly by way of the + # AI. The input parameter is a dictionary of field names to + # datagrams that describes the initial field values from the + # database. + assert(self.notify.debug("initFromServerResponse(%s)" % (valDict.keys(),))) + + dclass = self.dclass + for key, value in valDict.items(): + # Update the field + dclass.directUpdate(self, key, value) + + def requestDelete(self): + if not self.air: + doId = "none" + if hasattr(self, "doId"): + doId = self.doId + self.notify.warning("Tried to delete a %s (doId %s) that is already deleted" % (self.__class__, doId)) + return + self.air.requestDelete(self) + + def taskName(self, taskString): + return (taskString + "-" + str(self.getDoId())) + + def uniqueName(self, idString): + return (idString + "-" + str(self.getDoId())) + + def validate(self, avId, bool, msg): + if not bool: + self.air.writeServerEvent('suspicious', avId, msg) + self.notify.warning('validate error: avId: %s -- %s' % (avId, msg)) + return bool + + def beginBarrier(self, name, avIds, timeout, callback): + # Begins waiting for a set of avatars. When all avatars in + # the list have reported back in or the callback has expired, + # calls the indicated callback with the list of toons that + # made it through. There may be multiple barriers waiting + # simultaneously on different lists of avatars, although they + # should have different names. + + from toontown.ai import ToonBarrier + context = self.__nextBarrierContext + # We assume the context number is passed as a uint16. + self.__nextBarrierContext = (self.__nextBarrierContext + 1) & 0xffff + + assert(self.notify.debug('beginBarrier(%s, %s, %s, %s)' % (context, name, avIds, timeout))) + + if avIds: + barrier = ToonBarrier.ToonBarrier( + self.uniqueName(name), avIds, timeout, + doneFunc = PythonUtil.Functor(self.__barrierCallback, context, callback)) + self.__barriers[context] = barrier + + # Send the context number to each involved client. + self.sendUpdate("setBarrierData", [self.__getBarrierData()]) + else: + # No avatars; just call the callback immediately. + callback(avIds) + + return context + + def __getBarrierData(self): + # Returns the barrier data formatted as a blob for sending to + # the clients. This lists all of the current outstanding + # barriers and the avIds waiting for them. + dg = PyDatagram() + for context, barrier in self.__barriers.items(): + toons = barrier.pendingToons + if toons: + dg.addUint16(context) + dg.addUint16(len(toons)) + for avId in toons: + dg.addUint32(avId) + return dg.getMessage() + + def ignoreBarrier(self, context): + # Aborts a previously-set barrier. The context is the return + # value from the previous call to beginBarrier(). + barrier = self.__barriers.get(context) + if barrier: + barrier.cleanup() + del self.__barriers[context] + + def setBarrierReady(self, context): + # Generated by the clients to check in after a beginBarrier() + # call. + avId = self.air.msgSender + assert(self.notify.debug('setBarrierReady(%s, %s)' % (context, avId))) + barrier = self.__barriers.get(context) + if barrier == None: + # This may be None if a client was slow and missed an + # earlier timeout. Too bad. + return + + barrier.clear(avId) + + def __barrierCallback(self, context, callback, avIds): + assert(self.notify.debug('barrierCallback(%s, %s)' % (context, avIds))) + # The callback that is generated when a barrier is completed. + barrier = self.__barriers.get(context) + if barrier: + barrier.cleanup() + del self.__barriers[context] + callback(avIds) + else: + self.notify.warning("Unexpected completion from barrier %s" % (context)) + + diff --git a/direct/src/distributed/DistributedSmoothNode.py b/direct/src/distributed/DistributedSmoothNode.py index 737f1da80c..8bf6e8fdfc 100644 --- a/direct/src/distributed/DistributedSmoothNode.py +++ b/direct/src/distributed/DistributedSmoothNode.py @@ -1,10 +1,10 @@ """DistributedSmoothNode module: contains the DistributedSmoothNode class""" -from PandaModules import * +from pandac.PandaModules import * from ClockDelta import * import DistributedNode import DistributedSmoothNodeBase -import Task +from direct.task import Task # This number defines our tolerance for out-of-sync telemetry packets. # If a packet appears to have originated from more than MaxFuture diff --git a/direct/src/distributed/DistributedSmoothNodeAI.py b/direct/src/distributed/DistributedSmoothNodeAI.py index 9b854cb86d..4b02813740 100755 --- a/direct/src/distributed/DistributedSmoothNodeAI.py +++ b/direct/src/distributed/DistributedSmoothNodeAI.py @@ -1,4 +1,4 @@ -from AIBaseGlobal import * +from otp.ai.AIBaseGlobal import * import DistributedNodeAI import DistributedSmoothNodeBase diff --git a/direct/src/distributed/DistributedSmoothNodeBase.py b/direct/src/distributed/DistributedSmoothNodeBase.py index c58bf43039..eabe5ec60b 100755 --- a/direct/src/distributed/DistributedSmoothNodeBase.py +++ b/direct/src/distributed/DistributedSmoothNodeBase.py @@ -1,7 +1,7 @@ """DistributedSmoothNodeBase module: contains the DistributedSmoothNodeBase class""" from ClockDelta import * -import Task +from direct.task import Task class DistributedSmoothNodeBase: """common base class for DistributedSmoothNode and DistributedSmoothNodeAI diff --git a/direct/src/distributed/ParentMgr.py b/direct/src/distributed/ParentMgr.py index 77d45d024d..e29535c0f3 100644 --- a/direct/src/distributed/ParentMgr.py +++ b/direct/src/distributed/ParentMgr.py @@ -1,6 +1,6 @@ """ParentMgr module: contains the ParentMgr class""" -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal class ParentMgr: # This is now used on the AI as well. diff --git a/direct/src/distributed/PyDatagram.py b/direct/src/distributed/PyDatagram.py index 5bbc72e852..d7391d88bf 100755 --- a/direct/src/distributed/PyDatagram.py +++ b/direct/src/distributed/PyDatagram.py @@ -3,9 +3,9 @@ # class variable FuncDict and so we can import DCSubatomicType at the top # of the file rather than every time we call the putArg function. -from PandaModules import * +from pandac.PandaModules import * # Import the type numbers -from DCSubatomicType import * +from pandac.DCSubatomicType import * class PyDatagram(Datagram): diff --git a/direct/src/distributed/PyDatagramIterator.py b/direct/src/distributed/PyDatagramIterator.py index 91c6854fc0..76aad07f2c 100755 --- a/direct/src/distributed/PyDatagramIterator.py +++ b/direct/src/distributed/PyDatagramIterator.py @@ -3,9 +3,9 @@ # class variable FuncDict and so we can import DCSubatomicType at the top # of the file rather than every time we call the putArg function. -from PandaModules import * +from pandac.PandaModules import * # Import the type numbers -from DCSubatomicType import * +from pandac.DCSubatomicType import * class PyDatagramIterator(DatagramIterator): diff --git a/direct/src/distributed/RelatedObjectMgr.py b/direct/src/distributed/RelatedObjectMgr.py index 6c5d500f4b..bb3c9b4384 100644 --- a/direct/src/distributed/RelatedObjectMgr.py +++ b/direct/src/distributed/RelatedObjectMgr.py @@ -1,8 +1,8 @@ """RelatedObjectMgr module: contains the RelatedObjectMgr class""" -from ShowBaseGlobal import * -import DirectObject -import DirectNotifyGlobal +from direct.showbase.ShowBaseGlobal import * +from direct.showbase import DirectObject +from direct.directnotify import DirectNotifyGlobal class RelatedObjectMgr(DirectObject.DirectObject): """ diff --git a/direct/src/distributed/__init__.py b/direct/src/distributed/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index 9bd7a31cb4..dd97b057bd 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -153,7 +153,9 @@ check_datagram() { #ifdef HAVE_PYTHON case CLIENT_OBJECT_UPDATE_FIELD: case STATESERVER_OBJECT_UPDATE_FIELD: - handle_update_field(); + if (!handle_update_field()) { + return false; + } break; #endif // HAVE_PYTHON @@ -363,16 +365,18 @@ do_check_datagram() { // Description: Directly handles an update message on a field. // Python never touches the datagram; it just gets its // distributed method called with the appropriate -// parameters. +// parameters. Returns true if everything is ok, false +// if there was an error processing the field's update +// method. //////////////////////////////////////////////////////////////////// -void CConnectionRepository:: +bool CConnectionRepository:: handle_update_field() { #ifdef HAVE_PYTHON int do_id = _di.get_uint32(); if (_python_repository != (PyObject *)NULL) { PyObject *doId2do = PyObject_GetAttrString(_python_repository, "doId2do"); - nassertv(doId2do != NULL); + nassertr(doId2do != NULL, false); PyObject *doId = PyInt_FromLong(do_id); PyObject *distobj = PyDict_GetItem(doId2do, doId); @@ -381,11 +385,11 @@ handle_update_field() { if (distobj != NULL) { PyObject *dclass_obj = PyObject_GetAttrString(distobj, "dclass"); - nassertv(dclass_obj != NULL); + nassertr(dclass_obj != NULL, false); PyObject *dclass_this = PyObject_GetAttrString(dclass_obj, "this"); Py_DECREF(dclass_obj); - nassertv(dclass_this != NULL); + nassertr(dclass_this != NULL, false); DCClass *dclass = (DCClass *)PyInt_AsLong(dclass_this); Py_DECREF(dclass_this); @@ -397,7 +401,13 @@ handle_update_field() { Py_INCREF(distobj); dclass->receive_update(distobj, _di); Py_DECREF(distobj); + + if (PyErr_Occurred()) { + return false; + } } } #endif // HAVE_PYTHON + + return true; } diff --git a/direct/src/distributed/cConnectionRepository.h b/direct/src/distributed/cConnectionRepository.h index 9a808c87b6..ddf44c7f90 100644 --- a/direct/src/distributed/cConnectionRepository.h +++ b/direct/src/distributed/cConnectionRepository.h @@ -97,7 +97,7 @@ PUBLISHED: private: bool do_check_datagram(); - void handle_update_field(); + bool handle_update_field(); #ifdef HAVE_PYTHON PyObject *_python_repository; diff --git a/direct/src/extensions/CInterval-extensions.py b/direct/src/extensions/CInterval-extensions.py index 454fe62c58..9f1a390f13 100644 --- a/direct/src/extensions/CInterval-extensions.py +++ b/direct/src/extensions/CInterval-extensions.py @@ -4,7 +4,7 @@ of the CInterval class """ - from DirectNotifyGlobal import directNotify + from direct.directnotify.DirectNotifyGlobal import directNotify notify = directNotify.newCategory("Interval") def setT(self, t): @@ -41,9 +41,9 @@ """ Popup control panel for interval. """ - from TkGlobal import Toplevel, Frame, Button, LEFT, X, Pmw + from direct.showbase.TkGlobal import Toplevel, Frame, Button, LEFT, X, Pmw import math - import EntryScale + from direct.tkwidgets import EntryScale if tl == None: tl = Toplevel() tl.title('Interval Controls') diff --git a/direct/src/extensions/HTTPChannel-extensions.py b/direct/src/extensions/HTTPChannel-extensions.py index b4767ec567..f909cceb4f 100644 --- a/direct/src/extensions/HTTPChannel-extensions.py +++ b/direct/src/extensions/HTTPChannel-extensions.py @@ -15,14 +15,14 @@ """ if not name: name = self.getUrl().cStr() - import Task + from direct.task import Task task = Task.Task(self.doTask) task.callback = callback task.callbackArgs = extraArgs return taskMgr.add(task, name) def doTask(self, task): - import Task + from direct.task import Task if self.run(): return Task.cont if task.callback: diff --git a/direct/src/extensions/MouseWatcherRegion-extensions.py b/direct/src/extensions/MouseWatcherRegion-extensions.py index f4e095280b..000d305c43 100644 --- a/direct/src/extensions/MouseWatcherRegion-extensions.py +++ b/direct/src/extensions/MouseWatcherRegion-extensions.py @@ -13,7 +13,7 @@ node parented within the render2d hierarchy. """ - import Point3 + from pandac import Point3 # Get the relative transform to the node. mat = np.getMat(render2d) diff --git a/direct/src/extensions/NodePath-extensions.py b/direct/src/extensions/NodePath-extensions.py index 8d09a7ede3..8e67d2d954 100644 --- a/direct/src/extensions/NodePath-extensions.py +++ b/direct/src/extensions/NodePath-extensions.py @@ -105,7 +105,7 @@ return [self] def getTightBounds(self): - import Point3 + from pandac import Point3 v1 = Point3.Point3(0) v2 = Point3.Point3(0) self.calcTightBounds(v1,v2) @@ -277,9 +277,9 @@ # functorFunc is a function which can be called to create a functor. # functor creation is defered so initial state (sampled in functorFunc) # will be appropriate for the time the lerp is spawned - import Task - import LerpBlendHelpers - from TaskManagerGlobal import taskMgr + from direct.task import Task + from direct.showbase import LerpBlendHelpers + from direct.task.TaskManagerGlobal import taskMgr # upon death remove the functorFunc def lerpUponDeath(task): @@ -295,9 +295,9 @@ # make the task function def lerpTaskFunc(task): - from Lerp import Lerp - from ClockObject import ClockObject - from Task import Task, cont, done + from pandac.Lerp import Lerp + from pandac.ClockObject import ClockObject + from direct.task.Task import Task, cont, done if task.init == 1: # make the lerp functor = task.functorFunc() @@ -333,8 +333,8 @@ """_autoLerp(self, functor, float, string, string) This lerp uses C++ to handle the stepping. Bonus is its more efficient, trade-off is there is less control""" - import AutonomousLerp - import LerpBlendHelpers + from pandac import AutonomousLerp + from direct.showbase import LerpBlendHelpers # make a lerp that lives in C++ land functor = functorFunc() lerp = AutonomousLerp.AutonomousLerp(functor, time, @@ -368,7 +368,7 @@ string="noBlend", string=none, string=none) """ def functorFunc(self = self, r = r, g = g, b = b, a = a): - import ColorLerpFunctor + from pandac import ColorLerpFunctor # just end rgba values, use current color rgba values for start startColor = self.getColor() functor = ColorLerpFunctor.ColorLerpFunctor( @@ -392,7 +392,7 @@ """ def functorFunc(self = self, sr = sr, sg = sg, sb = sb, sa = sa, er = er, eg = eg, eb = eb, ea = ea): - import ColorLerpFunctor + from pandac import ColorLerpFunctor # start and end rgba values functor = ColorLerpFunctor.ColorLerpFunctor(self, sr, sg, sb, sa, er, eg, eb, ea) @@ -411,7 +411,7 @@ string=none) """ def functorFunc(self = self, endColor = endColor): - import ColorLerpFunctor + from pandac import ColorLerpFunctor # just end vec4, use current color for start startColor = self.getColor() functor = ColorLerpFunctor.ColorLerpFunctor( @@ -432,7 +432,7 @@ """ def functorFunc(self = self, startColor = startColor, endColor = endColor): - import ColorLerpFunctor + from pandac import ColorLerpFunctor # start color and end vec functor = ColorLerpFunctor.ColorLerpFunctor( self, startColor, endColor) @@ -471,7 +471,7 @@ string="noBlend", string=none, string=none) """ def functorFunc(self = self, r = r, g = g, b = b, a = a): - import ColorScaleLerpFunctor + from pandac import ColorScaleLerpFunctor # just end rgba values, use current color rgba values for start startColor = self.getColor() functor = ColorScaleLerpFunctor.ColorScaleLerpFunctor( @@ -495,7 +495,7 @@ """ def functorFunc(self = self, sr = sr, sg = sg, sb = sb, sa = sa, er = er, eg = eg, eb = eb, ea = ea): - import ColorScaleLerpFunctor + from pandac import ColorScaleLerpFunctor # start and end rgba values functor = ColorScaleLerpFunctor.ColorScaleLerpFunctor(self, sr, sg, sb, sa, er, eg, eb, ea) @@ -514,7 +514,7 @@ string=none) """ def functorFunc(self = self, endColor = endColor): - import ColorScaleLerpFunctor + from pandac import ColorScaleLerpFunctor # just end vec4, use current color for start startColor = self.getColor() functor = ColorScaleLerpFunctor.ColorScaleLerpFunctor( @@ -535,7 +535,7 @@ """ def functorFunc(self = self, startColor = startColor, endColor = endColor): - import ColorScaleLerpFunctor + from pandac import ColorScaleLerpFunctor # start color and end vec functor = ColorScaleLerpFunctor.ColorScaleLerpFunctor( self, startColor, endColor) @@ -573,7 +573,7 @@ """ def functorFunc(self = self, h = h, p = p, r = r, other = other, shortest=shortest): - import HprLerpFunctor + from pandac import HprLerpFunctor # it's individual hpr components if (other != None): # lerp wrt other @@ -609,7 +609,7 @@ """ def functorFunc(self = self, hpr = hpr, other = other, shortest=shortest): - import HprLerpFunctor + from pandac import HprLerpFunctor # it's a vbase3 hpr if (other != None): # lerp wrt other @@ -654,7 +654,7 @@ Perform a pos lerp with three floats as the end point """ def functorFunc(self = self, x = x, y = y, z = z, other = other): - import PosLerpFunctor + from pandac import PosLerpFunctor if (other != None): # lerp wrt other startPos = self.getPos(other) @@ -681,7 +681,7 @@ Perform a pos lerp with a Point3 as the end point """ def functorFunc(self = self, pos = pos, other = other): - import PosLerpFunctor + from pandac import PosLerpFunctor if (other != None): #lerp wrt other functor = PosLerpFunctor.PosLerpFunctor( @@ -721,7 +721,7 @@ """ def functorFunc(self = self, pos = pos, hpr = hpr, other = other, shortest=shortest): - import PosHprLerpFunctor + from pandac import PosHprLerpFunctor if (other != None): # lerp wrt other startPos = self.getPos(other) @@ -755,7 +755,7 @@ """ def functorFunc(self = self, x = x, y = y, z = z, h = h, p = p, r = r, other = other, shortest=shortest): - import PosHprLerpFunctor + from pandac import PosHprLerpFunctor if (other != None): # lerp wrt other startPos = self.getPos(other) @@ -797,7 +797,7 @@ """ def functorFunc(self = self, pos = pos, hpr = hpr, scale = scale, other = other, shortest=shortest): - import PosHprScaleLerpFunctor + from pandac import PosHprScaleLerpFunctor if (other != None): # lerp wrt other startPos = self.getPos(other) @@ -850,7 +850,7 @@ string=none, NodePath=None) """ def functorFunc(self = self, scale = scale, other = other): - import ScaleLerpFunctor + from pandac import ScaleLerpFunctor if (other != None): # lerp wrt other functor = ScaleLerpFunctor.ScaleLerpFunctor(self, @@ -875,7 +875,7 @@ string=none, string=none, NodePath=None) """ def functorFunc(self = self, sx = sx, sy = sy, sz = sz, other = other): - import ScaleLerpFunctor + from pandac import ScaleLerpFunctor if (other != None): # lerp wrt other startScale = self.getScale(other) @@ -901,17 +901,17 @@ def place(self): base.startDirect(fWantTk = 1) - import Placer + from direct.tkpanels import Placer return Placer.place(self) def explore(self): base.startDirect(fWantTk = 1) - import SceneGraphExplorer + from direct.tkwidgets import SceneGraphExplorer return SceneGraphExplorer.explore(self) def rgbPanel(self, cb = None): base.startTk() - import Slider + from direct.tkwidgets import Slider return Slider.rgbPanel(self, cb) def select(self): @@ -949,48 +949,48 @@ np.hide() def posInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpPosInterval(self, *args, **kw) def hprInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpHprInterval(self, *args, **kw) def scaleInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpScaleInterval(self, *args, **kw) def shearInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpShearInterval(self, *args, **kw) def posHprInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpPosHprInterval(self, *args, **kw) def hprScaleInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpHprScaleInterval(self, *args, **kw) def posHprScaleInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpPosHprScaleInterval(self, *args, **kw) def posHprScaleShearInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpPosHprScaleShearInterval(self, *args, **kw) def colorInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpColorInterval(self, *args, **kw) def colorScaleInterval(self, *args, **kw): - import LerpInterval + from direct.interval import LerpInterval return LerpInterval.LerpColorScaleInterval(self, *args, **kw) def attachCollisionSphere(self, name, cx,cy,cz,r, fromCollide, intoCollide): - import CollisionSphere - import CollisionNode + from pandac import CollisionSphere + from pandac import CollisionNode coll = CollisionSphere.CollisionSphere(cx,cy,cz,r) collNode = CollisionNode.CollisionNode(name) collNode.addSolid(coll) @@ -1000,8 +1000,8 @@ return collNodePath def attachCollisionSegment(self, name, ax,ay,az, bx,by,bz, fromCollide, intoCollide): - import CollisionSegment - import CollisionNode + from pandac import CollisionSegment + from pandac import CollisionNode coll = CollisionSegment.CollisionSegment(ax,ay,az, bx,by,bz) collNode = CollisionNode.CollisionNode(name) collNode.addSolid(coll) @@ -1011,8 +1011,8 @@ return collNodePath def attachCollisionRay(self, name, ox,oy,oz, dx,dy,dz, fromCollide, intoCollide): - import CollisionRay - import CollisionNode + from pandac import CollisionRay + from pandac import CollisionNode coll = CollisionRay.CollisionRay(ox,oy,oz, dx,dy,dz) collNode = CollisionNode.CollisionNode(name) collNode.addSolid(coll) diff --git a/direct/src/extensions/NodePathCollection-extensions.py b/direct/src/extensions/NodePathCollection-extensions.py index 51a410aa8d..99a1c7fca6 100644 --- a/direct/src/extensions/NodePathCollection-extensions.py +++ b/direct/src/extensions/NodePathCollection-extensions.py @@ -16,7 +16,7 @@ return npList def getTightBounds(self): - import Point3 + from pandac import Point3 if self.getNumPaths() == 0: return (Point3.Point3(0), Point3.Point3(0)) diff --git a/direct/src/extensions/__init__.py b/direct/src/extensions/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/ffi/FFIConstants.py b/direct/src/ffi/FFIConstants.py index 7b7abbf7a8..b203e8bcb3 100644 --- a/direct/src/ffi/FFIConstants.py +++ b/direct/src/ffi/FFIConstants.py @@ -1,6 +1,6 @@ # create a DirectNotify category for FFI modules -from DirectNotifyGlobal import * +from direct.directnotify.DirectNotifyGlobal import * notify = directNotify.newCategory("FFI") # This is the name of the file that the importing code will be stored diff --git a/direct/src/ffi/FFIExternalObject.py b/direct/src/ffi/FFIExternalObject.py index dbd26588d2..d24645b589 100644 --- a/direct/src/ffi/FFIExternalObject.py +++ b/direct/src/ffi/FFIExternalObject.py @@ -19,7 +19,7 @@ DowncastMap = {} # The type map is used for upcasting and downcasting through # the panda inheritance chain def registerInTypeMap(pythonClass): - import TypedObject + from pandac import TypedObject if issubclass(pythonClass, TypedObject.TypedObject): typeIndex = pythonClass.getClassType().getIndex() WrapperClassMap[typeIndex] = pythonClass @@ -191,7 +191,7 @@ class FFIExternalObject: # We create a LineStream for the output function to write to, then we extract # the string out of it and return it as our str try: - import LineStream + from pandac import LineStream lineStream = LineStream.LineStream() self.output(lineStream) baseRepr = lineStream.getLine() @@ -210,7 +210,7 @@ class FFIExternalObject: # Lots of Panda classes have an write or output function defined that takes an Ostream # We create a LineStream for the write or output function to write to, then we extract # the string out of it and return it as our repr - import LineStream + from pandac import LineStream lineStream = LineStream.LineStream() try: # First try the write function, that is the better one diff --git a/direct/src/ffi/FFIInterrogateDatabase.py b/direct/src/ffi/FFIInterrogateDatabase.py index 914bc3e87e..7d99a11f37 100644 --- a/direct/src/ffi/FFIInterrogateDatabase.py +++ b/direct/src/ffi/FFIInterrogateDatabase.py @@ -13,7 +13,7 @@ import FFISpecs import FFIRename import FFIConstants import FFIOverload -from PythonUtil import * +from direct.showbase.PythonUtil import * # FFIConstants.notify.setDebug(1) FFIConstants.notify.info('Importing interrogate library: ' + FFIConstants.InterrogateModuleName) @@ -155,7 +155,7 @@ def outputImportFileImports(file, typeList, CModuleName): file.write('\n') file.write('# Put the classes in the wrapper class map\n') - file.write('from FFIExternalObject import registerInTypeMap\n') + file.write('from direct.ffi.FFIExternalObject import registerInTypeMap\n') file.write('\n') for moduleName in moduleList: file.write('registerInTypeMap(' + moduleName + ')\n') @@ -718,6 +718,12 @@ class FFIInterrogateDatabase: file.write('from ' + CModuleName + 'Modules import *\n') file.close() + # Generate an empty __init__.py to make the directory a Python + # package. + init = os.path.join(codeDir, '__init__.py') + file = open(init, 'w') + file.close() + # Commented out based upon assumption that squeeze will do the compile #FFIConstants.notify.info( 'Compiling code...') #compileall.compile_dir(codeDir) diff --git a/direct/src/ffi/FFIOverload.py b/direct/src/ffi/FFIOverload.py index a1d2dd5b31..70d8c2a4d4 100644 --- a/direct/src/ffi/FFIOverload.py +++ b/direct/src/ffi/FFIOverload.py @@ -1,4 +1,4 @@ -from PythonUtil import * +from direct.showbase.PythonUtil import * from types import * import string import FFIConstants diff --git a/direct/src/ffi/FFISpecs.py b/direct/src/ffi/FFISpecs.py index 91b5348146..1409f2812c 100644 --- a/direct/src/ffi/FFISpecs.py +++ b/direct/src/ffi/FFISpecs.py @@ -4,7 +4,7 @@ import FFITypes import FFIOverload import string -from PythonUtil import * +from direct.showbase.PythonUtil import * augmentedAssignments = ['__iadd__', '__isub__', '__imul__', '__idiv__', '__ior__', '__iand__', '__ixor__', diff --git a/direct/src/ffi/FFITypes.py b/direct/src/ffi/FFITypes.py index 11f987e71c..c70e671e13 100644 --- a/direct/src/ffi/FFITypes.py +++ b/direct/src/ffi/FFITypes.py @@ -15,7 +15,7 @@ import FFIConstants import FFIOverload -from PythonUtil import * +from direct.showbase.PythonUtil import * TypedObjectDescriptor = None @@ -639,7 +639,7 @@ class ClassTypeDescriptor(BaseTypeDescriptor): indent(file, 0, 'import ' + moduleName + '\n') indent(file, 0, 'import ' + moduleName + 'Downcasts\n') indent(file, 0, '\n') - indent(file, 0, 'import FFIExternalObject\n') + indent(file, 0, 'from direct.ffi import FFIExternalObject\n') def outputImportsRecursively(self, parent, file, nesting): diff --git a/direct/src/ffi/__init__.py b/direct/src/ffi/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/ffi/genPyCode b/direct/src/ffi/genPyCode index 5da95dbcc2..95e254adff 100755 --- a/direct/src/ffi/genPyCode +++ b/direct/src/ffi/genPyCode @@ -57,7 +57,7 @@ if [ "$DIRECT" == "" ]; then fi fi -pyDir=$DIRECT/lib/py +pyDir=$DIRECT/lib/pandac extDir=$DIRECT/src/extensions pSqueezer=$DIRECT/src/showbase/pandaSqueezer.py @@ -90,13 +90,13 @@ elif [ "$buildType" = "win-publish" ]; then elif [ "$buildType" = "install" ]; then # Use relative paths; as installed on a machine without ctattach etc. - pyDir=$install_dir/lib/py + pyDir=$install_dir/pandac ppython=$install_dir/bin/ppython pSqueezer=$DIRECT/src/showbase/pandaSqueezer.py $ppython -d $install_dir/bin/generatePythonCode -O -v -d $pyDir -e $DIRECT/src/extensions -i libdtoolconfig libpandaexpress libpanda libpandaphysics libdirect $extra_genPyCode_libs || exit elif [ "$buildType" = "release" ]; then # Use relative paths; as installed on a machine without ctattach etc. - pyDir=$install_dir/lib/py + pyDir=$install_dir/pandac ppython=$install_dir/bin/ppython pSqueezer=$DIRECT/src/showbase/pandaSqueezer.py $ppython $install_dir/bin/generatePythonCode -v -d $pyDir -e $DIRECT/src/extensions -i libdtoolconfig libpandaexpress libpanda libpandaphysics libdirect $extra_genPyCode_libs || exit @@ -107,8 +107,9 @@ fi if [ "$fSqueeze" = "squeezeMe" ]; then echo SQUEEZING PandaModules - rm -f $pyDir/PandaModules.py* || exit + rm -f $pyDir/PandaModules.py* $pyDir/__init__.py || exit $ppython $ppythonOptimizeFlag $pSqueezer $optimizeFlag -d $pyDir || exit + touch $pyDir/__init__.py || exit else # renaming PandaModulesUnsqueezed.py to PandaModules.py cd $pyDir || exit diff --git a/direct/src/ffi/generatePythonCode b/direct/src/ffi/generatePythonCode index d2a4d888c6..c419f192e5 100644 --- a/direct/src/ffi/generatePythonCode +++ b/direct/src/ffi/generatePythonCode @@ -4,7 +4,7 @@ import getopt import sys import os -import FFIConstants +from direct.ffi import FFIConstants # Define a help string for the user helpString =""" @@ -117,7 +117,7 @@ else: FFIConstants.CodeModuleNameList = codeLibs # Ok, now we can start generating code -import FFIInterrogateDatabase +from direct.ffi import FFIInterrogateDatabase db = FFIInterrogateDatabase.FFIInterrogateDatabase() db.generateCode(outputDir, extensionsDir) diff --git a/direct/src/fsm/ClassicFSM.py b/direct/src/fsm/ClassicFSM.py index 729e52604e..f6a849300b 100644 --- a/direct/src/fsm/ClassicFSM.py +++ b/direct/src/fsm/ClassicFSM.py @@ -5,7 +5,7 @@ existing code. New code should use the FSM module instead. """ -from DirectObject import * +from direct.showbase.DirectObject import * import types class ClassicFSM(DirectObject): @@ -348,7 +348,7 @@ class ClassicFSM(DirectObject): return 0 def view(self): - import FSMInspector + from direct.tkpanels import FSMInspector FSMInspector.FSMInspector(self) diff --git a/direct/src/fsm/FSM.py b/direct/src/fsm/FSM.py index f835b30b3b..0a6ab15862 100644 --- a/direct/src/fsm/FSM.py +++ b/direct/src/fsm/FSM.py @@ -2,8 +2,8 @@ previously called FSM.py (now called ClassicFSM.py). """ -import DirectObject -import DirectNotifyGlobal +from direct.showbase import DirectObject +from direct.directnotify import DirectNotifyGlobal import types import string diff --git a/direct/src/fsm/FourState.py b/direct/src/fsm/FourState.py index e340c4fb45..4501d6c26f 100755 --- a/direct/src/fsm/FourState.py +++ b/direct/src/fsm/FourState.py @@ -1,10 +1,10 @@ -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal #import DistributedObject import ClassicFSM import State -import Task +from direct.task import Task class FourState: diff --git a/direct/src/fsm/FourStateAI.py b/direct/src/fsm/FourStateAI.py index 19e45b7113..1656cb6e1e 100755 --- a/direct/src/fsm/FourStateAI.py +++ b/direct/src/fsm/FourStateAI.py @@ -1,10 +1,10 @@ -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal #import DistributedObjectAI import ClassicFSM import State -import Task +from direct.task import Task class FourStateAI: diff --git a/direct/src/fsm/SampleFSM.py b/direct/src/fsm/SampleFSM.py index 000df0d774..022232bdd9 100644 --- a/direct/src/fsm/SampleFSM.py +++ b/direct/src/fsm/SampleFSM.py @@ -1,6 +1,6 @@ import FSM -from PandaModules import * -import Task +from pandac.PandaModules import * +from direct.task import Task import string diff --git a/direct/src/fsm/State.py b/direct/src/fsm/State.py index e1d210ae09..61195cc66a 100644 --- a/direct/src/fsm/State.py +++ b/direct/src/fsm/State.py @@ -1,7 +1,7 @@ """State module: contains State class""" -from DirectObject import * +from direct.showbase.DirectObject import * import types # This gets set by a dconfig variable in ShowBase.py diff --git a/direct/src/fsm/StateData.py b/direct/src/fsm/StateData.py index 6eaf0da7e0..cc80a60087 100644 --- a/direct/src/fsm/StateData.py +++ b/direct/src/fsm/StateData.py @@ -1,9 +1,9 @@ """StateData module: contains StateData class""" -from DirectObject import * +from direct.showbase.DirectObject import * -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal class StateData(DirectObject): """ diff --git a/direct/src/fsm/__init__.py b/direct/src/fsm/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index 0360f33eb3..8d12089acb 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/direct/src/gui/DirectGuiBase.py @@ -2,11 +2,11 @@ from DirectGuiGlobals import * from OnscreenText import * from OnscreenGeom import * from OnscreenImage import * -from DirectUtil import ROUND_TO -import PandaObject -import Task +from direct.directtools.DirectUtil import ROUND_TO +from direct.showbase import PandaObject +from direct.task import Task import string -import ShowBase +from direct.showbase import ShowBase """ Base class for all Direct Gui items. Handles composite widgets and diff --git a/direct/src/gui/DirectGuiGlobals.py b/direct/src/gui/DirectGuiGlobals.py index 12eb7ee11e..bd0d305e0e 100644 --- a/direct/src/gui/DirectGuiGlobals.py +++ b/direct/src/gui/DirectGuiGlobals.py @@ -2,7 +2,7 @@ Global definitions used by Direct Gui Classes and handy constants that can be used during widget construction """ -from PandaModules import * +from pandac.PandaModules import * # USEFUL GUI CONSTANTS # Constant used to indicate that an option can only be set by a call diff --git a/direct/src/gui/DirectGuiTest.py b/direct/src/gui/DirectGuiTest.py index 6de8fe164f..fd2d2c6dbe 100644 --- a/direct/src/gui/DirectGuiTest.py +++ b/direct/src/gui/DirectGuiTest.py @@ -1,4 +1,4 @@ -from ShowBaseGlobal import * +from direct.showbase.ShowBaseGlobal import * from DirectGui import * from whrandom import * diff --git a/direct/src/gui/DirectScrolledList.py b/direct/src/gui/DirectScrolledList.py index b5948a4618..e6b90c7c04 100644 --- a/direct/src/gui/DirectScrolledList.py +++ b/direct/src/gui/DirectScrolledList.py @@ -1,6 +1,6 @@ from DirectFrame import * from DirectButton import * -import Task +from direct.task import Task import types class DirectScrolledList(DirectFrame): diff --git a/direct/src/gui/OnscreenGeom.py b/direct/src/gui/OnscreenGeom.py index 82a7e136d2..3931dc449f 100644 --- a/direct/src/gui/OnscreenGeom.py +++ b/direct/src/gui/OnscreenGeom.py @@ -1,6 +1,6 @@ """OnscreenGeom module: contains the OnscreenGeom class""" -from PandaObject import * +from direct.showbase.PandaObject import * import types class OnscreenGeom(PandaObject, NodePath): diff --git a/direct/src/gui/OnscreenImage.py b/direct/src/gui/OnscreenImage.py index 6a78f6d8dd..ffb7e8201f 100644 --- a/direct/src/gui/OnscreenImage.py +++ b/direct/src/gui/OnscreenImage.py @@ -1,6 +1,6 @@ """OnscreenImage module: contains the OnscreenImage class""" -from PandaObject import * +from direct.showbase.PandaObject import * import types class OnscreenImage(PandaObject, NodePath): diff --git a/direct/src/gui/OnscreenText.py b/direct/src/gui/OnscreenText.py index 2a29c24ad9..61b666d878 100644 --- a/direct/src/gui/OnscreenText.py +++ b/direct/src/gui/OnscreenText.py @@ -1,6 +1,6 @@ """OnscreenText module: contains the OnscreenText class""" -from PandaObject import * +from direct.showbase.PandaObject import * import DirectGuiGlobals import types diff --git a/direct/src/gui/__init__.py b/direct/src/gui/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/interval/ActorInterval.py b/direct/src/interval/ActorInterval.py index 7f483d403c..ef15de581b 100644 --- a/direct/src/interval/ActorInterval.py +++ b/direct/src/interval/ActorInterval.py @@ -1,10 +1,10 @@ """ActorInterval module: contains the ActorInterval class""" -from PandaModules import * -from DirectNotifyGlobal import * +from pandac.PandaModules import * +from direct.directnotify.DirectNotifyGlobal import * import Interval import math -import LerpBlendHelpers +from direct.showbase import LerpBlendHelpers class ActorInterval(Interval.Interval): diff --git a/direct/src/interval/FunctionInterval.py b/direct/src/interval/FunctionInterval.py index 28be222496..49c78ebcac 100644 --- a/direct/src/interval/FunctionInterval.py +++ b/direct/src/interval/FunctionInterval.py @@ -1,8 +1,8 @@ """FunctionInterval module: contains the FunctionInterval class""" -from PandaModules import * -from MessengerGlobal import * -from DirectNotifyGlobal import * +from pandac.PandaModules import * +from direct.showbase.MessengerGlobal import * +from direct.directnotify.DirectNotifyGlobal import * import Interval import types @@ -381,7 +381,7 @@ t2.play() smiley = loader.loadModel('models/misc/smiley') -import Actor +from direct.actor import Actor donald = Actor.Actor() donald.loadModel("phase_6/models/char/donald-wheel-1000") donald.loadAnims({"steer":"phase_6/models/char/donald-wheel-wheel"}) diff --git a/direct/src/interval/IndirectInterval.py b/direct/src/interval/IndirectInterval.py index de99fe8ff5..aacc0daff7 100644 --- a/direct/src/interval/IndirectInterval.py +++ b/direct/src/interval/IndirectInterval.py @@ -1,9 +1,9 @@ """IndirectInterval module: contains the IndirectInterval class""" -from PandaModules import * -from DirectNotifyGlobal import * +from pandac.PandaModules import * +from direct.directnotify.DirectNotifyGlobal import * import Interval -import LerpBlendHelpers +from direct.showbase import LerpBlendHelpers class IndirectInterval(Interval.Interval): """ diff --git a/direct/src/interval/Interval.py b/direct/src/interval/Interval.py index 5de241d3d5..965e07eb9b 100644 --- a/direct/src/interval/Interval.py +++ b/direct/src/interval/Interval.py @@ -1,9 +1,9 @@ """Interval module: contains the Interval class""" -from DirectObject import * -from PandaModules import * -import Task -import PythonUtil +from direct.showbase.DirectObject import * +from pandac.PandaModules import * +from direct.task import Task +from direct.showbase import PythonUtil import math class Interval(DirectObject): @@ -342,7 +342,7 @@ class Interval(DirectObject): def __spawnTask(self): # Spawn task - import Task + from direct.task import Task self.__removeTask() taskName = self.getName() + '-play' task = Task.Task(self.__playTask) @@ -360,7 +360,7 @@ class Interval(DirectObject): taskMgr.remove(task) def __playTask(self, task): - import Task + from direct.task import Task again = self.stepPlay() self.privPostEvent() if again: @@ -372,12 +372,12 @@ class Interval(DirectObject): """ Popup control panel for interval. """ - import TkGlobal + from direct.showbase import TkGlobal import math # I moved this here because Toontown does not ship Tk from Tkinter import Toplevel, Frame, Button, LEFT, X import Pmw - import EntryScale + from direct.tkwidgets import EntryScale if tl == None: tl = Toplevel() tl.title('Interval Controls') diff --git a/direct/src/interval/IntervalGlobal.py b/direct/src/interval/IntervalGlobal.py index 0497a314ed..88a986a170 100644 --- a/direct/src/interval/IntervalGlobal.py +++ b/direct/src/interval/IntervalGlobal.py @@ -9,7 +9,7 @@ from IndirectInterval import * from MopathInterval import * from ParticleInterval import * from SoundInterval import * -from WaitInterval import * +from pandac.WaitInterval import * from ProjectileInterval import * from MetaInterval import * from IntervalManager import * diff --git a/direct/src/interval/IntervalManager.py b/direct/src/interval/IntervalManager.py index 5ec2d1d0a0..231f8009d7 100644 --- a/direct/src/interval/IntervalManager.py +++ b/direct/src/interval/IntervalManager.py @@ -1,6 +1,6 @@ -from PandaModules import * -from DirectNotifyGlobal import * -import EventManager +from pandac.PandaModules import * +from direct.directnotify.DirectNotifyGlobal import * +from direct.showbase import EventManager import Interval import types import fnmatch diff --git a/direct/src/interval/IntervalTest.py b/direct/src/interval/IntervalTest.py index 77f8777e0c..c2151d61b0 100644 --- a/direct/src/interval/IntervalTest.py +++ b/direct/src/interval/IntervalTest.py @@ -1,9 +1,9 @@ -from PandaModules import * -from ShowBaseGlobal import * +from pandac.PandaModules import * +from direct.showbase.ShowBaseGlobal import * from IntervalGlobal import * -from Actor import * +from direct.actor.Actor import * -import Mopath +from direct.directutil import Mopath boat = loader.loadModel('models/misc/smiley') boat.reparentTo(render) diff --git a/direct/src/interval/LerpInterval.py b/direct/src/interval/LerpInterval.py index 7a21088dfd..7de86465f4 100644 --- a/direct/src/interval/LerpInterval.py +++ b/direct/src/interval/LerpInterval.py @@ -1,9 +1,9 @@ """LerpInterval module: contains the LerpInterval class""" -from PandaModules import * -from DirectNotifyGlobal import * +from pandac.PandaModules import * +from direct.directnotify.DirectNotifyGlobal import * import Interval -import LerpBlendHelpers +from direct.showbase import LerpBlendHelpers # # Most of the intervals defined in this module--the group up here at diff --git a/direct/src/interval/MetaInterval.py b/direct/src/interval/MetaInterval.py index 90cbc28acd..423b2c25fb 100644 --- a/direct/src/interval/MetaInterval.py +++ b/direct/src/interval/MetaInterval.py @@ -1,8 +1,8 @@ -from PandaModules import * -from DirectNotifyGlobal import * +from pandac.PandaModules import * +from direct.directnotify.DirectNotifyGlobal import * from IntervalManager import ivalMgr import Interval -import Task +from direct.task import Task import types PREVIOUS_END = CMetaInterval.RSPreviousEnd diff --git a/direct/src/interval/MopathInterval.py b/direct/src/interval/MopathInterval.py index 10cbee3a92..f899b968ba 100644 --- a/direct/src/interval/MopathInterval.py +++ b/direct/src/interval/MopathInterval.py @@ -1,8 +1,8 @@ """MopathInterval module: contains the MopathInterval class""" import LerpInterval -from PandaModules import * -from DirectNotifyGlobal import * +from pandac.PandaModules import * +from direct.directnotify.DirectNotifyGlobal import * # import Mopath diff --git a/direct/src/interval/ParticleInterval.py b/direct/src/interval/ParticleInterval.py index 22c13b053b..a0262b36e7 100644 --- a/direct/src/interval/ParticleInterval.py +++ b/direct/src/interval/ParticleInterval.py @@ -1,10 +1,10 @@ """ParticleInterval module: contains the ParticleInterval class""" -from PandaModules import * -from DirectNotifyGlobal import * +from pandac.PandaModules import * +from direct.directnotify.DirectNotifyGlobal import * import Interval -import ParticleEffect +from direct.particles import ParticleEffect class ParticleInterval(Interval.Interval): # Name counter diff --git a/direct/src/interval/ProjectileInterval.py b/direct/src/interval/ProjectileInterval.py index 01c2e57391..a8e7b31189 100755 --- a/direct/src/interval/ProjectileInterval.py +++ b/direct/src/interval/ProjectileInterval.py @@ -1,10 +1,10 @@ """ProjectileInterval module: contains the ProjectileInterval class""" -from DirectObject import * -from PandaModules import * +from direct.showbase.DirectObject import * +from pandac.PandaModules import * from Interval import Interval -from PythonUtil import lerp -import PythonUtil +from direct.showbase.PythonUtil import lerp +from direct.showbase import PythonUtil class ProjectileInterval(Interval): """ProjectileInterval class: moves a nodepath through the trajectory diff --git a/direct/src/interval/SoundInterval.py b/direct/src/interval/SoundInterval.py index 945c1d9f04..8dc8c1c59b 100644 --- a/direct/src/interval/SoundInterval.py +++ b/direct/src/interval/SoundInterval.py @@ -1,7 +1,7 @@ """SoundInterval module: contains the SoundInterval class""" -from PandaModules import * -from DirectNotifyGlobal import * +from pandac.PandaModules import * +from direct.directnotify.DirectNotifyGlobal import * import Interval class SoundInterval(Interval.Interval): diff --git a/direct/src/interval/__init__.py b/direct/src/interval/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/level/AmbientSound.py b/direct/src/level/AmbientSound.py index d94110dc5e..7c3897ff34 100755 --- a/direct/src/level/AmbientSound.py +++ b/direct/src/level/AmbientSound.py @@ -1,4 +1,4 @@ -from IntervalGlobal import * +from direct.interval.IntervalGlobal import * import BasicEntities import random diff --git a/direct/src/level/BasicEntities.py b/direct/src/level/BasicEntities.py index 98ad17baac..8503d4f9fc 100755 --- a/direct/src/level/BasicEntities.py +++ b/direct/src/level/BasicEntities.py @@ -2,7 +2,7 @@ import Entity import DistributedEntity -import NodePath +from pandac import NodePath # base class for entities that support NodePath attributes # *** Don't derive directly from this class; derive from the appropriate diff --git a/direct/src/level/CutScene.py b/direct/src/level/CutScene.py index 2f5df45ba1..3192a898a7 100755 --- a/direct/src/level/CutScene.py +++ b/direct/src/level/CutScene.py @@ -1,20 +1,20 @@ """CutScene.py""" -import DirectObject -import DirectNotifyGlobal +from direct.showbase import DirectObject +from direct.directnotify import DirectNotifyGlobal import BasicEntities -from PandaModules import * -from ShowBaseGlobal import * -from IntervalGlobal import * -from ClockDelta import * +from pandac.PandaModules import * +from direct.showbase.ShowBaseGlobal import * +from direct.interval.IntervalGlobal import * +from direct.distributed.ClockDelta import * -import ToontownGlobals -import DirectNotifyGlobal -import ClassicFSM +from toontown.toonbase import ToontownGlobals +from direct.directnotify import DirectNotifyGlobal +from direct.fsm import ClassicFSM #import DistributedInteractiveEntity -import DelayDelete +from direct.distributed import DelayDelete # effects # diff --git a/direct/src/level/DistributedEntity.py b/direct/src/level/DistributedEntity.py index 9dadedd0df..7717deb6cc 100755 --- a/direct/src/level/DistributedEntity.py +++ b/direct/src/level/DistributedEntity.py @@ -1,6 +1,6 @@ -import DistributedObject +from direct.distributed import DistributedObject import Entity -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal class DistributedEntity(DistributedObject.DistributedObject, Entity.Entity): notify = DirectNotifyGlobal.directNotify.newCategory( diff --git a/direct/src/level/DistributedEntityAI.py b/direct/src/level/DistributedEntityAI.py index 6a1bdf9978..4ec6066b41 100755 --- a/direct/src/level/DistributedEntityAI.py +++ b/direct/src/level/DistributedEntityAI.py @@ -1,6 +1,6 @@ -import DistributedObjectAI +from direct.distributed import DistributedObjectAI import Entity -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal class DistributedEntityAI(DistributedObjectAI.DistributedObjectAI, Entity.Entity): diff --git a/direct/src/level/DistributedInteractiveEntity.py b/direct/src/level/DistributedInteractiveEntity.py index 3bbee44085..1709b9d975 100644 --- a/direct/src/level/DistributedInteractiveEntity.py +++ b/direct/src/level/DistributedInteractiveEntity.py @@ -1,11 +1,11 @@ """ DistributedInteractiveEntity module: contains the DistributedInteractiveEntity class, the client side representation of a 'landmark door'.""" -from ShowBaseGlobal import * -from ClockDelta import * +from direct.showbase.ShowBaseGlobal import * +from direct.distributed.ClockDelta import * -import DirectNotifyGlobal -import ClassicFSM +from direct.directnotify import DirectNotifyGlobal +from direct.fsm import ClassicFSM import DistributedEntity class DistributedInteractiveEntity(DistributedEntity.DistributedEntity): diff --git a/direct/src/level/DistributedInteractiveEntityAI.py b/direct/src/level/DistributedInteractiveEntityAI.py index 4db7916444..4fa4f3f544 100644 --- a/direct/src/level/DistributedInteractiveEntityAI.py +++ b/direct/src/level/DistributedInteractiveEntityAI.py @@ -3,13 +3,13 @@ prop.""" -from AIBaseGlobal import * -from ClockDelta import * +from otp.ai.AIBaseGlobal import * +from direct.distributed.ClockDelta import * -import DirectNotifyGlobal -import ClassicFSM +from direct.directnotify import DirectNotifyGlobal +from direct.fsm import ClassicFSM import DistributedEntityAI -import State +from direct.fsm import State class DistributedInteractiveEntityAI(DistributedEntityAI.DistributedEntityAI): diff --git a/direct/src/level/DistributedLevel.py b/direct/src/level/DistributedLevel.py index 7574d26301..f3e111015b 100755 --- a/direct/src/level/DistributedLevel.py +++ b/direct/src/level/DistributedLevel.py @@ -1,21 +1,21 @@ """DistributedLevel.py: contains the DistributedLevel class""" -from ClockDelta import * -from PandaModules import * -from PythonUtil import Functor, sameElements, list2dict, uniqueElements -from IntervalGlobal import * -from ToontownMsgTypes import * -import ToontownGlobals -import OTPGlobals -import DistributedObject +from direct.distributed.ClockDelta import * +from pandac.PandaModules import * +from direct.showbase.PythonUtil import Functor, sameElements, list2dict, uniqueElements +from direct.interval.IntervalGlobal import * +from toontown.distributed.ToontownMsgTypes import * +from toontown.toonbase import ToontownGlobals +from otp.otpbase import OTPGlobals +from direct.distributed import DistributedObject import Level import LevelConstants -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import EntityCreator -import OnscreenText -import Task +from direct.gui import OnscreenText +from direct.task import Task import LevelUtil -import FactoryCameraViews +from toontown.coghq import FactoryCameraViews import random class DistributedLevel(DistributedObject.DistributedObject, diff --git a/direct/src/level/DistributedLevelAI.py b/direct/src/level/DistributedLevelAI.py index 01a7a33dbe..eb713ea69b 100755 --- a/direct/src/level/DistributedLevelAI.py +++ b/direct/src/level/DistributedLevelAI.py @@ -1,12 +1,12 @@ """DistributedLevelAI.py: contains the DistributedLevelAI class""" -from AIBaseGlobal import * -from ClockDelta import * -import DistributedObjectAI +from otp.ai.AIBaseGlobal import * +from direct.distributed.ClockDelta import * +from direct.distributed import DistributedObjectAI import Level -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import EntityCreatorAI -from PythonUtil import Functor, weightedChoice +from direct.showbase.PythonUtil import Functor, weightedChoice class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI, Level.Level): @@ -162,7 +162,7 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI, useDisk = 0 specStr = repr(spec) - import DistributedLargeBlobSenderAI + from direct.directutil import DistributedLargeBlobSenderAI largeBlob = DistributedLargeBlobSenderAI.\ DistributedLargeBlobSenderAI( self.air, self.zoneId, senderId, specStr, diff --git a/direct/src/level/EditMgrAI.py b/direct/src/level/EditMgrAI.py index 0202ee551a..db2cf77576 100755 --- a/direct/src/level/EditMgrAI.py +++ b/direct/src/level/EditMgrAI.py @@ -2,7 +2,7 @@ import EditMgrBase if __dev__: - from PythonUtil import list2dict + from direct.showbase.PythonUtil import list2dict import EditorGlobals class EditMgrAI(EditMgrBase.EditMgrBase): diff --git a/direct/src/level/EditMgrBase.py b/direct/src/level/EditMgrBase.py index 0893249694..78bbf5a711 100755 --- a/direct/src/level/EditMgrBase.py +++ b/direct/src/level/EditMgrBase.py @@ -1,7 +1,7 @@ """EditMgrBase module: contains the EditMgrBase class""" import Entity -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal class EditMgrBase(Entity.Entity): """This class contains EditMgr code shared between AI and client""" diff --git a/direct/src/level/EditorGlobals.py b/direct/src/level/EditorGlobals.py index 1f1a96e9ae..6e51c21abd 100755 --- a/direct/src/level/EditorGlobals.py +++ b/direct/src/level/EditorGlobals.py @@ -1,6 +1,6 @@ """EditorGlobals module: contains global editor data""" -from PythonUtil import uniqueElements +from direct.showbase.PythonUtil import uniqueElements EntIdRange = 10000 # Once a range has been assigned to a user, please don't change it. diff --git a/direct/src/level/Entity.py b/direct/src/level/Entity.py index fe7d1a675f..4b2fc387b5 100755 --- a/direct/src/level/Entity.py +++ b/direct/src/level/Entity.py @@ -1,9 +1,9 @@ """Entity.py: contains the Entity class""" -from DirectObject import * -from PythonUtil import lineInfo +from direct.showbase.DirectObject import * +from direct.showbase.PythonUtil import lineInfo import string -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal class Entity(DirectObject): """Entity is the base class for all objects that exist in a Level diff --git a/direct/src/level/EntityCreator.py b/direct/src/level/EntityCreator.py index c03b7c0fdb..35065db0b1 100755 --- a/direct/src/level/EntityCreator.py +++ b/direct/src/level/EntityCreator.py @@ -3,7 +3,7 @@ import CutScene import EntityCreatorBase import BasicEntities -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import EditMgr import EntrancePoint import LevelMgr diff --git a/direct/src/level/EntityCreatorAI.py b/direct/src/level/EntityCreatorAI.py index d97c440544..fc820f6724 100755 --- a/direct/src/level/EntityCreatorAI.py +++ b/direct/src/level/EntityCreatorAI.py @@ -5,7 +5,7 @@ import LogicGate import EditMgrAI import LevelMgrAI import ZoneEntityAI -from PythonUtil import Functor +from direct.showbase.PythonUtil import Functor # some useful constructor functions # ctor functions for entities must take diff --git a/direct/src/level/EntityCreatorBase.py b/direct/src/level/EntityCreatorBase.py index f98570d725..f1bad67ebe 100755 --- a/direct/src/level/EntityCreatorBase.py +++ b/direct/src/level/EntityCreatorBase.py @@ -1,6 +1,6 @@ """EntityCreatorBase module: contains the EntityCreatorBase class""" -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal class EntityCreatorBase: """This class is responsible for creating instances of Entities on the diff --git a/direct/src/level/EntityTypeDesc.py b/direct/src/level/EntityTypeDesc.py index 7891f1ad94..d3cfd923b6 100755 --- a/direct/src/level/EntityTypeDesc.py +++ b/direct/src/level/EntityTypeDesc.py @@ -1,8 +1,8 @@ """EntityTypeDesc module: contains the EntityTypeDesc class""" -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import AttribDesc -from PythonUtil import mostDerivedLast +from direct.showbase.PythonUtil import mostDerivedLast class EntityTypeDesc: """This class is meta-data that describes an Entity type.""" diff --git a/direct/src/level/EntityTypeRegistry.py b/direct/src/level/EntityTypeRegistry.py index 1c38bbe86a..33bdd62764 100755 --- a/direct/src/level/EntityTypeRegistry.py +++ b/direct/src/level/EntityTypeRegistry.py @@ -1,11 +1,11 @@ """EntityTypeRegistry module: contains the EntityTypeRegistry class""" -from PandaModules import * -import DirectNotifyGlobal +from pandac.PandaModules import * +from direct.directnotify import DirectNotifyGlobal import types import AttribDesc import EntityTypeDesc -from PythonUtil import mostDerivedLast +from direct.showbase.PythonUtil import mostDerivedLast class EntityTypeRegistry: notify = DirectNotifyGlobal.directNotify.newCategory('EntityTypeRegistry') diff --git a/direct/src/level/EntityTypes.py b/direct/src/level/EntityTypes.py index b23a7547e1..0c7a581179 100755 --- a/direct/src/level/EntityTypes.py +++ b/direct/src/level/EntityTypes.py @@ -1,7 +1,7 @@ """EntityTypes module: contains classes that describe Entity types""" from EntityTypeDesc import EntityTypeDesc -from SpecImports import * +from toontown.coghq.SpecImports import * class Entity(EntityTypeDesc): abstract = 1 diff --git a/direct/src/level/EntrancePoint.py b/direct/src/level/EntrancePoint.py index 4e9e471a54..f0e81031d2 100755 --- a/direct/src/level/EntrancePoint.py +++ b/direct/src/level/EntrancePoint.py @@ -1,7 +1,7 @@ -from ToontownGlobals import * -import DirectNotifyGlobal +from toontown.toonbase.ToontownGlobals import * +from direct.directnotify import DirectNotifyGlobal import BasicEntities -import NodePath +from pandac import NodePath class EntrancePoint(BasicEntities.NodePathEntity): def __init__(self, level, entId): diff --git a/direct/src/level/Level.py b/direct/src/level/Level.py index 4ccbe79e03..a99c215f13 100755 --- a/direct/src/level/Level.py +++ b/direct/src/level/Level.py @@ -1,9 +1,9 @@ """Level.py: contains the Level class""" -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import string import LevelConstants -from PythonUtil import lineInfo, uniqueElements +from direct.showbase.PythonUtil import lineInfo, uniqueElements import types """ diff --git a/direct/src/level/LevelMgr.py b/direct/src/level/LevelMgr.py index d098692bf5..e6ca9abd99 100755 --- a/direct/src/level/LevelMgr.py +++ b/direct/src/level/LevelMgr.py @@ -1,6 +1,6 @@ """LevelMgr module: contains the LevelMgr class""" -from PythonUtil import Functor +from direct.showbase.PythonUtil import Functor import LevelMgrBase class LevelMgr(LevelMgrBase.LevelMgrBase): diff --git a/direct/src/level/LevelMgrAI.py b/direct/src/level/LevelMgrAI.py index a35dde365e..751bddace7 100755 --- a/direct/src/level/LevelMgrAI.py +++ b/direct/src/level/LevelMgrAI.py @@ -1,6 +1,6 @@ """LevelMgrAI module: contains the LevelMgrAI class""" -from PythonUtil import Functor +from direct.showbase.PythonUtil import Functor import LevelMgrBase class LevelMgrAI(LevelMgrBase.LevelMgrBase): diff --git a/direct/src/level/LevelSpec.py b/direct/src/level/LevelSpec.py index 724e6d20fc..225f0b1b78 100755 --- a/direct/src/level/LevelSpec.py +++ b/direct/src/level/LevelSpec.py @@ -1,7 +1,7 @@ """LevelSpec module: contains the LevelSpec class""" -import DirectNotifyGlobal -from PythonUtil import list2dict, uniqueElements +from direct.directnotify import DirectNotifyGlobal +from direct.showbase.PythonUtil import list2dict, uniqueElements import string import LevelConstants import types diff --git a/direct/src/level/LogicGate.py b/direct/src/level/LogicGate.py index 6ee7d68c1c..80b6b7f276 100755 --- a/direct/src/level/LogicGate.py +++ b/direct/src/level/LogicGate.py @@ -30,8 +30,8 @@ LogicGate.py 0 0 - 0 0 - 1 1 """ -import PandaObject -import DirectNotifyGlobal +from direct.showbase import PandaObject +from direct.directnotify import DirectNotifyGlobal import Entity diff --git a/direct/src/level/ModelEntity.py b/direct/src/level/ModelEntity.py index ce00135e3f..d9fccf3a0e 100755 --- a/direct/src/level/ModelEntity.py +++ b/direct/src/level/ModelEntity.py @@ -1,5 +1,5 @@ -from ToontownGlobals import * -import DirectNotifyGlobal +from toontown.toonbase.ToontownGlobals import * +from direct.directnotify import DirectNotifyGlobal import BasicEntities class ModelEntity(BasicEntities.NodePathEntity): diff --git a/direct/src/level/PathEntity.py b/direct/src/level/PathEntity.py index a9043206bc..70b8439b8d 100755 --- a/direct/src/level/PathEntity.py +++ b/direct/src/level/PathEntity.py @@ -1,8 +1,8 @@ -from ToontownGlobals import * -from IntervalGlobal import * -import DirectNotifyGlobal +from toontown.toonbase.ToontownGlobals import * +from direct.interval.IntervalGlobal import * +from direct.directnotify import DirectNotifyGlobal import BasicEntities -import GoonPathData +from toontown.suit import GoonPathData class PathEntity(BasicEntities.NodePathEntity): def __init__(self, level, entId): diff --git a/direct/src/level/PropSpinner.py b/direct/src/level/PropSpinner.py index 30383134c1..3c6bda448f 100755 --- a/direct/src/level/PropSpinner.py +++ b/direct/src/level/PropSpinner.py @@ -1,4 +1,4 @@ -from IntervalGlobal import * +from direct.interval.IntervalGlobal import * import Entity class PropSpinner(Entity.Entity): diff --git a/direct/src/level/SpecUtil.py b/direct/src/level/SpecUtil.py index 9e3ec46e38..c4dfd20ecf 100755 --- a/direct/src/level/SpecUtil.py +++ b/direct/src/level/SpecUtil.py @@ -1,17 +1,17 @@ """SpecUtil module: contains utility functions for creating and managing level specs""" -from ShowBaseGlobal import * +from direct.showbase.ShowBaseGlobal import * import LevelSpec import LevelConstants import LevelUtil -from PythonUtil import list2dict +from direct.showbase.PythonUtil import list2dict import EntityTypes import types """ TO CREATE A NEW SPEC: import SpecUtil -import FactoryEntityTypes +from toontown.coghq import FactoryEntityTypes SpecUtil.makeNewSpec('$TOONTOWN/src/coghq/FactoryMockupSpec.py', 'phase_9/models/cogHQ/SelbotLegFactory', FactoryEntityTypes) """ def makeNewSpec(filename, modelPath, entTypeModule=EntityTypes): @@ -28,14 +28,14 @@ def makeNewSpec(filename, modelPath, entTypeModule=EntityTypes): """ FOR SAME LEVEL MODEL PATH: import SpecUtil -import SellbotLegFactorySpec -import FactoryEntityTypes +from toontown.coghq import SellbotLegFactorySpec +from toontown.coghq import FactoryEntityTypes SpecUtil.updateSpec(SellbotLegFactorySpec, FactoryEntityTypes) FOR DIFFERENT LEVEL MODEL PATH: import SpecUtil -import SellbotLegFactorySpec -import FactoryEntityTypes +from toontown.coghq import SellbotLegFactorySpec +from toontown.coghq import FactoryEntityTypes SpecUtil.updateSpec(SellbotLegFactorySpec, FactoryEntityTypes, '/i/beta/toons/maya/work/CogHeadquarters/CogFactoriesInteriors/AllFactories/LegFactory/SelbotLegFactory_v##s#.mb') """ diff --git a/direct/src/level/__init__.py b/direct/src/level/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/leveleditor/LevelEditor.py b/direct/src/leveleditor/LevelEditor.py index c2498a8f7c..b0dbb705fb 100644 --- a/direct/src/leveleditor/LevelEditor.py +++ b/direct/src/leveleditor/LevelEditor.py @@ -1,22 +1,22 @@ -from DirectStart import * -from PandaObject import * +from direct.directbase.DirectStart import * +from direct.showbase.PandaObject import * from PieMenu import * -from DirectGuiGlobals import * -from TkGlobal import * -from DirectUtil import * -from DirectGeometry import * -from SceneGraphExplorer import * +from direct.gui.DirectGuiGlobals import * +from direct.showbase.TkGlobal import * +from direct.directtools.DirectUtil import * +from direct.directtools.DirectGeometry import * +from direct.tkwidgets.SceneGraphExplorer import * from tkMessageBox import showinfo from tkFileDialog import * from whrandom import * -import Floater -import VectorWidgets +from direct.tkwidgets import Floater +from direct.tkwidgets import VectorWidgets import string import os import getopt import sys import whrandom -import Task +from direct.task import Task import __builtin__ visualizeZones = base.config.GetBool("visualize-zones", 0) @@ -3161,7 +3161,7 @@ class LevelEditor(NodePath, PandaObject): # First clear out old labels if any self.clearZoneLabels() visGroups = self.getDNAVisGroups(self.NPToplevel) - import DirectGui + from direct.gui import DirectGui for np, dna in visGroups: name = dna.getName() label = DirectGui.DirectLabel(text = name, diff --git a/direct/src/leveleditor/LevelEditorStart.py b/direct/src/leveleditor/LevelEditorStart.py index 499cbbebe0..816e990e4f 100644 --- a/direct/src/leveleditor/LevelEditorStart.py +++ b/direct/src/leveleditor/LevelEditorStart.py @@ -1,3 +1,3 @@ -from ShowBaseGlobal import * +from direct.showbase.ShowBaseGlobal import * import LevelEditor l = LevelEditor.LevelEditor() diff --git a/direct/src/leveleditor/PieMenu.py b/direct/src/leveleditor/PieMenu.py index 0e2ea5184a..44f4f501f9 100644 --- a/direct/src/leveleditor/PieMenu.py +++ b/direct/src/leveleditor/PieMenu.py @@ -1,6 +1,6 @@ -from PandaObject import * -from DirectGeometry import * -import Task +from direct.showbase.PandaObject import * +from direct.directtools.DirectGeometry import * +from direct.task import Task class PieMenu(NodePath, PandaObject): def __init__(self, visibleMenu, menuItems, @@ -133,7 +133,7 @@ class TextPieMenu(PieMenu): height = 480 aspectRatio = width/float(height) # Add items - from DirectGuiGlobals import getDefaultFont + from direct.gui.DirectGuiGlobals import getDefaultFont for i in range (numItems): # Create text node for each item if (textList[i] != None): diff --git a/direct/src/leveleditor/__init__.py b/direct/src/leveleditor/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/particles/ForceGroup.py b/direct/src/particles/ForceGroup.py index 1f062480af..458affa893 100644 --- a/direct/src/particles/ForceGroup.py +++ b/direct/src/particles/ForceGroup.py @@ -1,9 +1,9 @@ -from PandaModules import * -from DirectObject import * -from PhysicsManagerGlobal import * +from pandac.PandaModules import * +from direct.showbase.DirectObject import * +from direct.showbase.PhysicsManagerGlobal import * -import ForceNode -import DirectNotifyGlobal +from pandac import ForceNode +from direct.directnotify import DirectNotifyGlobal import sys class ForceGroup(DirectObject): diff --git a/direct/src/particles/ParticleEffect.py b/direct/src/particles/ParticleEffect.py index bf2ca5210f..42f76ea767 100644 --- a/direct/src/particles/ParticleEffect.py +++ b/direct/src/particles/ParticleEffect.py @@ -1,7 +1,7 @@ -from PandaModules import * +from pandac.PandaModules import * import Particles import ForceGroup -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal class ParticleEffect(NodePath): diff --git a/direct/src/particles/ParticleManagerGlobal.py b/direct/src/particles/ParticleManagerGlobal.py index 5bdb4bf7c7..2b023e35f3 100644 --- a/direct/src/particles/ParticleManagerGlobal.py +++ b/direct/src/particles/ParticleManagerGlobal.py @@ -1,4 +1,4 @@ """ParticleManagerGlobal module: contains the global particle system manager""" -import ParticleSystemManager +from pandac import ParticleSystemManager particleMgr = ParticleSystemManager.ParticleSystemManager() diff --git a/direct/src/particles/ParticleTest.py b/direct/src/particles/ParticleTest.py index 4c558898cd..426fc03666 100644 --- a/direct/src/particles/ParticleTest.py +++ b/direct/src/particles/ParticleTest.py @@ -1,7 +1,7 @@ -from ShowBaseGlobal import * +from direct.showbase.ShowBaseGlobal import * import ParticleEffect -import ParticlePanel +from direct.tkpanels import ParticlePanel import ForceGroup # Showbase diff --git a/direct/src/particles/Particles.py b/direct/src/particles/Particles.py index b644a9a8ed..32d0ba670b 100644 --- a/direct/src/particles/Particles.py +++ b/direct/src/particles/Particles.py @@ -1,31 +1,31 @@ -from PandaModules import * +from pandac.PandaModules import * from ParticleManagerGlobal import * -from PhysicsManagerGlobal import * +from direct.showbase.PhysicsManagerGlobal import * -import ParticleSystem -import BaseParticleFactory -import PointParticleFactory -import ZSpinParticleFactory +from pandac import ParticleSystem +from pandac import BaseParticleFactory +from pandac import PointParticleFactory +from pandac import ZSpinParticleFactory #import OrientedParticleFactory -import BaseParticleRenderer -import PointParticleRenderer -import LineParticleRenderer -import GeomParticleRenderer -import SparkleParticleRenderer -import SpriteParticleRenderer -import BaseParticleEmitter -import BoxEmitter -import DiscEmitter -import LineEmitter -import PointEmitter -import RectangleEmitter -import RingEmitter -import SphereSurfaceEmitter -import SphereVolumeEmitter -import TangentRingEmitter +from pandac import BaseParticleRenderer +from pandac import PointParticleRenderer +from pandac import LineParticleRenderer +from pandac import GeomParticleRenderer +from pandac import SparkleParticleRenderer +from pandac import SpriteParticleRenderer +from pandac import BaseParticleEmitter +from pandac import BoxEmitter +from pandac import DiscEmitter +from pandac import LineEmitter +from pandac import PointEmitter +from pandac import RectangleEmitter +from pandac import RingEmitter +from pandac import SphereSurfaceEmitter +from pandac import SphereVolumeEmitter +from pandac import TangentRingEmitter import string import os -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import sys class Particles(ParticleSystem.ParticleSystem): @@ -135,7 +135,7 @@ class Particles(ParticleSystem.ParticleSystem): npath = NodePath('default-geom') # This was moved here because we do not want to download # the direct tools with toontown. - import DirectSelection + from direct.directtools import DirectSelection bbox = DirectSelection.DirectBoundingBox(npath) self.renderer.setGeomNode(bbox.lines.node()) elif (type == "SparkleParticleRenderer"): diff --git a/direct/src/particles/__init__.py b/direct/src/particles/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/pyinst/__init__.py b/direct/src/pyinst/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/showbase/ControlManager.py b/direct/src/showbase/ControlManager.py index ec04580fbb..a876bdbb31 100755 --- a/direct/src/showbase/ControlManager.py +++ b/direct/src/showbase/ControlManager.py @@ -4,15 +4,15 @@ from ShowBaseGlobal import * #from PythonUtil import * #from IntervalGlobal import * -import Avatar +from otp.avatar import Avatar if __debug__: import DevWalker -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import GhostWalker import GravityWalker import NonPhysicsWalker import PhysicsWalker -import Task +from direct.task import Task class ControlManager: diff --git a/direct/src/showbase/DevWalker.py b/direct/src/showbase/DevWalker.py index 50766fad56..c912894dd4 100755 --- a/direct/src/showbase/DevWalker.py +++ b/direct/src/showbase/DevWalker.py @@ -16,7 +16,7 @@ animations based on walker events. from ShowBaseGlobal import * -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import DirectObject class DevWalker(DirectObject.DirectObject): diff --git a/direct/src/showbase/DirectObject.py b/direct/src/showbase/DirectObject.py index cb5a4204c5..0badf32c53 100644 --- a/direct/src/showbase/DirectObject.py +++ b/direct/src/showbase/DirectObject.py @@ -1,6 +1,6 @@ from MessengerGlobal import * -from DirectNotifyGlobal import * +from direct.directnotify.DirectNotifyGlobal import * from PythonUtil import * class DirectObject: diff --git a/direct/src/showbase/EventManager.py b/direct/src/showbase/EventManager.py index f7f29a8414..952a74cdbb 100644 --- a/direct/src/showbase/EventManager.py +++ b/direct/src/showbase/EventManager.py @@ -1,7 +1,7 @@ from MessengerGlobal import * -from TaskManagerGlobal import * -from DirectNotifyGlobal import * +from direct.task.TaskManagerGlobal import * +from direct.directnotify.DirectNotifyGlobal import * class EventManager: @@ -79,7 +79,7 @@ class EventManager: def restart(self): - from PandaModules import EventQueue, EventHandler + from pandac.PandaModules import EventQueue, EventHandler if self.eventQueue == None: self.eventQueue = EventQueue.getGlobalEventQueue() diff --git a/direct/src/showbase/Finder.py b/direct/src/showbase/Finder.py index 685d4a1e4f..ed140d6ee6 100644 --- a/direct/src/showbase/Finder.py +++ b/direct/src/showbase/Finder.py @@ -155,7 +155,7 @@ def replaceTaskMgrFunc(oldFunc, newFunc): print ('replaced taskMgr function: ' + newFunc.__name__) def replaceStateFunc(oldFunc, newFunc): - import State + from direct.fsm import State res = State.redefineEnterFunc(oldFunc, newFunc) if res: print ('replaced state enter function: ' + newFunc.__name__) diff --git a/direct/src/showbase/GhostWalker.py b/direct/src/showbase/GhostWalker.py index 5f98c7ede9..5177632042 100755 --- a/direct/src/showbase/GhostWalker.py +++ b/direct/src/showbase/GhostWalker.py @@ -16,7 +16,7 @@ animations based on walker events. from ShowBaseGlobal import * -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import NonPhysicsWalker class GhostWalker(NonPhysicsWalker.NonPhysicsWalker): diff --git a/direct/src/showbase/GravityWalker.py b/direct/src/showbase/GravityWalker.py index 7be1da1786..6a960b01c7 100755 --- a/direct/src/showbase/GravityWalker.py +++ b/direct/src/showbase/GravityWalker.py @@ -16,9 +16,9 @@ animations based on walker events. from ShowBaseGlobal import * -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import DirectObject -import PhysicsManager +from pandac import PhysicsManager import math @@ -77,9 +77,9 @@ class GravityWalker(DirectObject.DirectObject): assert self.notify.debugStateCall(self) if not self.wantDebugIndicator: return - from PandaModules import * - from IntervalGlobal import * - import MovingPlatform + from pandac.PandaModules import * + from direct.interval.IntervalGlobal import * + from toontown.coghq import MovingPlatform if hasattr(self, "platform"): # Remove the prior instantiation: diff --git a/direct/src/showbase/InputState.py b/direct/src/showbase/InputState.py index 479b8b9c5b..d5ce2b6020 100755 --- a/direct/src/showbase/InputState.py +++ b/direct/src/showbase/InputState.py @@ -1,6 +1,6 @@ -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import DirectObject diff --git a/direct/src/showbase/LerpBlendHelpers.py b/direct/src/showbase/LerpBlendHelpers.py index 1831bb88b1..6941c3df35 100644 --- a/direct/src/showbase/LerpBlendHelpers.py +++ b/direct/src/showbase/LerpBlendHelpers.py @@ -1,6 +1,6 @@ """LerpBlendHelpers module: contains LerpBlendHelpers class""" -from PandaModules import * +from pandac.PandaModules import * """global lerp blend types for lerp function""" diff --git a/direct/src/showbase/Loader.py b/direct/src/showbase/Loader.py index f6b7b0616e..fa2919865a 100644 --- a/direct/src/showbase/Loader.py +++ b/direct/src/showbase/Loader.py @@ -1,7 +1,7 @@ """Loader module: contains the Loader class""" -from PandaModules import * -from DirectNotifyGlobal import * +from pandac.PandaModules import * +from direct.directnotify.DirectNotifyGlobal import * # You can specify a phaseChecker callback to check # a modelPath to see if it is being loaded in the correct diff --git a/direct/src/showbase/Messenger.py b/direct/src/showbase/Messenger.py index 617c363f8e..7f68e3ea66 100644 --- a/direct/src/showbase/Messenger.py +++ b/direct/src/showbase/Messenger.py @@ -1,6 +1,6 @@ from PythonUtil import * -from DirectNotifyGlobal import * +from direct.directnotify.DirectNotifyGlobal import * import types class Messenger: diff --git a/direct/src/showbase/NonPhysicsWalker.py b/direct/src/showbase/NonPhysicsWalker.py index 7f92005813..da2d526aad 100755 --- a/direct/src/showbase/NonPhysicsWalker.py +++ b/direct/src/showbase/NonPhysicsWalker.py @@ -16,7 +16,7 @@ animations based on walker events. from ShowBaseGlobal import * -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import DirectObject class NonPhysicsWalker(DirectObject.DirectObject): diff --git a/direct/src/showbase/OnScreenDebug.py b/direct/src/showbase/OnScreenDebug.py index daacb11baa..09c58d610d 100755 --- a/direct/src/showbase/OnScreenDebug.py +++ b/direct/src/showbase/OnScreenDebug.py @@ -1,10 +1,10 @@ -from PandaModules import * +from pandac.PandaModules import * import types -import OnscreenText -import DirectUtil +from direct.gui import OnscreenText +from direct.directtools import DirectUtil class OnScreenDebug: def __init__(self): diff --git a/direct/src/showbase/PandaObject.py b/direct/src/showbase/PandaObject.py index ffbaa37c72..4fdc5e6df8 100644 --- a/direct/src/showbase/PandaObject.py +++ b/direct/src/showbase/PandaObject.py @@ -1,5 +1,5 @@ from DirectObject import * -from PandaModules import * +from pandac.PandaModules import * class PandaObject(DirectObject): """ diff --git a/direct/src/showbase/PhysicsManagerGlobal.py b/direct/src/showbase/PhysicsManagerGlobal.py index b15868db1c..714130325d 100644 --- a/direct/src/showbase/PhysicsManagerGlobal.py +++ b/direct/src/showbase/PhysicsManagerGlobal.py @@ -1,4 +1,4 @@ """PhysicsManagerGlobal module: contains the global physics manager""" -import PhysicsManager +from pandac import PhysicsManager physicsMgr = PhysicsManager.PhysicsManager() diff --git a/direct/src/showbase/PhysicsWalker.py b/direct/src/showbase/PhysicsWalker.py index 81a0f6a1db..97d40391bf 100755 --- a/direct/src/showbase/PhysicsWalker.py +++ b/direct/src/showbase/PhysicsWalker.py @@ -16,9 +16,9 @@ animations based on walker events. from ShowBaseGlobal import * -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import DirectObject -import PhysicsManager +from pandac import PhysicsManager import math #import LineStream @@ -66,9 +66,9 @@ class PhysicsWalker(DirectObject.DirectObject): assert(self.debugPrint("\n\nspawnTest()\n")) if not self.wantAvatarPhysicsIndicator: return - from PandaModules import * - from IntervalGlobal import * - import MovingPlatform + from pandac.PandaModules import * + from direct.interval.IntervalGlobal import * + from toontown.coghq import MovingPlatform if hasattr(self, "platform"): # Remove the prior instantiation: diff --git a/direct/src/showbase/PythonUtil.py b/direct/src/showbase/PythonUtil.py index c7090cce27..c10a19db90 100644 --- a/direct/src/showbase/PythonUtil.py +++ b/direct/src/showbase/PythonUtil.py @@ -8,7 +8,7 @@ import os import sys import random -import Verify +from direct.directutil import Verify # NOTE: ifAbsentPut has been replaced with Python's dictionary's builtin setdefault @@ -377,7 +377,7 @@ def adjust(command = None, dim = 1, parent = None, **kw): 10.0 """ # Make sure we enable Tk - import Valuator + from direct.tkwidgets import Valuator # Set command if specified if command: kw['command'] = lambda x: apply(command, x) diff --git a/direct/src/showbase/SfxPlayer.py b/direct/src/showbase/SfxPlayer.py index b5ce01ddc0..829d987b52 100644 --- a/direct/src/showbase/SfxPlayer.py +++ b/direct/src/showbase/SfxPlayer.py @@ -1,6 +1,6 @@ import math -from PandaModules import * +from pandac.PandaModules import * class SfxPlayer: """ diff --git a/direct/src/showbase/ShadowPlacer.py b/direct/src/showbase/ShadowPlacer.py index 35e04afd5f..36d9cb5c70 100755 --- a/direct/src/showbase/ShadowPlacer.py +++ b/direct/src/showbase/ShadowPlacer.py @@ -8,7 +8,7 @@ the its parent node. from ShowBaseGlobal import * -import DirectNotifyGlobal +from direct.directnotify import DirectNotifyGlobal import DirectObject class ShadowPlacer(DirectObject.DirectObject): diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index b9c2759ad2..0f6e22a6ee 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -3,33 +3,33 @@ # Annoying and very noisy, but sometimes useful #import VerboseImport -from PandaModules import * +from pandac.PandaModules import * # This needs to be available early for DirectGUI imports __builtins__["config"] = ConfigConfigureGetConfigConfigShowbase -from DirectNotifyGlobal import * +from direct.directnotify.DirectNotifyGlobal import * from MessengerGlobal import * -from TaskManagerGlobal import * +from direct.task.TaskManagerGlobal import * from EventManagerGlobal import * from PythonUtil import * -from ParticleManagerGlobal import * +from direct.particles.ParticleManagerGlobal import * from PhysicsManagerGlobal import * -from IntervalManager import ivalMgr +from direct.interval.IntervalManager import ivalMgr from InputStateGlobal import inputState -import Task +from direct.task import Task import EventManager import math import sys import Loader import time -import ClassicFSM -import State +from direct.fsm import ClassicFSM +from direct.fsm import State import DirectObject import SfxPlayer if __debug__: - import DeltaProfiler + from direct.directutil import DeltaProfiler import OnScreenDebug __builtins__["FADE_SORT_INDEX"] = 1000 @@ -1526,7 +1526,7 @@ class ShowBase(DirectObject.DirectObject): self.startTk(fWantTk) self.wantDirect = fWantDirect if self.wantDirect: - import DirectSession + from direct.directtools import DirectSession direct.enable() else: __builtins__["direct"] = self.direct = None diff --git a/direct/src/showbase/ShowBaseGlobal.py b/direct/src/showbase/ShowBaseGlobal.py index 2b1e6be1fb..522984f973 100644 --- a/direct/src/showbase/ShowBaseGlobal.py +++ b/direct/src/showbase/ShowBaseGlobal.py @@ -14,7 +14,7 @@ assert(base) directNotify.setDconfigLevels() def inspect(anObject): - import Inspector + from direct.tkpanels import Inspector return Inspector.inspect(anObject) __builtins__["inspect"] = inspect diff --git a/direct/src/showbase/TkGlobal.py b/direct/src/showbase/TkGlobal.py index 3ac8ecff85..e5b27b58fb 100644 --- a/direct/src/showbase/TkGlobal.py +++ b/direct/src/showbase/TkGlobal.py @@ -18,7 +18,7 @@ def tkloop(self): return Task.cont # Get the taskMgr -from TaskManagerGlobal import * +from direct.task.TaskManagerGlobal import * def spawnTkLoop(): # Spawn this task diff --git a/direct/src/showbase/Transitions.py b/direct/src/showbase/Transitions.py index cdb80238f4..4d544f8f97 100644 --- a/direct/src/showbase/Transitions.py +++ b/direct/src/showbase/Transitions.py @@ -1,7 +1,7 @@ -from PandaModules import * -from DirectGui import * -import Task +from pandac.PandaModules import * +from direct.gui.DirectGui import * +from direct.task import Task class Transitions: diff --git a/direct/src/showbase/__init__.py b/direct/src/showbase/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/showbase/pandaSqueezeTool.py b/direct/src/showbase/pandaSqueezeTool.py index fbf51d9319..d9e088ff62 100755 --- a/direct/src/showbase/pandaSqueezeTool.py +++ b/direct/src/showbase/pandaSqueezeTool.py @@ -159,8 +159,9 @@ class Loader(ihooks.ModuleLoader): if type != PYZ_MODULE: return ihooks.ModuleLoader.load_module(self, name, stuff) #print "PYZ:", "import", name - code = self.__modules[name] - del self.__modules[name] # no need to keep this one around + basename = name.split('.')[-1] + code = self.__modules[basename] + del self.__modules[basename] # no need to keep this one around m = self.hooks.add_module(name) m.__file__ = filename exec code in m.__dict__ @@ -330,27 +331,28 @@ exec "import %(start)s" # create bootstrap code fp = open(bootstrap, "w") - # Note: David Rose adjusted the following to be more general. + # Note: David Rose adjusted the following to be panda-specific. fp.write("""\ #%(localMagic)s %(archiveid)s import ihooks,zlib,marshal,os,sys +import pandac + def searchPath(filename): - # Look along the python load path for the indicated filename. - # Returns the located pathname, or None if the filename is not - # found. - for dir in sys.path: + # Look along pandac.__path__ for the indicated filename. Returns + # the located pathname, or None if the filename is not found. + for dir in pandac.__path__: pathname = os.path.join(dir, filename) if os.path.exists(pathname): return pathname return None -# Look for %(archive)s along the sys.path. +# Look for %(archive)s along pandac.__path__. archiveName = "%(archive)s" archivePath = searchPath(archiveName) if archivePath == None: - raise ImportError, "Could not locate %%s on PYTHONPATH." %% (archiveName) + raise ImportError, "Could not locate pandac.%%s." %% (archiveName) f=open(archivePath,"rb") exec marshal.loads(%(zbegin)sf.read(%(loaderlen)d)%(zend)s) diff --git a/direct/src/showbase/sitecustomize.py b/direct/src/showbase/sitecustomize.py index 3592cc96eb..83496eaf82 100644 --- a/direct/src/showbase/sitecustomize.py +++ b/direct/src/showbase/sitecustomize.py @@ -93,4 +93,68 @@ def getPackages(): for package in packages: addpackage(package) -getPackages() + +def getPath(): + """ + Add to sys.path the appropriate director(ies) to search for the + various Panda projects. Typically, these will all be in the same + directory (which is presumably already on sys.path), but if the VR + Studio ctattach tools are in use they could be scattered around in + several places. + """ + + ctprojs = os.getenv("CTPROJS") + if ctprojs: + # The CTPROJS environment variable is defined. We must be + # using the ctattach tools. In this case, we need to figure + # out the location of each of the separate trees, and put the + # parent directory of each one on sys.path. In many cases, + # these will all be siblings, so we filter out duplicate + # parent directories. + + print ' Appending to sys.path based on $CTPROJS:' + + # First, get the list of packages, then reverse the list to + # put it in ctattach order. (The reversal may not matter too + # much these days, but let's be as correct as we can be.) + packages = [] + for proj in ctprojs.split(): + projName = proj.split(':')[0] + packages.append(projName) + packages.reverse() + + # Now walk through the packages and figure out the parent of + # each referenced directory. + + parents = [] + for package in packages: + tree = os.getenv(package) + if tree == None: + print " CTPROJS contains %s, but $%s is not defined." % (package, package) + sys.exit(1) + + parent, base = os.path.split(tree) + if base != package.lower(): + print " Warning: $%s refers to a directory named %s (instead of %s)" % (package, base, package.lower()) + + if parent not in parents: + parents.append(parent) + + + # We also put tree/lib on sys.path by hand, because we + # will need to load up the generated C++ modules that got + # put there. Also, we will find the output of genPyCode + # in $DIRECT/lib/pandac. + libdir = os.path.join(tree, 'lib') + if os.path.isdir(libdir): + sys.path.append(libdir) + + + # Now the result goes onto sys.path. + for parent in parents: + print " %s" % (parent) + sys.path.append(parent) + + +#getPackages() +getPath() diff --git a/direct/src/showutil/Effects.py b/direct/src/showutil/Effects.py index f091c559e5..fdefc255e8 100644 --- a/direct/src/showutil/Effects.py +++ b/direct/src/showutil/Effects.py @@ -1,7 +1,7 @@ """ Showutil Effects module: contains code for useful showcode effects. """ -from DirectObject import * -from PandaModules import * -from IntervalGlobal import * +from direct.showbase.DirectObject import * +from pandac.PandaModules import * +from direct.interval.IntervalGlobal import * # bounce types SX_BOUNCE = 0 diff --git a/direct/src/showutil/Rope.py b/direct/src/showutil/Rope.py index 2576590a32..557d0cda00 100644 --- a/direct/src/showutil/Rope.py +++ b/direct/src/showutil/Rope.py @@ -1,4 +1,4 @@ -from PandaModules import * +from pandac.PandaModules import * import types class Rope(NodePath): diff --git a/direct/src/showutil/__init__.py b/direct/src/showutil/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/task/Task.py b/direct/src/task/Task.py index e17d247d54..71b15b297f 100644 --- a/direct/src/task/Task.py +++ b/direct/src/task/Task.py @@ -1,8 +1,8 @@ -from libpandaexpressModules import * -from DirectNotifyGlobal import * -from PythonUtil import * -from MessengerGlobal import * +from pandac.libpandaexpressModules import * +from direct.directnotify.DirectNotifyGlobal import * +from direct.showbase.PythonUtil import * +from direct.showbase.MessengerGlobal import * import time import fnmatch import string @@ -106,7 +106,7 @@ class Task: def setupPStats(self, name): if __debug__: - import PStatCollector + from pandac import PStatCollector self.pstats = PStatCollector.PStatCollector("App:Show code:" + name) def finishTask(self, verbose): @@ -906,7 +906,7 @@ class TaskManager: task.setStartTimeFrame(self.currentTime, self.currentFrame) def popupControls(self): - import TaskManagerPanel + from direct.tkpanels import TaskManagerPanel return TaskManagerPanel.TaskManagerPanel(self) def __getTimeFrame(self): diff --git a/direct/src/task/Timer.py b/direct/src/task/Timer.py index 3ec3e843be..7b816b070a 100644 --- a/direct/src/task/Timer.py +++ b/direct/src/task/Timer.py @@ -1,4 +1,4 @@ -from PandaModules import * +from pandac.PandaModules import * import Task class Timer: diff --git a/direct/src/task/__init__.py b/direct/src/task/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/tkpanels/AnimPanel.py b/direct/src/tkpanels/AnimPanel.py index 9783012ef6..bf72a304a4 100644 --- a/direct/src/tkpanels/AnimPanel.py +++ b/direct/src/tkpanels/AnimPanel.py @@ -3,13 +3,13 @@ ### SEE END OF FILE FOR EXAMPLE USEAGE ### # Import Tkinter, Pmw, and the floater code from this directory tree. -from AppShell import * -from TkGlobal import * +from direct.tkwidgets.AppShell import * +from direct.showbase.TkGlobal import * from tkSimpleDialog import askfloat import string import math import types -import Task +from direct.task import Task FRAMES = 0 SECONDS = 1 @@ -509,7 +509,7 @@ class ActorControl(Pmw.MegaWidget): """ # EXAMPLE CODE -import Actor +from direct.actor import Actor import AnimPanel a = Actor.Actor({250:{"head":"phase_3/models/char/dogMM_Shorts-head-250", diff --git a/direct/src/tkpanels/DirectSessionPanel.py b/direct/src/tkpanels/DirectSessionPanel.py index 11ecef5488..4fef0425b6 100644 --- a/direct/src/tkpanels/DirectSessionPanel.py +++ b/direct/src/tkpanels/DirectSessionPanel.py @@ -1,16 +1,16 @@ """ DIRECT Session Main panel """ # Import Tkinter, Pmw, and the dial code -from PandaObject import * -from TkGlobal import * -from AppShell import * +from direct.showbase.PandaObject import * +from direct.showbase.TkGlobal import * +from direct.tkwidgets.AppShell import * import string -import Dial -import Floater -import Slider -import VectorWidgets -import SceneGraphExplorer +from direct.tkwidgets import Dial +from direct.tkwidgets import Floater +from direct.tkwidgets import Slider +from direct.tkwidgets import VectorWidgets +from direct.tkwidgets import SceneGraphExplorer from TaskManagerPanel import TaskManagerWidget """ diff --git a/direct/src/tkpanels/FSMInspector.py b/direct/src/tkpanels/FSMInspector.py index 1b8075e536..6e055130df 100644 --- a/direct/src/tkpanels/FSMInspector.py +++ b/direct/src/tkpanels/FSMInspector.py @@ -1,7 +1,7 @@ """ Finite State Machine Inspector module """ -from PandaObject import * -from AppShell import * -from TkGlobal import * +from direct.showbase.PandaObject import * +from direct.tkwidgets.AppShell import * +from direct.showbase.TkGlobal import * from tkSimpleDialog import askstring import math import operator @@ -452,10 +452,10 @@ want-tk #t 2) start up the show and create a Finite State Machine -from ShowBaseGlobal import * +from direct.showbase.ShowBaseGlobal import * -import ClassicFSM -import State +from direct.fsm import ClassicFSM +from direct.fsm import State def enterState(): print 'enterState' @@ -522,7 +522,7 @@ occasionally results in everything locking up. This procedure seems to avoid the problem for me: # Start up the show -from ShowBaseGlobal import * +from direct.showbase.ShowBaseGlobal import * # You will see the window and a Tk panel pop open diff --git a/direct/src/tkpanels/Inspector.py b/direct/src/tkpanels/Inspector.py index 5d97abf6dc..2a65b76815 100644 --- a/direct/src/tkpanels/Inspector.py +++ b/direct/src/tkpanels/Inspector.py @@ -4,7 +4,7 @@ ### so that I can just type: inspect(anObject) any time. import string -from TkGlobal import * +from direct.showbase.TkGlobal import * ### public API @@ -407,8 +407,8 @@ class InspectorWindow: return part = self.topInspector().partNumber(partNumber) print part - from PandaModules import NodePath - import ClassicFSM + from pandac.PandaModules import NodePath + from direct.fsm import ClassicFSM popupMenu = None if isinstance(part, NodePath): popupMenu = self.createPopupMenu( diff --git a/direct/src/tkpanels/MopathRecorder.py b/direct/src/tkpanels/MopathRecorder.py index 4870edb7d3..ffa609682d 100644 --- a/direct/src/tkpanels/MopathRecorder.py +++ b/direct/src/tkpanels/MopathRecorder.py @@ -1,21 +1,21 @@ """ Mopath Recorder Panel Module """ # Import Tkinter, Pmw, and the dial code from this directory tree. -from PandaObject import * -from TkGlobal import * -from AppShell import * -from DirectGlobals import * -from DirectUtil import * -from DirectGeometry import * -from DirectSelection import * +from direct.showbase.PandaObject import * +from direct.showbase.TkGlobal import * +from direct.tkwidgets.AppShell import * +from direct.directtools.DirectGlobals import * +from direct.directtools.DirectUtil import * +from direct.directtools.DirectGeometry import * +from direct.directtools.DirectSelection import * from tkFileDialog import * import os import string -import Dial -import Floater -import Slider -import EntryScale -import VectorWidgets +from direct.tkwidgets import Dial +from direct.tkwidgets import Floater +from direct.tkwidgets import Slider +from direct.tkwidgets import EntryScale +from direct.tkwidgets import VectorWidgets import __builtin__ PRF_UTILITIES = [ @@ -1785,7 +1785,7 @@ class MopathRecorder(AppShell, PandaObject): kw['max'] = max kw['resolution'] = resolution #widget = apply(EntryScale.EntryScale, (parent,), kw) - import Slider + from direct.tkwidgets import Slider widget = apply(Slider.Slider, (parent,), kw) # Do this after the widget so command isn't called on creation widget['command'] = command diff --git a/direct/src/tkpanels/NotifyPanel.py b/direct/src/tkpanels/NotifyPanel.py index 8cab6f162e..c783fd9e05 100644 --- a/direct/src/tkpanels/NotifyPanel.py +++ b/direct/src/tkpanels/NotifyPanel.py @@ -9,11 +9,11 @@ class NotifyPanel: notify levels for all available DIRECT and PANDA notify categories """ # Make sure TK mainloop is running - from TkGlobal import Pmw, Toplevel, Frame, Label , Radiobutton - from TkGlobal import HORIZONTAL, X, W, NW, BOTH, LEFT, RIGHT, IntVar + from direct.showbase.TkGlobal import Pmw, Toplevel, Frame, Label , Radiobutton + from direct.showbase.TkGlobal import HORIZONTAL, X, W, NW, BOTH, LEFT, RIGHT, IntVar # To get severity levels - from NotifySeverity import NSFatal, NSError, NSWarning, NSInfo - from NotifySeverity import NSDebug, NSSpam + from pandac.NotifySeverity import NSFatal, NSError, NSWarning, NSInfo + from pandac.NotifySeverity import NSDebug, NSSpam if tl == None: tl = Toplevel() @@ -29,7 +29,7 @@ class NotifyPanel: categoryFrame = framePane.add('categories', size = 200) severityFrame = framePane.add('severities', size = 50) # Category frame - import NotifyCategory + from pandac import NotifyCategory # Assemble PANDA categories categories = self.getPandaCategoriesAsList() self.__categories = {} @@ -122,7 +122,7 @@ class NotifyPanel: return categories def getPandaCategories(self): - from PandaModules import Notify + from pandac.PandaModules import Notify topCategory = Notify.ptr().getTopCategory() return self._getPandaCategories(topCategory) diff --git a/direct/src/tkpanels/ParticlePanel.py b/direct/src/tkpanels/ParticlePanel.py index bf44b104e2..b9b2b829c5 100644 --- a/direct/src/tkpanels/ParticlePanel.py +++ b/direct/src/tkpanels/ParticlePanel.py @@ -1,19 +1,19 @@ """PANDA3D Particle Panel""" # Import Tkinter, Pmw, and the floater code from this directory tree. -from AppShell import * -from TkGlobal import * +from direct.tkwidgets.AppShell import * +from direct.showbase.TkGlobal import * from tkFileDialog import * from tkSimpleDialog import askstring import os -import Dial -import Floater -import Slider -import VectorWidgets +from direct.tkwidgets import Dial +from direct.tkwidgets import Floater +from direct.tkwidgets import Slider +from direct.tkwidgets import VectorWidgets import Placer -import ForceGroup -import Particles -import ParticleEffect +from direct.particles import ForceGroup +from direct.particles import Particles +from direct.particles import ParticleEffect class ParticlePanel(AppShell): # Override class variables diff --git a/direct/src/tkpanels/Placer.py b/direct/src/tkpanels/Placer.py index ff25f658c5..a262bee406 100644 --- a/direct/src/tkpanels/Placer.py +++ b/direct/src/tkpanels/Placer.py @@ -1,11 +1,11 @@ """ DIRECT Nine DoF Manipulation Panel """ # Import Tkinter, Pmw, and the dial code from this directory tree. -from PandaObject import * -from TkGlobal import * -from AppShell import * -import Dial -import Floater +from direct.showbase.PandaObject import * +from direct.showbase.TkGlobal import * +from direct.tkwidgets.AppShell import * +from direct.tkwidgets import Dial +from direct.tkwidgets import Floater """ TODO: diff --git a/direct/src/tkpanels/TaskManagerPanel.py b/direct/src/tkpanels/TaskManagerPanel.py index 776e22fc34..419796c9aa 100644 --- a/direct/src/tkpanels/TaskManagerPanel.py +++ b/direct/src/tkpanels/TaskManagerPanel.py @@ -1,4 +1,4 @@ -from AppShell import * +from direct.tkwidgets.AppShell import * class TaskManagerPanel(AppShell): # Override class variables here @@ -46,7 +46,7 @@ class TaskManagerWidget(PandaObject): tasks managed by the taskManager. """ # Make sure TK mainloop is running - import TkGlobal + from direct.showbase import TkGlobal # Record parent (used by ok cancel dialog boxes) self.parent = parent # Record taskManager diff --git a/direct/src/tkpanels/__init__.py b/direct/src/tkpanels/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/direct/src/tkwidgets/AppShell.py b/direct/src/tkwidgets/AppShell.py index 7aa7fdba0b..240a1a9c3d 100644 --- a/direct/src/tkwidgets/AppShell.py +++ b/direct/src/tkwidgets/AppShell.py @@ -4,8 +4,8 @@ This is an adaption of AppShell.py found in Python and Tkinter Programming by John E. Grayson which is a streamlined adaptation of GuiAppD.py, originally created by Doug Hellmann (doughellmann@mindspring.com). """ -from PandaObject import * -from TkGlobal import * +from direct.showbase.PandaObject import * +from direct.showbase.TkGlobal import * from tkFileDialog import * import Dial import Floater diff --git a/direct/src/tkwidgets/Dial.py b/direct/src/tkwidgets/Dial.py index 24916e9e99..bcd4ec2894 100644 --- a/direct/src/tkwidgets/Dial.py +++ b/direct/src/tkwidgets/Dial.py @@ -2,13 +2,13 @@ Dial Class: Velocity style controller for floating point values with a label, entry (validated), and scale """ -from TkGlobal import * +from direct.showbase.TkGlobal import * from Valuator import * -import Task +from direct.task import Task import math import string import operator -from PandaModules import ClockObject +from pandac.PandaModules import ClockObject TWO_PI = 2.0 * math.pi ONEPOINTFIVE_PI = 1.5 * math.pi diff --git a/direct/src/tkwidgets/EntryScale.py b/direct/src/tkwidgets/EntryScale.py index 721a252ab9..0a1599c8f8 100644 --- a/direct/src/tkwidgets/EntryScale.py +++ b/direct/src/tkwidgets/EntryScale.py @@ -1,8 +1,8 @@ """ EntryScale Class: Scale with a label, and a linked and validated entry """ -from PandaObject import * -from TkGlobal import * +from direct.showbase.PandaObject import * +from direct.showbase.TkGlobal import * import string import tkColorChooser from tkSimpleDialog import * diff --git a/direct/src/tkwidgets/Floater.py b/direct/src/tkwidgets/Floater.py index fdbeb6457b..21413d3353 100644 --- a/direct/src/tkwidgets/Floater.py +++ b/direct/src/tkwidgets/Floater.py @@ -2,10 +2,10 @@ Floater Class: Velocity style controller for floating point values with a label, entry (validated), and scale """ -from PandaObject import * -from TkGlobal import * +from direct.showbase.PandaObject import * +from direct.showbase.TkGlobal import * from Valuator import * -import Task +from direct.task import Task import math import string diff --git a/direct/src/tkwidgets/ProgressBar.py b/direct/src/tkwidgets/ProgressBar.py index fb160401d9..540d3e7e7d 100644 --- a/direct/src/tkwidgets/ProgressBar.py +++ b/direct/src/tkwidgets/ProgressBar.py @@ -1,7 +1,7 @@ """ A basic widget for showing the progress being made in a task. """ -from TkGlobal import * +from direct.showbase.TkGlobal import * class ProgressBar: def __init__(self, master=None, orientation="horizontal", diff --git a/direct/src/tkwidgets/SceneGraphExplorer.py b/direct/src/tkwidgets/SceneGraphExplorer.py index a76d72e9f7..3a96aadc13 100644 --- a/direct/src/tkwidgets/SceneGraphExplorer.py +++ b/direct/src/tkwidgets/SceneGraphExplorer.py @@ -1,5 +1,5 @@ -from PandaObject import * -from TkGlobal import * +from direct.showbase.PandaObject import * +from direct.showbase.TkGlobal import * from Tree import * # changing these strings requires changing DirectSession.py SGE_ strs too! diff --git a/direct/src/tkwidgets/Slider.py b/direct/src/tkwidgets/Slider.py index b58268ed3c..98f22888df 100644 --- a/direct/src/tkwidgets/Slider.py +++ b/direct/src/tkwidgets/Slider.py @@ -2,13 +2,13 @@ Slider Class: Velocity style controller for floating point values with a label, entry (validated), and min/max slider """ -from TkGlobal import * +from direct.showbase.TkGlobal import * from Valuator import * -import Task +from direct.task import Task import math import string import operator -from PandaModules import ClockObject +from pandac.PandaModules import ClockObject class Slider(Valuator): """ diff --git a/direct/src/tkwidgets/Tree.py b/direct/src/tkwidgets/Tree.py index cceeef59be..bb10e1ffd3 100644 --- a/direct/src/tkwidgets/Tree.py +++ b/direct/src/tkwidgets/Tree.py @@ -18,8 +18,8 @@ import os import sys import string -from TkGlobal import * -from PandaObject import * +from direct.showbase.TkGlobal import * +from direct.showbase.PandaObject import * # Initialize icon directory f = Filename('icons') diff --git a/direct/src/tkwidgets/Valuator.py b/direct/src/tkwidgets/Valuator.py index 33fae13b83..41852cafa1 100644 --- a/direct/src/tkwidgets/Valuator.py +++ b/direct/src/tkwidgets/Valuator.py @@ -1,9 +1,9 @@ -from PandaObject import * -from TkGlobal import * +from direct.showbase.PandaObject import * +from direct.showbase.TkGlobal import * import tkColorChooser import WidgetPropertiesDialog import string -from DirectUtil import getTkColorString +from direct.directtools.DirectUtil import getTkColorString VALUATOR_MINI = 'mini' VALUATOR_FULL = 'full' diff --git a/direct/src/tkwidgets/VectorWidgets.py b/direct/src/tkwidgets/VectorWidgets.py index a9829087eb..e5cb9a8760 100644 --- a/direct/src/tkwidgets/VectorWidgets.py +++ b/direct/src/tkwidgets/VectorWidgets.py @@ -1,4 +1,4 @@ -from TkGlobal import * +from direct.showbase.TkGlobal import * import Valuator import Floater import Slider diff --git a/direct/src/tkwidgets/WidgetPropertiesDialog.py b/direct/src/tkwidgets/WidgetPropertiesDialog.py index 8fd2c47a5e..393600c0dc 100644 --- a/direct/src/tkwidgets/WidgetPropertiesDialog.py +++ b/direct/src/tkwidgets/WidgetPropertiesDialog.py @@ -1,4 +1,4 @@ -from TkGlobal import * +from direct.showbase.TkGlobal import * import types import string diff --git a/direct/src/tkwidgets/__init__.py b/direct/src/tkwidgets/__init__.py new file mode 100644 index 0000000000..e69de29bb2