mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
- Added selection conversion functions in MapSet class
- Fixed some bugs with labels in Sectors Mode
This commit is contained in:
parent
cde2e783d6
commit
67c6a343f7
14 changed files with 210 additions and 100 deletions
|
@ -675,6 +675,7 @@
|
|||
<Compile Include="General\CRC.cs" />
|
||||
<Compile Include="General\ErrorItem.cs" />
|
||||
<Compile Include="General\ErrorLogger.cs" />
|
||||
<Compile Include="Map\SelectionType.cs" />
|
||||
<Compile Include="Windows\ErrorsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -362,35 +362,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
SetupLabels();
|
||||
|
||||
// Convert geometry selection to sectors only
|
||||
General.Map.Map.ClearAllMarks(false);
|
||||
General.Map.Map.MarkSelectedVertices(true, true);
|
||||
ICollection<Linedef> lines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
|
||||
foreach(Linedef l in lines) l.Selected = true;
|
||||
General.Map.Map.ClearMarkedSectors(true);
|
||||
foreach(Linedef l in General.Map.Map.Linedefs)
|
||||
{
|
||||
if(!l.Selected)
|
||||
{
|
||||
if(l.Front != null) l.Front.Sector.Marked = false;
|
||||
if(l.Back != null) l.Back.Sector.Marked = false;
|
||||
}
|
||||
}
|
||||
General.Map.Map.ClearSelectedLinedefs();
|
||||
General.Map.Map.ClearSelectedVertices();
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
if(s.Marked)
|
||||
{
|
||||
s.Selected = true;
|
||||
foreach(Sidedef sd in s.Sidedefs) sd.Line.Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.Selected = false;
|
||||
}
|
||||
}
|
||||
General.Map.Map.ConvertSelection(SelectionType.Sectors);
|
||||
|
||||
// Update
|
||||
General.Map.Map.SelectionType = SelectionType.Sectors;
|
||||
UpdateSelectedLabels();
|
||||
UpdateOverlay();
|
||||
}
|
||||
|
@ -405,6 +380,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.SeparatorSectors1);
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
|
||||
|
||||
// Keep only sectors selected
|
||||
General.Map.Map.ClearSelectedLinedefs();
|
||||
|
||||
// Going to EditSelectionMode?
|
||||
if(General.Editing.NewMode is EditSelectionMode)
|
||||
{
|
||||
|
|
|
@ -612,8 +612,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Map.Map.MarkSelectedVertices(true, true);
|
||||
General.Map.Map.MarkSelectedThings(true, true);
|
||||
General.Map.Map.MarkSelectedLinedefs(true, true);
|
||||
General.Map.Map.MarkSelectedSectors(true, true);
|
||||
ICollection<Vertex> verts = General.Map.Map.GetVerticesFromLinesMarks(true);
|
||||
foreach(Vertex v in verts) v.Marked = true;
|
||||
ICollection<Sector> sects = General.Map.Map.GetSelectedSectors(true);
|
||||
foreach(Sector s in sects)
|
||||
{
|
||||
foreach(Sidedef sd in s.Sidedefs)
|
||||
{
|
||||
sd.Line.Marked = true;
|
||||
sd.Line.Start.Marked = true;
|
||||
sd.Line.End.Marked = true;
|
||||
}
|
||||
}
|
||||
selectedvertices = General.Map.Map.GetMarkedVertices(true);
|
||||
selectedthings = General.Map.Map.GetMarkedThings(true);
|
||||
unselectedvertices = General.Map.Map.GetMarkedVertices(false);
|
||||
|
|
|
@ -84,6 +84,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Map.Map.ClearAllMarks(false);
|
||||
General.Map.Map.MarkAllSelectedGeometry(true, false);
|
||||
General.Map.Map.ClearAllSelected();
|
||||
General.Map.Map.SelectionType = SelectionType.All;
|
||||
|
||||
// Show toolbox window
|
||||
BuilderPlug.Me.ErrorCheckForm.Show((Form)General.Interface);
|
||||
|
|
|
@ -79,7 +79,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
{
|
||||
base.OnEngage();
|
||||
renderer.SetPresentation(Presentation.Standard);
|
||||
|
||||
General.Map.Map.SelectionType = SelectionType.All;
|
||||
|
||||
// Show toolbox window
|
||||
BuilderPlug.Me.FindReplaceForm.Show((Form)General.Interface);
|
||||
}
|
||||
|
|
|
@ -203,12 +203,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.CurveLinedefs);
|
||||
|
||||
// Convert geometry selection to linedefs selection
|
||||
General.Map.Map.ClearAllMarks(false);
|
||||
General.Map.Map.MarkSelectedVertices(true, true);
|
||||
ICollection<Linedef> lines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
|
||||
foreach(Linedef l in lines) l.Selected = true;
|
||||
General.Map.Map.ClearSelectedSectors();
|
||||
General.Map.Map.ClearSelectedVertices();
|
||||
General.Map.Map.ConvertSelection(SelectionType.Linedefs);
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
|
|
|
@ -299,6 +299,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
p.AddLayer(new PresentLayer(RendererLayer.Things, BlendingMode.Alpha, Presentation.THINGS_BACK_ALPHA, false));
|
||||
p.AddLayer(new PresentLayer(RendererLayer.Geometry, BlendingMode.Alpha, 1f, true));
|
||||
renderer.SetPresentation(p);
|
||||
General.Map.Map.SelectionType = SelectionType.All;
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
|
|
|
@ -176,7 +176,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(removelines)
|
||||
{
|
||||
// Go for all selected linedefs
|
||||
ICollection<Linedef> selectedlines = General.Map.Map.GetSelectedLinedefs(true);
|
||||
List<Linedef> selectedlines = new List<Linedef>(General.Map.Map.GetSelectedLinedefs(true));
|
||||
foreach(Linedef ld in selectedlines)
|
||||
{
|
||||
// Front and back side?
|
||||
|
@ -206,7 +206,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Clear selection
|
||||
General.Map.Map.ClearAllSelected();
|
||||
orderedselection.Clear();
|
||||
|
||||
// Make text labels for sectors
|
||||
SetupLabels();
|
||||
UpdateSelectedLabels();
|
||||
}
|
||||
|
||||
// This highlights a new item
|
||||
|
@ -401,33 +404,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.AddButton(BuilderPlug.Me.MenusForm.MakeGradientCeilings);
|
||||
|
||||
// Convert geometry selection to sectors only
|
||||
General.Map.Map.ClearAllMarks(false);
|
||||
General.Map.Map.MarkSelectedVertices(true, true);
|
||||
ICollection<Linedef> lines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
|
||||
foreach(Linedef l in lines) l.Selected = true;
|
||||
General.Map.Map.ClearMarkedSectors(true);
|
||||
foreach(Linedef l in General.Map.Map.Linedefs)
|
||||
{
|
||||
if(!l.Selected)
|
||||
{
|
||||
if(l.Front != null) l.Front.Sector.Marked = false;
|
||||
if(l.Back != null) l.Back.Sector.Marked = false;
|
||||
}
|
||||
}
|
||||
General.Map.Map.ClearSelectedLinedefs();
|
||||
General.Map.Map.ClearSelectedVertices();
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
if(s.Marked)
|
||||
{
|
||||
s.Selected = true;
|
||||
foreach(Sidedef sd in s.Sidedefs) sd.Line.Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.Selected = false;
|
||||
}
|
||||
}
|
||||
General.Map.Map.ConvertSelection(SelectionType.Sectors);
|
||||
|
||||
// Make text labels for sectors
|
||||
SetupLabels();
|
||||
|
@ -448,7 +425,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientBrightness);
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientFloors);
|
||||
General.Interface.RemoveButton(BuilderPlug.Me.MenusForm.MakeGradientCeilings);
|
||||
|
||||
|
||||
// Keep only sectors selected
|
||||
General.Map.Map.ClearSelectedLinedefs();
|
||||
|
||||
// Going to EditSelectionMode?
|
||||
if(General.Editing.NewMode is EditSelectionMode)
|
||||
{
|
||||
|
@ -1001,7 +981,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public void DeleteItem()
|
||||
{
|
||||
// Make list of selected sectors
|
||||
ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(true);
|
||||
List<Sector> selected = new List<Sector>(General.Map.Map.GetSelectedSectors(true));
|
||||
if((selected.Count == 0) && (highlighted != null) && !highlighted.IsDisposed) selected.Add(highlighted);
|
||||
|
||||
// Anything to do?
|
||||
|
@ -1057,7 +1037,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Update cache values
|
||||
General.Map.IsChanged = true;
|
||||
General.Map.Map.Update();
|
||||
|
||||
|
||||
// Make text labels for sectors
|
||||
SetupLabels();
|
||||
UpdateSelectedLabels();
|
||||
|
||||
// Redraw screen
|
||||
General.Interface.RedrawDisplay();
|
||||
}
|
||||
|
|
|
@ -92,12 +92,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
renderer.SetPresentation(Presentation.Things);
|
||||
|
||||
// Convert geometry selection to linedefs selection
|
||||
General.Map.Map.ClearAllMarks(false);
|
||||
General.Map.Map.MarkSelectedVertices(true, true);
|
||||
ICollection<Linedef> lines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
|
||||
foreach(Linedef l in lines) l.Selected = true;
|
||||
General.Map.Map.ClearSelectedSectors();
|
||||
General.Map.Map.ClearSelectedVertices();
|
||||
General.Map.Map.ConvertSelection(SelectionType.Linedefs);
|
||||
General.Map.Map.SelectionType = SelectionType.Things;
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
|
|
|
@ -84,21 +84,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Mode engages
|
||||
public override void OnEngage()
|
||||
{
|
||||
ICollection<Vertex> verts;
|
||||
|
||||
base.OnEngage();
|
||||
renderer.SetPresentation(Presentation.Standard);
|
||||
|
||||
// Convert geometry selection to vertices only
|
||||
General.Map.Map.ClearAllMarks(false);
|
||||
General.Map.Map.MarkSelectedLinedefs(true, true);
|
||||
General.Map.Map.MarkSelectedSectors(true, true);
|
||||
verts = General.Map.Map.GetVerticesFromLinesMarks(true);
|
||||
foreach(Vertex v in verts) v.Selected = true;
|
||||
verts = General.Map.Map.GetVerticesFromSectorsMarks(true);
|
||||
foreach(Vertex v in verts) v.Selected = true;
|
||||
General.Map.Map.ClearSelectedSectors();
|
||||
General.Map.Map.ClearSelectedLinedefs();
|
||||
General.Map.Map.ConvertSelection(SelectionType.Vertices);
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
|
|
|
@ -70,14 +70,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Disposer
|
||||
public virtual void Dispose()
|
||||
{
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
fields = null;
|
||||
|
||||
// Done
|
||||
isdisposed = true;
|
||||
}
|
||||
// Clean up
|
||||
fields = null;
|
||||
|
||||
// Done
|
||||
isdisposed = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -74,6 +74,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
private LinkedList<Linedef> sel_linedefs;
|
||||
private LinkedList<Sector> sel_sectors;
|
||||
private LinkedList<Thing> sel_things;
|
||||
private SelectionType sel_type;
|
||||
|
||||
// Statics
|
||||
private static long emptylongname;
|
||||
|
@ -97,6 +98,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
internal LinkedList<Linedef> SelectedLinedefs { get { return sel_linedefs; } }
|
||||
internal LinkedList<Sector> SelectedSectors { get { return sel_sectors; } }
|
||||
internal LinkedList<Thing> SelectedThings { get { return sel_things; } }
|
||||
public SelectionType SelectionType { get { return sel_type; } set { sel_type = value; } }
|
||||
|
||||
public static long EmptyLongName { get { return emptylongname; } }
|
||||
public static string VirtualSectorField { get { return VIRTUAL_SECTOR_FIELD; } }
|
||||
|
@ -871,7 +873,120 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#endregion
|
||||
|
||||
#region ================== Selection
|
||||
|
||||
|
||||
// This checks a flag in a selection type
|
||||
private bool InSelectionType(SelectionType value, SelectionType bits)
|
||||
{
|
||||
return (value & bits) == bits;
|
||||
}
|
||||
|
||||
// This converts the selection to a different selection
|
||||
// NOTE: This function uses the markings to convert the selection
|
||||
public void ConvertSelection(SelectionType target)
|
||||
{
|
||||
ConvertSelection(SelectionType.All, target);
|
||||
}
|
||||
|
||||
// This converts the selection to a different selection
|
||||
// NOTE: This function uses the markings to convert the selection
|
||||
public void ConvertSelection(SelectionType source, SelectionType target)
|
||||
{
|
||||
ICollection<Linedef> lines;
|
||||
ICollection<Vertex> verts;
|
||||
|
||||
ClearAllMarks(false);
|
||||
|
||||
switch(target)
|
||||
{
|
||||
// Convert geometry selection to vertices only
|
||||
case SelectionType.Vertices:
|
||||
if(InSelectionType(source, SelectionType.Linedefs)) MarkSelectedLinedefs(true, true);
|
||||
if(InSelectionType(source, SelectionType.Sectors)) General.Map.Map.MarkSelectedSectors(true, true);
|
||||
verts = General.Map.Map.GetVerticesFromLinesMarks(true);
|
||||
foreach(Vertex v in verts) v.Selected = true;
|
||||
verts = General.Map.Map.GetVerticesFromSectorsMarks(true);
|
||||
foreach(Vertex v in verts) v.Selected = true;
|
||||
General.Map.Map.ClearSelectedSectors();
|
||||
General.Map.Map.ClearSelectedLinedefs();
|
||||
break;
|
||||
|
||||
// Convert geometry selection to linedefs only
|
||||
case SelectionType.Linedefs:
|
||||
if(InSelectionType(source, SelectionType.Vertices)) MarkSelectedVertices(true, true);
|
||||
if(!InSelectionType(source, SelectionType.Linedefs)) ClearSelectedLinedefs();
|
||||
lines = General.Map.Map.LinedefsFromMarkedVertices(false, true, false);
|
||||
foreach(Linedef l in lines) l.Selected = true;
|
||||
if(InSelectionType(source, SelectionType.Sectors))
|
||||
{
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
if(s.Selected)
|
||||
{
|
||||
foreach(Sidedef sd in s.Sidedefs)
|
||||
sd.Line.Selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
General.Map.Map.ClearSelectedSectors();
|
||||
General.Map.Map.ClearSelectedVertices();
|
||||
break;
|
||||
|
||||
// Convert geometry selection to sectors only
|
||||
case SelectionType.Sectors:
|
||||
if(InSelectionType(source, SelectionType.Vertices)) MarkSelectedVertices(true, true);
|
||||
if(!InSelectionType(source, SelectionType.Linedefs)) ClearSelectedLinedefs();
|
||||
lines = LinedefsFromMarkedVertices(false, true, false);
|
||||
foreach(Linedef l in lines) l.Selected = true;
|
||||
ClearMarkedSectors(true);
|
||||
foreach(Linedef l in linedefs)
|
||||
{
|
||||
if(!l.Selected)
|
||||
{
|
||||
if(l.Front != null) l.Front.Sector.Marked = false;
|
||||
if(l.Back != null) l.Back.Sector.Marked = false;
|
||||
}
|
||||
}
|
||||
ClearSelectedLinedefs();
|
||||
ClearSelectedVertices();
|
||||
if(InSelectionType(source, SelectionType.Sectors))
|
||||
{
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
if(s.Marked || s.Selected)
|
||||
{
|
||||
s.Selected = true;
|
||||
foreach(Sidedef sd in s.Sidedefs)
|
||||
sd.Line.Selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
if(s.Marked)
|
||||
{
|
||||
s.Selected = true;
|
||||
foreach(Sidedef sd in s.Sidedefs)
|
||||
sd.Line.Selected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
s.Selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentException("Unsupported selection target conversion");
|
||||
break;
|
||||
}
|
||||
|
||||
// New selection type
|
||||
sel_type = target;
|
||||
}
|
||||
|
||||
// This clears all selected items
|
||||
public void ClearAllSelected()
|
||||
{
|
||||
|
|
|
@ -62,14 +62,11 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Disposer
|
||||
public override void Dispose()
|
||||
{
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Remove from selection
|
||||
if(selected) Selected = false;
|
||||
|
||||
// Done
|
||||
base.Dispose();
|
||||
}
|
||||
// Remove from selection
|
||||
if(selected) Selected = false;
|
||||
|
||||
// Done
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
43
Source/Map/SelectionType.cs
Normal file
43
Source/Map/SelectionType.cs
Normal file
|
@ -0,0 +1,43 @@
|
|||
|
||||
#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 System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Map
|
||||
{
|
||||
[Flags]
|
||||
public enum SelectionType
|
||||
{
|
||||
None = 0,
|
||||
Vertices = 1,
|
||||
Linedefs = 2,
|
||||
Sectors = 4,
|
||||
Things = 8,
|
||||
All = 0x7FFFFFFF,
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue