mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2024-11-10 06:41:49 +00:00
Added colormap rendering to Visual Mode (alpha value is ignored for now)
This commit is contained in:
parent
a609c3c565
commit
f69597c6d1
9 changed files with 92 additions and 40 deletions
|
@ -104,6 +104,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override Dictionary<int, int[]> VertexSlopeTypes { get { return vertexSlopeTypes; } }
|
||||
public override int SlopeVertexType { get { return 9500; } }
|
||||
public override int Custom3DFloorType { get { return 160; } }
|
||||
public override int ColormapType { get { return -1; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -104,6 +104,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override Dictionary<int, int[]> VertexSlopeTypes { get { return vertexSlopeTypes; } }
|
||||
public override int SlopeVertexType { get { return 9500; } }
|
||||
public override int Custom3DFloorType { get { return 160; } }
|
||||
public override int ColormapType { get { return -1; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -76,5 +76,6 @@ namespace CodeImp.DoomBuilder.IO
|
|||
Dictionary<int, int[]> VertexSlopeTypes { get; }
|
||||
int SlopeVertexType { get; }
|
||||
int Custom3DFloorType { get; }
|
||||
int ColormapType { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,6 +97,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public abstract Dictionary<int, int[]> VertexSlopeTypes { get; }
|
||||
public abstract int SlopeVertexType { get; }
|
||||
public abstract int Custom3DFloorType { get; }
|
||||
public abstract int ColormapType { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -142,6 +142,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override int SlopeVertexType { get { return 750; } }
|
||||
public override int MaxThingHeight { get { return 4095; } }
|
||||
public override int MinThingHeight { get { return 0; } }
|
||||
public override int ColormapType { get { return 606; } }
|
||||
#endregion
|
||||
|
||||
#region ================== Reading
|
||||
|
|
|
@ -154,6 +154,7 @@ namespace CodeImp.DoomBuilder.IO
|
|||
public override Dictionary<int, int[]> VertexSlopeTypes { get { return vertexSlopeTypes; } }
|
||||
public override int SlopeVertexType { get { return 9500; } }
|
||||
public override int Custom3DFloorType { get { return 160; } }
|
||||
public override int ColormapType { get { return -1; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -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 IsColormap { get { return Action == General.Map.FormatInterface.ColormapType; } }
|
||||
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
|
||||
public List<int> Tags { get { return tags; } set { BeforePropsChange(); tags = value; } } //mxd
|
||||
public float LengthSq { get { return lengthsq; } }
|
||||
|
@ -833,6 +834,25 @@ namespace CodeImp.DoomBuilder.Map
|
|||
return result;
|
||||
}
|
||||
|
||||
//Read color value from texture name (#RRGGBBA)
|
||||
public void ParseColor(string tex, out int color, out int alpha)
|
||||
{
|
||||
color = 0x000000;
|
||||
alpha = 255;
|
||||
if (tex.StartsWith("#") && tex.Length >= 7)
|
||||
{
|
||||
string colorString = tex.Substring(1,6);
|
||||
Regex r = new Regex("^[A-F0-9]*$");
|
||||
if (r.IsMatch(colorString)) color = Convert.ToInt32(colorString, 16);
|
||||
if (tex.Length == 8)
|
||||
{
|
||||
char alphaChar = tex.ToUpper()[7];
|
||||
if (alphaChar >= 'A' && alphaChar <= 'Z') alpha = (int)(((float)(alphaChar - 'A' + 10) / 25) * 255);
|
||||
else if (alphaChar >= '0' && alphaChar <= '9') alpha = (int)(((float)(alphaChar - '0') / 25) * 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Set slope arguments for SRB2-style slopes. See http://zdoom.org/wiki/Plane_Align.
|
||||
public void SetSlopeArgs()
|
||||
{
|
||||
|
|
|
@ -948,58 +948,83 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// MascaraSnake: Vertex slopes, SRB2-style
|
||||
if (General.Map.SRB2 && l.IsVertexSlope)
|
||||
if (General.Map.SRB2)
|
||||
{
|
||||
l.SetVertexSlopeArgs();
|
||||
bool slopefloor = l.Args[1] == 0;
|
||||
List<Thing> slopevertices = new List<Thing>(3);
|
||||
Sector s = (l.Args[0] == 0) ? l.Front.Sector : l.Back.Sector;
|
||||
|
||||
//If NOKNUCKLES is set, use tag, X offset and Y offset to search for slope vertices.
|
||||
if (l.IsFlagSet("8192"))
|
||||
//MascaraSnake: Colormap
|
||||
if (l.IsColormap && l.Front != null)
|
||||
{
|
||||
bool foundtag = false;
|
||||
bool foundxoffset = false;
|
||||
bool foundyoffset = false;
|
||||
foreach (Thing t in General.Map.Map.Things)
|
||||
int sectortag = l.Tag;
|
||||
int color;
|
||||
int alpha;
|
||||
l.ParseColor(l.Front.HighTexture, out color, out alpha);
|
||||
if (sectortags.ContainsKey(sectortag))
|
||||
{
|
||||
if (t.IsSlopeVertex)
|
||||
List<Sector> sectors = sectortags[sectortag];
|
||||
foreach (Sector s in sectors)
|
||||
{
|
||||
if (!foundtag && (int)t.AngleDoom == l.Tag)
|
||||
{
|
||||
slopevertices.Add(t);
|
||||
foundtag = true;
|
||||
}
|
||||
if (!foundxoffset && (int)t.AngleDoom == l.Front.OffsetX)
|
||||
{
|
||||
slopevertices.Add(t);
|
||||
foundxoffset = true;
|
||||
}
|
||||
if (!foundyoffset && (int)t.AngleDoom == l.Front.OffsetY)
|
||||
{
|
||||
slopevertices.Add(t);
|
||||
foundyoffset = true;
|
||||
}
|
||||
s.Fields.BeforeFieldsChange();
|
||||
if (s.Fields.ContainsKey("lightcolor")) s.Fields["lightcolor"] = new UniValue(UniversalType.Color, color);
|
||||
else s.Fields.Add("lightcolor", new UniValue(UniversalType.Color, color));
|
||||
//TODO: Find out why the alpha value is ignored.
|
||||
/*if (s.Fields.ContainsKey("lightalpha")) s.Fields["lightalpha"] = new UniValue(UniversalType.Integer, alpha);
|
||||
else s.Fields.Add("lightalpha", new UniValue(UniversalType.Integer, alpha));*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//Otherwise, just use tag.
|
||||
else
|
||||
|
||||
// MascaraSnake: Vertex slopes, SRB2-style
|
||||
if (l.IsVertexSlope)
|
||||
{
|
||||
foreach (Thing t in General.Map.Map.Things)
|
||||
l.SetVertexSlopeArgs();
|
||||
bool slopefloor = l.Args[1] == 0;
|
||||
List<Thing> slopevertices = new List<Thing>(3);
|
||||
Sector s = (l.Args[0] == 0) ? l.Front.Sector : l.Back.Sector;
|
||||
|
||||
//If NOKNUCKLES is set, use tag, X offset and Y offset to search for slope vertices.
|
||||
if (l.IsFlagSet("8192"))
|
||||
{
|
||||
if (t.IsSlopeVertex && (int)t.AngleDoom == l.Tag) slopevertices.Add(t);
|
||||
bool foundtag = false;
|
||||
bool foundxoffset = false;
|
||||
bool foundyoffset = false;
|
||||
foreach (Thing t in General.Map.Map.Things)
|
||||
{
|
||||
if (t.IsSlopeVertex)
|
||||
{
|
||||
if (!foundtag && (int)t.AngleDoom == l.Tag)
|
||||
{
|
||||
slopevertices.Add(t);
|
||||
foundtag = true;
|
||||
}
|
||||
if (!foundxoffset && (int)t.AngleDoom == l.Front.OffsetX)
|
||||
{
|
||||
slopevertices.Add(t);
|
||||
foundxoffset = true;
|
||||
}
|
||||
if (!foundyoffset && (int)t.AngleDoom == l.Front.OffsetY)
|
||||
{
|
||||
slopevertices.Add(t);
|
||||
foundyoffset = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//Otherwise, just use tag.
|
||||
else
|
||||
{
|
||||
foreach (Thing t in General.Map.Map.Things)
|
||||
{
|
||||
if (t.IsSlopeVertex && (int)t.AngleDoom == l.Tag) slopevertices.Add(t);
|
||||
}
|
||||
}
|
||||
if (slopevertices.Count >= 3)
|
||||
{
|
||||
SectorData sd = GetSectorData(s);
|
||||
sd.AddEffectSRB2ThingVertexSlope(slopevertices, slopefloor);
|
||||
}
|
||||
}
|
||||
if (slopevertices.Count >= 3)
|
||||
{
|
||||
SectorData sd = GetSectorData(s);
|
||||
sd.AddEffectSRB2ThingVertexSlope(slopevertices, slopefloor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// MascaraSnake: 3D floor handling
|
||||
// ========== Sector 3D floor (see http://zdoom.org/wiki/Sector_Set3dFloor) ==========
|
||||
if (l.Is3DFloor)
|
||||
|
|
|
@ -267,6 +267,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
bool fabs = sector.Fields.GetValue("lightfloorabsolute", false);
|
||||
int clight = sector.Fields.GetValue("lightceiling", 0);
|
||||
bool cabs = sector.Fields.GetValue("lightceilingabsolute", false);
|
||||
//int alpha = sector.Fields.GetValue("lightalpha", 255);
|
||||
|
||||
// Determine colors & light levels
|
||||
PixelColor lightcolor = PixelColor.FromInt(color);
|
||||
|
|
Loading…
Reference in a new issue