mirror of
https://git.do.srb2.org/STJr/ZoneBuilder.git
synced 2025-01-31 05:00:34 +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,16 +539,29 @@ namespace CodeImp.DoomBuilder
|
|||
// Restore selection groups
|
||||
options.ReadSelectionGroups();
|
||||
|
||||
// Center map in screen or on stored coordinates
|
||||
ClassicMode mode = General.Editing.Mode as ClassicMode;
|
||||
if(mode != null)
|
||||
if(General.Editing.Mode != null)
|
||||
{
|
||||
mode.OnRedoEnd();
|
||||
if(General.Editing.Mode is ClassicMode)
|
||||
{
|
||||
ClassicMode mode = (ClassicMode)General.Editing.Mode;
|
||||
mode.OnRedoEnd();
|
||||
|
||||
if(options.ViewPosition.IsFinite() && !float.IsNaN(options.ViewScale))
|
||||
mode.CenterOnCoordinates(options.ViewPosition, options.ViewScale);
|
||||
else
|
||||
mode.CenterInScreen();
|
||||
// Center map in screen or on stored coordinates
|
||||
if(options.ViewPosition.IsFinite() && !float.IsNaN(options.ViewScale))
|
||||
mode.CenterOnCoordinates(options.ViewPosition, options.ViewScale);
|
||||
else
|
||||
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
|
||||
|
|
|
@ -1150,18 +1150,22 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
[BeginAction("centeroncoordinates", BaseAction = true)]
|
||||
protected virtual void CenterOnCoordinates()
|
||||
{
|
||||
//show form...
|
||||
// Show form...
|
||||
CenterOnCoordinatesForm form = new CenterOnCoordinatesForm();
|
||||
if(form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Sector s = General.Map.Map.GetSectorByCoordinates(form.Coordinates, blockmap);
|
||||
if(form.ShowDialog() == DialogResult.OK) CenterOnCoordinates(form.Coordinates);
|
||||
}
|
||||
|
||||
if(s == null)
|
||||
General.Map.VisualCamera.Position = form.Coordinates;
|
||||
else
|
||||
General.Map.VisualCamera.Position = new Vector3D(form.Coordinates.x, form.Coordinates.y, s.FloorHeight + 54);
|
||||
General.Map.VisualCamera.Sector = s;
|
||||
}
|
||||
//mxd
|
||||
public void CenterOnCoordinates(Vector2D coords)
|
||||
{
|
||||
Sector s = General.Map.Map.GetSectorByCoordinates(coords, blockmap);
|
||||
|
||||
if(s == null)
|
||||
General.Map.VisualCamera.Position = coords;
|
||||
else
|
||||
General.Map.VisualCamera.Position = new Vector3D(coords.x, coords.y, s.FloorHeight + 54);
|
||||
|
||||
General.Map.VisualCamera.Sector = s;
|
||||
}
|
||||
|
||||
//mxd
|
||||
|
|
Loading…
Reference in a new issue