mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-17 01:22:18 +00:00
Fixed some more cases where UniValues were set to floats. Added throwing exceptions to the UniValue constructor (gasp!)
This commit is contained in:
parent
abb61f1f09
commit
bdc6a23934
10 changed files with 29 additions and 20 deletions
|
@ -1687,7 +1687,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
if(l.Front.MiddleRequired() && l.Front.LongMiddleTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Front.LongMiddleTexture))
|
||||
{
|
||||
ImageData texture = General.Map.Data.GetTextureImage(l.Front.LongMiddleTexture);
|
||||
float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
if(texture.IsImageLoaded) offset %= texture.Width;
|
||||
if(offset > 0) UniFields.SetFloat(l.Front.Fields, "offsetx_mid", offset);
|
||||
}
|
||||
|
@ -1695,7 +1695,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
if(l.Front.HighRequired() && l.Front.LongHighTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Front.LongHighTexture))
|
||||
{
|
||||
ImageData texture = General.Map.Data.GetTextureImage(l.Front.LongHighTexture);
|
||||
float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
if(texture.IsImageLoaded) offset %= texture.Width;
|
||||
if(offset > 0) UniFields.SetFloat(l.Front.Fields, "offsetx_top", offset);
|
||||
}
|
||||
|
@ -1703,7 +1703,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
if(l.Front.LowRequired() && l.Front.LongLowTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Front.LongLowTexture))
|
||||
{
|
||||
ImageData texture = General.Map.Data.GetTextureImage(l.Front.LongLowTexture);
|
||||
float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
if(texture.IsImageLoaded) offset %= texture.Width;
|
||||
if(offset > 0) UniFields.SetFloat(l.Front.Fields, "offsetx_bottom", offset);
|
||||
}
|
||||
|
@ -1714,7 +1714,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
if(l.Back.MiddleRequired() && l.Back.LongMiddleTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Back.LongMiddleTexture))
|
||||
{
|
||||
ImageData texture = General.Map.Data.GetTextureImage(l.Back.LongMiddleTexture);
|
||||
float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
if(texture.IsImageLoaded) offset %= texture.Width;
|
||||
if(offset > 0) UniFields.SetFloat(l.Back.Fields, "offsetx_mid", offset);
|
||||
}
|
||||
|
@ -1722,7 +1722,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
if(l.Back.HighRequired() && l.Back.LongHighTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Back.LongHighTexture))
|
||||
{
|
||||
ImageData texture = General.Map.Data.GetTextureImage(l.Back.LongHighTexture);
|
||||
float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
if(texture.IsImageLoaded) offset %= texture.Width;
|
||||
if(offset > 0) UniFields.SetFloat(l.Back.Fields, "offsetx_top", offset);
|
||||
}
|
||||
|
@ -1730,7 +1730,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
if(l.Back.LowRequired() && l.Back.LongLowTexture != MapSet.EmptyLongName && General.Map.Data.GetTextureExists(l.Back.LongLowTexture))
|
||||
{
|
||||
ImageData texture = General.Map.Data.GetTextureImage(l.Back.LongLowTexture);
|
||||
float offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
double offset = (int)Math.Round((reversed ? totalLength - curLength - l.Length : curLength));
|
||||
if(texture.IsImageLoaded) offset %= texture.Width;
|
||||
if(offset > 0) UniFields.SetFloat(l.Back.Fields, "offsetx_bottom", offset);
|
||||
}
|
||||
|
|
|
@ -279,12 +279,12 @@ namespace CodeImp.DoomBuilder.IO
|
|||
{
|
||||
writer.Write((int)UniversalType.Boolean);
|
||||
writer.Write((bool)f.Value.Value);
|
||||
}
|
||||
}/*
|
||||
else if(f.Value.Value is float)
|
||||
{
|
||||
writer.Write((int)UniversalType.Float);
|
||||
writer.Write((float)f.Value.Value);
|
||||
}
|
||||
}*/
|
||||
else if(f.Value.Value is double)
|
||||
{
|
||||
writer.Write((int)UniversalType.Float);
|
||||
|
|
|
@ -128,12 +128,12 @@ namespace CodeImp.DoomBuilder.Map
|
|||
//mxd. Rednering
|
||||
public Color4 FogColor { get { return fogcolor; } }
|
||||
public SectorFogMode FogMode { get { return fogmode; } }
|
||||
public float Desaturation
|
||||
public double Desaturation
|
||||
{
|
||||
get
|
||||
{
|
||||
if (General.Map.UDMF && Fields.ContainsKey("desaturation"))
|
||||
return (float)Fields["desaturation"].Value;
|
||||
return (double)Fields["desaturation"].Value;
|
||||
return 0f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,6 +226,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
if(val1.Type != val2.Type) return false;
|
||||
if(val1.Value is int) return (int)val1.Value == (int)val2.Value;
|
||||
if(val1.Value is float) return (float)val1.Value == (float)val2.Value;
|
||||
if(val1.Value is double) return (double)val1.Value == (double)val2.Value;
|
||||
if(val1.Value is bool) return (bool)val1.Value == (bool)val2.Value;
|
||||
if(val1.Value is string) return (string)val1.Value == (string)val2.Value;
|
||||
throw new NotImplementedException("Unknown Custom Field type: " + val1.Value.GetType());
|
||||
|
|
|
@ -68,6 +68,10 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Constructor
|
||||
public UniValue(int type, object value)
|
||||
{
|
||||
// Value may only be a primitive type. Throwing exceptions in the constructor! Civil war!
|
||||
if ((!(value is int) && !(value is double) && !(value is string) && !(value is bool)) || (value == null))
|
||||
throw new ArgumentException("Universal field values can only be of type int, double, string or bool.");
|
||||
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
|
||||
|
@ -78,6 +82,10 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Constructor
|
||||
public UniValue(UniversalType type, object value)
|
||||
{
|
||||
// Value may only be a primitive type. Throwing exceptions in the constructor! Civil war!
|
||||
if ((!(value is int) && !(value is double) && !(value is string) && !(value is bool)) || (value == null))
|
||||
throw new ArgumentException("Universal field values can only be of type int, double, string or bool.");
|
||||
|
||||
this.type = (int)type;
|
||||
this.value = value;
|
||||
|
||||
|
|
|
@ -897,7 +897,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetUniform(UniformName.highlightcolor, CalculateHighlightColor((g == highlighted) && showhighlight, (g.Selected && showselection)));
|
||||
|
||||
// [ZZ] include desaturation factor
|
||||
graphics.SetUniform(UniformName.desaturation, sector.Sector.Desaturation);
|
||||
graphics.SetUniform(UniformName.desaturation, (float)sector.Sector.Desaturation);
|
||||
|
||||
// Render!
|
||||
graphics.Draw(PrimitiveType.TriangleList, g.VertexOffset, g.Triangles);
|
||||
|
@ -994,7 +994,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
// [ZZ] apply desaturation
|
||||
if (t.Thing.Sector != null)
|
||||
graphics.SetUniform(UniformName.desaturation, t.Thing.Sector.Desaturation);
|
||||
graphics.SetUniform(UniformName.desaturation, (float)t.Thing.Sector.Desaturation);
|
||||
else graphics.SetUniform(UniformName.desaturation, 0.0f);
|
||||
|
||||
// Apply changes
|
||||
|
@ -1204,7 +1204,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
|
||||
//
|
||||
graphics.SetUniform(UniformName.desaturation, sector.Sector.Desaturation);
|
||||
graphics.SetUniform(UniformName.desaturation, (float)sector.Sector.Desaturation);
|
||||
|
||||
// Set the colors to use
|
||||
graphics.SetUniform(UniformName.sectorfogcolor, sector.Sector.FogColor);
|
||||
|
@ -1340,7 +1340,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
graphics.SetUniform(UniformName.stencilColor, t.StencilColor.ToColorValue());
|
||||
|
||||
//
|
||||
graphics.SetUniform(UniformName.desaturation, t.Thing.Sector.Desaturation);
|
||||
graphics.SetUniform(UniformName.desaturation, (float)t.Thing.Sector.Desaturation);
|
||||
|
||||
// Apply changes
|
||||
graphics.SetUniform(UniformName.world, world);
|
||||
|
@ -1514,7 +1514,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
}
|
||||
|
||||
if (t.Thing.Sector != null)
|
||||
graphics.SetUniform(UniformName.desaturation, t.Thing.Sector.Desaturation);
|
||||
graphics.SetUniform(UniformName.desaturation, (float)t.Thing.Sector.Desaturation);
|
||||
else graphics.SetUniform(UniformName.desaturation, 0.0f);
|
||||
|
||||
int lightIndex = 0;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
public long ceiltexture;
|
||||
|
||||
//
|
||||
public float desaturation;
|
||||
public double desaturation;
|
||||
|
||||
// Constructor
|
||||
internal SurfaceEntry(int numvertices, int bufferindex, int vertexoffset)
|
||||
|
|
|
@ -616,7 +616,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
VertexBuffer lastbuffer = null;
|
||||
foreach(SurfaceEntry entry in imgsurfaces.Value)
|
||||
{
|
||||
graphics.SetUniform(UniformName.desaturation, entry.desaturation);
|
||||
graphics.SetUniform(UniformName.desaturation, (float)entry.desaturation);
|
||||
|
||||
// Set the vertex buffer
|
||||
SurfaceBufferSet set = sets[entry.numvertices];
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
public long ceiltexture;
|
||||
|
||||
//
|
||||
public float desaturation;
|
||||
public double desaturation;
|
||||
|
||||
// Constructor
|
||||
internal SurfaceUpdate(int numvertices, bool updatefloor, bool updateceiling)
|
||||
|
|
|
@ -258,13 +258,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
protected override void SetTextureOffsetX(int x)
|
||||
{
|
||||
Sidedef.Fields.BeforeFieldsChange();
|
||||
Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, (float)x);
|
||||
Sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, (double)x);
|
||||
}
|
||||
|
||||
protected override void SetTextureOffsetY(int y)
|
||||
{
|
||||
Sidedef.Fields.BeforeFieldsChange();
|
||||
Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, (float)y);
|
||||
Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, (double)y);
|
||||
}
|
||||
|
||||
protected override void MoveTextureOffset(int offsetx, int offsety)
|
||||
|
|
Loading…
Reference in a new issue