mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
Changed: "Selection Options" window is now resized automatically.
Fixed: parts of UniFileds.UniValuesMatch() logic were inverted. In some cases this resulted in incorrect behavior of "Select Similar" action in UDMF map format. Fixed, UDMF: alpha should be ignored when applying sector fade/light color gradients. Ported eevee's fix for incorrect sector geometry occasionally created after dragging map elements (more info: https://github.com/sirjuddington/SLADE/issues/542).
This commit is contained in:
parent
2627a5bb39
commit
364b3c11c7
10 changed files with 47 additions and 25 deletions
|
@ -58,22 +58,24 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
}
|
||||
|
||||
//mxd
|
||||
public static int InterpolateColor(PixelColor c1, PixelColor c2, float delta)
|
||||
public static PixelColor InterpolateColor(PixelColor c1, PixelColor c2, float delta)
|
||||
{
|
||||
float invdelta = 1.0f - delta;
|
||||
byte a = (byte)(c1.a * invdelta + c2.a * delta);
|
||||
byte r = (byte)(c1.r * invdelta + c2.r * delta);
|
||||
byte g = (byte)(c1.g * invdelta + c2.g * delta);
|
||||
byte b = (byte)(c1.b * invdelta + c2.b * delta);
|
||||
return new PixelColor(255, r, g, b).ToInt();
|
||||
return new PixelColor(a, r, g, b);
|
||||
}
|
||||
|
||||
//mxd
|
||||
public static int InterpolateColor(PixelColor c1, PixelColor c2, float delta, Mode mode)
|
||||
public static PixelColor InterpolateColor(PixelColor c1, PixelColor c2, float delta, Mode mode)
|
||||
{
|
||||
byte a = (byte)Math.Round(Interpolate(c1.a, c2.a, delta, mode));
|
||||
byte r = (byte)Math.Round(Interpolate(c1.r, c2.r, delta, mode));
|
||||
byte g = (byte)Math.Round(Interpolate(c1.g, c2.g, delta, mode));
|
||||
byte b = (byte)Math.Round(Interpolate(c1.b, c2.b, delta, mode));
|
||||
return new PixelColor(255, r, g, b).ToInt();
|
||||
return new PixelColor(a, r, g, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
float min_dist = float.MaxValue;
|
||||
Linedef nearest = null;
|
||||
|
||||
// Go through map lines
|
||||
// Fire a ray east from the vertex and find the first line it crosses
|
||||
foreach(Linedef line in General.Map.Map.Linedefs)
|
||||
{
|
||||
// Ignore if the line is completely left of the vertex
|
||||
|
@ -238,11 +238,23 @@ namespace CodeImp.DoomBuilder.Map
|
|||
float dist = Math.Abs(int_x - vr_x);
|
||||
|
||||
// Check if closest
|
||||
if(dist < min_dist)
|
||||
if(nearest == null || dist < min_dist)
|
||||
{
|
||||
min_dist = dist;
|
||||
nearest = line;
|
||||
}
|
||||
else if(Math.Abs(dist - min_dist) < 0.001f)
|
||||
{
|
||||
// In the case of a tie, use the distance to each line as a tiebreaker - this fixes cases where the ray hits a vertex
|
||||
// shared by two lines. Choosing the further line would mean choosing an inner edge, which is clearly wrong.
|
||||
float line_dist = line.SafeDistanceToSq(vertex_right.Position, true);
|
||||
float nearest_dist = nearest.SafeDistanceToSq(vertex_right.Position, true);
|
||||
if(line_dist < nearest_dist)
|
||||
{
|
||||
min_dist = dist;
|
||||
nearest = line;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for valid line
|
||||
|
@ -250,8 +262,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Determine the edge side
|
||||
float side = -nearest.SideOfLine(vertex_right.Position); //mxd. SideOfLine logic is inverted in Slade 3
|
||||
return new LinedefSide(nearest, side > 0); //mxd. The meaning of 0.0 is also inverted!!!
|
||||
//mxd. I've spent 2 days figuring this out... :(
|
||||
return new LinedefSide(nearest, side > 0); //mxd. The meaning of 0.0 is also inverted!!! (I've spent 2 days figuring this out...)
|
||||
}
|
||||
|
||||
/// <summary>Find the closest edge within the current outline (that isn't part of the current outline)</summary>
|
||||
|
|
|
@ -224,11 +224,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
public static bool UniValuesMatch(UniValue val1, UniValue val2)
|
||||
{
|
||||
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 bool) return (bool)val1.Value != (bool)val2.Value;
|
||||
if(val1.Value is string) return (string)val1.Value != (string)val2.Value;
|
||||
throw new Exception("Got unknown Custom Field type to compare: " + val1.Value.GetType());
|
||||
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 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());
|
||||
}
|
||||
|
||||
/// <summary>This compares types and values of given UniFields by key.</summary>
|
||||
|
|
|
@ -1935,7 +1935,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
var form = new SelectSimilarElementOptionsPanel();
|
||||
if(form.Setup(this)) form.ShowDialog();
|
||||
if(form.Setup(this)) form.ShowDialog(General.Interface);
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
|
|
@ -2078,7 +2078,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
s.Fields.BeforeFieldsChange();
|
||||
float u = index / (orderedselection.Count - 1.0f);
|
||||
int c = InterpolationTools.InterpolateColor(startcolor, endcolor, u, interpolationmode);
|
||||
int c = InterpolationTools.InterpolateColor(startcolor, endcolor, u, interpolationmode).WithAlpha(0).ToInt(); // No alpha here!
|
||||
|
||||
UniFields.SetInteger(s.Fields, key, c, defaultvalue);
|
||||
s.UpdateNeeded = true;
|
||||
|
@ -2502,7 +2502,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
var form = new SelectSimilarElementOptionsPanel();
|
||||
if(form.Setup(this)) form.ShowDialog();
|
||||
if(form.Setup(this)) form.ShowDialog(General.Interface);
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
|
|
@ -1613,7 +1613,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
var form = new SelectSimilarElementOptionsPanel();
|
||||
if(form.Setup(this)) form.ShowDialog();
|
||||
if(form.Setup(this)) form.ShowDialog(General.Interface);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -1103,7 +1103,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
var form = new SelectSimilarElementOptionsPanel();
|
||||
if(form.Setup(this)) form.ShowDialog();
|
||||
if(form.Setup(this)) form.ShowDialog(General.Interface);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -228,10 +228,12 @@
|
|||
this.Controls.Add(this.enableall);
|
||||
this.Controls.Add(this.apply);
|
||||
this.Controls.Add(this.cancel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(300, 200);
|
||||
this.MinimumSize = new System.Drawing.Size(396, 200);
|
||||
this.Name = "SelectSimilarElementOptionsPanel";
|
||||
this.Opacity = 1;
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
|
|
|
@ -11,7 +11,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
public partial class SelectSimilarElementOptionsPanel : DelayedForm
|
||||
{
|
||||
private static Size size = Size.Empty;
|
||||
private static Point location = Point.Empty;
|
||||
private static readonly object[] flags = {
|
||||
new SectorPropertiesCopySettings(),
|
||||
|
@ -30,10 +29,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
InitializeComponent();
|
||||
|
||||
//apply window size and location
|
||||
if(!size.IsEmpty && !location.IsEmpty)
|
||||
if(!location.IsEmpty)
|
||||
{
|
||||
this.StartPosition = FormStartPosition.Manual;
|
||||
this.Size = size;
|
||||
this.Location = location;
|
||||
}
|
||||
|
||||
|
@ -79,6 +77,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
//fill flags
|
||||
showntabs = new List<TabPage>();
|
||||
int maxheight = int.MinValue;
|
||||
foreach(TabPage page in activetabs)
|
||||
{
|
||||
CheckboxArrayControl curControl = page.Controls[0] as CheckboxArrayControl;
|
||||
|
@ -102,9 +101,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
curControl.PositionCheckboxes();
|
||||
showntabs.Add(page);
|
||||
|
||||
// Store height
|
||||
maxheight = Math.Max(maxheight, curControl.GetHeight());
|
||||
}
|
||||
}
|
||||
|
||||
// Apply height
|
||||
if(maxheight != int.MinValue)
|
||||
{
|
||||
this.Height += maxheight - activetabs[0].Controls[0].Height;
|
||||
}
|
||||
|
||||
// Got anything to show?
|
||||
if(showntabs.Count == 0) return SetupFailed("This action doesn't support current editing mode...");
|
||||
|
||||
|
@ -124,7 +132,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
private void SelectSimilarElementOptionsPanel_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
size = this.Size;
|
||||
location = this.Location;
|
||||
}
|
||||
|
||||
|
|
|
@ -304,7 +304,7 @@ 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);
|
||||
v.c = InterpolationTools.InterpolateColor(GetGlowColor(data.CeilingGlow, vc), vc, delta).WithAlpha(255).ToInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,7 +319,7 @@ 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);
|
||||
v.c = InterpolationTools.InterpolateColor(vc, GetGlowColor(data.FloorGlow, vc), delta).WithAlpha(255).ToInt();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue