mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-17 12:12:10 -04:00
added spec edit username tracking
This commit is contained in:
parent
5d5cc31024
commit
1425878410
@ -440,26 +440,12 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
||||
|
||||
if __debug__:
|
||||
# level editing stuff
|
||||
def setAttribChange(self, entId, attribName, valueStr):
|
||||
def setAttribChange(self, entId, attribName, valueStr, username):
|
||||
"""every time the spec is edited, we get this message
|
||||
from the AI"""
|
||||
value = eval(valueStr)
|
||||
self.levelSpec.setAttribChange(entId, attribName, value)
|
||||
self.levelSpec.setAttribChange(entId, attribName, value, username)
|
||||
|
||||
"""
|
||||
if __debug__:
|
||||
# if someone has edited the level, we'll get the full up-to-date
|
||||
# spec in this message
|
||||
def setLevelSpecOverride(self, specStr):
|
||||
if self.levelSpec is not None:
|
||||
return
|
||||
|
||||
try:
|
||||
self.levelSpec = eval(specStr)
|
||||
except Exception, e:
|
||||
print ('Exception in %s(%s):\n\t%s' %
|
||||
(lineInfo()[2], specStr, e))
|
||||
raise e
|
||||
"""
|
||||
|
||||
def spawnTitleText(self):
|
||||
def getDescription(zoneId, self=self):
|
||||
entId = self.zoneNum2entId.get(zoneId)
|
||||
@ -528,4 +514,3 @@ class DistributedLevel(DistributedObject.DistributedObject,
|
||||
assert(DistributedLevel.notify.debug("hideTitleTextTask()"))
|
||||
self.smallTitleText.hide()
|
||||
return Task.done
|
||||
|
||||
|
@ -95,12 +95,12 @@ class DistributedLevelAI(DistributedObjectAI.DistributedObjectAI,
|
||||
if __debug__:
|
||||
# level editors should call this func to tweak attributes of level
|
||||
# entities
|
||||
def setAttribChange(self, entId, attribName, value):
|
||||
def setAttribChange(self, entId, attribName, value, username='SYSTEM'):
|
||||
# send a copy to the client-side level obj FIRST
|
||||
# (it may be a message that creates an entity)
|
||||
self.sendUpdate('setAttribChange',
|
||||
[entId, attribName, repr(value)])
|
||||
self.levelSpec.setAttribChange(entId, attribName, value)
|
||||
[entId, attribName, repr(value), username])
|
||||
self.levelSpec.setAttribChange(entId, attribName, value, username)
|
||||
|
||||
self.modified = 1
|
||||
self.scheduleSave()
|
||||
|
@ -1,13 +1,13 @@
|
||||
"""EditMgrAI module: contains the EditMgrAI class"""
|
||||
|
||||
import EditMgrBase
|
||||
if __debug__:
|
||||
from PythonUtil import list2dict
|
||||
import EditorGlobals
|
||||
|
||||
class EditMgrAI(EditMgrBase.EditMgrBase):
|
||||
"""This class handles AI-side editor-specific functionality"""
|
||||
if __debug__:
|
||||
from PythonUtil import list2dict
|
||||
import EditorGlobals
|
||||
|
||||
def setRequestNewEntity(self, data):
|
||||
# pick an unused entId
|
||||
spec = self.level.levelSpec
|
||||
|
@ -15,6 +15,9 @@ class EditMgrBase(Entity.Entity):
|
||||
|
||||
if __debug__:
|
||||
def setInsertEntity(self, data):
|
||||
# tell the level who created this entity
|
||||
self.level.setEntityCreatorUsername(data['entId'], data['username'])
|
||||
# create the entity
|
||||
self.level.levelSpec.insertEntity(data['entId'],
|
||||
data['entType'],
|
||||
data['parentEntId'],
|
||||
|
@ -24,6 +24,9 @@ def assertReadyToEdit():
|
||||
assert editUsername in username2entIdBase, (
|
||||
"unknown editor username '%s'; see %s.py" % (editUsername, __name__))
|
||||
|
||||
def getEditUsername():
|
||||
return editUsername
|
||||
|
||||
def getEntIdAllocRange():
|
||||
"""range of valid entId values for this user.
|
||||
returns [min, max+1] (values taken by range() and xrange())"""
|
||||
|
@ -277,13 +277,19 @@ class Level:
|
||||
return 'removeEntity-%s' % self.levelId
|
||||
|
||||
# these handlers are called directly by our levelSpec
|
||||
def handleAttribChange(self, entId, attrib, value):
|
||||
def handleAttribChange(self, entId, attrib, value, username=None):
|
||||
entity = self.getEntity(entId)
|
||||
# the entity might be AI- or client-only
|
||||
if entity is not None:
|
||||
entity.handleAttribChange(attrib, value)
|
||||
messenger.send(self.getAttribChangeEventName(),
|
||||
[entId, attrib, value])
|
||||
[entId, attrib, value, username])
|
||||
|
||||
def setEntityCreatorUsername(self, entId, editUsername):
|
||||
# this is called just before an entity is inserted, with the
|
||||
# entId of the new entity and the username of the editor
|
||||
# that requested its creation.
|
||||
pass
|
||||
|
||||
def handleEntityInsert(self, entId):
|
||||
self.createEntity(entId)
|
||||
|
@ -92,17 +92,17 @@ class LevelSpec:
|
||||
def setFilename(self, filename):
|
||||
self.filename = filename
|
||||
|
||||
def setAttribChange(self, entId, attrib, value):
|
||||
def setAttribChange(self, entId, attrib, value, username):
|
||||
""" we're being asked to change an attribute """
|
||||
LevelSpec.notify.debug("setAttribChange: %s, %s = '%s'" %
|
||||
(entId, attrib, repr(value)))
|
||||
LevelSpec.notify.debug("setAttribChange(%s): %s, %s = '%s'" %
|
||||
(username, entId, attrib, repr(value)))
|
||||
assert entId in self.entId2specDict
|
||||
specDict = self.entId2specDict[entId]
|
||||
assert specDict[entId].has_key(attrib)
|
||||
specDict[entId][attrib] = value
|
||||
# let the level know that this attribute value has
|
||||
# officially changed
|
||||
self.level.handleAttribChange(entId, attrib, value)
|
||||
self.level.handleAttribChange(entId, attrib, value, username)
|
||||
|
||||
def insertEntity(self, entId, entType, parentEntId):
|
||||
LevelSpec.notify.debug('inserting entity %s' % entId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user