mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-26 22:01:45 +00:00
- 'delete item' implemented for all elements
- fixed bug with disposing a Vertex
This commit is contained in:
parent
b8be666814
commit
8805a48058
11 changed files with 183 additions and 10 deletions
|
@ -312,7 +312,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
MoveGeometryRelative(new Vector2D(0f, 0f), false, false);
|
||||
|
||||
// Make undo for the dragging
|
||||
General.Map.UndoRedo.CreateUndo("drag", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Drag geometry", UndoGroup.None, 0);
|
||||
|
||||
// Move selected geometry to final position
|
||||
MoveGeometryRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest);
|
||||
|
|
|
@ -286,7 +286,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
MoveThingsRelative(new Vector2D(0f, 0f), false, false);
|
||||
|
||||
// Make undo for the dragging
|
||||
General.Map.UndoRedo.CreateUndo("drag things", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Drag things", UndoGroup.None, 0);
|
||||
|
||||
// Move selected geometry to final position
|
||||
MoveThingsRelative(mousemappos - dragstartmappos, snaptogrid, snaptonearest);
|
||||
|
|
|
@ -164,7 +164,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(points.Count > 0)
|
||||
{
|
||||
// Make undo for the draw
|
||||
General.Map.UndoRedo.CreateUndo("line draw", UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Line draw", UndoGroup.None, 0);
|
||||
|
||||
/***************************************************\
|
||||
STEP 1: Create the new geometry
|
||||
|
|
|
@ -404,6 +404,37 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Actions
|
||||
|
||||
[BeginAction("deleteitem", BaseAction = true)]
|
||||
public void DeleteItem()
|
||||
{
|
||||
// Make list of selected linedefs
|
||||
ICollection<Linedef> selected = General.Map.Map.GetSelectedLinedefs(true);
|
||||
if((selected.Count == 0) && (highlighted != null) && !highlighted.IsDisposed) selected.Add(highlighted);
|
||||
|
||||
// Anything to do?
|
||||
if(selected.Count > 0)
|
||||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " linedefs", UndoGroup.None, 0);
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Delete linedef", UndoGroup.None, 0);
|
||||
|
||||
// Dispose selected linedefs
|
||||
foreach(Linedef ld in selected) ld.Dispose();
|
||||
|
||||
// Update cache values
|
||||
General.Map.Map.Update();
|
||||
|
||||
// Invoke a new mousemove so that the highlighted item updates
|
||||
MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0);
|
||||
OnMouseMove(e);
|
||||
|
||||
// Redraw screen
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
[BeginAction("splitlinedefs")]
|
||||
public void SplitLinedefs()
|
||||
{
|
||||
|
@ -415,7 +446,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(selected.Count > 0)
|
||||
{
|
||||
// Make undo
|
||||
General.Map.UndoRedo.CreateUndo("Split " + selected.Count + " linedefs", UndoGroup.None, 0);
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Split " + selected.Count + " linedefs", UndoGroup.None, 0);
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Split linedef", UndoGroup.None, 0);
|
||||
|
||||
// Go for all linedefs to split
|
||||
foreach(Linedef ld in selected)
|
||||
|
@ -482,7 +516,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(selected.Count > 0)
|
||||
{
|
||||
// Make undo
|
||||
General.Map.UndoRedo.CreateUndo("Flip linedefs", UndoGroup.None, 0);
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " linedefs", UndoGroup.None, 0);
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Flip linedef", UndoGroup.None, 0);
|
||||
|
||||
// Flip all selected linedefs
|
||||
foreach(Linedef l in selected)
|
||||
|
@ -504,7 +541,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(selected.Count > 0)
|
||||
{
|
||||
// Make undo
|
||||
General.Map.UndoRedo.CreateUndo("Flip sidedefs", UndoGroup.None, 0);
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Flip " + selected.Count + " sidedefs", UndoGroup.None, 0);
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Flip sidedef", UndoGroup.None, 0);
|
||||
|
||||
// Flip sidedefs in all selected linedefs
|
||||
foreach(Linedef l in selected)
|
||||
|
|
|
@ -523,7 +523,59 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Actions
|
||||
|
||||
// Thi joins sectors together and keeps all lines
|
||||
[BeginAction("deleteitem", BaseAction = true)]
|
||||
public void DeleteItem()
|
||||
{
|
||||
// Make list of selected sectors
|
||||
ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(true);
|
||||
if((selected.Count == 0) && (highlighted != null) && !highlighted.IsDisposed) selected.Add(highlighted);
|
||||
|
||||
// Anything to do?
|
||||
if(selected.Count > 0)
|
||||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " sectors", UndoGroup.None, 0);
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Delete sector", UndoGroup.None, 0);
|
||||
|
||||
// Dispose selected sectors
|
||||
foreach(Sector s in selected)
|
||||
{
|
||||
// Get all the linedefs
|
||||
General.Map.Map.ClearMarkedLinedefs(false);
|
||||
foreach(Sidedef sd in s.Sidedefs) sd.Line.Marked = true;
|
||||
List<Linedef> lines = General.Map.Map.GetMarkedLinedefs(true);
|
||||
|
||||
// Dispose the sector
|
||||
s.Dispose();
|
||||
|
||||
// Check all the lines
|
||||
for(int i = lines.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// If the line has become orphaned, remove it
|
||||
if((lines[i].Front == null) && (lines[i].Back == null))
|
||||
{
|
||||
// Remove line
|
||||
lines[i].Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Update sided flags
|
||||
lines[i].ApplySidedFlags();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update cache values
|
||||
General.Map.Map.Update();
|
||||
|
||||
// Redraw screen
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
// This joins sectors together and keeps all lines
|
||||
[BeginAction("joinsectors")]
|
||||
public void JoinSectors()
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -366,5 +367,40 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Actions
|
||||
|
||||
[BeginAction("deleteitem", BaseAction = true)]
|
||||
public void DeleteItem()
|
||||
{
|
||||
// Make list of selected things
|
||||
ICollection<Thing> selected = General.Map.Map.GetSelectedThings(true);
|
||||
if((selected.Count == 0) && (highlighted != null) && !highlighted.IsDisposed) selected.Add(highlighted);
|
||||
|
||||
// Anything to do?
|
||||
if(selected.Count > 0)
|
||||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " things", UndoGroup.None, 0);
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Delete thing", UndoGroup.None, 0);
|
||||
|
||||
// Dispose selected things
|
||||
foreach(Thing t in selected) t.Dispose();
|
||||
|
||||
// Update cache values
|
||||
General.Map.Map.Update();
|
||||
|
||||
// Invoke a new mousemove so that the highlighted item updates
|
||||
MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0);
|
||||
OnMouseMove(e);
|
||||
|
||||
// Redraw screen
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
using CodeImp.DoomBuilder.Controls;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -340,5 +341,40 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Actions
|
||||
|
||||
[BeginAction("deleteitem", BaseAction = true)]
|
||||
public void DeleteItem()
|
||||
{
|
||||
// Make list of selected vertices
|
||||
ICollection<Vertex> selected = General.Map.Map.GetSelectedVertices(true);
|
||||
if((selected.Count == 0) && (highlighted != null) && !highlighted.IsDisposed) selected.Add(highlighted);
|
||||
|
||||
// Anything to do?
|
||||
if(selected.Count > 0)
|
||||
{
|
||||
// Make undo
|
||||
if(selected.Count > 1)
|
||||
General.Map.UndoRedo.CreateUndo("Delete " + selected.Count + " vertices", UndoGroup.None, 0);
|
||||
else
|
||||
General.Map.UndoRedo.CreateUndo("Delete vertex", UndoGroup.None, 0);
|
||||
|
||||
// Dispose selected vertices
|
||||
foreach(Vertex v in selected) v.Dispose();
|
||||
|
||||
// Update cache values
|
||||
General.Map.Map.Update();
|
||||
|
||||
// Invoke a new mousemove so that the highlighted item updates
|
||||
MouseEventArgs e = new MouseEventArgs(MouseButtons.None, 0, (int)mousepos.x, (int)mousepos.y, 0);
|
||||
OnMouseMove(e);
|
||||
|
||||
// Redraw screen
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
|
||||
// Make undo
|
||||
if(lines.Count > 1) undodesc = lines.Count + " linedefs";
|
||||
General.Map.UndoRedo.CreateUndo("edit " + undodesc, UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Edit " + undodesc, UndoGroup.None, 0);
|
||||
|
||||
// Go for all the lines
|
||||
foreach(Linedef l in lines)
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
|
||||
// Make undo
|
||||
if(sectors.Count > 1) undodesc = sectors.Count + " sectors";
|
||||
General.Map.UndoRedo.CreateUndo("edit " + undodesc, UndoGroup.None, 0);
|
||||
General.Map.UndoRedo.CreateUndo("Edit " + undodesc, UndoGroup.None, 0);
|
||||
|
||||
// Go for all sectors
|
||||
foreach(Sector s in sectors)
|
||||
|
|
|
@ -110,7 +110,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
|
||||
// Dispose the lines that are attached to this vertex
|
||||
// because a linedef cannot exist without 2 vertices.
|
||||
while(linedefs.First != null) linedefs.First.Value.Dispose();
|
||||
foreach(Linedef ld in linedefs) ld.Dispose();
|
||||
|
||||
// Clean up
|
||||
linedefs = null;
|
||||
|
|
|
@ -233,6 +233,15 @@ insertvertex
|
|||
allowscroll = true;
|
||||
}
|
||||
|
||||
deleteitem
|
||||
{
|
||||
title = "2D: Delete Item";
|
||||
description = "Deletes the highlighted or selected items.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
gridsetup
|
||||
{
|
||||
title = "View: Grid Setup";
|
||||
|
|
Loading…
Reference in a new issue