mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
Restored the ability to paste map elements copied in DB2/DB64.
This commit is contained in:
parent
c2ef080268
commit
0a6a6bbd20
1 changed files with 38 additions and 13 deletions
|
@ -27,6 +27,7 @@ using CodeImp.DoomBuilder.Geometry;
|
||||||
using CodeImp.DoomBuilder.GZBuilder.Data;
|
using CodeImp.DoomBuilder.GZBuilder.Data;
|
||||||
using CodeImp.DoomBuilder.IO;
|
using CodeImp.DoomBuilder.IO;
|
||||||
using CodeImp.DoomBuilder.Map;
|
using CodeImp.DoomBuilder.Map;
|
||||||
|
using CodeImp.DoomBuilder.Types;
|
||||||
using CodeImp.DoomBuilder.Windows;
|
using CodeImp.DoomBuilder.Windows;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -38,6 +39,7 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
#region ================== Constants
|
#region ================== Constants
|
||||||
|
|
||||||
private const string CLIPBOARD_DATA_FORMAT = "GZDOOM_BUILDER_GEOMETRY";
|
private const string CLIPBOARD_DATA_FORMAT = "GZDOOM_BUILDER_GEOMETRY";
|
||||||
|
private const string CLIPBOARD_DATA_FORMAT_DB2 = "DOOM_BUILDER_GEOMETRY";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -287,8 +289,11 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
// Check if possible to copy/paste
|
// Check if possible to copy/paste
|
||||||
if(General.Editing.Mode.Attributes.AllowCopyPaste)
|
if(General.Editing.Mode.Attributes.AllowCopyPaste)
|
||||||
{
|
{
|
||||||
|
bool havepastedata = Clipboard.ContainsData(CLIPBOARD_DATA_FORMAT); //mxd
|
||||||
|
bool havedb2pastedata = Clipboard.ContainsData(CLIPBOARD_DATA_FORMAT_DB2); //mxd
|
||||||
|
|
||||||
// Anything to paste?
|
// Anything to paste?
|
||||||
if(Clipboard.ContainsData(CLIPBOARD_DATA_FORMAT))
|
if(havepastedata || havedb2pastedata)
|
||||||
{
|
{
|
||||||
// Cancel volatile mode
|
// Cancel volatile mode
|
||||||
General.Editing.DisengageVolatileMode();
|
General.Editing.DisengageVolatileMode();
|
||||||
|
@ -307,22 +312,42 @@ namespace CodeImp.DoomBuilder.Editing
|
||||||
General.Map.Map.ClearAllMarks(true);
|
General.Map.Map.ClearAllMarks(true);
|
||||||
|
|
||||||
// Read from clipboard
|
// Read from clipboard
|
||||||
using(Stream memstream = (Stream)Clipboard.GetData(CLIPBOARD_DATA_FORMAT))
|
if(havepastedata)
|
||||||
{
|
{
|
||||||
// Rewind before use
|
using(Stream memstream = (Stream)Clipboard.GetData(CLIPBOARD_DATA_FORMAT))
|
||||||
memstream.Seek(0, SeekOrigin.Begin);
|
|
||||||
|
|
||||||
// Read data stream
|
|
||||||
ClipboardStreamReader reader = new ClipboardStreamReader(); //mxd
|
|
||||||
General.Map.Map.BeginAddRemove();
|
|
||||||
bool success = reader.Read(General.Map.Map, memstream);
|
|
||||||
General.Map.Map.EndAddRemove();
|
|
||||||
if(!success) //mxd
|
|
||||||
{
|
{
|
||||||
General.Map.UndoRedo.WithdrawUndo(); // This will also mess with the marks...
|
// Rewind before use
|
||||||
General.Map.Map.ClearAllMarks(true); // So re-mark all current geometry...
|
memstream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
// Read data stream
|
||||||
|
ClipboardStreamReader reader = new ClipboardStreamReader(); //mxd
|
||||||
|
General.Map.Map.BeginAddRemove();
|
||||||
|
bool success = reader.Read(General.Map.Map, memstream);
|
||||||
|
General.Map.Map.EndAddRemove();
|
||||||
|
if(!success) //mxd
|
||||||
|
{
|
||||||
|
General.Map.UndoRedo.WithdrawUndo(); // This will also mess with the marks...
|
||||||
|
General.Map.Map.ClearAllMarks(true); // So re-mark all current geometry...
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// mxd. DB2/DB64 interop
|
||||||
|
else if(havedb2pastedata)
|
||||||
|
{
|
||||||
|
using(Stream memstream = (Stream)Clipboard.GetData(CLIPBOARD_DATA_FORMAT_DB2))
|
||||||
|
{
|
||||||
|
// Read data stream
|
||||||
|
UniversalStreamReader reader = new UniversalStreamReader(new Dictionary<MapElementType, Dictionary<string, UniversalType>>());
|
||||||
|
reader.StrictChecking = false;
|
||||||
|
General.Map.Map.BeginAddRemove();
|
||||||
|
reader.Read(General.Map.Map, memstream);
|
||||||
|
General.Map.Map.EndAddRemove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException("Unknown clipboard data format!");
|
||||||
|
}
|
||||||
|
|
||||||
// The new geometry is not marked, so invert the marks to get it marked
|
// The new geometry is not marked, so invert the marks to get it marked
|
||||||
General.Map.Map.InvertAllMarks();
|
General.Map.Map.InvertAllMarks();
|
||||||
|
|
Loading…
Reference in a new issue