From a3f2f131a194f6ed3fc2e05cd9a4dcc55c932cb4 Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Mon, 4 Jan 2016 20:26:34 +0100 Subject: [PATCH] Render translucent walls in Visual Mode --- Source/Core/IO/DoomMapSetIO.cs | 9 ++++++--- Source/Core/IO/HexenMapSetIO.cs | 3 +++ Source/Core/IO/IMapSetIO.cs | 1 + Source/Core/IO/MapSetIO.cs | 1 + Source/Core/IO/SRB2MapSetIO.cs | 13 +++++++++++++ Source/Core/IO/UniversalMapSetIO.cs | 3 +++ Source/Core/Map/Linedef.cs | 10 ++++++++++ .../VisualModes/BaseVisualGeometrySidedef.cs | 3 ++- 8 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Source/Core/IO/DoomMapSetIO.cs b/Source/Core/IO/DoomMapSetIO.cs index 3e738ce..d238b1e 100644 --- a/Source/Core/IO/DoomMapSetIO.cs +++ b/Source/Core/IO/DoomMapSetIO.cs @@ -39,6 +39,7 @@ namespace CodeImp.DoomBuilder.IO protected Dictionary slopeTypes; protected Dictionary slopeCopyTypes; protected Dictionary vertexSlopeTypes; + protected Dictionary translucentLineTypes; #endregion #region ================== Constructor / Disposer @@ -50,13 +51,14 @@ namespace CodeImp.DoomBuilder.IO slopeTypes = new Dictionary() { { 181, new int[2] { -1, -1 } } }; slopeCopyTypes = new Dictionary() { { 118, new int[2] { -1, -1 } } }; vertexSlopeTypes = new Dictionary() { }; + translucentLineTypes = new Dictionary() { { 208, -1.0f } }; } - #endregion + #endregion - #region ================== Properties + #region ================== Properties - public override int MaxSidedefs { get { return ushort.MaxValue; } } + public override int MaxSidedefs { get { return ushort.MaxValue; } } public override int MaxVertices { get { return ushort.MaxValue; } } public override int MaxLinedefs { get { return ushort.MaxValue; } } public override int MaxSectors { get { return ushort.MaxValue; } } @@ -102,6 +104,7 @@ namespace CodeImp.DoomBuilder.IO public override Dictionary SlopeTypes { get { return slopeTypes; } } public override Dictionary SlopeCopyTypes { get { return slopeCopyTypes; } } public override Dictionary VertexSlopeTypes { get { return vertexSlopeTypes; } } + public override Dictionary TranslucentLineTypes { get { return translucentLineTypes; } } public override int SlopeVertexType { get { return 9500; } } public override int Custom3DFloorType { get { return 160; } } public override int ColormapType { get { return -1; } } diff --git a/Source/Core/IO/HexenMapSetIO.cs b/Source/Core/IO/HexenMapSetIO.cs index c76b9cf..a559c16 100644 --- a/Source/Core/IO/HexenMapSetIO.cs +++ b/Source/Core/IO/HexenMapSetIO.cs @@ -39,6 +39,7 @@ namespace CodeImp.DoomBuilder.IO protected Dictionary slopeTypes; protected Dictionary slopeCopyTypes; protected Dictionary vertexSlopeTypes; + protected Dictionary translucentLineTypes; #endregion #region ================== Constructor / Disposer @@ -50,6 +51,7 @@ namespace CodeImp.DoomBuilder.IO slopeTypes = new Dictionary() { { 181, new int[2] { -1, -1 } } }; slopeCopyTypes = new Dictionary() { { 118, new int[2] { -1, -1 } } }; vertexSlopeTypes = new Dictionary() { }; + translucentLineTypes = new Dictionary() { { 208, -1.0f } }; } #endregion @@ -102,6 +104,7 @@ namespace CodeImp.DoomBuilder.IO public override Dictionary SlopeTypes { get { return slopeTypes; } } public override Dictionary SlopeCopyTypes { get { return slopeCopyTypes; } } public override Dictionary VertexSlopeTypes { get { return vertexSlopeTypes; } } + public override Dictionary TranslucentLineTypes { get { return translucentLineTypes; } } public override int SlopeVertexType { get { return 9500; } } public override int Custom3DFloorType { get { return 160; } } public override int ColormapType { get { return -1; } } diff --git a/Source/Core/IO/IMapSetIO.cs b/Source/Core/IO/IMapSetIO.cs index e1387bf..e47fc95 100644 --- a/Source/Core/IO/IMapSetIO.cs +++ b/Source/Core/IO/IMapSetIO.cs @@ -74,6 +74,7 @@ namespace CodeImp.DoomBuilder.IO Dictionary SlopeTypes { get; } Dictionary SlopeCopyTypes { get; } Dictionary VertexSlopeTypes { get; } + Dictionary TranslucentLineTypes { get; } int SlopeVertexType { get; } int Custom3DFloorType { get; } int ColormapType { get; } diff --git a/Source/Core/IO/MapSetIO.cs b/Source/Core/IO/MapSetIO.cs index cf5935d..824ac0b 100644 --- a/Source/Core/IO/MapSetIO.cs +++ b/Source/Core/IO/MapSetIO.cs @@ -95,6 +95,7 @@ namespace CodeImp.DoomBuilder.IO public abstract Dictionary SlopeTypes { get; } public abstract Dictionary SlopeCopyTypes { get; } public abstract Dictionary VertexSlopeTypes { get; } + public abstract Dictionary TranslucentLineTypes { get; } public abstract int SlopeVertexType { get; } public abstract int Custom3DFloorType { get; } public abstract int ColormapType { get; } diff --git a/Source/Core/IO/SRB2MapSetIO.cs b/Source/Core/IO/SRB2MapSetIO.cs index f10e334..a0b42f6 100644 --- a/Source/Core/IO/SRB2MapSetIO.cs +++ b/Source/Core/IO/SRB2MapSetIO.cs @@ -130,6 +130,19 @@ namespace CodeImp.DoomBuilder.IO { 714, new int[2] { 1, 0 } }, { 715, new int[2] { 1, 1 } }, }; + + translucentLineTypes = new Dictionary() { + { 900, 0.9f }, + { 901, 0.8f }, + { 902, 0.7f }, + { 903, 0.6f }, + { 904, 0.5f }, + { 905, 0.4f }, + { 906, 0.3f }, + { 907, 0.2f }, + { 908, 0.1f }, + }; + } #endregion diff --git a/Source/Core/IO/UniversalMapSetIO.cs b/Source/Core/IO/UniversalMapSetIO.cs index a1045e5..6df82d7 100644 --- a/Source/Core/IO/UniversalMapSetIO.cs +++ b/Source/Core/IO/UniversalMapSetIO.cs @@ -42,6 +42,7 @@ namespace CodeImp.DoomBuilder.IO protected Dictionary slopeTypes; protected Dictionary slopeCopyTypes; protected Dictionary vertexSlopeTypes; + protected Dictionary translucentLineTypes; #endregion #region ================== Constructor / Disposer @@ -55,6 +56,7 @@ namespace CodeImp.DoomBuilder.IO slopeTypes = new Dictionary() { { 181, new int[2] { -1, -1 } } }; slopeCopyTypes = new Dictionary() { { 118, new int[2] { -1, -1 } } }; vertexSlopeTypes = new Dictionary() { }; + translucentLineTypes = new Dictionary() { { 208, -1.0f } }; // Make configuration Configuration config = new Configuration(); @@ -152,6 +154,7 @@ namespace CodeImp.DoomBuilder.IO public override Dictionary SlopeTypes { get { return slopeTypes; } } public override Dictionary SlopeCopyTypes { get { return slopeCopyTypes; } } public override Dictionary VertexSlopeTypes { get { return vertexSlopeTypes; } } + public override Dictionary TranslucentLineTypes { get { return translucentLineTypes; } } public override int SlopeVertexType { get { return 9500; } } public override int Custom3DFloorType { get { return 160; } } public override int ColormapType { get { return -1; } } diff --git a/Source/Core/Map/Linedef.cs b/Source/Core/Map/Linedef.cs index 1b366e3..40e8983 100644 --- a/Source/Core/Map/Linedef.cs +++ b/Source/Core/Map/Linedef.cs @@ -95,6 +95,7 @@ namespace CodeImp.DoomBuilder.Map public bool IsSlope { get { return General.Map.FormatInterface.SlopeTypes.ContainsKey(Action); } } public bool IsSlopeCopy { get { return General.Map.FormatInterface.SlopeCopyTypes.ContainsKey(Action); } } public bool IsVertexSlope { get { return General.Map.FormatInterface.VertexSlopeTypes.ContainsKey(Action); } } + public bool IsTranslucentLine { get { return General.Map.FormatInterface.TranslucentLineTypes.ContainsKey(Action); } } public bool IsColormap { get { return Action == General.Map.FormatInterface.ColormapType; } } public bool IsFlatAlignment { get { return Action == General.Map.FormatInterface.FlatAlignmentType; } } public int Tag { get { return tags[0]; } set { BeforePropsChange(); tags[0] = value; if((value < General.Map.FormatInterface.MinTag) || (value > General.Map.FormatInterface.MaxTag)) throw new ArgumentOutOfRangeException("Tag", "Invalid tag number"); } } //mxd @@ -895,6 +896,15 @@ namespace CodeImp.DoomBuilder.Map Args[1] = settings[1]; } + //Set translucent line arguments for SRB2-style translucent walls. See http://zdoom.org/wiki/TranslucentLine. + public void SetTranslucentLineArgs() + { + Args[0] = 0; //lineid (irrelevant for SRB2) + Args[1] = (int)(General.Map.FormatInterface.TranslucentLineTypes[Action]*255); //amount + Args[2] = 0; //additive + Args[3] = 0; //moreflags (irrelevant for SRB2) + } + // This checks and returns a flag without creating it public bool IsFlagSet(string flagname) { diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs index 907526b..0333525 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs @@ -104,8 +104,9 @@ namespace CodeImp.DoomBuilder.BuilderModes bool canhavealpha = (this is VisualMiddleDouble || this is VisualMiddle3D || this is VisualMiddleBack); //mxd // From TranslucentLine action - if(Sidedef.Line.Action == 208) + if(Sidedef.Line.IsTranslucentLine) { + if (!General.Map.FormatInterface.HasLinedefParameters) Sidedef.Line.SetTranslucentLineArgs(); alpha = (byte)General.Clamp(Sidedef.Line.Args[1], 0, 255); if(canhavealpha && Sidedef.Line.Args[2] == 1)