mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
Changed, Visual mode, Auto-align textures actions, UDMF: aligned texture coordinates are no longer rounded to integer values.
Changed, Things, Sectors, Linedefs, Vertices modes: we shouldn't select highlighted map element during the copy action when no map elements are selected. Internal: removed some debug stuff from CheckTextureAlignment and ResultTexturesMisaligned.
This commit is contained in:
parent
210c04ceed
commit
2dff39b8bc
10 changed files with 90 additions and 113 deletions
|
@ -1841,9 +1841,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
|
||||
//if we don't have UpperUnpegged flag, normalize offset
|
||||
float surfaceHeight = side.GetHighHeight() * scaleY;
|
||||
|
||||
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
|
||||
return (float)Math.Round(offset - surfaceHeight);
|
||||
return (float)Math.Round((fromNormalized ? offset + surfaceHeight : offset - surfaceHeight), General.Map.FormatInterface.VertexDecimals);
|
||||
}
|
||||
|
||||
//mxd. This converts offsetY from/to "normalized" offset for given middle wall
|
||||
|
@ -1882,8 +1880,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
}
|
||||
}
|
||||
|
||||
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
|
||||
return (float)Math.Round(offset - surfaceHeight);
|
||||
return (float)Math.Round((fromNormalized ? offset + surfaceHeight : offset - surfaceHeight), General.Map.FormatInterface.VertexDecimals);
|
||||
}
|
||||
|
||||
//mxd. This converts offsetY from/to "normalized" offset for given lower wall
|
||||
|
@ -1905,8 +1902,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.FloorHeight) * scaleY;
|
||||
}
|
||||
|
||||
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
|
||||
return (float)Math.Round(offset - surfaceHeight);
|
||||
return (float)Math.Round((fromNormalized ? offset + surfaceHeight : offset - surfaceHeight), General.Map.FormatInterface.VertexDecimals);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
1
Source/Core/Windows/MainForm.Designer.cs
generated
1
Source/Core/Windows/MainForm.Designer.cs
generated
|
@ -2244,7 +2244,6 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
this.Activated += new System.EventHandler(this.MainForm_Activated);
|
||||
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyUp);
|
||||
this.Move += new System.EventHandler(this.MainForm_Move);
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
|
||||
this.Resize += new System.EventHandler(this.MainForm_Resize);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.MainForm_KeyDown);
|
||||
this.ResizeEnd += new System.EventHandler(this.MainForm_ResizeEnd);
|
||||
|
|
|
@ -644,56 +644,56 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
}
|
||||
|
||||
// Window is being closed
|
||||
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
protected override void OnFormClosing(FormClosingEventArgs e)
|
||||
{
|
||||
if(e.CloseReason != CloseReason.ApplicationExitCall)
|
||||
base.OnFormClosing(e);
|
||||
|
||||
if(e.CloseReason == CloseReason.ApplicationExitCall) return;
|
||||
if(General.Map != null && General.Map.Launcher.GameEngineRunning)
|
||||
General.Map.Launcher.StopGameEngine(); //mxd
|
||||
|
||||
// Close the map
|
||||
if(General.CloseMap())
|
||||
{
|
||||
//mxd
|
||||
if(General.Map != null && General.Map.Launcher.GameEngineRunning) General.Map.Launcher.StopGameEngine();
|
||||
|
||||
// Close the map
|
||||
if(General.CloseMap())
|
||||
{
|
||||
General.WriteLogLine("Closing main interface window...");
|
||||
|
||||
// Stop timers
|
||||
statusflasher.Stop();
|
||||
statusresetter.Stop();
|
||||
blinkTimer.Stop(); //mxd
|
||||
General.WriteLogLine("Closing main interface window...");
|
||||
|
||||
// Stop exclusive mode, if any is active
|
||||
StopExclusiveMouseInput();
|
||||
StopProcessing();
|
||||
// Stop timers
|
||||
statusflasher.Stop();
|
||||
statusresetter.Stop();
|
||||
blinkTimer.Stop(); //mxd
|
||||
|
||||
// Unbind methods
|
||||
General.Actions.UnbindMethods(this);
|
||||
// Stop exclusive mode, if any is active
|
||||
StopExclusiveMouseInput();
|
||||
StopProcessing();
|
||||
|
||||
// Determine window state to save
|
||||
int windowstate;
|
||||
if(this.WindowState != FormWindowState.Minimized)
|
||||
windowstate = (int)this.WindowState;
|
||||
else
|
||||
windowstate = (int)FormWindowState.Normal;
|
||||
// Unbind methods
|
||||
General.Actions.UnbindMethods(this);
|
||||
|
||||
// Save window settings
|
||||
General.Settings.WriteSetting("mainwindow.positionx", lastposition.X);
|
||||
General.Settings.WriteSetting("mainwindow.positiony", lastposition.Y);
|
||||
General.Settings.WriteSetting("mainwindow.sizewidth", lastsize.Width);
|
||||
General.Settings.WriteSetting("mainwindow.sizeheight", lastsize.Height);
|
||||
General.Settings.WriteSetting("mainwindow.windowstate", windowstate);
|
||||
General.Settings.WriteSetting("mainwindow.expandedinfopanel", IsInfoPanelExpanded);
|
||||
|
||||
// Save recent files
|
||||
SaveRecentFiles();
|
||||
|
||||
// Terminate the program
|
||||
General.Terminate(true);
|
||||
}
|
||||
// Determine window state to save
|
||||
int windowstate;
|
||||
if(this.WindowState != FormWindowState.Minimized)
|
||||
windowstate = (int)this.WindowState;
|
||||
else
|
||||
{
|
||||
// Cancel the close
|
||||
e.Cancel = true;
|
||||
}
|
||||
windowstate = (int)FormWindowState.Normal;
|
||||
|
||||
// Save window settings
|
||||
General.Settings.WriteSetting("mainwindow.positionx", lastposition.X);
|
||||
General.Settings.WriteSetting("mainwindow.positiony", lastposition.Y);
|
||||
General.Settings.WriteSetting("mainwindow.sizewidth", lastsize.Width);
|
||||
General.Settings.WriteSetting("mainwindow.sizeheight", lastsize.Height);
|
||||
General.Settings.WriteSetting("mainwindow.windowstate", windowstate);
|
||||
General.Settings.WriteSetting("mainwindow.expandedinfopanel", IsInfoPanelExpanded);
|
||||
|
||||
// Save recent files
|
||||
SaveRecentFiles();
|
||||
|
||||
// Terminate the program
|
||||
General.Terminate(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Cancel the close
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -812,6 +812,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make the highlight the selection
|
||||
highlighted.Selected = true;
|
||||
|
||||
//mxd. Actually, we want it marked, not selected
|
||||
bool result = base.OnCopyBegin();
|
||||
highlighted.Selected = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
return base.OnCopyBegin();
|
||||
|
|
|
@ -1253,8 +1253,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if((General.Map.Map.GetSelectedSectors(true).Count == 0) && (highlighted != null))
|
||||
{
|
||||
// Make the highlight the selection
|
||||
SelectSector(highlighted, true, true);
|
||||
UpdateOverlaySurfaces();//mxd
|
||||
SelectSector(highlighted, true, false);
|
||||
|
||||
//mxd. Actually, we want it marked, not selected
|
||||
bool result = base.OnCopyBegin();
|
||||
SelectSector(highlighted, false, false);
|
||||
return result;
|
||||
}
|
||||
|
||||
return base.OnCopyBegin();
|
||||
|
|
|
@ -680,6 +680,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make the highlight the selection
|
||||
highlighted.Selected = true;
|
||||
|
||||
//mxd. Actually, we want it marked, not selected
|
||||
bool result = base.OnCopyBegin();
|
||||
highlighted.Selected = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
return base.OnCopyBegin();
|
||||
|
|
|
@ -683,6 +683,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Make the highlight the selection
|
||||
highlighted.Selected = true;
|
||||
|
||||
//mxd. Actually, we want it marked, not selected
|
||||
bool result = base.OnCopyBegin();
|
||||
highlighted.Selected = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
return base.OnCopyBegin();
|
||||
|
|
|
@ -193,16 +193,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
float targetscaley = GetSidedefValue(target, targetparttype, "scaley", 1.0f);
|
||||
if(targetscaley != linescaley)
|
||||
{
|
||||
#if DEBUG //TODO: remove this
|
||||
string msg = "Case 1: '" + texturename + "' source " + sidedef.Line.Index + " (" + (sidedef.IsFront ? "front" : "back")
|
||||
+ "), target " + target.Line.Index + " (" + (target.IsFront ? "front" : "back")
|
||||
+ "): scale mismatch: target: " + targetscaley
|
||||
+ "; source: " + linescaley;
|
||||
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename, msg));
|
||||
#else
|
||||
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename));
|
||||
#endif
|
||||
}
|
||||
|
||||
float targetscalex = GetSidedefValue(target, targetparttype, "scalex", 1.0f);
|
||||
|
||||
alignedY %= texture.Height;
|
||||
|
@ -214,16 +207,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Submit result if target offsets don't match expected ones
|
||||
if(offsetx != alignedX || offsety != alignedY)
|
||||
{
|
||||
#if DEBUG //TODO: remove this
|
||||
string msg = "Case 1: '" + texturename + "' source " + sidedef.Line.Index + " (" + (sidedef.IsFront ? "front" : "back")
|
||||
+ "), target " + target.Line.Index + " (" + (target.IsFront ? "front" : "back")
|
||||
+ "): expected: " + alignedX + ", " + alignedY
|
||||
+ "; actual [source]: " + offsetx + ", " + offsety;
|
||||
|
||||
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename, msg));
|
||||
#else
|
||||
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Add to collection
|
||||
|
@ -258,15 +242,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
float targetscaley = GetSidedefValue(target, targetparttype, "scaley", 1.0f);
|
||||
if (targetscaley != linescaley)
|
||||
{
|
||||
#if DEBUG //TODO: remove this
|
||||
string msg = "Case 2: '" + texturename + "' source " + sidedef.Line.Index + " (" + (sidedef.IsFront ? "front" : "back")
|
||||
+ "), target " + target.Line.Index + " (" + (target.IsFront ? "front" : "back")
|
||||
+ "): scale mismatch: target: " + targetscaley
|
||||
+ "; source: " + linescaley;
|
||||
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename, msg));
|
||||
#else
|
||||
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename));
|
||||
#endif
|
||||
}
|
||||
|
||||
alignedY %= texture.Height;
|
||||
|
@ -278,16 +254,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Submit result if target offsets don't match expected ones
|
||||
if(offsetx != alignedX || offsety != alignedY)
|
||||
{
|
||||
#if DEBUG //TODO: remove this
|
||||
string msg = "Case 2: '" + texturename + "' source " + sidedef.Line.Index + " (" + (sidedef.IsFront ? "front" : "back")
|
||||
+ "), target " + target.Line.Index + " (" + (target.IsFront ? "front" : "back")
|
||||
+ "): expected: " + alignedX + ", " + alignedY
|
||||
+ "; actual [source]: " + offsetx + ", " + offsety;
|
||||
|
||||
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename, msg));
|
||||
#else
|
||||
SubmitResult(new ResultTexturesMisaligned(sidedef, target, texturename));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Add to collection
|
||||
|
@ -334,7 +301,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
donesides[type2][s2.Index][type1].Add(s1.Index, false);
|
||||
}
|
||||
|
||||
private int GetExpectedOffsetY(Sidedef source, Sidedef target, string texturename, int textureheight, float texturescaley, float linescaley, Rectangle partsize, out VisualGeometryType matchingparttype)
|
||||
private static int GetExpectedOffsetY(Sidedef source, Sidedef target, string texturename, int textureheight, float texturescaley, float linescaley, Rectangle partsize, out VisualGeometryType matchingparttype)
|
||||
{
|
||||
if(target.MiddleTexture == texturename
|
||||
&& partsize.IntersectsWith(BuilderModesTools.GetSidedefPartSize(target, VisualGeometryType.WALL_MIDDLE)))
|
||||
|
|
|
@ -27,19 +27,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
#if DEBUG //TODO: remove this
|
||||
public ResultTexturesMisaligned(Sidedef side1, Sidedef side2, string texturename, string message)
|
||||
{
|
||||
// Initialize
|
||||
this.side1 = side1;
|
||||
this.side2 = side2;
|
||||
this.texturename = texturename;
|
||||
viewobjects.Add(side1.Line);
|
||||
viewobjects.Add(side2.Line);
|
||||
hidden = (side1.IgnoredErrorChecks.Contains(this.GetType()) && side2.IgnoredErrorChecks.Contains(this.GetType()));
|
||||
description = "Textures are not aligned on given sidedefs. Some players may not like that.\n" + message;
|
||||
}
|
||||
#else
|
||||
public ResultTexturesMisaligned(Sidedef side1, Sidedef side2, string texturename)
|
||||
{
|
||||
// Initialize
|
||||
|
@ -51,7 +38,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
hidden = (side1.IgnoredErrorChecks.Contains(this.GetType()) && side2.IgnoredErrorChecks.Contains(this.GetType()));
|
||||
description = "Textures are not aligned on given sidedefs. Some players may not like that.";
|
||||
}
|
||||
#endif
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -3825,9 +3825,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
if(!matchbottom && !matchtop && !matchmid) continue; //mxd
|
||||
|
||||
j.sidedef.Fields.BeforeFieldsChange();
|
||||
j.controlSide.Fields.BeforeFieldsChange(); //mxd
|
||||
|
||||
//mxd. We want to skip realigning of the starting wall part
|
||||
if(matchtop) matchtop = (j.sidedef != start.Sidedef || start.GeometryType != VisualGeometryType.WALL_UPPER);
|
||||
if(matchmid) matchmid = (j.sidedef != start.Sidedef || (start.GeometryType != VisualGeometryType.WALL_MIDDLE && start.GeometryType != VisualGeometryType.WALL_MIDDLE_3D));
|
||||
if(matchbottom) matchbottom = (j.sidedef != start.Sidedef || start.GeometryType != VisualGeometryType.WALL_LOWER);
|
||||
|
||||
if(matchbottom || matchtop || matchmid)
|
||||
{
|
||||
j.sidedef.Fields.BeforeFieldsChange();
|
||||
j.controlSide.Fields.BeforeFieldsChange(); //mxd
|
||||
}
|
||||
|
||||
//mxd. Apply Scale
|
||||
if(matchtop)
|
||||
|
@ -3874,7 +3882,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
float offset = ((start.Sidedef.Sector.CeilHeight - j.ceilingHeight) / scaley) * j.scaleY + ystartalign; //mxd
|
||||
offset -= j.sidedef.OffsetY; //mxd
|
||||
offset = (float)Math.Round(offset); //mxd
|
||||
offset = (float)Math.Round(offset, General.Map.FormatInterface.VertexDecimals); //mxd
|
||||
|
||||
if(matchtop)
|
||||
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, Tools.GetSidedefTopOffsetY(j.sidedef, offset, j.scaleY / scaley, true) % General.Map.Data.GetTextureImage(j.sidedef.LongHighTexture).Height); //mxd
|
||||
|
@ -3898,7 +3906,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
//mxd. This should be doublesided non-wrapped line. Find the nearset aligned position
|
||||
float curoffset = UDMFTools.GetFloat(j.sidedef.Fields, "offsety_mid");
|
||||
offset += midtex.Height * (int)Math.Round((curoffset - offset) / midtex.Height);
|
||||
offset += midtex.Height * ((curoffset - offset) / midtex.Height);
|
||||
|
||||
// Make sure the surface stays between floor and ceiling
|
||||
if(offset < -midtex.Height)
|
||||
|
@ -3911,12 +3919,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, offset); //mxd
|
||||
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, (float)Math.Round(offset, General.Map.FormatInterface.VertexDecimals)); //mxd
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
forwardoffset = j.offsetx + (int)Math.Round(j.sidedef.Line.Length / scalex * first.scaleX);
|
||||
forwardoffset = j.offsetx + (float)Math.Round(j.sidedef.Line.Length / scalex * first.scaleX, General.Map.FormatInterface.VertexDecimals);
|
||||
backwardoffset = j.offsetx;
|
||||
|
||||
// Done this sidedef
|
||||
|
@ -3936,7 +3944,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Apply alignment
|
||||
if(alignx)
|
||||
{
|
||||
float offset = j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex * first.scaleX);
|
||||
float offset = j.offsetx - (float)Math.Round(j.sidedef.Line.Length / scalex * first.scaleX, General.Map.FormatInterface.VertexDecimals);
|
||||
offset -= j.sidedef.OffsetX;
|
||||
|
||||
if(matchtop)
|
||||
|
@ -3954,11 +3962,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
j.sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, offset % General.Map.Data.GetTextureImage(j.sidedef.LongMiddleTexture).Width);
|
||||
}
|
||||
}
|
||||
|
||||
if(aligny)
|
||||
{
|
||||
float offset = ((start.Sidedef.Sector.CeilHeight - j.ceilingHeight) / scaley) * j.scaleY + ystartalign; //mxd
|
||||
offset -= j.sidedef.OffsetY; //mxd
|
||||
offset = (float)Math.Round(offset); //mxd
|
||||
offset = (float)Math.Round(offset, General.Map.FormatInterface.VertexDecimals); //mxd
|
||||
|
||||
if(matchtop)
|
||||
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, Tools.GetSidedefTopOffsetY(j.sidedef, offset, j.scaleY / scaley, true) % General.Map.Data.GetTextureImage(j.sidedef.LongHighTexture).Height); //mxd
|
||||
|
@ -3982,7 +3991,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
//mxd. This should be doublesided non-wrapped line. Find the nearset aligned position
|
||||
float curoffset = UDMFTools.GetFloat(j.sidedef.Fields, "offsety_mid");
|
||||
offset += midtex.Height * (int)Math.Round((curoffset - offset) / midtex.Height);
|
||||
offset += midtex.Height * (float)Math.Round((curoffset - offset) / midtex.Height, General.Map.FormatInterface.VertexDecimals);
|
||||
|
||||
// Make sure the surface stays between floor and ceiling
|
||||
if(offset < -midtex.Height)
|
||||
|
@ -3999,8 +4008,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
forwardoffset = j.offsetx;
|
||||
backwardoffset = j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex * first.scaleX);
|
||||
backwardoffset = j.offsetx - (float)Math.Round(j.sidedef.Line.Length / scalex * first.scaleX, General.Map.FormatInterface.VertexDecimals);
|
||||
|
||||
// Done this sidedef
|
||||
j.sidedef.Marked = true;
|
||||
|
|
Loading…
Reference in a new issue