mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-02-07 16:31:24 +00:00
Fixed a crash when using "Open map in current WAD" action in Visual mode.
This commit is contained in:
parent
5a6e62aa4f
commit
64c93749a0
2 changed files with 35 additions and 18 deletions
|
@ -539,17 +539,30 @@ namespace CodeImp.DoomBuilder
|
||||||
// Restore selection groups
|
// Restore selection groups
|
||||||
options.ReadSelectionGroups();
|
options.ReadSelectionGroups();
|
||||||
|
|
||||||
// Center map in screen or on stored coordinates
|
if(General.Editing.Mode != null)
|
||||||
ClassicMode mode = General.Editing.Mode as ClassicMode;
|
|
||||||
if(mode != null)
|
|
||||||
{
|
{
|
||||||
|
if(General.Editing.Mode is ClassicMode)
|
||||||
|
{
|
||||||
|
ClassicMode mode = (ClassicMode)General.Editing.Mode;
|
||||||
mode.OnRedoEnd();
|
mode.OnRedoEnd();
|
||||||
|
|
||||||
|
// Center map in screen or on stored coordinates
|
||||||
if(options.ViewPosition.IsFinite() && !float.IsNaN(options.ViewScale))
|
if(options.ViewPosition.IsFinite() && !float.IsNaN(options.ViewScale))
|
||||||
mode.CenterOnCoordinates(options.ViewPosition, options.ViewScale);
|
mode.CenterOnCoordinates(options.ViewPosition, options.ViewScale);
|
||||||
else
|
else
|
||||||
mode.CenterInScreen();
|
mode.CenterInScreen();
|
||||||
}
|
}
|
||||||
|
else if(General.Editing.Mode is VisualMode)
|
||||||
|
{
|
||||||
|
VisualMode mode = (VisualMode)General.Editing.Mode;
|
||||||
|
|
||||||
|
// This will rebuild blockmap, among the other things
|
||||||
|
General.Editing.Mode.OnReloadResources();
|
||||||
|
|
||||||
|
// Update camera position
|
||||||
|
if(options.ViewPosition.IsFinite()) mode.CenterOnCoordinates(options.ViewPosition);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Success
|
// Success
|
||||||
this.changed = maprestored;
|
this.changed = maprestored;
|
||||||
|
|
|
@ -1150,19 +1150,23 @@ namespace CodeImp.DoomBuilder.VisualModes
|
||||||
[BeginAction("centeroncoordinates", BaseAction = true)]
|
[BeginAction("centeroncoordinates", BaseAction = true)]
|
||||||
protected virtual void CenterOnCoordinates()
|
protected virtual void CenterOnCoordinates()
|
||||||
{
|
{
|
||||||
//show form...
|
// Show form...
|
||||||
CenterOnCoordinatesForm form = new CenterOnCoordinatesForm();
|
CenterOnCoordinatesForm form = new CenterOnCoordinatesForm();
|
||||||
if(form.ShowDialog() == DialogResult.OK)
|
if(form.ShowDialog() == DialogResult.OK) CenterOnCoordinates(form.Coordinates);
|
||||||
|
}
|
||||||
|
|
||||||
|
//mxd
|
||||||
|
public void CenterOnCoordinates(Vector2D coords)
|
||||||
{
|
{
|
||||||
Sector s = General.Map.Map.GetSectorByCoordinates(form.Coordinates, blockmap);
|
Sector s = General.Map.Map.GetSectorByCoordinates(coords, blockmap);
|
||||||
|
|
||||||
if(s == null)
|
if(s == null)
|
||||||
General.Map.VisualCamera.Position = form.Coordinates;
|
General.Map.VisualCamera.Position = coords;
|
||||||
else
|
else
|
||||||
General.Map.VisualCamera.Position = new Vector3D(form.Coordinates.x, form.Coordinates.y, s.FloorHeight + 54);
|
General.Map.VisualCamera.Position = new Vector3D(coords.x, coords.y, s.FloorHeight + 54);
|
||||||
|
|
||||||
General.Map.VisualCamera.Sector = s;
|
General.Map.VisualCamera.Sector = s;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
[BeginAction("togglehighlight", BaseAction = true)]
|
[BeginAction("togglehighlight", BaseAction = true)]
|
||||||
|
|
Loading…
Reference in a new issue