UndoManager and UndoAction (SOLVED)
by Eero Karvonen · in Torque 2D Beginner · 06/09/2014 (11:57 am) · 5 replies
Hi,
has anyone used UndoManager? Do you know how to attach an actual command to an UndoAction?
has anyone used UndoManager? Do you know how to attach an actual command to an UndoAction?
#2
Hope it helps? :-)
06/09/2014 (5:04 pm)
I haven't used it either, but it might be worth looking at the C++ side even if your not comfortable with it (engine/collection/undo...). There seems to be another undo-related class not on the wiki called "UndoScriptAction", above it was this comment (haven't tried it, but it looks exposed to TS)://
// Script Undo Action Creation
//
// Undo actions can be created in script like this:
//
// ...
// %undo = new UndoScriptAction() { class = SampleUndo; actionName = "Sample Undo"; };
// %undo.addToManager(UndoManager);
// ...
//
// function SampleUndo::undo()
// {
// ...
// }
//
// function SampleUndo::redo()
// {
// ...
// }Hope it helps? :-)
#3
06/09/2014 (6:59 pm)
It's used heavily in the legacy editors. I will probably be using it for my editors as well, but I haven't gotten that far yet. You just want to know how to attach an action, is that it?
#4
06/10/2014 (1:37 pm)
@Mich, that would be a great start.
#5
06/13/2014 (12:15 pm)
Found an example in the commercial legacy product. The implementation is a bit more complicated than I had thought, but very logical.
Associate Mike Lilligreen
Retired T2Der
If you have a source code license to the legacy engine, download TGB 1.8 and have a look at how the level builder uses it as an example. The script file can be found under this path: tgb/tools/levelEditor/scripts/undo.ed.cs