mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
added objects renaming capability
This commit is contained in:
parent
244f2c0356
commit
d71ea75038
@ -86,9 +86,28 @@ class ObjectPaletteBase:
|
||||
try:
|
||||
item = self.data[name]
|
||||
except:
|
||||
return None;
|
||||
return None
|
||||
return item
|
||||
|
||||
def rename(self, oldName, newName):
|
||||
#import pdb;set_trace()
|
||||
if oldName == newName:
|
||||
return False
|
||||
if newName == "":
|
||||
return False
|
||||
try:
|
||||
for key in self.dataStruct.keys():
|
||||
if self.dataStruct[key] == oldName:
|
||||
self.dataStruct[key] = newName
|
||||
|
||||
self.dataStruct[newName] = self.dataStruct.pop(oldName)
|
||||
item = self.data.pop(oldName)
|
||||
item.name = newName
|
||||
self.data[newName] = item
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
|
||||
def populate(self):
|
||||
# You should implement this in subclass
|
||||
raise NotImplementedError('populate() must be implemented in ObjectPalette.py')
|
||||
|
Loading…
x
Reference in New Issue
Block a user