mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 12:22:35 +00:00
@ code cleanup
This commit is contained in:
parent
159617106e
commit
7be6466f80
4 changed files with 28 additions and 59 deletions
|
@ -152,27 +152,19 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
{
|
{
|
||||||
ImageData img = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
ImageData img = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
||||||
if((img != null) && img.IsImageLoaded)
|
if((img != null) && img.IsImageLoaded)
|
||||||
{
|
|
||||||
float xpan, ypan, xscale, yscale, rotate;
|
|
||||||
int color, light;
|
|
||||||
bool absolute;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
// Fetch ZDoom fields
|
// Fetch ZDoom fields
|
||||||
xpan = s.Fields.ContainsKey("xpanningfloor") ? (float)s.Fields["xpanningfloor"].Value : 0.0f;
|
Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningfloor", 0.0f),
|
||||||
ypan = s.Fields.ContainsKey("ypanningfloor") ? (float)s.Fields["ypanningfloor"].Value : 0.0f;
|
s.Fields.GetValue("ypanningfloor", 0.0f));
|
||||||
xscale = s.Fields.ContainsKey("xscalefloor") ? (float)s.Fields["xscalefloor"].Value : 1.0f;
|
Vector2D scale = new Vector2D(s.Fields.GetValue("xscalefloor", 1.0f),
|
||||||
yscale = s.Fields.ContainsKey("yscalefloor") ? (float)s.Fields["yscalefloor"].Value : 1.0f;
|
s.Fields.GetValue("yscalefloor", 1.0f));
|
||||||
rotate = s.Fields.ContainsKey("rotationfloor") ? (float)s.Fields["rotationfloor"].Value : 0.0f;
|
float rotate = s.Fields.GetValue("rotationfloor", 0.0f);
|
||||||
color = s.Fields.ContainsKey("lightcolor") ? (int)s.Fields["lightcolor"].Value : -1;
|
int color = s.Fields.GetValue("lightcolor", -1);
|
||||||
light = s.Fields.ContainsKey("lightfloor") ? (int)s.Fields["lightfloor"].Value : 0;
|
int light = s.Fields.GetValue("lightfloor", 0);
|
||||||
absolute = s.Fields.ContainsKey("lightfloorabsolute") ? (bool)s.Fields["lightfloorabsolute"].Value : false;
|
bool absolute = s.Fields.GetValue("lightfloorabsolute", false);
|
||||||
}
|
|
||||||
catch(Exception) { return; }
|
|
||||||
|
|
||||||
// Setup the vertices with the given settings
|
// Setup the vertices with the given settings
|
||||||
SetupSurfaceVertices(vertices, s, img, xpan, ypan, xscale, yscale, rotate, color, light, absolute);
|
SetupSurfaceVertices(vertices, s, img, offset, scale, rotate, color, light, absolute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,39 +173,29 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
{
|
{
|
||||||
ImageData img = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
ImageData img = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
||||||
if((img != null) && img.IsImageLoaded)
|
if((img != null) && img.IsImageLoaded)
|
||||||
{
|
|
||||||
float xpan, ypan, xscale, yscale, rotate;
|
|
||||||
int color, light;
|
|
||||||
bool absolute;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
// Fetch ZDoom fields
|
// Fetch ZDoom fields
|
||||||
xpan = s.Fields.ContainsKey("xpanningceiling") ? (float)s.Fields["xpanningceiling"].Value : 0.0f;
|
Vector2D offset = new Vector2D(s.Fields.GetValue("xpanningceiling", 0.0f),
|
||||||
ypan = s.Fields.ContainsKey("ypanningceiling") ? (float)s.Fields["ypanningceiling"].Value : 0.0f;
|
s.Fields.GetValue("ypanningceiling", 0.0f));
|
||||||
xscale = s.Fields.ContainsKey("xscaleceiling") ? (float)s.Fields["xscaleceiling"].Value : 1.0f;
|
Vector2D scale = new Vector2D(s.Fields.GetValue("xscaleceiling", 1.0f),
|
||||||
yscale = s.Fields.ContainsKey("yscaleceiling") ? (float)s.Fields["yscaleceiling"].Value : 1.0f;
|
s.Fields.GetValue("yscaleceiling", 1.0f));
|
||||||
rotate = s.Fields.ContainsKey("rotationceiling") ? (float)s.Fields["rotationceiling"].Value : 0.0f;
|
float rotate = s.Fields.GetValue("rotationceiling", 0.0f);
|
||||||
color = s.Fields.ContainsKey("lightcolor") ? (int)s.Fields["lightcolor"].Value : -1;
|
int color = s.Fields.GetValue("lightcolor", -1);
|
||||||
light = s.Fields.ContainsKey("lightceiling") ? (int)s.Fields["lightceiling"].Value : 0;
|
int light = s.Fields.GetValue("lightceiling", 0);
|
||||||
absolute = s.Fields.ContainsKey("lightceilingabsolute") ? (bool)s.Fields["lightceilingabsolute"].Value : false;
|
bool absolute = s.Fields.GetValue("lightceilingabsolute", false);
|
||||||
}
|
|
||||||
catch(Exception) { return; }
|
|
||||||
|
|
||||||
// Setup the vertices with the given settings
|
// Setup the vertices with the given settings
|
||||||
SetupSurfaceVertices(vertices, s, img, xpan, ypan, xscale, yscale, rotate, color, light, absolute);
|
SetupSurfaceVertices(vertices, s, img, offset, scale, rotate, color, light, absolute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This applies the given values on the vertices
|
// This applies the given values on the vertices
|
||||||
private void SetupSurfaceVertices(FlatVertex[] vertices, Sector s, ImageData img, float xpan, float ypan,
|
private void SetupSurfaceVertices(FlatVertex[] vertices, Sector s, ImageData img, Vector2D offset,
|
||||||
float xscale, float yscale, float rotate, int color, int light, bool absolute)
|
Vector2D scale, float rotate, int color, int light, bool absolute)
|
||||||
{
|
{
|
||||||
// Prepare for math!
|
// Prepare for math!
|
||||||
rotate = Angle2D.DegToRad(rotate);
|
rotate = Angle2D.DegToRad(rotate);
|
||||||
Vector2D scale = new Vector2D(xscale, yscale);
|
|
||||||
Vector2D texscale = new Vector2D(1.0f / img.ScaledWidth, 1.0f / img.ScaledHeight);
|
Vector2D texscale = new Vector2D(1.0f / img.ScaledWidth, 1.0f / img.ScaledHeight);
|
||||||
Vector2D offset = new Vector2D(xpan, ypan);
|
|
||||||
if(!absolute) light = s.Brightness + light;
|
if(!absolute) light = s.Brightness + light;
|
||||||
PixelColor lightcolor = PixelColor.FromInt(color);
|
PixelColor lightcolor = PixelColor.FromInt(color);
|
||||||
PixelColor brightness = PixelColor.FromInt(General.Map.Renderer2D.CalculateBrightness(light));
|
PixelColor brightness = PixelColor.FromInt(General.Map.Renderer2D.CalculateBrightness(light));
|
||||||
|
|
|
@ -112,21 +112,11 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
else
|
else
|
||||||
this.RenderPass = RenderPass.Solid;
|
this.RenderPass = RenderPass.Solid;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// From UDMF field
|
// From UDMF field
|
||||||
else if(Sidedef.Line.Fields.ContainsKey("renderstyle") ||
|
string field = Sidedef.Line.Fields.GetValue("renderstyle", "translucent");
|
||||||
Sidedef.Line.Fields.ContainsKey("alpha"))
|
alpha = (byte)(Sidedef.Line.Fields.GetValue("alpha", 1.0f) * 255.0f);
|
||||||
{
|
|
||||||
string field = "translucent";
|
|
||||||
|
|
||||||
if(Sidedef.Line.Fields.ContainsKey("renderstyle"))
|
|
||||||
field = Sidedef.Line.Fields["renderstyle"].Value.ToString();
|
|
||||||
|
|
||||||
if(Sidedef.Line.Fields.ContainsKey("alpha"))
|
|
||||||
{
|
|
||||||
float a;
|
|
||||||
if(float.TryParse(Sidedef.Line.Fields["alpha"].Value.ToString(), out a))
|
|
||||||
alpha = (byte)(a * 255.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(field == "add")
|
if(field == "add")
|
||||||
this.RenderPass = RenderPass.Additive;
|
this.RenderPass = RenderPass.Additive;
|
||||||
|
|
|
@ -459,6 +459,7 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
// Find sectors with 3 vertices, because they can be sloped
|
// Find sectors with 3 vertices, because they can be sloped
|
||||||
foreach(Sector s in General.Map.Map.Sectors)
|
foreach(Sector s in General.Map.Map.Sectors)
|
||||||
{
|
{
|
||||||
|
// ========== Thing vertex slope ==========
|
||||||
if(s.Sidedefs.Count == 3)
|
if(s.Sidedefs.Count == 3)
|
||||||
{
|
{
|
||||||
List<Thing> slopeceilingthings = new List<Thing>(3);
|
List<Thing> slopeceilingthings = new List<Thing>(3);
|
||||||
|
|
|
@ -189,12 +189,8 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||||
CropPoly(ref poly, osd.Floor.plane, true);
|
CropPoly(ref poly, osd.Floor.plane, true);
|
||||||
|
|
||||||
// Determine if we should repeat the middle texture
|
// Determine if we should repeat the middle texture
|
||||||
repeatmidtex = false;
|
|
||||||
if(Sidedef.Fields.ContainsKey("wrapmidtex"))
|
if(Sidedef.Fields.ContainsKey("wrapmidtex"))
|
||||||
{
|
repeatmidtex = Sidedef.Fields.GetValue("wrapmidtex", false);
|
||||||
if(Sidedef.Fields["wrapmidtex"].Value is bool)
|
|
||||||
repeatmidtex = (bool)Sidedef.Fields["wrapmidtex"].Value;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
repeatmidtex = Sidedef.Line.IsFlagSet("wrapmidtex");
|
repeatmidtex = Sidedef.Line.IsFlagSet("wrapmidtex");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue