mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
Updated, GLDEFS parser: updated glowing texture parsing logic to better match GZDoom logic.
Removed, GLDEFS parser: removed GLOOME glow definitions support code.
This commit is contained in:
parent
fc9d18b9bc
commit
437fe9ce86
9 changed files with 58 additions and 91 deletions
|
@ -8,8 +8,6 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
public int Height;
|
||||
public int Brightness = 255;
|
||||
public bool Fullbright;
|
||||
public bool Fullblack; // GLOOME only
|
||||
public bool Subtractive; // GLOOME only
|
||||
public bool CalculateTextureColor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -579,11 +579,12 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
while(SkipWhitespace(true))
|
||||
{
|
||||
token = ReadToken();
|
||||
token = StripQuotes(ReadToken(false));
|
||||
if(string.IsNullOrEmpty(token)) continue;
|
||||
if(token == "}") break;
|
||||
|
||||
// Add glow data
|
||||
long flatnamehash = General.Map.Data.GetFullLongFlatName(Lump.MakeLongName(token, General.Map.Options.UseLongTextureNames));
|
||||
// Add glow data. Hash the name exactly as given.
|
||||
long flatnamehash = Lump.MakeLongName(token, true);
|
||||
glowingflats[flatnamehash] = new GlowingFlatData
|
||||
{
|
||||
Height = DEFAULT_GLOW_HEIGHT * 2,
|
||||
|
@ -594,43 +595,16 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
}
|
||||
break;
|
||||
|
||||
case "subwalls":
|
||||
case "subflats":
|
||||
if(!NextTokenIs("{", false))
|
||||
{
|
||||
ReportError("Expected opening brace");
|
||||
return false;
|
||||
}
|
||||
|
||||
while(SkipWhitespace(true))
|
||||
{
|
||||
token = ReadToken();
|
||||
if(token == "}") break;
|
||||
|
||||
// Add glow data
|
||||
long flatnamehash = General.Map.Data.GetFullLongFlatName(Lump.MakeLongName(token, General.Map.Options.UseLongTextureNames));
|
||||
glowingflats[flatnamehash] = new GlowingFlatData
|
||||
{
|
||||
Height = DEFAULT_GLOW_HEIGHT * 2,
|
||||
Fullblack = true,
|
||||
Subtractive = true,
|
||||
Color = new PixelColor(255, 0, 0, 0),
|
||||
CalculateTextureColor = false
|
||||
};
|
||||
}
|
||||
break;
|
||||
|
||||
case "subtexture":
|
||||
case "texture":
|
||||
{
|
||||
int color;
|
||||
PixelColor color = new PixelColor();
|
||||
int glowheight = DEFAULT_GLOW_HEIGHT;
|
||||
bool subtractivetexture = (token == "subtexture");
|
||||
string texturename = StripQuotes(ReadToken(false));
|
||||
string texturename;
|
||||
|
||||
if(!ReadTextureName(out texturename)) return false;
|
||||
if(string.IsNullOrEmpty(texturename))
|
||||
{
|
||||
ReportError("expected " + token + " name");
|
||||
ReportError("Expected " + token + " name");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -643,25 +617,16 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
// Next is color
|
||||
SkipWhitespace(true);
|
||||
token = ReadToken();
|
||||
token = ReadToken(false);
|
||||
|
||||
if(!int.TryParse(token, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out color))
|
||||
if(!GetColorFromString(token, ref color))
|
||||
{
|
||||
//probably it's a color name?
|
||||
Color c = Color.FromName(token); //should be similar to C++ color name detection, I suppose
|
||||
if(c.IsKnownColor)
|
||||
{
|
||||
color = PixelColor.FromColor(c).ToInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportError("expected glow color value, but got \"" + token + "\"");
|
||||
return false;
|
||||
}
|
||||
ReportError("Expected glow color value, but got \"" + token + "\"");
|
||||
return false;
|
||||
}
|
||||
|
||||
// The glow data is valid at thispoint. Let's get texture hash
|
||||
long texturehash = General.Map.Data.GetFullLongFlatName(Lump.MakeLongName(texturename, General.Map.Options.UseLongTextureNames));
|
||||
// The glow data is valid at thispoint. Hash the name exactly as given.
|
||||
long texturehash = Lump.MakeLongName(texturename, true);
|
||||
|
||||
// Now we can find a comma
|
||||
if(!NextTokenIs(",", false))
|
||||
|
@ -670,8 +635,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
glowingflats[texturehash] = new GlowingFlatData
|
||||
{
|
||||
Height = glowheight * 2,
|
||||
Subtractive = subtractivetexture,
|
||||
Color = PixelColor.FromInt(color).WithAlpha(255),
|
||||
Color = color.WithAlpha(255),
|
||||
CalculateTextureColor = false
|
||||
};
|
||||
continue;
|
||||
|
@ -694,8 +658,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
glowingflats[texturehash] = new GlowingFlatData
|
||||
{
|
||||
Height = glowheight * 2,
|
||||
Subtractive = subtractivetexture,
|
||||
Color = PixelColor.FromInt(color).WithAlpha(255),
|
||||
Color = color.WithAlpha(255),
|
||||
CalculateTextureColor = false
|
||||
};
|
||||
continue;
|
||||
|
@ -706,14 +669,10 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
token = ReadToken().ToLowerInvariant();
|
||||
}
|
||||
|
||||
// Next is "fullbright" or "fullblack" flag
|
||||
bool fullbright = (token == "fullbright");
|
||||
bool fullblack = (!subtractivetexture && token == "fullblack");
|
||||
|
||||
if(!fullblack && !fullbright)
|
||||
// Next must be "fullbright" flag
|
||||
if(token != "fullbright")
|
||||
{
|
||||
string expectedflags = (subtractivetexture ? "\"fullbright\"" : "\"fullbright\" or \"fullblack\"");
|
||||
ReportError("expected " + expectedflags + " flag, but got \"" + token + "\"");
|
||||
ReportError("Expected \"fullbright\" flag, but got \"" + token + "\"");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -721,10 +680,8 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
glowingflats[texturehash] = new GlowingFlatData
|
||||
{
|
||||
Height = glowheight * 2,
|
||||
Fullbright = fullbright,
|
||||
Fullblack = fullblack,
|
||||
Subtractive = subtractivetexture,
|
||||
Color = PixelColor.FromInt(color).WithAlpha(255),
|
||||
Fullbright = true,
|
||||
Color = color.WithAlpha(255),
|
||||
CalculateTextureColor = false
|
||||
};
|
||||
}
|
||||
|
@ -739,8 +696,9 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
private bool ParseSkybox()
|
||||
{
|
||||
SkipWhitespace(true);
|
||||
string name = StripQuotes(ReadToken());
|
||||
string name;
|
||||
|
||||
if(!ReadTextureName(out name)) return false;
|
||||
if(string.IsNullOrEmpty(name))
|
||||
{
|
||||
ReportError("Expected skybox name");
|
||||
|
|
|
@ -84,7 +84,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
// First token is the class name
|
||||
parser.SkipWhitespace(true);
|
||||
name = parser.StripTokenQuotes(parser.ReadToken(false)); //mxd. Don't skip newline
|
||||
if(!parser.ReadTextureName(out name, "patch")) return; //mxd
|
||||
if(string.IsNullOrEmpty(name))
|
||||
{
|
||||
parser.ReportError("Expected patch name");
|
||||
|
|
|
@ -9,7 +9,7 @@ using CodeImp.DoomBuilder.Data;
|
|||
//mxd. Parser used to determine which script type given text is.
|
||||
namespace CodeImp.DoomBuilder.ZDoom.Scripting
|
||||
{
|
||||
internal sealed class ScriptTypeParserSE :ZDTextParser
|
||||
internal sealed class ScriptTypeParserSE : ZDTextParser
|
||||
{
|
||||
internal override ScriptType ScriptType { get { return scripttype; } }
|
||||
private ScriptType scripttype;
|
||||
|
|
|
@ -86,14 +86,14 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
// First token is the texture name
|
||||
parser.SkipWhitespace(true);
|
||||
name = parser.StripTokenQuotes(parser.ReadToken(false)); //mxd. Don't skip newline
|
||||
if(!parser.ReadTextureName(out name, typename)) return; //mxd
|
||||
|
||||
//mxd. It can also be "optional" keyword.
|
||||
if(name.ToLowerInvariant() == "optional")
|
||||
{
|
||||
optional = true;
|
||||
parser.SkipWhitespace(true);
|
||||
name = parser.StripTokenQuotes(parser.ReadToken(false)); //mxd. Don't skip newline
|
||||
if(!parser.ReadTextureName(out name, typename)) return; //mxd
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(name))
|
||||
|
|
|
@ -215,6 +215,24 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
return token;
|
||||
}
|
||||
|
||||
//mxd
|
||||
internal bool ReadTextureName(out string name) { return ReadTextureName(out name, "texture"); }
|
||||
internal bool ReadTextureName(out string name, string elementname)
|
||||
{
|
||||
string token = ReadToken(false);
|
||||
name = StripQuotes(token);
|
||||
|
||||
if(!string.IsNullOrEmpty(name)
|
||||
&& name.Length > DataManager.CLASIC_IMAGE_NAME_LENGTH
|
||||
&& name.Length == token.Length)
|
||||
{
|
||||
ReportError("Long " + elementname + " names must be quoted. See \"" + token + "\"");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// This skips whitespace on the stream, placing the read
|
||||
// position right before the first non-whitespace character
|
||||
// Returns false when the end of the stream is reached
|
||||
|
|
|
@ -340,10 +340,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
//mxd. Apply GLDEFS override?
|
||||
if(General.Map.Data.GlowingFlats.ContainsKey(s.LongFloorTexture)
|
||||
&& (General.Map.Data.GlowingFlats[s.LongFloorTexture].Fullbright || General.Map.Data.GlowingFlats[s.LongFloorTexture].Fullblack))
|
||||
&& General.Map.Data.GlowingFlats[s.LongFloorTexture].Fullbright)
|
||||
{
|
||||
color = -1;
|
||||
light = (General.Map.Data.GlowingFlats[s.LongFloorTexture].Fullbright ? 255 : 0);
|
||||
light = 255;
|
||||
absolute = true;
|
||||
}
|
||||
else
|
||||
|
@ -392,10 +392,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
//mxd. Apply GLDEFS override?
|
||||
if(General.Map.Data.GlowingFlats.ContainsKey(s.LongCeilTexture)
|
||||
&& (General.Map.Data.GlowingFlats[s.LongCeilTexture].Fullbright || General.Map.Data.GlowingFlats[s.LongCeilTexture].Fullblack))
|
||||
&& General.Map.Data.GlowingFlats[s.LongCeilTexture].Fullbright)
|
||||
{
|
||||
color = -1;
|
||||
light = (General.Map.Data.GlowingFlats[s.LongCeilTexture].Fullbright ? 255 : 0);
|
||||
light = 255;
|
||||
absolute = true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -303,8 +303,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
float cz = data.Ceiling.plane.GetZ(v.x, v.y);
|
||||
float delta = 1.0f - (((v.z - cgz) / (cz - cgz)) * 0.9f);
|
||||
PixelColor vc = PixelColor.FromInt(v.c);
|
||||
v.c = InterpolationTools.InterpolateColor(GetGlowColor(data.CeilingGlow, vc), vc, delta).WithAlpha(255).ToInt();
|
||||
PixelColor vertexcolor = PixelColor.FromInt(v.c);
|
||||
PixelColor glowcolor = PixelColor.Add(vertexcolor, data.CeilingGlow.Color);
|
||||
v.c = InterpolationTools.InterpolateColor(glowcolor, vertexcolor, delta).WithAlpha(255).ToInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,21 +319,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
float fz = data.Floor.plane.GetZ(v.x, v.y);
|
||||
float delta = 1.0f - (((v.z - fz) / (fgz - fz)) * 0.9f);
|
||||
PixelColor vc = PixelColor.FromInt(v.c);
|
||||
v.c = InterpolationTools.InterpolateColor(vc, GetGlowColor(data.FloorGlow, vc), delta).WithAlpha(255).ToInt();
|
||||
PixelColor vertexcolor = PixelColor.FromInt(v.c);
|
||||
PixelColor glowcolor = PixelColor.Add(vertexcolor, data.FloorGlow.Color);
|
||||
v.c = InterpolationTools.InterpolateColor(vertexcolor, glowcolor, delta).WithAlpha(255).ToInt();
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
//mxd
|
||||
private static PixelColor GetGlowColor(GlowingFlatData data, PixelColor vertexcolor)
|
||||
{
|
||||
if(data.Subtractive) return PixelColor.Subtract(vertexcolor, data.Color);
|
||||
return PixelColor.Add(vertexcolor, data.Color);
|
||||
}
|
||||
|
||||
// This splits a polygon with a plane and returns the other part as a new polygon
|
||||
// The polygon is expected to be convex and clockwise
|
||||
protected static WallPolygon SplitPoly(ref WallPolygon poly, Plane p, bool keepfront)
|
||||
|
|
|
@ -465,18 +465,16 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
//mxd. Apply ceiling glow effect?
|
||||
if(CeilingGlow != null)
|
||||
if(CeilingGlow != null && CeilingGlow.Fullbright)
|
||||
{
|
||||
if(CeilingGlow.Fullbright) ceiling.color = PixelColor.INT_WHITE;
|
||||
else if(CeilingGlow.Fullblack) ceiling.color = PixelColor.INT_BLACK;
|
||||
ceiling.color = PixelColor.INT_WHITE;
|
||||
}
|
||||
|
||||
//mxd. Apply floor glow effect?
|
||||
if(FloorGlow != null)
|
||||
{
|
||||
// Update floor color
|
||||
if(FloorGlow.Fullbright) floor.color = PixelColor.INT_WHITE;
|
||||
else if(FloorGlow.Fullblack) floor.color = PixelColor.INT_BLACK;
|
||||
if(FloorGlow.Fullbright) floor.color = PixelColor.INT_WHITE;
|
||||
|
||||
// Update brightness
|
||||
floor.brightnessbelow = (FloorGlow.Fullbright ? 255 : Math.Max(128, floor.brightnessbelow));
|
||||
|
|
Loading…
Reference in a new issue