mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 22:41:46 +00:00
fixed invalid view/zoom when opening an empty map
This commit is contained in:
parent
4b068e93fe
commit
63b4f20172
1 changed files with 40 additions and 12 deletions
|
@ -275,6 +275,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
float bottom = float.MinValue;
|
||||
float scalew, scaleh, scale;
|
||||
float width, height;
|
||||
bool anything = false;
|
||||
|
||||
// Go for all vertices
|
||||
foreach(Vertex v in General.Map.Map.Vertices)
|
||||
|
@ -287,9 +288,28 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
if(v.Position.x > right) right = v.Position.x;
|
||||
if(v.Position.y < top) top = v.Position.y;
|
||||
if(v.Position.y > bottom) bottom = v.Position.y;
|
||||
anything = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Not already found something to center in view?
|
||||
if(!anything)
|
||||
{
|
||||
// Go for all things
|
||||
foreach(Thing t in General.Map.Map.Things)
|
||||
{
|
||||
// Adjust boundaries by vertices
|
||||
if(t.Position.x < left) left = t.Position.x;
|
||||
if(t.Position.x > right) right = t.Position.x;
|
||||
if(t.Position.y < top) top = t.Position.y;
|
||||
if(t.Position.y > bottom) bottom = t.Position.y;
|
||||
anything = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Anything found to center in view?
|
||||
if(anything)
|
||||
{
|
||||
// Calculate width/height
|
||||
width = (right - left);
|
||||
height = (bottom - top);
|
||||
|
@ -303,6 +323,14 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
renderer2d.ScaleView(scale);
|
||||
renderer2d.PositionView(left + (right - left) * 0.5f, top + (bottom - top) * 0.5f);
|
||||
this.OnViewChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Default view
|
||||
renderer2d.ScaleView(0.5f);
|
||||
renderer2d.PositionView(0.0f, 0.0f);
|
||||
this.OnViewChanged();
|
||||
}
|
||||
|
||||
// Redraw
|
||||
//General.Map.Map.Update();
|
||||
|
|
Loading…
Reference in a new issue