2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
2014-05-08 09:24:32 +00:00
|
|
|
using System;
|
2009-04-19 18:07:22 +00:00
|
|
|
using System.Collections.Generic;
|
2014-09-19 22:19:25 +00:00
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
2009-04-19 18:07:22 +00:00
|
|
|
using CodeImp.DoomBuilder.Map;
|
2014-05-08 09:24:32 +00:00
|
|
|
using CodeImp.DoomBuilder.GZBuilder.Tools;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
//mxd
|
|
|
|
public class FieldDescription : Attribute
|
|
|
|
{
|
|
|
|
public string Description { get; private set; }
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
public FieldDescription(string description)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
this.Description = description;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//mxd
|
|
|
|
public class VertexPropertiesCopySettings
|
|
|
|
{
|
|
|
|
[FieldDescription("Vertex Floor Height")]
|
|
|
|
public bool ZFloor = true;
|
|
|
|
[FieldDescription("Vertex Ceiling Height")]
|
|
|
|
public bool ZCeiling = true;
|
|
|
|
[FieldDescription("Custom Fields")]
|
|
|
|
public bool Fields = true;
|
|
|
|
}
|
|
|
|
|
2010-08-15 13:45:43 +00:00
|
|
|
// Vertex
|
|
|
|
public class VertexProperties
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
public static VertexPropertiesCopySettings CopySettings = new VertexPropertiesCopySettings();
|
2014-04-09 10:16:33 +00:00
|
|
|
|
|
|
|
private readonly UniFields fields;
|
|
|
|
private readonly float zceiling; //mxd
|
|
|
|
private readonly float zfloor; //mxd
|
2010-08-15 13:45:43 +00:00
|
|
|
|
|
|
|
public VertexProperties(Vertex v)
|
|
|
|
{
|
|
|
|
fields = new UniFields(v.Fields);
|
2013-07-08 13:13:28 +00:00
|
|
|
zceiling = v.ZCeiling; //mxd
|
|
|
|
zfloor = v.ZFloor; //mxd
|
2010-08-15 13:45:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Apply(Vertex v)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if(CopySettings.ZCeiling) v.ZCeiling = zceiling; //mxd
|
|
|
|
if(CopySettings.ZFloor) v.ZFloor = zfloor; //mxd
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.Fields)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
v.Fields.BeforeFieldsChange();
|
|
|
|
v.Fields.Clear();
|
|
|
|
foreach (KeyValuePair<string, UniValue> uv in fields)
|
|
|
|
v.Fields.Add(uv.Key, new UniValue(uv.Value));
|
|
|
|
}
|
2010-08-15 13:45:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-08 09:24:32 +00:00
|
|
|
//mxd
|
|
|
|
public class SectorPropertiesCopySettings
|
|
|
|
{
|
|
|
|
[FieldDescription("Floor Height")]
|
|
|
|
public bool FloorHeight = true;
|
|
|
|
[FieldDescription("Ceiling Height")]
|
|
|
|
public bool CeilingHeight = true;
|
|
|
|
[FieldDescription("Floor Texture")]
|
|
|
|
public bool FloorTexture = true;
|
|
|
|
[FieldDescription("Ceiling Texture")]
|
|
|
|
public bool CeilingTexture = true;
|
|
|
|
[FieldDescription("Brightness")]
|
|
|
|
public bool Brightness = true;
|
2014-09-19 22:19:25 +00:00
|
|
|
[FieldDescription("Ceiling Slope")]
|
|
|
|
public bool CeilingSlope = true;
|
|
|
|
[FieldDescription("Floor Slope")]
|
|
|
|
public bool FloorSlope = true;
|
2014-05-08 09:24:32 +00:00
|
|
|
[FieldDescription("Tag")]
|
|
|
|
public bool Tag = true;
|
|
|
|
[FieldDescription("Effect")]
|
|
|
|
public bool Special = true;
|
|
|
|
[FieldDescription("Flags")]
|
|
|
|
public bool Flags = true;
|
|
|
|
[FieldDescription("Custom Fields")]
|
|
|
|
public bool Fields = true;
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Sector
|
|
|
|
public class SectorProperties
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
//mxd
|
|
|
|
public static SectorPropertiesCopySettings CopySettings = new SectorPropertiesCopySettings();
|
2014-04-09 10:16:33 +00:00
|
|
|
|
|
|
|
private readonly int floorheight;
|
|
|
|
private readonly int ceilheight;
|
|
|
|
private readonly string floortexture;
|
|
|
|
private readonly string ceilingtexture;
|
|
|
|
private readonly int effect;
|
|
|
|
private readonly int brightness;
|
2014-09-19 22:19:25 +00:00
|
|
|
private readonly float ceilslopeoffset;
|
|
|
|
private readonly float floorslopeoffset;
|
|
|
|
private readonly Vector3D ceilslope;
|
|
|
|
private readonly Vector3D floorslope;
|
2014-04-09 10:16:33 +00:00
|
|
|
private readonly int tag;
|
|
|
|
private readonly UniFields fields;
|
|
|
|
private readonly Dictionary<string, bool> flags; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
public SectorProperties(Sector s)
|
|
|
|
{
|
|
|
|
floorheight = s.FloorHeight;
|
|
|
|
ceilheight = s.CeilHeight;
|
|
|
|
floortexture = s.FloorTexture;
|
|
|
|
ceilingtexture = s.CeilTexture;
|
|
|
|
brightness = s.Brightness;
|
2010-08-15 13:45:43 +00:00
|
|
|
effect = s.Effect;
|
2014-10-17 11:55:08 +00:00
|
|
|
ceilslopeoffset = s.CeilSlopeOffset;
|
2014-09-19 22:19:25 +00:00
|
|
|
floorslopeoffset = s.FloorSlopeOffset;
|
2014-10-17 11:55:08 +00:00
|
|
|
ceilslope = s.CeilSlope;
|
2014-09-19 22:19:25 +00:00
|
|
|
floorslope = s.FloorSlope;
|
2009-04-19 18:07:22 +00:00
|
|
|
tag = s.Tag;
|
2010-08-15 13:45:43 +00:00
|
|
|
fields = new UniFields(s.Fields);
|
2013-09-11 08:49:45 +00:00
|
|
|
flags = s.GetFlags(); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Apply(Sector s)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if(CopySettings.FloorHeight) s.FloorHeight = floorheight;
|
|
|
|
if(CopySettings.CeilingHeight) s.CeilHeight = ceilheight;
|
|
|
|
if(CopySettings.FloorTexture) s.SetFloorTexture(floortexture);
|
|
|
|
if(CopySettings.CeilingTexture) s.SetCeilTexture(ceilingtexture);
|
|
|
|
if(CopySettings.Brightness) s.Brightness = brightness;
|
|
|
|
if(CopySettings.Tag) s.Tag = tag;
|
|
|
|
if(CopySettings.Special) s.Effect = effect;
|
2014-09-19 22:19:25 +00:00
|
|
|
if (CopySettings.CeilingSlope)
|
|
|
|
{
|
2014-10-17 11:55:08 +00:00
|
|
|
s.CeilSlopeOffset = ceilslopeoffset;
|
|
|
|
s.CeilSlope = ceilslope;
|
2014-09-19 22:19:25 +00:00
|
|
|
}
|
|
|
|
if(CopySettings.FloorSlope)
|
|
|
|
{
|
|
|
|
s.FloorSlopeOffset = floorslopeoffset;
|
|
|
|
s.FloorSlope = floorslope;
|
|
|
|
}
|
|
|
|
if(CopySettings.Flags)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
s.ClearFlags(); //mxd
|
|
|
|
foreach (KeyValuePair<string, bool> f in flags) //mxd
|
|
|
|
s.SetFlag(f.Key, f.Value);
|
|
|
|
}
|
2014-09-19 22:19:25 +00:00
|
|
|
if(CopySettings.Fields)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
s.Fields.BeforeFieldsChange();
|
|
|
|
s.Fields.Clear();
|
|
|
|
foreach (KeyValuePair<string, UniValue> v in fields)
|
|
|
|
s.Fields.Add(v.Key, new UniValue(v.Value));
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
2010-08-15 13:45:43 +00:00
|
|
|
|
2014-05-08 09:24:32 +00:00
|
|
|
//mxd
|
|
|
|
public class SidedefPropertiesCopySettings
|
|
|
|
{
|
|
|
|
[FieldDescription("Upper Texture")]
|
|
|
|
public bool UpperTexture = true;
|
|
|
|
[FieldDescription("Middle Texture")]
|
|
|
|
public bool MiddleTexture = true;
|
|
|
|
[FieldDescription("Lower Texture")]
|
|
|
|
public bool LowerTexture = true;
|
|
|
|
[FieldDescription("Offset X")]
|
|
|
|
public bool OffsetX = true;
|
|
|
|
[FieldDescription("Offset Y")]
|
|
|
|
public bool OffsetY = true;
|
|
|
|
[FieldDescription("Flags")]
|
|
|
|
public bool Flags = true;
|
|
|
|
[FieldDescription("Custom Fields")]
|
|
|
|
public bool Fields = true;
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Sidedef
|
|
|
|
public class SidedefProperties
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
//mxd
|
|
|
|
public static SidedefPropertiesCopySettings CopySettings = new SidedefPropertiesCopySettings();
|
|
|
|
|
2014-04-09 10:16:33 +00:00
|
|
|
private readonly string hightexture;
|
|
|
|
private readonly string middletexture;
|
|
|
|
private readonly string lowtexture;
|
|
|
|
private readonly int offsetx;
|
|
|
|
private readonly int offsety;
|
|
|
|
private readonly UniFields fields;
|
|
|
|
private readonly Dictionary<string, bool> flags; //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
public SidedefProperties(Sidedef s)
|
|
|
|
{
|
|
|
|
hightexture = s.HighTexture;
|
|
|
|
middletexture = s.MiddleTexture;
|
|
|
|
lowtexture = s.LowTexture;
|
|
|
|
offsetx = s.OffsetX;
|
|
|
|
offsety = s.OffsetY;
|
2010-08-15 13:45:43 +00:00
|
|
|
fields = new UniFields(s.Fields);
|
2013-09-11 08:49:45 +00:00
|
|
|
flags = s.GetFlags(); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Apply(Sidedef s)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if(CopySettings.UpperTexture) s.SetTextureHigh(hightexture);
|
|
|
|
if(CopySettings.MiddleTexture) s.SetTextureMid(middletexture);
|
|
|
|
if(CopySettings.LowerTexture) s.SetTextureLow(lowtexture);
|
|
|
|
if(CopySettings.OffsetX) s.OffsetX = offsetx;
|
|
|
|
if(CopySettings.OffsetY) s.OffsetY = offsety;
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.Flags)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
s.ClearFlags(); //mxd
|
|
|
|
foreach (KeyValuePair<string, bool> f in flags) //mxd
|
|
|
|
s.SetFlag(f.Key, f.Value);
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.Fields)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
s.Fields.BeforeFieldsChange();
|
|
|
|
s.Fields.Clear();
|
|
|
|
foreach (KeyValuePair<string, UniValue> v in fields)
|
|
|
|
s.Fields.Add(v.Key, new UniValue(v.Value));
|
|
|
|
}
|
2010-08-15 13:45:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-08 09:24:32 +00:00
|
|
|
//mxd
|
|
|
|
public class LinedefPropertiesCopySettings
|
|
|
|
{
|
|
|
|
[FieldDescription("Sidedef Properties")]
|
|
|
|
public bool SidedefProperties = true;
|
|
|
|
[FieldDescription("Action")]
|
|
|
|
public bool Action = true;
|
|
|
|
[FieldDescription("Action Arguments")]
|
|
|
|
public bool Arguments = true;
|
|
|
|
[FieldDescription("Activation")]
|
|
|
|
public bool Activation = true;
|
|
|
|
[FieldDescription("Tag")]
|
|
|
|
public bool Tag = true;
|
|
|
|
[FieldDescription("Flags")]
|
|
|
|
public bool Flags = true;
|
|
|
|
[FieldDescription("Custom Fields")]
|
|
|
|
public bool Fields = true;
|
|
|
|
}
|
|
|
|
|
2010-08-15 13:45:43 +00:00
|
|
|
// Linedef
|
|
|
|
public class LinedefProperties
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
//mxd
|
|
|
|
public static LinedefPropertiesCopySettings CopySettings = new LinedefPropertiesCopySettings();
|
2014-04-09 10:16:33 +00:00
|
|
|
|
|
|
|
private readonly SidedefProperties front;
|
|
|
|
private readonly SidedefProperties back;
|
|
|
|
private readonly Dictionary<string, bool> flags;
|
|
|
|
private readonly int action;
|
|
|
|
private readonly int activate;
|
|
|
|
private readonly int tag;
|
|
|
|
private readonly int[] args;
|
|
|
|
private readonly UniFields fields;
|
2010-08-15 13:45:43 +00:00
|
|
|
|
|
|
|
public LinedefProperties(Linedef l)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
front = (l.Front != null ? new SidedefProperties(l.Front) : null);
|
|
|
|
back = (l.Back != null ? new SidedefProperties(l.Back) : null);
|
2010-08-15 13:45:43 +00:00
|
|
|
|
|
|
|
flags = l.GetFlags();
|
|
|
|
action = l.Action;
|
|
|
|
activate = l.Activate;
|
|
|
|
tag = l.Tag;
|
|
|
|
args = (int[])(l.Args.Clone());
|
|
|
|
fields = new UniFields(l.Fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Apply(Linedef l)
|
|
|
|
{
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.SidedefProperties)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
if ((front != null) && (l.Front != null)) front.Apply(l.Front);
|
|
|
|
if ((back != null) && (l.Back != null)) back.Apply(l.Back);
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.Flags)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
l.ClearFlags();
|
|
|
|
foreach (KeyValuePair<string, bool> f in flags)
|
|
|
|
l.SetFlag(f.Key, f.Value);
|
|
|
|
}
|
2014-05-08 09:24:32 +00:00
|
|
|
if(CopySettings.Activation) l.Activate = activate;
|
|
|
|
if(CopySettings.Tag) l.Tag = tag;
|
|
|
|
if(CopySettings.Action) l.Action = action;
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.Arguments)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
for(int i = 0; i < l.Args.Length; i++)
|
2014-04-09 10:16:33 +00:00
|
|
|
l.Args[i] = args[i];
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.Fields)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
l.Fields.BeforeFieldsChange();
|
|
|
|
l.Fields.Clear();
|
|
|
|
foreach (KeyValuePair<string, UniValue> v in fields)
|
|
|
|
l.Fields.Add(v.Key, new UniValue(v.Value));
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-08 09:24:32 +00:00
|
|
|
|
|
|
|
//mxd
|
|
|
|
public class ThingPropertiesCopySettings
|
|
|
|
{
|
|
|
|
[FieldDescription("Type")]
|
|
|
|
public bool Type = true;
|
|
|
|
[FieldDescription("Angle")]
|
|
|
|
public bool Angle = true;
|
|
|
|
[FieldDescription("Pitch")]
|
|
|
|
public bool Pitch = true;
|
|
|
|
[FieldDescription("Roll")]
|
|
|
|
public bool Roll = true;
|
|
|
|
[FieldDescription("Scale")]
|
|
|
|
public bool Scale = true;
|
|
|
|
[FieldDescription("Action")]
|
|
|
|
public bool Action = true;
|
|
|
|
[FieldDescription("Action Arguments")]
|
|
|
|
public bool Arguments = true;
|
|
|
|
[FieldDescription("Tag")]
|
|
|
|
public bool Tag = true;
|
|
|
|
[FieldDescription("Flags")]
|
|
|
|
public bool Flags = true;
|
|
|
|
[FieldDescription("Custom Fields")]
|
|
|
|
public bool Fields = true;
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Thing
|
|
|
|
public class ThingProperties
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
//mxd
|
|
|
|
public static ThingPropertiesCopySettings CopySettings = new ThingPropertiesCopySettings();
|
2014-04-09 10:16:33 +00:00
|
|
|
|
|
|
|
private readonly int type;
|
|
|
|
private readonly float angle;
|
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
|
|
|
private readonly int pitch; //mxd
|
|
|
|
private readonly int roll; //mxd
|
|
|
|
private readonly float scalex; //mxd
|
|
|
|
private readonly float scaley; //mxd
|
2014-04-09 10:16:33 +00:00
|
|
|
private readonly Dictionary<string, bool> flags;
|
|
|
|
private readonly int tag;
|
|
|
|
private readonly int action;
|
|
|
|
private readonly int[] args;
|
|
|
|
private readonly UniFields fields;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
public ThingProperties(Thing t)
|
|
|
|
{
|
|
|
|
type = t.Type;
|
|
|
|
angle = t.Angle;
|
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
|
|
|
pitch = t.Pitch;
|
|
|
|
roll = t.Roll;
|
|
|
|
scalex = t.ScaleX;
|
|
|
|
scaley = t.ScaleY;
|
2009-06-11 21:21:20 +00:00
|
|
|
flags = t.GetFlags();
|
2009-04-19 18:07:22 +00:00
|
|
|
tag = t.Tag;
|
Model rendering (all modes): UDMF scale, pitch and roll are now displayed.
Thing Edit Form, UDMF: added controls for setting pitch, roll, scale, render style, fill color, alpha, health and score.
Visual mode, UDMF: UDMF scale is now applied when rendering sprites.
Added Thing Statistics form (Edit -> View Thing Types...), which shows all loaded thing types with some additional info.
Visual mode: sprites with negative ScaleX and positive ScaleY were not rendered properly.
Classic modes: display was not updated after loading a sprite.
Current testing engine change was not saved on closing the program when no other game configuration settings were changed.
2014-04-30 10:01:22 +00:00
|
|
|
action = t.Action;
|
2009-04-19 18:07:22 +00:00
|
|
|
args = (int[])(t.Args.Clone());
|
2010-08-15 13:45:43 +00:00
|
|
|
fields = new UniFields(t.Fields);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Apply(Thing t)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if(CopySettings.Type) t.Type = type;
|
|
|
|
if(CopySettings.Angle) t.Rotate(angle);
|
|
|
|
if(CopySettings.Pitch) t.SetPitch(pitch);
|
|
|
|
if(CopySettings.Roll) t.SetRoll(roll);
|
|
|
|
if(CopySettings.Scale) t.SetScale(scalex, scaley);
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.Flags)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
t.ClearFlags();
|
|
|
|
foreach (KeyValuePair<string, bool> f in flags)
|
|
|
|
t.SetFlag(f.Key, f.Value);
|
|
|
|
}
|
2014-05-08 09:24:32 +00:00
|
|
|
if(CopySettings.Tag) t.Tag = tag;
|
|
|
|
if(CopySettings.Action) t.Action = action;
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.Arguments)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
for(int i = 0; i < t.Args.Length; i++)
|
2014-04-09 10:16:33 +00:00
|
|
|
t.Args[i] = args[i];
|
|
|
|
}
|
2014-12-03 23:15:26 +00:00
|
|
|
if(CopySettings.Fields)
|
|
|
|
{
|
2014-04-09 10:16:33 +00:00
|
|
|
t.Fields.BeforeFieldsChange();
|
|
|
|
t.Fields.Clear();
|
|
|
|
foreach (KeyValuePair<string, UniValue> v in fields)
|
|
|
|
t.Fields.Add(v.Key, new UniValue(v.Value));
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-08 09:24:32 +00:00
|
|
|
|
|
|
|
//mxd. A class, which checks whether source and target map element's properties match
|
|
|
|
public static class PropertiesComparer
|
|
|
|
{
|
|
|
|
|
|
|
|
#region Vertex
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
public static bool PropertiesMatch(VertexPropertiesCopySettings flags, Vertex source, Vertex target)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if(flags.ZCeiling && source.ZCeiling != target.ZCeiling) return false;
|
|
|
|
if(flags.ZFloor && source.ZFloor != target.ZFloor) return false;
|
|
|
|
return !flags.Fields || UDMFTools.FieldsMatch(source.Fields, target.Fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Sector
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
public static bool PropertiesMatch(SectorPropertiesCopySettings flags, Sector source, Sector target)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if(flags.FloorHeight && source.FloorHeight != target.FloorHeight) return false;
|
|
|
|
if(flags.CeilingHeight && source.CeilHeight != target.CeilHeight) return false;
|
|
|
|
if(flags.FloorTexture && source.FloorTexture != target.FloorTexture) return false;
|
|
|
|
if(flags.CeilingTexture && source.CeilTexture != target.CeilTexture) return false;
|
|
|
|
if(flags.Brightness && source.Brightness != target.Brightness) return false;
|
|
|
|
if(flags.Tag && source.Tag != target.Tag) return false;
|
|
|
|
if(flags.Special && source.Effect != target.Effect) return false;
|
|
|
|
if(flags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
|
|
|
|
return !flags.Fields || UDMFTools.FieldsMatch(source.Fields, target.Fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Linedef
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
public static bool PropertiesMatch(LinedefPropertiesCopySettings linedefflags, SidedefPropertiesCopySettings sideflags, Linedef source, Linedef target)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if(linedefflags.Action && source.Action != target.Action) return false;
|
|
|
|
if(linedefflags.Activation && source.Activate != target.Activate) return false;
|
|
|
|
if(linedefflags.Tag && source.Tag != target.Tag) return false;
|
2014-12-03 23:15:26 +00:00
|
|
|
if(linedefflags.Arguments)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < source.Args.Length; i++)
|
2014-05-08 09:24:32 +00:00
|
|
|
if(source.Args[i] != target.Args[i]) return false;
|
|
|
|
}
|
|
|
|
if(linedefflags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
|
2014-12-03 23:15:26 +00:00
|
|
|
if(linedefflags.SidedefProperties)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if ((source.Front == null && target.Front != null) || (source.Front != null && target.Front == null) ||
|
|
|
|
(source.Back == null && target.Back != null) || (source.Back != null && target.Back == null))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(source.Front != null && !PropertiesMatch(sideflags, source.Front, target.Front)) return false;
|
|
|
|
if(source.Back != null && !PropertiesMatch(sideflags, source.Back, target.Back)) return false;
|
|
|
|
}
|
|
|
|
return !linedefflags.Fields || UDMFTools.FieldsMatch(source.Fields, target.Fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Sidedef
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
public static bool PropertiesMatch(SidedefPropertiesCopySettings flags, Sidedef source, Sidedef target)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if(flags.OffsetX && source.OffsetX != target.OffsetX) return false;
|
|
|
|
if(flags.OffsetY && source.OffsetY != target.OffsetY) return false;
|
|
|
|
if(flags.UpperTexture && source.HighTexture != target.HighTexture) return false;
|
|
|
|
if(flags.MiddleTexture && source.MiddleTexture != target.MiddleTexture) return false;
|
|
|
|
if(flags.LowerTexture && source.LowTexture != target.LowTexture) return false;
|
|
|
|
if(flags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
|
|
|
|
return !flags.Fields || UDMFTools.FieldsMatch(source.Fields, target.Fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Thing
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
public static bool PropertiesMatch(ThingPropertiesCopySettings flags, Thing source, Thing target)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if(flags.Type && source.Type != target.Type) return false;
|
|
|
|
if(flags.Angle && source.AngleDoom != target.AngleDoom) return false;
|
|
|
|
if(flags.Action && source.Action != target.Action) return false;
|
2014-12-03 23:15:26 +00:00
|
|
|
if (flags.Arguments)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < source.Args.Length; i++)
|
2014-05-08 09:24:32 +00:00
|
|
|
if (source.Args[i] != target.Args[i]) return false;
|
|
|
|
}
|
|
|
|
if(flags.Tag && source.Tag != target.Tag) return false;
|
|
|
|
if(flags.Pitch && source.Pitch != target.Pitch) return false;
|
|
|
|
if(flags.Roll && source.Roll != target.Roll) return false;
|
|
|
|
if(flags.Scale && (source.ScaleX != target.ScaleX) || (source.ScaleY != target.ScaleY))
|
|
|
|
return false;
|
|
|
|
if(flags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false;
|
|
|
|
return !flags.Fields || UDMFTools.FieldsMatch(source.Fields, target.Fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2014-12-03 23:15:26 +00:00
|
|
|
private static bool FlagsMatch(Dictionary<string, bool> flags1, Dictionary<string, bool> flags2)
|
|
|
|
{
|
2014-05-08 09:24:32 +00:00
|
|
|
if (flags1.Count != flags2.Count) return false;
|
2014-12-03 23:15:26 +00:00
|
|
|
foreach (KeyValuePair<string, bool> group in flags1)
|
2014-05-08 09:24:32 +00:00
|
|
|
if (!flags2.ContainsKey(group.Key) || flags2[group.Key] != flags1[group.Key]) return false;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|