Browse Source

factory editor framework

Darren Ranalli 22 years ago
parent
commit
4a01fe9851

+ 17 - 0
direct/src/level/DistributedLevel.py

@@ -355,3 +355,20 @@ class DistributedLevel(DistributedObject.DistributedObject,
                 
             entity = self.getEntity(entId)
             entity.handleAttribChange(attribName, value)
+
+        """
+    if __debug__:
+        # if someone has edited the level, we'll get the full up-to-date
+        # spec in this message
+        def setSpecOverride(self, specStr):
+            if self.spec is not None:
+                return
+
+            try:
+                self.spec = eval(specStr)
+            except Exception, e:
+                print ('Exception in %s(%s):\n\t%s' %
+                       (lineInfo()[2], specStr, e))
+                raise e
+            """
+            

+ 11 - 0
direct/src/level/DistributedLevelAI.py

@@ -109,3 +109,14 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
             
             entity = self.getEntity(entId)
             entity.handleAttribChange(attribName, value)
+
+            # send a copy of the entire spec for any new users that
+            # might come in
+            ##self.sendUpdate('setSpecOverride', [repr(self.spec)])
+
+        """
+        def getSpecOverride(self):
+            # This is the value we'll send until someone actually edits
+            # the level
+            return repr(None)
+        """

+ 8 - 15
direct/src/level/Entity.py

@@ -16,24 +16,17 @@ class Entity:
         ('comment', str, 0),
         )
 
-    def __init__(self, level=None, entId=None, attribs=None):
-        if level is not None and entId is not None:
-            self.initializeEntity(level, entId, attribs)
-        else:
-            self.level = level
-            self.entId = entId
-            self.attribs = Entity.Attribs
+    def __init__(self, level=None, entId=None):
+        self.initializeEntity(level, entId)
 
-    def initializeEntity(self, level, entId, attribs=None):
+    def initializeEntity(self, level, entId):
+        """Distributed entities don't know their level or entId values
+        until they've been generated, so they call this after they've
+        been generated. At that point, the entity is good to go."""
         self.level = level
         self.entId = entId
-
-        self.attribs = Entity.Attribs
-        # add any additional tweakable values
-        if attribs is not None:
-            self.attribs.update(attribs)
-
-        self.level.initializeEntity(self)
+        if (self.level is not None) and (self.entId is not None):
+            self.level.initializeEntity(self)
 
     def __str__(self):
         return 'ent%s(%s)' % (self.entId, self.level.getEntityType(self.entId))

+ 3 - 4
direct/src/level/LevelBase.py

@@ -7,7 +7,8 @@ from PythonUtil import lineInfo
 """
 Any data that can be edited by a level editor must be represented as
 an attribute of an entity owned by the level, in order to keep the
-level-editing interface simple and unchanging.
+level-editing interface simple and constant (there are at least three
+places where the entire editing interface must be duplicated).
 
 To support this, we have entities such as 'levelMgr' and 'zoneEntity' that
 contain crucial level information, much of which is needed when setting
@@ -15,8 +16,6 @@ up the level object, and is needed before other entity types can be
 effectively created. (If you try to create a distributed entity, but
 you don't yet have the information for the zone that it's in, because
 you haven't created the zone's ZoneEntity, you're hurting.)
-
-
 """
 
 """
@@ -35,7 +34,7 @@ class LevelBase:
     UberZoneEntId = 0
 
     def __init__(self):
-        pass
+        self.spec = None
 
     def initializeLevel(self, levelId, spec, scenarioIndex):
         """ subclass should call this as soon as it has located