fixed undo level when pasting or inserting a prefab

This commit is contained in:
codeimp 2009-01-03 11:35:12 +00:00
parent a0fa6601ce
commit 4b068e93fe
2 changed files with 19 additions and 10 deletions

View file

@ -744,18 +744,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
Cursor.Current = Cursors.AppStarting;
// Reset geometry in original position
if(linesflipped) FlipLinedefs(); // Flip linedefs back if they were flipped
int index = 0;
foreach(Vertex v in selectedvertices)
v.Move(vertexpos[index++]);
if(!pasting)
{
// Reset geometry in original position to create an undo
if(linesflipped) FlipLinedefs(); // Flip linedefs back if they were flipped
int index = 0;
foreach(Vertex v in selectedvertices)
v.Move(vertexpos[index++]);
index = 0;
foreach(Thing t in selectedthings)
t.Move(thingpos[index++]);
index = 0;
foreach(Thing t in selectedthings)
t.Move(thingpos[index++]);
// Make undo
General.Map.UndoRedo.CreateUndo("Edit selection");
// Make undo
General.Map.UndoRedo.CreateUndo("Edit selection");
}
// Mark selected geometry
General.Map.Map.ClearAllMarks(false);

View file

@ -137,6 +137,9 @@ namespace CodeImp.DoomBuilder.Editing
// This pastes a prefab. Returns false when paste was cancelled.
internal void PastePrefab(Stream filedata)
{
// Create undo
General.Map.UndoRedo.CreateUndo("Insert prefab");
// Decompress stream
MemoryStream decompressed = new MemoryStream((int)filedata.Length * 3);
filedata.Seek(0, SeekOrigin.Begin);
@ -220,6 +223,9 @@ namespace CodeImp.DoomBuilder.Editing
// Ask the editing mode to prepare selection for pasting.
if(General.Editing.Mode.OnPasteBegin())
{
// Create undo
General.Map.UndoRedo.CreateUndo("Paste");
// Read from clipboard
Stream memstream = (Stream)Clipboard.GetData(CLIPBOARD_DATA_FORMAT);
memstream.Seek(0, SeekOrigin.Begin);