Game Development Community

iT2D 1.4.1 Release - Undo after Deleting Breaks Mounts - RESOLVED

by Mark Grossnickle · in iTorque 2D · 04/06/2011 (11:36 am) · 4 replies

Build: 1.4.1 Release

Platform: OS 10.6.6

Target: Editor

Issues: Undo after Deleting Breaks Mounts

Steps to Repeat
1. Open any project (or create a new one) in the TGB editor.
2. Add 2 visual assets to the scene. In my case I am using a body image and a head image.
3. Mount one asset to the other. In my case I am mounting the head to the body.
4. Select the items in the Object tree.
5. Delete
6. Undo
7. The items will re-appear but the mount will be gone.

Note: Feel free to group the items before deleting. Undo after deleting still removes the mount. Also, complex groups do not get re-created correctly (groups disappear along with sceneObjects), but that is a bug for another day once I can narrow down exact steps.

Suggested Fixes:
*update* It appears if you hit Undo a second time, then item will get 'remounted'. Therefore, my suggested fix would be to modify the delete undo action so that it contains the mount undo action as well. I could see a Macro undo action being useful for the future... one that contains a sequence of undo actions.

#1
04/06/2011 (3:16 pm)
Logged as ITGB-152.
#2
04/08/2011 (9:23 pm)
I was able to fix this by creating a MacroUndoAction that records multiple UndoActions. The way it works is as follows:

- Call a function on UndoManager for 'beginRecordingMacro' which sets a isRecording flag to true and creates a new MacroUndoAction.
- While isRecording is true, any new actions added to the UndoManager gets added to the MacroUndoAction instead of the manager's queue.
- Call a function on UndoManager for 'endRecordingMacro' which sets isRecording to false and then adds the recently created MacroUndoAction to the manager's queue.
- When Undo or Redo gets called on the MacroUndoAction, it loops through all the actions that was added to it and calls undo/redo on them.

So in the case of delete, the deletion action happens in two steps. 1. Unmount objects. 2. Delete objects. Start recording when deleteAcquiredObjects gets called and end before the return. This will wrap both steps in one action.
#3
04/08/2011 (9:26 pm)
Oh yeah, side note. When mounting is involved, you will also need to ensure all mounted children get deleted before the root object. When the root object gets deleted, all the children also get deleted but they are not placed in the recycleBin. instead they are permanently wiped. Thus, recycle the children before you recycle the root.

You can do this by accessing the notify on delete list that is populated with mounted children.

Cheers!
#4
09/27/2011 (7:15 pm)
Fixed in 1.5.