mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 20:32:34 +00:00
712dbd03e8
Changed: current 2D position and zoom is now stored in the .dbs file when saving the map and restored when opening it (should this be turned into toggleable option?). Draw Lines mode, Draw Curve mode: you can now hold Alt - Shift to snap to 8 cardinal directions. Draw Rectangle mode, Draw Grid mode: you can now hold Alt - Shift to draw square shapes. Draw Ellipse mode: you can now hold Alt - Shift to draw circle shapes. You can now hold Alt - Shift to snap to 8 cardinal directions while dragging map objects. Fixed, Draw Lines mode: line angle is now displayed in 0..359 range (was -45..314). Fixed, Linedef info panel: line angle is now displayed in 0..359 range (was -45..314).
125 lines
2.8 KiB
C#
125 lines
2.8 KiB
C#
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
/*
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
* This program is released under GNU General Public License
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
*/
|
|
|
|
#endregion
|
|
|
|
#region ================== Namespaces
|
|
|
|
using System;
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
using System.Drawing;
|
|
|
|
#endregion
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
{
|
|
public class LineLengthLabel : IDisposable
|
|
{
|
|
#region ================== Constants
|
|
|
|
private const int TEXT_CAPACITY = 15;
|
|
private const float TEXT_SCALE = 14f;
|
|
private const string VALUE_FORMAT = "0";
|
|
|
|
#endregion
|
|
|
|
#region ================== Variables
|
|
|
|
protected TextLabel label;
|
|
protected Vector2D start;
|
|
protected Vector2D end;
|
|
private readonly bool showAngle; //mxd
|
|
|
|
#endregion
|
|
|
|
#region ================== Properties
|
|
|
|
public TextLabel TextLabel { get { return label; } }
|
|
public Vector2D Start { get { return start; } set { start = value; Update(); } }
|
|
public Vector2D End { get { return end; } set { end = value; Update(); } }
|
|
|
|
#endregion
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
// Constructor
|
|
public LineLengthLabel(bool showAngle)
|
|
{
|
|
this.showAngle = showAngle; //mxd
|
|
// Initialize
|
|
Initialize();
|
|
}
|
|
|
|
// Constructor
|
|
public LineLengthLabel(Vector2D start, Vector2D end)
|
|
{
|
|
// Initialize
|
|
Initialize();
|
|
Move(start, end);
|
|
}
|
|
|
|
// Initialization
|
|
protected virtual void Initialize()
|
|
{
|
|
label = new TextLabel(TEXT_CAPACITY);
|
|
label.AlignX = TextAlignmentX.Center;
|
|
label.AlignY = TextAlignmentY.Middle;
|
|
label.Color = General.Colors.Highlight;
|
|
label.Backcolor = General.Colors.Background;
|
|
label.Scale = TEXT_SCALE;
|
|
label.TransformCoords = true;
|
|
}
|
|
|
|
// Disposer
|
|
public void Dispose()
|
|
{
|
|
label.Dispose();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ================== Methods
|
|
|
|
// This updates the text
|
|
protected virtual void Update()
|
|
{
|
|
Vector2D delta = end - start;
|
|
float length = delta.GetLength();
|
|
|
|
//mxd
|
|
if(showAngle)
|
|
{
|
|
int angle = General.ClampAngle((int)Math.Round(Angle2D.RadToDeg(delta.GetAngle())));
|
|
label.Text = "l:" + length.ToString(VALUE_FORMAT) + "; a:" + angle;
|
|
}
|
|
else
|
|
{
|
|
label.Text = length.ToString(VALUE_FORMAT);
|
|
}
|
|
|
|
label.Rectangle = new RectangleF(start.x + delta.x * 0.5f, start.y + delta.y * 0.5f, 0f, 0f);
|
|
}
|
|
|
|
// This moves the label
|
|
public void Move(Vector2D start, Vector2D end)
|
|
{
|
|
this.start = start;
|
|
this.end = end;
|
|
Update();
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|