mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
some fixes and the ability to start drawing with right-click (Edit) when nothing is highlighted
This commit is contained in:
parent
8805a48058
commit
e2e9e17985
9 changed files with 113 additions and 28 deletions
BIN
Resources/Icons/ThingsListIcon.png
Normal file
BIN
Resources/Icons/ThingsListIcon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 729 B |
BIN
Resources/ThingColors.png
Normal file
BIN
Resources/ThingColors.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 114 KiB |
|
@ -745,6 +745,32 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Update();
|
||||
}
|
||||
|
||||
// This draws a point at a specific location
|
||||
public void DrawPointAt(Vector2D pos, bool stitch)
|
||||
{
|
||||
DrawnVertex newpoint = new DrawnVertex();
|
||||
newpoint.pos = pos;
|
||||
newpoint.stitch = stitch;
|
||||
points.Add(newpoint);
|
||||
labels.Add(new LineLengthLabel());
|
||||
labels[labels.Count - 1].Start = newpoint.pos;
|
||||
if(labels.Count > 1) labels[labels.Count - 2].End = newpoint.pos;
|
||||
Update();
|
||||
|
||||
// Check if point stitches with the first
|
||||
if((points.Count > 1) && (points[points.Count - 1].stitch))
|
||||
{
|
||||
Vector2D p1 = points[0].pos;
|
||||
Vector2D p2 = points[points.Count - 1].pos;
|
||||
Vector2D delta = p1 - p2;
|
||||
if((Math.Abs(delta.x) <= 0.001f) && (Math.Abs(delta.y) <= 0.001f))
|
||||
{
|
||||
// Finish drawing
|
||||
FinishDraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Drawing a point
|
||||
[BeginAction("drawpoint")]
|
||||
public void DrawPoint()
|
||||
|
@ -753,24 +779,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(General.Interface.MouseInDisplay)
|
||||
{
|
||||
DrawnVertex newpoint = GetCurrentPosition();
|
||||
points.Add(newpoint);
|
||||
labels.Add(new LineLengthLabel());
|
||||
labels[labels.Count - 1].Start = newpoint.pos;
|
||||
if(labels.Count > 1) labels[labels.Count - 2].End = newpoint.pos;
|
||||
Update();
|
||||
|
||||
// Check if point stitches with the first
|
||||
if((points.Count > 1) && (points[points.Count - 1].stitch))
|
||||
{
|
||||
Vector2D p1 = points[0].pos;
|
||||
Vector2D p2 = points[points.Count - 1].pos;
|
||||
Vector2D delta = p1 - p2;
|
||||
if((Math.Abs(delta.x) <= 0.001f) && (Math.Abs(delta.y) <= 0.001f))
|
||||
{
|
||||
// Finish drawing
|
||||
FinishDraw();
|
||||
}
|
||||
}
|
||||
DrawPointAt(newpoint.pos, newpoint.stitch);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
// Edit pressed in this mode
|
||||
editpressed = true;
|
||||
|
||||
|
||||
// Highlighted item not selected?
|
||||
if(!highlighted.Selected)
|
||||
{
|
||||
|
@ -282,7 +282,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
renderer.Present();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Start drawing mode
|
||||
DrawGeometryMode drawmode = new DrawGeometryMode();
|
||||
drawmode.DrawPointAt(mousemappos, true);
|
||||
General.Map.ChangeMode(drawmode);
|
||||
}
|
||||
|
||||
base.OnEdit();
|
||||
}
|
||||
|
||||
|
|
|
@ -344,7 +344,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
renderer.Present();
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Start drawing mode
|
||||
DrawGeometryMode drawmode = new DrawGeometryMode();
|
||||
drawmode.DrawPointAt(mousemappos, true);
|
||||
General.Map.ChangeMode(drawmode);
|
||||
}
|
||||
|
||||
base.OnEdit();
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
#region ================== Constants
|
||||
|
||||
public const float VERTEX_HIGHLIGHT_RANGE = 20f;
|
||||
public const float LINEDEF_SPLIT_RANGE = 8f;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -242,9 +243,48 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Start editing
|
||||
protected override void OnEdit()
|
||||
{
|
||||
// Edit pressed in this mode
|
||||
editpressed = true;
|
||||
// Vertex highlighted?
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
{
|
||||
// Edit pressed in this mode
|
||||
editpressed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the nearest linedef within highlight range
|
||||
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, LINEDEF_SPLIT_RANGE / renderer.Scale);
|
||||
|
||||
// Found a line?
|
||||
if(l != null)
|
||||
{
|
||||
// Create undo
|
||||
General.Map.UndoRedo.CreateUndo("Split linedef", UndoGroup.None, 0);
|
||||
|
||||
// Create vertex at nearest point on line
|
||||
Vector2D nearestpos = l.NearestOnLine(mousemappos);
|
||||
Vertex v = General.Map.Map.CreateVertex(nearestpos);
|
||||
|
||||
// Snap to map format accuracy
|
||||
v.SnapToAccuracy();
|
||||
|
||||
// Split the line with this vertex
|
||||
l.Split(v);
|
||||
|
||||
// Highlight it
|
||||
Highlight(v);
|
||||
|
||||
// Redraw display
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start drawing mode
|
||||
DrawGeometryMode drawmode = new DrawGeometryMode();
|
||||
drawmode.DrawPointAt(mousemappos, true);
|
||||
General.Map.ChangeMode(drawmode);
|
||||
}
|
||||
}
|
||||
|
||||
base.OnEdit();
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
public bool AllowScroll { get { return allowscroll; } }
|
||||
public bool DisregardShift { get { return disregardshift; } }
|
||||
public bool Repeat { get { return repeat; } }
|
||||
|
||||
public bool BeginBound { get { return (begindelegates.Count > 0); } }
|
||||
public bool EndBound { get { return (enddelegates.Count > 0); } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
|
|
@ -469,17 +469,22 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
// This will call the associated actions for a keypress
|
||||
private void BeginActionByKey(int key, bool repeated)
|
||||
{
|
||||
// Go for all actions
|
||||
// Get all actions for which a begin is bound
|
||||
List<Action> boundactions = new List<Action>(actions.Count);
|
||||
foreach(KeyValuePair<string, Action> a in actions)
|
||||
if(a.Value.BeginBound) boundactions.Add(a.Value);
|
||||
|
||||
// Go for all actions
|
||||
foreach(Action a in boundactions)
|
||||
{
|
||||
// This action is associated with this key?
|
||||
if(a.Value.KeyMatches(key))
|
||||
if(a.KeyMatches(key))
|
||||
{
|
||||
// Allowed to repeat?
|
||||
if(a.Value.Repeat || !repeated)
|
||||
if(a.Repeat || !repeated)
|
||||
{
|
||||
// Invoke action
|
||||
a.Value.Begin();
|
||||
a.Begin();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -89,6 +89,21 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// Initialize
|
||||
this.renderer = General.Map.Renderer2D;
|
||||
this.renderer2d = (Renderer2D)General.Map.Renderer2D;
|
||||
|
||||
// If the current mode is a ClassicMode, copy mouse properties
|
||||
if(General.Map.Mode is ClassicMode)
|
||||
{
|
||||
ClassicMode oldmode = General.Map.Mode as ClassicMode;
|
||||
|
||||
// Copy mouse properties
|
||||
mousepos = oldmode.mousepos;
|
||||
mousemappos = oldmode.mousemappos;
|
||||
mousedownpos = oldmode.mousedownpos;
|
||||
mousedownmappos = oldmode.mousedownmappos;
|
||||
mousebuttons = oldmode.mousebuttons;
|
||||
mouseinside = oldmode.mouseinside;
|
||||
mousedragging = oldmode.mousedragging;
|
||||
}
|
||||
}
|
||||
|
||||
// Disposer
|
||||
|
|
Loading…
Reference in a new issue