mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
Added string support for spotlight colors
This commit is contained in:
parent
6565b83a0e
commit
e91fe94794
10 changed files with 143 additions and 81 deletions
|
@ -645,6 +645,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -671,6 +672,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -702,6 +704,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -732,6 +735,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -758,6 +762,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -788,6 +793,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -814,6 +820,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -845,6 +852,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -875,6 +883,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -901,6 +910,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -931,6 +941,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -957,6 +968,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -988,6 +1000,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -1018,6 +1031,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -1044,6 +1058,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -1074,6 +1089,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -1100,6 +1116,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -1131,6 +1148,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -1161,6 +1179,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
@ -1187,6 +1206,7 @@ gzdoom_lights
|
|||
{
|
||||
title = "Color";
|
||||
default = 16777215;
|
||||
str = true;
|
||||
}
|
||||
arg1
|
||||
{
|
||||
|
|
|
@ -129,7 +129,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
string rendercolor = cfg.ReadSetting(argspath + ".arg" + istr + ".rendercolor", string.Empty);
|
||||
this.rendercolor = General.Colors.InfoLine;
|
||||
|
||||
if(!string.IsNullOrEmpty(rendercolor) && !ZDTextParser.GetColorFromString(rendercolor, ref this.rendercolor))
|
||||
if(!string.IsNullOrEmpty(rendercolor) && !ZDTextParser.GetColorFromString(rendercolor, out this.rendercolor))
|
||||
General.ErrorLogger.Add(ErrorType.Error, "\"" + argspath + ".arg" + istr + "\": action argument \"" + this.title + "\": unable to get rendercolor from value \"" + rendercolor + "\"!");
|
||||
|
||||
this.rendercolor.a = HELPER_SHAPE_ALPHA;
|
||||
|
@ -142,7 +142,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
string minrangecolor = cfg.ReadSetting(argspath + ".arg" + istr + ".minrangecolor", string.Empty);
|
||||
this.minrangecolor = General.Colors.Indication;
|
||||
|
||||
if(!string.IsNullOrEmpty(minrangecolor) && !ZDTextParser.GetColorFromString(minrangecolor, ref this.minrangecolor))
|
||||
if(!string.IsNullOrEmpty(minrangecolor) && !ZDTextParser.GetColorFromString(minrangecolor, out this.minrangecolor))
|
||||
General.ErrorLogger.Add(ErrorType.Error, "\"" + argspath + ".arg" + istr + "\": action argument \"" + this.title + "\": unable to get minrangecolor from value \"" + minrangecolor + "\"!");
|
||||
|
||||
this.minrangecolor.a = RANGE_SHAPE_ALPHA;
|
||||
|
@ -156,7 +156,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
string maxrangecolor = cfg.ReadSetting(argspath + ".arg" + istr + ".maxrangecolor", string.Empty);
|
||||
this.maxrangecolor = General.Colors.Indication;
|
||||
|
||||
if(!string.IsNullOrEmpty(maxrangecolor) && !ZDTextParser.GetColorFromString(maxrangecolor, ref this.maxrangecolor))
|
||||
if(!string.IsNullOrEmpty(maxrangecolor) && !ZDTextParser.GetColorFromString(maxrangecolor, out this.maxrangecolor))
|
||||
General.ErrorLogger.Add(ErrorType.Error, "\"" + argspath + ".arg" + istr + "\": action argument \"" + this.title + "\": unable to get maxrangecolor from value \"" + maxrangecolor + "\"!");
|
||||
|
||||
this.maxrangecolor.a = RANGE_SHAPE_ALPHA;
|
||||
|
@ -303,7 +303,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Get rendercolor
|
||||
this.rendercolor = General.Colors.InfoLine;
|
||||
|
||||
if(!string.IsNullOrEmpty(rendercolor) && !ZDTextParser.GetColorFromString(rendercolor, ref this.rendercolor))
|
||||
if(!string.IsNullOrEmpty(rendercolor) && !ZDTextParser.GetColorFromString(rendercolor, out this.rendercolor))
|
||||
General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + argtitle + "\": unable to get rendercolor from value \"" + rendercolor + "\"!");
|
||||
|
||||
this.rendercolor.a = HELPER_SHAPE_ALPHA;
|
||||
|
@ -314,7 +314,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Get minrangecolor
|
||||
this.minrangecolor = General.Colors.Indication;
|
||||
|
||||
if(!string.IsNullOrEmpty(minrangecolor) && !ZDTextParser.GetColorFromString(minrangecolor, ref this.minrangecolor))
|
||||
if(!string.IsNullOrEmpty(minrangecolor) && !ZDTextParser.GetColorFromString(minrangecolor, out this.minrangecolor))
|
||||
General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + this.title + "\": unable to get minrangecolor from value \"" + minrangecolor + "\"!");
|
||||
|
||||
this.minrangecolor.a = RANGE_SHAPE_ALPHA;
|
||||
|
@ -326,7 +326,7 @@ namespace CodeImp.DoomBuilder.Config
|
|||
// Get minrangecolor
|
||||
this.maxrangecolor = General.Colors.Indication;
|
||||
|
||||
if(!string.IsNullOrEmpty(maxrangecolor) && !ZDTextParser.GetColorFromString(maxrangecolor, ref this.maxrangecolor))
|
||||
if(!string.IsNullOrEmpty(maxrangecolor) && !ZDTextParser.GetColorFromString(maxrangecolor, out this.maxrangecolor))
|
||||
General.ErrorLogger.Add(ErrorType.Error, actorname + ": action argument \"" + this.title + "\": unable to get maxrangecolor from value \"" + maxrangecolor + "\"!");
|
||||
|
||||
this.maxrangecolor.a = RANGE_SHAPE_ALPHA;
|
||||
|
|
|
@ -531,20 +531,8 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
|
||||
#region ================== GetDynamicLightShapes
|
||||
|
||||
public static List<Line3D> GetDynamicLightShapes(IEnumerable<Thing> things, bool highlight)
|
||||
public static List<Line3D> GetPointLightShape(Thing t, bool highlight, GZGeneral.LightData ld, int linealpha)
|
||||
{
|
||||
List<Line3D> circles = new List<Line3D>();
|
||||
if(General.Map.DOOM) return circles;
|
||||
|
||||
const int linealpha = 128;
|
||||
foreach(Thing t in things)
|
||||
{
|
||||
GZGeneral.LightData ld = t.DynamicLightType;
|
||||
if (ld == null) continue;
|
||||
if (ld.LightType == GZGeneral.LightType.SPOT)
|
||||
continue; // spotlights don't work well with the current representation.
|
||||
// todo: have 2D ortho projection of actual light cone
|
||||
|
||||
// TODO: this basically duplicates VisualThing.UpdateLight()...
|
||||
// Determine light radiii
|
||||
int primaryradius;
|
||||
|
@ -571,42 +559,73 @@ namespace CodeImp.DoomBuilder.GZBuilder.Data
|
|||
}
|
||||
|
||||
// Check radii...
|
||||
if(primaryradius < 1 && secondaryradius < 1) continue;
|
||||
if (primaryradius < 1 && secondaryradius < 1) return null;
|
||||
|
||||
// Determine light color
|
||||
PixelColor color;
|
||||
if (highlight)
|
||||
{
|
||||
color = General.Colors.Highlight.WithAlpha(linealpha);
|
||||
color = General.Colors.Highlight.WithAlpha((byte)linealpha);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (t.DynamicLightType.LightDef)
|
||||
{
|
||||
case GZGeneral.LightDef.VAVOOM_GENERIC: // Vavoom light
|
||||
color = new PixelColor(linealpha, 255, 255, 255);
|
||||
color = new PixelColor((byte)linealpha, 255, 255, 255);
|
||||
break;
|
||||
|
||||
case GZGeneral.LightDef.VAVOOM_COLORED: // Vavoom colored light
|
||||
color = new PixelColor(linealpha, (byte)t.Args[1], (byte)t.Args[2], (byte)t.Args[3]);
|
||||
break;
|
||||
|
||||
case GZGeneral.LightDef.SPOT_NORMAL:
|
||||
case GZGeneral.LightDef.SPOT_ADDITIVE:
|
||||
case GZGeneral.LightDef.SPOT_SUBTRACTIVE:
|
||||
case GZGeneral.LightDef.SPOT_ATTENUATED:
|
||||
color = new PixelColor(linealpha, (byte)((t.Args[0] & 0xFF0000) >> 16), (byte)((t.Args[0] & 0x00FF00) >> 8), (byte)((t.Args[0] & 0x0000FF)));
|
||||
color = new PixelColor((byte)linealpha, (byte)t.Args[1], (byte)t.Args[2], (byte)t.Args[3]);
|
||||
break;
|
||||
|
||||
default:
|
||||
color = new PixelColor(linealpha, (byte)t.Args[0], (byte)t.Args[1], (byte)t.Args[2]);
|
||||
color = new PixelColor((byte)linealpha, (byte)t.Args[0], (byte)t.Args[1], (byte)t.Args[2]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Add lines if visible
|
||||
List<Line3D> circles = new List<Line3D>();
|
||||
if (primaryradius > 0) circles.AddRange(MakeCircleLines(t.Position, color, primaryradius, CIRCLE_SIDES));
|
||||
if (secondaryradius > 0) circles.AddRange(MakeCircleLines(t.Position, color, secondaryradius, CIRCLE_SIDES));
|
||||
return circles;
|
||||
}
|
||||
|
||||
public static List<Line3D> GetSpotLightShape(Thing t, bool highlight, GZGeneral.LightData ld, int linealpha)
|
||||
{
|
||||
List<Line3D> shapes = new List<Line3D>();
|
||||
float lAngle1 = Angle2D.DegToRad(t.Args[1] / 2);
|
||||
float lAngle2 = Angle2D.DegToRad(t.Args[2] / 2);
|
||||
float lRadius = t.Args[3];
|
||||
float lDirY = (float)Math.Sin(-lAngle1) * lRadius;
|
||||
float lDirX = (float)Math.Cos(-lAngle1) * lRadius;
|
||||
shapes.Add(new Line3D(new Vector3D(0, 0, 0), new Vector3D(lDirX, lDirY, 0)));
|
||||
shapes.Add(new Line3D(new Vector3D(0, 0, 0), new Vector3D(lDirX, -lDirY, 0)));
|
||||
return shapes;
|
||||
}
|
||||
|
||||
public static List<Line3D> GetDynamicLightShapes(IEnumerable<Thing> things, bool highlight)
|
||||
{
|
||||
List<Line3D> circles = new List<Line3D>();
|
||||
if(General.Map.DOOM) return circles;
|
||||
|
||||
const int linealpha = 128;
|
||||
foreach(Thing t in things)
|
||||
{
|
||||
GZGeneral.LightData ld = t.DynamicLightType;
|
||||
if (ld == null) continue;
|
||||
|
||||
if (ld.LightType != GZGeneral.LightType.SPOT)
|
||||
{
|
||||
List<Line3D> lshape = GetPointLightShape(t, highlight, ld, linealpha);
|
||||
circles.AddRange(lshape);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<Line3D> lshape = GetSpotLightShape(t, highlight, ld, linealpha);
|
||||
circles.AddRange(lshape);
|
||||
}
|
||||
}
|
||||
|
||||
// Done
|
||||
|
|
|
@ -550,7 +550,16 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
if (t.DynamicLightType.LightDef == GZGeneral.LightDef.VAVOOM_COLORED) //vavoom colored light
|
||||
return new PixelColor(255, (byte)t.Args[1], (byte)t.Args[2], (byte)t.Args[3]);
|
||||
if (t.DynamicLightType.LightType == GZGeneral.LightType.SPOT)
|
||||
{
|
||||
if (t.Fields.ContainsKey("arg0str"))
|
||||
{
|
||||
PixelColor pc;
|
||||
ZDoom.ZDTextParser.GetColorFromString(t.Fields["arg0str"].Value.ToString(), out pc);
|
||||
pc.a = 255;
|
||||
return pc;
|
||||
}
|
||||
return new PixelColor(255, (byte)((t.Args[0] & 0xFF0000) >> 16), (byte)((t.Args[0] & 0x00FF00) >> 8), (byte)((t.Args[0] & 0x0000FF)));
|
||||
}
|
||||
return new PixelColor(255, (byte)t.Args[0], (byte)t.Args[1], (byte)t.Args[2]);
|
||||
}
|
||||
|
||||
|
|
|
@ -688,9 +688,22 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
}
|
||||
else
|
||||
{
|
||||
int c1 = (thing.Args[0] & 0xFF0000) >> 16;
|
||||
int c2 = (thing.Args[0] & 0x00FF00) >> 8;
|
||||
int c3 = (thing.Args[0] & 0x0000FF);
|
||||
int c1, c2, c3;
|
||||
if (thing.Fields.ContainsKey("arg0str"))
|
||||
{
|
||||
PixelColor pc;
|
||||
ZDoom.ZDTextParser.GetColorFromString(thing.Fields["arg0str"].Value.ToString(), out pc);
|
||||
c1 = pc.r;
|
||||
c2 = pc.g;
|
||||
c3 = pc.b;
|
||||
}
|
||||
else
|
||||
{
|
||||
c1 = (thing.Args[0] & 0xFF0000) >> 16;
|
||||
c2 = (thing.Args[0] & 0x00FF00) >> 8;
|
||||
c3 = (thing.Args[0] & 0x0000FF);
|
||||
}
|
||||
|
||||
if (ld.LightDef != GZGeneral.LightDef.SPOT_SUBTRACTIVE)
|
||||
{
|
||||
lightColor = new Color4((float)ld.LightRenderStyle / 100.0f,
|
||||
|
|
|
@ -160,7 +160,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
case "color":
|
||||
PixelColor cv = new PixelColor();
|
||||
if(!string.IsNullOrEmpty(value) && !GetColorFromString(value, ref cv))
|
||||
if(!string.IsNullOrEmpty(value) && !GetColorFromString(value, out cv))
|
||||
{
|
||||
ReportError("Cvar \"" + name + "\" has invalid color value: \"" + value + "\"");
|
||||
return false;
|
||||
|
|
|
@ -637,7 +637,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
SkipWhitespace(true);
|
||||
token = ReadToken(false);
|
||||
|
||||
if(!GetColorFromString(token, ref color))
|
||||
if(!GetColorFromString(token, out color))
|
||||
{
|
||||
ReportError("Expected glow color value, but got \"" + token + "\"");
|
||||
return false;
|
||||
|
|
|
@ -641,7 +641,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
|
||||
// Try to get the color...
|
||||
PixelColor color = new PixelColor();
|
||||
if(GetColorFromString(colorval, ref color))
|
||||
if(GetColorFromString(colorval, out color))
|
||||
{
|
||||
if(fadetype == "fade")
|
||||
mapinfo.FadeColor = color.ToColorValue();
|
||||
|
|
|
@ -173,7 +173,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
token = parser.ReadToken(false);
|
||||
if(!parser.ReadByte(token, ref color.r))
|
||||
{
|
||||
if(!ZDTextParser.GetColorFromString(token, ref color))
|
||||
if(!ZDTextParser.GetColorFromString(token, out color))
|
||||
{
|
||||
parser.ReportError("Unsupported patch blend definition");
|
||||
return;
|
||||
|
|
|
@ -605,7 +605,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
}
|
||||
|
||||
//mxd. This replicates ZDoom's V_GetColorFromString method
|
||||
public static bool GetColorFromString(string name, ref PixelColor color)
|
||||
public static bool GetColorFromString(string name, out PixelColor color)
|
||||
{
|
||||
name = StripQuotes(name.Replace(" ", ""));
|
||||
|
||||
|
@ -644,6 +644,7 @@ namespace CodeImp.DoomBuilder.ZDoom
|
|||
return true;
|
||||
}
|
||||
|
||||
color = new PixelColor();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue