Sectors mode: hold Alt while (de)selecting sectors to (de)select things inside of them.

Sectors mode, rectangular selection: you can now hold Alt to select things inside of selected sectors.
Sector highlight is now shown when selecting sectors in Tag Explorer.
This commit is contained in:
MaxED 2014-01-13 12:49:54 +00:00
parent fabf8031a1
commit 75114595ed
9 changed files with 84 additions and 14 deletions

View file

@ -797,6 +797,13 @@ namespace CodeImp.DoomBuilder.Editing
ScrollBy(lastmappos.x - mousemappos.x, lastmappos.y - mousemappos.y);
}
}
/// <summary>
/// This selects given map element (mxd)
/// </summary>
public virtual void SelectMapElement(SelectableElement element) {
element.Selected = true;
}
#endregion

View file

@ -2920,7 +2920,7 @@ namespace CodeImp.DoomBuilder.Map
}
//mxd
/// <summary>This returns a sector if given coordinates lie inide one.</summary>
/// <summary>This returns a sector if given coordinates are inside one.</summary>
public Sector GetSectorByCoordinates(Vector2D pos) {
Linedef nl;
Sector sector = null;
@ -2930,10 +2930,10 @@ namespace CodeImp.DoomBuilder.Map
// Check what side of line we are at
if (nl.SideOfLine(pos) < 0f) {
// Front side
if (nl.Front != null) sector = nl.Front.Sector; else sector = null;
if (nl.Front != null) sector = nl.Front.Sector;
} else {
// Back side
if (nl.Back != null) sector = nl.Back.Sector; else sector = null;
if (nl.Back != null) sector = nl.Back.Sector;
}
}
return sector;

View file

@ -28,4 +28,4 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.14.0.1877")]
[assembly: AssemblyVersion("1.14.0.1879")]

View file

@ -41,6 +41,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Variables
protected bool paintselectpressed; //mxd
protected bool marqueSelectionIncludesThings; //mxd
#endregion
@ -141,6 +142,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
marqueSelectionMode = MarqueSelectionMode.ADD;
else
marqueSelectionMode = MarqueSelectionMode.SELECT;
marqueSelectionIncludesThings = General.Interface.AltState;
}
//mxd

View file

@ -266,6 +266,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
"Hold <b>" + selectKey + "</b> and drag to use rectangular selection",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_clearselection") + "</b> to clear selection",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_deleteitem") + "</b> to delete selected linedef(s)",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_dissolveitem") + "</b> to delete selected linedef(s) and try to preserve surrounding geometry",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_classicedit") + "</b> to edit properties of current selection",
"Use <b>" + Actions.Action.GetShortcutKeyDesc("builder_griddec") + "</b> and <b>" + Actions.Action.GetShortcutKeyDesc("builder_gridinc") + "</b> to change grid size",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("buildermodes_drawlinesmode") + "</b> or <b>" + Actions.Action.GetShortcutKeyDesc("builder_insertitem") + "</b> to start drawing lines",

View file

@ -529,7 +529,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
string selectKey = Actions.Action.GetShortcutKeyDesc("builder_classicselect");
hints = new[]{ "Hold <b>" + Actions.Action.GetShortcutKeyDesc("builder_pan_view") + "</b> to pan the view",
"Press <b>" + selectKey + "</b> to select a sector",
"Press <b>" + selectKey + "</b> to select a sector. Hold <b>Alt<b> to (de)select things inside of a sector",
"Hold <b>" + selectKey + "</b> and drag to use rectangular selection",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_clearselection") + "</b> to clear selection",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_deleteitem") + "</b> to delete selected sector(s)",
@ -551,9 +551,21 @@ namespace CodeImp.DoomBuilder.BuilderModes
multiselectionHints = new[] { "Hold <b>Shift</b> to " + (BuilderPlug.Me.AdditiveSelect ? "disable" : "enable") + " additive selection",
"Hold <b>Ctrl</b> to enable subtractive selection",
"Hold <b>Ctrl-Shift</b> to intersect the new selection with already existing one",
"Hold <b>Alt<b> to select things inside of selected sectors"
};
}
//mxd
public override void SelectMapElement(SelectableElement element) {
if(element is Sector) {
SelectSector(element as Sector, true, true);
// Update overlay
updateOverlaySurfaces();
updateSelectionInfo();
}
}
#endregion
#region ================== Events
@ -718,6 +730,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
{
//mxd. Flip selection
SelectSector(highlighted, !highlighted.Selected, true);
//mxd. Also (de)select things inside of this sector
if (General.Interface.AltState) {
foreach(Thing t in General.Map.ThingsFilter.VisibleThings) {
t.DetermineSector();
if(t.Sector != highlighted) continue;
t.Selected = highlighted.Selected;
}
// Render things
if(renderer.StartThings(true)) {
renderer.RenderThingSet(General.Map.ThingsFilter.HiddenThings, Presentation.THINGS_HIDDEN_ALPHA);
renderer.RenderThingSet(General.Map.ThingsFilter.VisibleThings, 1.0f);
renderer.Finish();
}
}
// Update display
if(renderer.StartPlotter(false))
@ -1060,6 +1088,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(select && !s.Selected) SelectSector(s, true, false);
else if(!select && s.Selected) SelectSector(s, false, false);
}
if (marqueSelectionIncludesThings) {
ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(true);
foreach (Thing t in General.Map.ThingsFilter.VisibleThings) {
t.DetermineSector();
if(t.Sector == null) continue;
t.Selected = selectionrect.Contains(t.Position.x, t.Position.y) && selected.Contains(t.Sector);
}
}
break;
case MarqueSelectionMode.ADD:
@ -1067,6 +1104,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!s.Selected && isInSelectionRect(s, selectionOutline))
SelectSector(s, true, false);
}
if (marqueSelectionIncludesThings) {
ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(true);
foreach (Thing t in General.Map.ThingsFilter.VisibleThings) {
t.DetermineSector();
if(t.Sector == null) continue;
t.Selected |= selectionrect.Contains(t.Position.x, t.Position.y) && selected.Contains(t.Sector);
}
}
break;
case MarqueSelectionMode.SUBTRACT:
@ -1075,6 +1121,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(isInSelectionRect(s, selectionOutline))
SelectSector(s, false, false);
}
if (marqueSelectionIncludesThings) {
foreach (Thing t in General.Map.ThingsFilter.VisibleThings)
if (selectionrect.Contains(t.Position.x, t.Position.y)) t.Selected = false;
}
break;
default: //should be Intersect
@ -1083,6 +1133,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(!isInSelectionRect(s, selectionOutline))
SelectSector(s, false, false);
}
if (marqueSelectionIncludesThings) {
foreach(Thing t in General.Map.ThingsFilter.VisibleThings)
if(!selectionrect.Contains(t.Position.x, t.Position.y)) t.Selected = false;
}
break;
}

View file

@ -670,6 +670,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_clearselection") + "</b> to clear selection",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_insertitem") + "</b> to insert a new vertex",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_deleteitem") + "</b> to delete selected vertices",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_dissolveitem") + "</b> to delete selected vertices and try to preserve surrounding geometry",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("builder_classicedit") + "</b> to edit properties of current selection",
"Use <b>" + Actions.Action.GetShortcutKeyDesc("builder_griddec") + "</b> and <b>" + Actions.Action.GetShortcutKeyDesc("builder_gridinc") + "</b> to change grid size",
"Press <b>" + Actions.Action.GetShortcutKeyDesc("buildermodes_drawlinesmode") + "</b> to start drawing lines",

View file

@ -28,4 +28,4 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.14.0.1877")]
[assembly: AssemblyVersion("1.14.0.1879")]

View file

@ -585,22 +585,26 @@ namespace CodeImp.DoomBuilder.TagExplorer
General.Map.Map.ClearAllSelected();
//make selection
if (info.Type == NodeInfoType.THING) {
if (info.Type == NodeInfoType.THING)
{
General.Editing.ChangeMode("ThingsMode");
Thing t = General.Map.Map.GetThingByIndex(info.Index);
if (t != null) t.Selected = true;
} else if (info.Type == NodeInfoType.LINEDEF) {
}
else if (info.Type == NodeInfoType.LINEDEF)
{
General.Editing.ChangeMode("LinedefsMode");
Linedef l = General.Map.Map.GetLinedefByIndex(info.Index);
if (l != null) l.Selected = true;
} else {
}
else
{
General.Editing.ChangeMode("SectorsMode");
Sector s = General.Map.Map.GetSectorByIndex(info.Index);
if (s != null) {
s.Selected = true;
foreach (Sidedef sd in s.Sidedefs)
sd.Line.Selected = true;
if (s != null)
{
((ClassicMode)General.Editing.Mode).SelectMapElement(s);
foreach (Sidedef sd in s.Sidedefs) sd.Line.Selected = true;
}
}
}