mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
added automatic zoom in on selected object in Map Analysis mode
This commit is contained in:
parent
f4b62e26ca
commit
943a9f9f85
11 changed files with 85 additions and 5 deletions
|
@ -33,6 +33,7 @@ using CodeImp.DoomBuilder.Editing;
|
|||
using CodeImp.DoomBuilder.Actions;
|
||||
using CodeImp.DoomBuilder.Types;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using System.Drawing;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -43,6 +44,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
#region ================== Variables
|
||||
|
||||
protected string description;
|
||||
protected List<MapElement> viewobjects;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -64,6 +66,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public ErrorResult()
|
||||
{
|
||||
// Initialize
|
||||
viewobjects = new List<MapElement>(1);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -112,6 +115,74 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
}
|
||||
|
||||
// Call this to zoom in on the given selection
|
||||
public void ZoomToObject()
|
||||
{
|
||||
List<Vector2D> points = new List<Vector2D>();
|
||||
RectangleF area = MapSet.CreateEmptyArea();
|
||||
|
||||
// Add all points to a list
|
||||
foreach(MapElement obj in viewobjects)
|
||||
{
|
||||
if(obj is Vertex)
|
||||
{
|
||||
points.Add((obj as Vertex).Position);
|
||||
}
|
||||
else if(obj is Linedef)
|
||||
{
|
||||
points.Add((obj as Linedef).Start.Position);
|
||||
points.Add((obj as Linedef).End.Position);
|
||||
}
|
||||
else if(obj is Sector)
|
||||
{
|
||||
Sector s = (obj as Sector);
|
||||
foreach(Sidedef sd in s.Sidedefs)
|
||||
{
|
||||
points.Add(sd.Line.Start.Position);
|
||||
points.Add(sd.Line.End.Position);
|
||||
}
|
||||
}
|
||||
else if(obj is Thing)
|
||||
{
|
||||
Thing t = (obj as Thing);
|
||||
Vector2D p = (Vector2D)t.Position;
|
||||
points.Add(p);
|
||||
points.Add(p + new Vector2D(t.Size * 2.0f, t.Size * 2.0f));
|
||||
points.Add(p + new Vector2D(t.Size * 2.0f, -t.Size * 2.0f));
|
||||
points.Add(p + new Vector2D(-t.Size * 2.0f, t.Size * 2.0f));
|
||||
points.Add(p + new Vector2D(-t.Size * 2.0f, -t.Size * 2.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
General.Fail("Unknown object given to zoom in on.");
|
||||
}
|
||||
}
|
||||
|
||||
// Make a view area from the points
|
||||
foreach(Vector2D p in points) area = MapSet.IncreaseArea(area, p);
|
||||
|
||||
// Make the area square, using the largest side
|
||||
if(area.Width > area.Height)
|
||||
{
|
||||
float delta = area.Width - area.Height;
|
||||
area.Y -= delta * 0.5f;
|
||||
area.Height += delta;
|
||||
}
|
||||
else
|
||||
{
|
||||
float delta = area.Height - area.Width;
|
||||
area.X -= delta * 0.5f;
|
||||
area.Width += delta;
|
||||
}
|
||||
|
||||
// Add padding
|
||||
area.Inflate(100f, 100f);
|
||||
|
||||
// Zoom to area
|
||||
ClassicMode editmode = (General.Editing.Mode as ClassicMode);
|
||||
editmode.CenterOnArea(area, 0.6f);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Initialize
|
||||
this.line = l;
|
||||
this.viewobjects.Add(l);
|
||||
this.description = "This linedef has a back sidedef, but is missing a front sidedef. " +
|
||||
"A line must have at least a front side and optionally a back side! " +
|
||||
"Click Flip Linedef if the line is supposed to be single-sided.";
|
||||
|
|
|
@ -67,6 +67,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Initialize
|
||||
this.line = l;
|
||||
this.viewobjects.Add(l);
|
||||
this.description = "This linedef is missing front and back sidedefs." +
|
||||
"A line must have at least a front side and optionally a back side!";
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Initialize
|
||||
this.line = l;
|
||||
this.viewobjects.Add(l);
|
||||
this.description = "This linedef is marked as double-sided, but is missing the back sidedef. Click Make Single-Sided to remove the double-sided flag from the line.";
|
||||
|
||||
// One solution is to remove the double-sided flag
|
||||
|
|
|
@ -61,6 +61,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Initialize
|
||||
this.line = l;
|
||||
this.viewobjects.Add(l);
|
||||
this.description = "This linedef is marked as single-sided, but has both a front and a back sidedef. Click Make Double-Sided to flag the line as double-sided." +
|
||||
" Or click Remove Sidedef to remove the sidedef on the back side (making the line really single-sided).";
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Initialize
|
||||
this.line1 = l1;
|
||||
this.line2 = l2;
|
||||
this.viewobjects.Add(l1);
|
||||
this.viewobjects.Add(l2);
|
||||
this.description = "These linedefs are overlapping and they do not reference the same sector on all sides. Overlapping lines is only allowed when they reference the same sector on all sides.";
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Initialize
|
||||
this.thing = t;
|
||||
this.viewobjects.Add(t);
|
||||
this.description = "This thing is stucked in a wall (single-sided line) and will likely not be able to move around.";
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Initialize
|
||||
this.thing = t;
|
||||
this.viewobjects.Add(t);
|
||||
this.description = "This thing is completely outside the map.";
|
||||
}
|
||||
|
||||
|
|
|
@ -101,10 +101,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Thing t = (obj as Thing);
|
||||
Vector2D p = (Vector2D)t.Position;
|
||||
points.Add(p);
|
||||
points.Add(p + new Vector2D(t.Size, t.Size));
|
||||
points.Add(p + new Vector2D(t.Size, -t.Size));
|
||||
points.Add(p + new Vector2D(-t.Size, t.Size));
|
||||
points.Add(p + new Vector2D(-t.Size, -t.Size));
|
||||
points.Add(p + new Vector2D(t.Size * 2.0f, t.Size * 2.0f));
|
||||
points.Add(p + new Vector2D(t.Size * 2.0f, -t.Size * 2.0f));
|
||||
points.Add(p + new Vector2D(-t.Size * 2.0f, t.Size * 2.0f));
|
||||
points.Add(p + new Vector2D(-t.Size * 2.0f, -t.Size * 2.0f));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Zoom to area
|
||||
ClassicMode editmode = (General.Editing.Mode as ClassicMode);
|
||||
editmode.CenterOnArea(area, 1f);
|
||||
editmode.CenterOnArea(area, 0.6f);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -375,6 +375,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
fix1.Visible = (r.Buttons >= 1);
|
||||
fix2.Visible = (r.Buttons >= 2);
|
||||
fix3.Visible = (r.Buttons >= 3);
|
||||
r.ZoomToObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue