mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
Map Analysis mode: added "Check very short linedefs" check (unchecked by default), which finds linedefs shorter than 1 m.u.
Fixed: script editor must be closed during "Open map in current WAD" action. Added: PNG offsets are now taken into account when loading sprites.
This commit is contained in:
parent
712dbd03e8
commit
643460efa6
7 changed files with 155 additions and 4 deletions
|
@ -1309,6 +1309,9 @@ namespace CodeImp.DoomBuilder
|
|||
mainwindow.ClearDisplay();
|
||||
mainwindow.RemoveHintsDocker(); //mxd
|
||||
|
||||
//mxd. Close the script editor
|
||||
map.CloseScriptEditor(false);
|
||||
|
||||
// Let the plugins know
|
||||
plugins.OnMapOpenBegin();
|
||||
|
||||
|
|
|
@ -376,9 +376,43 @@ namespace CodeImp.DoomBuilder.IO
|
|||
{
|
||||
offsetx = int.MinValue;
|
||||
offsety = int.MinValue;
|
||||
return ReadAsBitmap(stream);
|
||||
}
|
||||
Bitmap bmp = ReadAsBitmap(stream);
|
||||
|
||||
//mxd. Read PNG offsets
|
||||
if(imagetype == DevilImageType.IL_PNG && bmp != null)
|
||||
{
|
||||
stream.Position = 8;
|
||||
using(BinaryReader reader = new BinaryReader(stream))
|
||||
{
|
||||
// Read chunks untill we encounter either "grAb" or "IDAT"
|
||||
while(reader.BaseStream.Position < reader.BaseStream.Length)
|
||||
{
|
||||
// Big Endian!
|
||||
int chunklength = ToInt32BigEndian(reader.ReadBytes(4));
|
||||
string chunkname = new string(reader.ReadChars(4));
|
||||
|
||||
if(chunkname == "grAb")
|
||||
{
|
||||
offsetx = ToInt32BigEndian(reader.ReadBytes(4));
|
||||
offsety = ToInt32BigEndian(reader.ReadBytes(4));
|
||||
break;
|
||||
}
|
||||
else if(chunkname == "IDAT")
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skip the rest of the chunk
|
||||
reader.BaseStream.Position += chunklength + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return the image
|
||||
return bmp;
|
||||
}
|
||||
|
||||
// This reads the image and returns a Bitmap
|
||||
public Bitmap ReadAsBitmap(Stream stream)
|
||||
|
@ -478,6 +512,12 @@ namespace CodeImp.DoomBuilder.IO
|
|||
throw new InvalidDataException();
|
||||
}
|
||||
}
|
||||
|
||||
//mxd
|
||||
private static int ToInt32BigEndian(byte[] buffer)
|
||||
{
|
||||
return (buffer[0] << 24) | (buffer[1] << 16) | (buffer[2] << 8) | buffer[3];
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -228,6 +228,7 @@
|
|||
<Compile Include="ErrorChecks\CheckMissingFlats.cs" />
|
||||
<Compile Include="ErrorChecks\CheckMissingTextures.cs" />
|
||||
<Compile Include="ErrorChecks\CheckOverlappingVertices.cs" />
|
||||
<Compile Include="ErrorChecks\CheckShortLinedefs.cs" />
|
||||
<Compile Include="ErrorChecks\CheckStrayVertices.cs" />
|
||||
<Compile Include="ErrorChecks\CheckTextureAlignment.cs" />
|
||||
<Compile Include="ErrorChecks\CheckUnknownFlats.cs" />
|
||||
|
@ -238,6 +239,7 @@
|
|||
<Compile Include="ErrorChecks\ResultMissingFlat.cs" />
|
||||
<Compile Include="ErrorChecks\ResultNoErrors.cs" />
|
||||
<Compile Include="ErrorChecks\ResultSectorInvalid.cs" />
|
||||
<Compile Include="ErrorChecks\ResultShortLinedef.cs" />
|
||||
<Compile Include="ErrorChecks\ResultStrayVertex.cs" />
|
||||
<Compile Include="ErrorChecks\ResultStuckThingInThing.cs" />
|
||||
<Compile Include="ErrorChecks\ResultMissingTexture.cs" />
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
using CodeImp.DoomBuilder.Map;
|
||||
using System.Threading;
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
[ErrorChecker("Check very short linedefs", false, 10)]
|
||||
public class CheckShortLinedefs : ErrorChecker
|
||||
{
|
||||
private const int PROGRESS_STEP = 1000;
|
||||
|
||||
// Constructor
|
||||
public CheckShortLinedefs()
|
||||
{
|
||||
// Total progress is done when all linedefs are checked
|
||||
SetTotalProgress(General.Map.Map.Linedefs.Count / PROGRESS_STEP);
|
||||
}
|
||||
|
||||
// This runs the check
|
||||
public override void Run()
|
||||
{
|
||||
int progress = 0;
|
||||
int stepprogress = 0;
|
||||
|
||||
// Go for all linedefs
|
||||
foreach(Linedef l in General.Map.Map.Linedefs)
|
||||
{
|
||||
if(l.Length < 1.0f) SubmitResult(new ResultShortLinedef(l));
|
||||
|
||||
// Handle thread interruption
|
||||
try { Thread.Sleep(0); } catch(ThreadInterruptedException) { return; }
|
||||
|
||||
// We are making progress!
|
||||
if((++progress / PROGRESS_STEP) > stepprogress)
|
||||
{
|
||||
stepprogress = (progress / PROGRESS_STEP);
|
||||
AddProgress(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
int progress = 0;
|
||||
int stepprogress = 0;
|
||||
|
||||
// Go for all things
|
||||
// Go for all vertices
|
||||
foreach(Vertex v in General.Map.Map.Vertices)
|
||||
{
|
||||
if(v.Linedefs == null || v.Linedefs.Count == 0) SubmitResult(new ResultStrayVertex(v));
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
public class ResultShortLinedef : ErrorResult
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
private readonly Linedef line;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override int Buttons { get { return 0; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Destructor
|
||||
|
||||
// Constructor
|
||||
public ResultShortLinedef(Linedef l)
|
||||
{
|
||||
// Initialize
|
||||
line = l;
|
||||
viewobjects.Add(l);
|
||||
hidden = l.IgnoredErrorChecks.Contains(this.GetType()); //mxd
|
||||
description = "This linedef is shorter than 1 map unit. This can porentially cause nodebuilding errors.";
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This sets if this result is displayed in ErrorCheckForm (mxd)
|
||||
internal override void Hide(bool hide)
|
||||
{
|
||||
hidden = hide;
|
||||
Type t = this.GetType();
|
||||
if(hide) line.IgnoredErrorChecks.Add(t);
|
||||
else if(line.IgnoredErrorChecks.Contains(t)) line.IgnoredErrorChecks.Remove(t);
|
||||
}
|
||||
|
||||
// This must return the string that is displayed in the listbox
|
||||
public override string ToString()
|
||||
{
|
||||
return "Linedef " + line.Index + " is shorter than 1 m.u.";
|
||||
}
|
||||
|
||||
// Rendering
|
||||
public override void PlotSelection(IRenderer2D renderer)
|
||||
{
|
||||
renderer.PlotLinedef(line, General.Colors.Selection);
|
||||
renderer.PlotVertex(line.Start, ColorCollection.VERTICES);
|
||||
renderer.PlotVertex(line.End, ColorCollection.VERTICES);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue