From 75114595edae3f92ec2061e6d58e7fb50fd064e7 Mon Sep 17 00:00:00 2001 From: MaxED Date: Mon, 13 Jan 2014 12:49:54 +0000 Subject: [PATCH] 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. --- Source/Core/Editing/ClassicMode.cs | 7 +++ Source/Core/Map/MapSet.cs | 6 +- Source/Core/Properties/AssemblyInfo.cs | 2 +- .../ClassicModes/BaseClassicMode.cs | 3 + .../BuilderModes/ClassicModes/LinedefsMode.cs | 1 + .../BuilderModes/ClassicModes/SectorsMode.cs | 56 ++++++++++++++++++- .../BuilderModes/ClassicModes/VerticesMode.cs | 1 + .../BuilderModes/Properties/AssemblyInfo.cs | 2 +- .../TagExplorer/Controls/TagExplorer.cs | 20 ++++--- 9 files changed, 84 insertions(+), 14 deletions(-) diff --git a/Source/Core/Editing/ClassicMode.cs b/Source/Core/Editing/ClassicMode.cs index b886b8e6..873eb13f 100644 --- a/Source/Core/Editing/ClassicMode.cs +++ b/Source/Core/Editing/ClassicMode.cs @@ -797,6 +797,13 @@ namespace CodeImp.DoomBuilder.Editing ScrollBy(lastmappos.x - mousemappos.x, lastmappos.y - mousemappos.y); } } + + /// + /// This selects given map element (mxd) + /// + public virtual void SelectMapElement(SelectableElement element) { + element.Selected = true; + } #endregion diff --git a/Source/Core/Map/MapSet.cs b/Source/Core/Map/MapSet.cs index 4af35f05..4b8aa1b6 100644 --- a/Source/Core/Map/MapSet.cs +++ b/Source/Core/Map/MapSet.cs @@ -2920,7 +2920,7 @@ namespace CodeImp.DoomBuilder.Map } //mxd - /// This returns a sector if given coordinates lie inide one. + /// This returns a sector if given coordinates are inside one. 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; diff --git a/Source/Core/Properties/AssemblyInfo.cs b/Source/Core/Properties/AssemblyInfo.cs index 85f1fc79..34f49044 100644 --- a/Source/Core/Properties/AssemblyInfo.cs +++ b/Source/Core/Properties/AssemblyInfo.cs @@ -28,4 +28,4 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.14.0.1877")] \ No newline at end of file +[assembly: AssemblyVersion("1.14.0.1879")] \ No newline at end of file diff --git a/Source/Plugins/BuilderModes/ClassicModes/BaseClassicMode.cs b/Source/Plugins/BuilderModes/ClassicModes/BaseClassicMode.cs index aa3a7559..b66ba89a 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/BaseClassicMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/BaseClassicMode.cs @@ -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 diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index 80d70683..58f4acb7 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -266,6 +266,7 @@ namespace CodeImp.DoomBuilder.BuilderModes "Hold " + selectKey + " and drag to use rectangular selection", "Press " + Actions.Action.GetShortcutKeyDesc("builder_clearselection") + " to clear selection", "Press " + Actions.Action.GetShortcutKeyDesc("builder_deleteitem") + " to delete selected linedef(s)", + "Press " + Actions.Action.GetShortcutKeyDesc("builder_dissolveitem") + " to delete selected linedef(s) and try to preserve surrounding geometry", "Press " + Actions.Action.GetShortcutKeyDesc("builder_classicedit") + " to edit properties of current selection", "Use " + Actions.Action.GetShortcutKeyDesc("builder_griddec") + " and " + Actions.Action.GetShortcutKeyDesc("builder_gridinc") + " to change grid size", "Press " + Actions.Action.GetShortcutKeyDesc("buildermodes_drawlinesmode") + " or " + Actions.Action.GetShortcutKeyDesc("builder_insertitem") + " to start drawing lines", diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 97f1eda3..fb51f3c1 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -529,7 +529,7 @@ namespace CodeImp.DoomBuilder.BuilderModes string selectKey = Actions.Action.GetShortcutKeyDesc("builder_classicselect"); hints = new[]{ "Hold " + Actions.Action.GetShortcutKeyDesc("builder_pan_view") + " to pan the view", - "Press " + selectKey + " to select a sector", + "Press " + selectKey + " to select a sector. Hold Alt to (de)select things inside of a sector", "Hold " + selectKey + " and drag to use rectangular selection", "Press " + Actions.Action.GetShortcutKeyDesc("builder_clearselection") + " to clear selection", "Press " + Actions.Action.GetShortcutKeyDesc("builder_deleteitem") + " to delete selected sector(s)", @@ -551,9 +551,21 @@ namespace CodeImp.DoomBuilder.BuilderModes multiselectionHints = new[] { "Hold Shift to " + (BuilderPlug.Me.AdditiveSelect ? "disable" : "enable") + " additive selection", "Hold Ctrl to enable subtractive selection", "Hold Ctrl-Shift to intersect the new selection with already existing one", + "Hold Alt 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 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 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; } diff --git a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs index 6b2dbcdd..4951cd40 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs @@ -670,6 +670,7 @@ namespace CodeImp.DoomBuilder.BuilderModes "Press " + Actions.Action.GetShortcutKeyDesc("builder_clearselection") + " to clear selection", "Press " + Actions.Action.GetShortcutKeyDesc("builder_insertitem") + " to insert a new vertex", "Press " + Actions.Action.GetShortcutKeyDesc("builder_deleteitem") + " to delete selected vertices", + "Press " + Actions.Action.GetShortcutKeyDesc("builder_dissolveitem") + " to delete selected vertices and try to preserve surrounding geometry", "Press " + Actions.Action.GetShortcutKeyDesc("builder_classicedit") + " to edit properties of current selection", "Use " + Actions.Action.GetShortcutKeyDesc("builder_griddec") + " and " + Actions.Action.GetShortcutKeyDesc("builder_gridinc") + " to change grid size", "Press " + Actions.Action.GetShortcutKeyDesc("buildermodes_drawlinesmode") + " to start drawing lines", diff --git a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs index 3f0c84a4..0926c1db 100644 --- a/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs +++ b/Source/Plugins/BuilderModes/Properties/AssemblyInfo.cs @@ -28,4 +28,4 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("1.14.0.1877")] +[assembly: AssemblyVersion("1.14.0.1879")] diff --git a/Source/Plugins/TagExplorer/Controls/TagExplorer.cs b/Source/Plugins/TagExplorer/Controls/TagExplorer.cs index aa431756..abd0533e 100644 --- a/Source/Plugins/TagExplorer/Controls/TagExplorer.cs +++ b/Source/Plugins/TagExplorer/Controls/TagExplorer.cs @@ -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; } } }