- Insert action in Vertices, Lines and Sectors mode now inserts a vertex that also snaps to geometry and grid, when preferred

- Undo now works for insertactions
This commit is contained in:
codeimp 2009-01-17 12:14:46 +00:00
parent 88124438aa
commit 9854653465
4 changed files with 7 additions and 51 deletions

View file

@ -523,30 +523,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This creates a new vertex at the mouse position
[BeginAction("insertitem", BaseAction = true)]
public virtual void InsertVertex()
{
// Mouse in window?
if(mouseinside)
{
// Create vertex at mouse position
Vertex v = General.Map.Map.CreateVertex(mousemappos);
// Snap to grid enabled?
if(General.Interface.SnapToGrid)
{
// Snap to grid
v.SnapToGrid();
}
else
{
// Snap to map format accuracy
v.SnapToAccuracy();
}
// Redraw screen
General.Interface.RedrawDisplay();
}
}
public virtual void InsertVertexAction() { VerticesMode.InsertVertex(mousemappos, renderer.Scale); }
[BeginAction("deleteitem", BaseAction = true)]
public void DeleteItem()

View file

@ -675,30 +675,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This creates a new vertex at the mouse position
[BeginAction("insertitem", BaseAction = true)]
public virtual void InsertVertex()
{
// Mouse in window?
if(mouseinside)
{
// Create vertex at mouse position
Vertex v = General.Map.Map.CreateVertex(mousemappos);
// Snap to grid enabled?
if(General.Interface.SnapToGrid)
{
// Snap to grid
v.SnapToGrid();
}
else
{
// Snap to map format accuracy
v.SnapToAccuracy();
}
// Redraw screen
General.Interface.RedrawDisplay();
}
}
public virtual void InsertVertexAction() { VerticesMode.InsertVertex(mousemappos, renderer.Scale); }
[BeginAction("makedoor")]
public void MakeDoor()

View file

@ -510,6 +510,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(mouseinside)
{
// Insert new thing
General.Map.UndoRedo.CreateUndo("Insert thing");
InsertThing(mousemappos);
// Redraw screen

View file

@ -446,13 +446,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This creates a new vertex at the mouse position
[BeginAction("insertitem", BaseAction = true)]
public virtual void InsertVertex()
public virtual void InsertVertexAction() { VerticesMode.InsertVertex(mousemappos, renderer.Scale); }
public static void InsertVertex(Vector2D mousemappos, float rendererscale)
{
bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid;
bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge;
// Mouse in window?
if(mouseinside)
if(General.Interface.MouseInDisplay)
{
Vector2D insertpos;
Linedef l = null;
@ -461,7 +462,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Map.UndoRedo.CreateUndo("Insert vertex");
// Snap to geometry?
l = General.Map.Map.NearestLinedefRange(mousemappos, LINEDEF_SPLIT_RANGE / renderer.Scale);
l = General.Map.Map.NearestLinedefRange(mousemappos, LINEDEF_SPLIT_RANGE / rendererscale);
if(snaptonearest && (l != null))
{
// Snip to grid also?