mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
added objects renaming capability
This commit is contained in:
parent
244f2c0356
commit
d71ea75038
@ -86,9 +86,28 @@ class ObjectPaletteBase:
|
|||||||
try:
|
try:
|
||||||
item = self.data[name]
|
item = self.data[name]
|
||||||
except:
|
except:
|
||||||
return None;
|
return None
|
||||||
return item
|
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):
|
def populate(self):
|
||||||
# You should implement this in subclass
|
# You should implement this in subclass
|
||||||
raise NotImplementedError('populate() must be implemented in ObjectPalette.py')
|
raise NotImplementedError('populate() must be implemented in ObjectPalette.py')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user