mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
Fixed a bug of undoing addNewObject
This commit is contained in:
parent
6f905b2834
commit
938d5fb27c
@ -51,6 +51,7 @@ class ActionBase(Functor):
|
|||||||
def _do__call__(self, *args, **kargs):
|
def _do__call__(self, *args, **kargs):
|
||||||
self.saveStatus()
|
self.saveStatus()
|
||||||
self.result = Functor._do__call__(self, *args, **kargs)
|
self.result = Functor._do__call__(self, *args, **kargs)
|
||||||
|
self.postCall()
|
||||||
return self.result
|
return self.result
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
@ -60,6 +61,10 @@ class ActionBase(Functor):
|
|||||||
def saveStatus(self):
|
def saveStatus(self):
|
||||||
# save object status for undo here
|
# save object status for undo here
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def postCall(self):
|
||||||
|
# implement post process here
|
||||||
|
pass
|
||||||
|
|
||||||
def undo(self):
|
def undo(self):
|
||||||
print "undo method is not defined for this action"
|
print "undo method is not defined for this action"
|
||||||
@ -73,6 +78,11 @@ class ActionAddNewObj(ActionBase):
|
|||||||
ActionBase.__init__(self, function, *args, **kargs)
|
ActionBase.__init__(self, function, *args, **kargs)
|
||||||
self.uid = None
|
self.uid = None
|
||||||
|
|
||||||
|
def postCall(self):
|
||||||
|
obj = self.editor.objectMgr.findObjectByNodePath(self.result)
|
||||||
|
if obj:
|
||||||
|
self.uid = obj[OG.OBJ_UID]
|
||||||
|
|
||||||
def redo(self):
|
def redo(self):
|
||||||
if self.uid is None:
|
if self.uid is None:
|
||||||
print "Can't redo this add"
|
print "Can't redo this add"
|
||||||
@ -85,12 +95,15 @@ class ActionAddNewObj(ActionBase):
|
|||||||
print "Can't undo this add"
|
print "Can't undo this add"
|
||||||
else:
|
else:
|
||||||
print "Undo: addNewObject"
|
print "Undo: addNewObject"
|
||||||
obj = self.editor.objectMgr.findObjectByNodePath(self.result)
|
if self.uid:
|
||||||
|
obj = self.editor.objectMgr.findObjectById(self.uid)
|
||||||
|
else:
|
||||||
|
obj = self.editor.objectMgr.findObjectByNodePath(self.result)
|
||||||
if obj:
|
if obj:
|
||||||
self.uid = obj[OG.OBJ_UID]
|
self.uid = obj[OG.OBJ_UID]
|
||||||
self.editor.ui.sceneGraphUI.delete(self.uid)
|
self.editor.ui.sceneGraphUI.delete(self.uid)
|
||||||
base.direct.deselect(self.result)
|
base.direct.deselect(obj[OG.OBJ_NP])
|
||||||
base.direct.removeNodePath(self.result)
|
base.direct.removeNodePath(obj[OG.OBJ_NP])
|
||||||
self.result = None
|
self.result = None
|
||||||
else:
|
else:
|
||||||
print "Can't undo this add"
|
print "Can't undo this add"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user