From e29f7af4275bd00185d1777a4920841ce3dff815 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Thu, 14 Jan 2016 23:33:17 +0100 Subject: [PATCH] Unflippable Thing types and Thing types where the Z position is ignored are now handled via the config --- Build/Configurations/Srb2-21slopeszb.cfg | 15 +++++++++++ Source/Core/Config/ThingCategory.cs | 21 +++++++++++---- Source/Core/Config/ThingTypeInfo.cs | 27 ++++++++++++++----- Source/Core/IO/DoomMapSetIO.cs | 1 - Source/Core/IO/HexenMapSetIO.cs | 1 - Source/Core/IO/IMapSetIO.cs | 1 - Source/Core/IO/MapSetIO.cs | 2 -- Source/Core/IO/SRB2MapSetIO.cs | 2 -- Source/Core/IO/UniversalMapSetIO.cs | 1 - Source/Core/Map/Thing.cs | 7 +---- .../VisualModes/BaseVisualThing.cs | 4 +-- 11 files changed, 55 insertions(+), 27 deletions(-) diff --git a/Build/Configurations/Srb2-21slopeszb.cfg b/Build/Configurations/Srb2-21slopeszb.cfg index 38014a9..8f56216 100644 --- a/Build/Configurations/Srb2-21slopeszb.cfg +++ b/Build/Configurations/Srb2-21slopeszb.cfg @@ -3281,12 +3281,14 @@ thingtypes sprite = "RINGA0"; width = 96; height = 192; + unflippable = true; } 605 { title = "Circle of Rings (Big)"; sprite = "RINGA0"; width = 192; + unflippable = true; } 606 { @@ -3294,12 +3296,14 @@ thingtypes sprite = "NWNGA0"; width = 96; height = 192; + unflippable = true; } 607 { title = "Circle of Wing Logos (Big)"; sprite = "NWNGA0"; width = 192; + unflippable = true; } 608 { @@ -3307,12 +3311,14 @@ thingtypes sprite = "NWNGA0"; width = 96; height = 192; + unflippable = true; } 609 { title = "Circle of Rings and Wings (Big)"; sprite = "NWNGA0"; width = 192; + unflippable = true; } } @@ -3831,6 +3837,7 @@ thingtypes sprite = "NBMPG3G7"; width = 32; height = 64; + unflippable = true; } 1705 { @@ -3839,6 +3846,7 @@ thingtypes sprite = "HOOPA0"; width = 80; height = 160; + unflippable = true; } 1706 { @@ -3892,6 +3900,7 @@ thingtypes sprite = "HOOPA0"; width = 80; height = 160; + unflippable = true; } } @@ -3908,16 +3917,22 @@ thingtypes title = "Axis"; sprite = "internal:axis1"; circle = 1; + unflippable = true; + ignoreZ = true; } 1701 { title = "Axis Transfer"; sprite = "internal:axis2"; + unflippable = true; + ignoreZ = true; } 1702 { title = "Axis Transfer Line"; sprite = "internal:axis3"; + unflippable = true; + ignoreZ = true; } 1710 { diff --git a/Source/Core/Config/ThingCategory.cs b/Source/Core/Config/ThingCategory.cs index c97f181..775da89 100644 --- a/Source/Core/Config/ThingCategory.cs +++ b/Source/Core/Config/ThingCategory.cs @@ -60,9 +60,11 @@ namespace CodeImp.DoomBuilder.Config private readonly bool absolutez; private readonly float spritescale; private readonly int heightoffset; - - // Disposing - private bool isdisposed; + private readonly bool isUnflippable; + private readonly bool ignoreZ; + + // Disposing + private bool isdisposed; //mxd. Validity private bool isinvalid; @@ -94,7 +96,8 @@ namespace CodeImp.DoomBuilder.Config public float SpriteScale { get { return spritescale; } } public List Things { get { return things; } } public int HeightOffset { get { return heightoffset; } } - + public bool IsUnflippable { get { return isUnflippable; } } + public bool IgnoreZ { get { return ignoreZ; } } #endregion #region ================== Constructor / Disposer @@ -127,7 +130,9 @@ namespace CodeImp.DoomBuilder.Config this.absolutez = parent.absolutez; this.spritescale = parent.spritescale; this.heightoffset = parent.heightoffset; - } + this.isUnflippable = parent.isUnflippable; + this.ignoreZ = parent.ignoreZ; + } // Set default properties else { @@ -147,6 +152,8 @@ namespace CodeImp.DoomBuilder.Config this.absolutez = false; this.spritescale = 1.0f; this.heightoffset = 0; + this.isUnflippable = false; + this.ignoreZ = false; } // We have no destructor @@ -203,6 +210,8 @@ namespace CodeImp.DoomBuilder.Config this.absolutez = cfg.ReadSetting("thingtypes." + name + ".absolutez", parent.absolutez); this.spritescale = cfg.ReadSetting("thingtypes." + name + ".spritescale", parent.spritescale); this.heightoffset = cfg.ReadSetting("thingtypes." + name + ".flags8height", parent.heightoffset); + this.isUnflippable = cfg.ReadSetting("thingtypes." + name + ".unflippable", parent.isUnflippable); + this.ignoreZ = cfg.ReadSetting("thingtypes." + name + ".ignoreZ", parent.ignoreZ); } else { @@ -222,6 +231,8 @@ namespace CodeImp.DoomBuilder.Config this.absolutez = cfg.ReadSetting("thingtypes." + name + ".absolutez", false); this.spritescale = cfg.ReadSetting("thingtypes." + name + ".spritescale", 1.0f); this.heightoffset = cfg.ReadSetting("thingtypes." + name + ".flags8height", 0); + this.isUnflippable = cfg.ReadSetting("thingtypes." + name + ".unflippable", false); + this.ignoreZ = cfg.ReadSetting("thingtypes." + name + ".ignoreZ", false); } // Safety diff --git a/Source/Core/Config/ThingTypeInfo.cs b/Source/Core/Config/ThingTypeInfo.cs index 1303064..e336735 100644 --- a/Source/Core/Config/ThingTypeInfo.cs +++ b/Source/Core/Config/ThingTypeInfo.cs @@ -76,9 +76,11 @@ namespace CodeImp.DoomBuilder.Config private string obsoletemessage; //mxd private IDictionary flags; private int heightoffset; + private bool isUnflippable; + private bool ignoreZ; - //mxd. GLOOME rendering settings - private Thing.SpriteRenderMode rendermode; + //mxd. GLOOME rendering settings + private Thing.SpriteRenderMode rendermode; private bool rollsprite; private bool sticktoplane; @@ -121,7 +123,8 @@ namespace CodeImp.DoomBuilder.Config public bool RollSprite { get { return rollsprite; } } public bool StickToPlane { get { return sticktoplane; } } public int HeightOffset { get { return heightoffset; } } - + public bool IsUnflippable { get { return isUnflippable; } } + public bool IgnoreZ { get { return ignoreZ; } } #endregion #region ================== Constructor / Disposer @@ -158,9 +161,11 @@ namespace CodeImp.DoomBuilder.Config this.locksprite = false; //mxd this.flags = new Dictionary(); this.heightoffset = 0; - - // We have no destructor - GC.SuppressFinalize(this); + this.isUnflippable = false; + this.ignoreZ = false; + + // We have no destructor + GC.SuppressFinalize(this); } // Constructor @@ -199,6 +204,8 @@ namespace CodeImp.DoomBuilder.Config this.flags = new Dictionary(cat.Flags); ReadThingSpecificFlags(cfg); this.heightoffset = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".flags8height", cat.HeightOffset); + this.isUnflippable = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".unflippable", cat.IsUnflippable); + this.ignoreZ = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".ignoreZ", cat.IgnoreZ); // Read the args for (int i = 0; i < Linedef.NUM_ARGS; i++) @@ -252,6 +259,8 @@ namespace CodeImp.DoomBuilder.Config this.flags = new Dictionary(cat.Flags); ReadThingSpecificFlags(cfg); this.heightoffset = cat.HeightOffset; + this.isUnflippable = cat.IsUnflippable; + this.ignoreZ = cat.IgnoreZ; // Safety if (this.radius < 4f) this.radius = 8f; @@ -299,6 +308,8 @@ namespace CodeImp.DoomBuilder.Config this.spritescale = new SizeF(cat.SpriteScale, cat.SpriteScale); this.flags = new Dictionary(cat.Flags); this.heightoffset = cat.HeightOffset; + this.isUnflippable = cat.IsUnflippable; + this.ignoreZ = cat.IgnoreZ; // Safety if (this.radius < 4f) this.radius = 8f; @@ -343,6 +354,8 @@ namespace CodeImp.DoomBuilder.Config this.spritescale = new SizeF(cat.SpriteScale, cat.SpriteScale); this.flags = new Dictionary(cat.Flags); this.heightoffset = cat.HeightOffset; + this.isUnflippable = cat.IsUnflippable; + this.ignoreZ = cat.IgnoreZ; // Safety if (this.radius < 4f) this.radius = 8f; @@ -389,6 +402,8 @@ namespace CodeImp.DoomBuilder.Config this.spritescale = new SizeF(other.spritescale.Width, other.spritescale.Height); this.flags = new Dictionary(other.flags); this.heightoffset = other.heightoffset; + this.isUnflippable = other.isUnflippable; + this.ignoreZ = other.ignoreZ; //mxd. Copy GLOOME properties this.rendermode = other.rendermode; diff --git a/Source/Core/IO/DoomMapSetIO.cs b/Source/Core/IO/DoomMapSetIO.cs index 344dc9a..353d4f0 100644 --- a/Source/Core/IO/DoomMapSetIO.cs +++ b/Source/Core/IO/DoomMapSetIO.cs @@ -47,7 +47,6 @@ namespace CodeImp.DoomBuilder.IO slopeCopyTypes = new Dictionary() { { 118, new int[2] { -1, -1 } } }; vertexSlopeTypes = new Dictionary() { }; translucentLineTypes = new Dictionary() { { 208, -1.0f } }; - unflippableTypes = new List(); startTypes = new List(); centerHitboxTypes = new List(); } diff --git a/Source/Core/IO/HexenMapSetIO.cs b/Source/Core/IO/HexenMapSetIO.cs index 292609a..a985656 100644 --- a/Source/Core/IO/HexenMapSetIO.cs +++ b/Source/Core/IO/HexenMapSetIO.cs @@ -47,7 +47,6 @@ namespace CodeImp.DoomBuilder.IO slopeCopyTypes = new Dictionary() { { 118, new int[2] { -1, -1 } } }; vertexSlopeTypes = new Dictionary() { }; translucentLineTypes = new Dictionary() { { 208, -1.0f } }; - unflippableTypes = new List(); startTypes = new List(); centerHitboxTypes = new List(); } diff --git a/Source/Core/IO/IMapSetIO.cs b/Source/Core/IO/IMapSetIO.cs index b3cb188..2bdcb14 100644 --- a/Source/Core/IO/IMapSetIO.cs +++ b/Source/Core/IO/IMapSetIO.cs @@ -82,7 +82,6 @@ namespace CodeImp.DoomBuilder.IO int AxisType { get; } int AxisTransferType { get; } int AxisTransferLineType { get; } - List UnflippableTypes { get; } List StartTypes { get; } List CenterHitboxTypes { get; } } diff --git a/Source/Core/IO/MapSetIO.cs b/Source/Core/IO/MapSetIO.cs index b7d514b..bd48927 100644 --- a/Source/Core/IO/MapSetIO.cs +++ b/Source/Core/IO/MapSetIO.cs @@ -50,7 +50,6 @@ namespace CodeImp.DoomBuilder.IO protected Dictionary slopeCopyTypes; protected Dictionary vertexSlopeTypes; protected Dictionary translucentLineTypes; - protected List unflippableTypes; protected List startTypes; protected List centerHitboxTypes; #endregion @@ -111,7 +110,6 @@ namespace CodeImp.DoomBuilder.IO public abstract int AxisType { get; } public abstract int AxisTransferType { get; } public abstract int AxisTransferLineType { get; } - public List UnflippableTypes { get { return unflippableTypes; } } public List StartTypes { get { return startTypes; } } public List CenterHitboxTypes { get { return centerHitboxTypes; } } #endregion diff --git a/Source/Core/IO/SRB2MapSetIO.cs b/Source/Core/IO/SRB2MapSetIO.cs index a7c4931..cf8da7e 100644 --- a/Source/Core/IO/SRB2MapSetIO.cs +++ b/Source/Core/IO/SRB2MapSetIO.cs @@ -143,8 +143,6 @@ namespace CodeImp.DoomBuilder.IO { 908, 0.1f }, }; - unflippableTypes = new List() { 604, 605, 606, 607, 608, 609, 1700, 1701, 1702, 1704, 1705, 1713 }; - startTypes = new List() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35 }; centerHitboxTypes = new List() { 604, 605, 606, 607, 608, 609, 1705, 1713 }; diff --git a/Source/Core/IO/UniversalMapSetIO.cs b/Source/Core/IO/UniversalMapSetIO.cs index 733b02f..44e5fff 100644 --- a/Source/Core/IO/UniversalMapSetIO.cs +++ b/Source/Core/IO/UniversalMapSetIO.cs @@ -52,7 +52,6 @@ namespace CodeImp.DoomBuilder.IO slopeCopyTypes = new Dictionary() { { 118, new int[2] { -1, -1 } } }; vertexSlopeTypes = new Dictionary() { }; translucentLineTypes = new Dictionary() { { 208, -1.0f } }; - unflippableTypes = new List(); startTypes = new List(); centerHitboxTypes = new List(); diff --git a/Source/Core/Map/Thing.cs b/Source/Core/Map/Thing.cs index 9564da8..c1142d7 100644 --- a/Source/Core/Map/Thing.cs +++ b/Source/Core/Map/Thing.cs @@ -129,13 +129,8 @@ namespace CodeImp.DoomBuilder.Map } } public bool IsReverse { get { return General.Map.SRB2 && !Unflippable && IsFlagSet("2"); } } - public bool Unflippable { get { return General.Map.FormatInterface.UnflippableTypes.Contains(Type); } } + public bool Unflippable { get { return General.Map.Data.GetThingInfo(Type).IsUnflippable; } } public bool CenterHitbox { get { return General.Map.FormatInterface.CenterHitboxTypes.Contains(Type); } } - public bool IsNiGHTSPathItem { get { return General.Map.FormatInterface.AxisType == Type - || General.Map.FormatInterface.AxisTransferType == Type - || General.Map.FormatInterface.AxisTransferLineType == Type; - } - } #endregion #region ================== Constructor / Disposer diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs index a96a74d..3ae98ad 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualThing.cs @@ -428,7 +428,7 @@ namespace CodeImp.DoomBuilder.BuilderModes pos.z = sd.Floor.sector.FloorHeight + Thing.Position.z - Thing.Height/2; } } - else if (Thing.IsNiGHTSPathItem) + else if (info.IgnoreZ) { //Z position is always 0. if (Thing.Sector != null) @@ -828,7 +828,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // Raise/lower thing public void OnChangeTargetHeight(int amount) { - if (Thing.IsNiGHTSPathItem) return; //NiGHTS path items have no height. + if (info.IgnoreZ) return; if(General.Map.FormatInterface.HasThingHeight) {