From 4f2a8a15cae2711a098e90eed399e72bde2d880c Mon Sep 17 00:00:00 2001 From: sphere Date: Wed, 10 Nov 2021 01:26:41 +0100 Subject: [PATCH] Visual Mode: first attempt at handling multitags --- .../VisualModes/BaseVisualMode.cs | 107 ++++++++++++++++-- 1 file changed, 100 insertions(+), 7 deletions(-) diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs index 11f03a8..99156b7 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualMode.cs @@ -996,7 +996,76 @@ namespace CodeImp.DoomBuilder.BuilderModes } if (General.Map.SRB2) - { + { + //sphere: Multi-tagging + if (l.Action == 96) + { + int[] tags = new int[5]; + + tags[0] = l.Tag; + if (l.IsFlagSet("8192")) + { + tags[1] = l.Front.OffsetX; + tags[2] = l.Front.OffsetY; + } + if (l.IsFlagSet("32768") && l.Back != null) + { + tags[3] = l.Back.OffsetX; + tags[4] = l.Back.OffsetY; + } + + if (!sectortags.ContainsKey(l.Front.Sector.Tag)) sectortags[l.Front.Sector.Tag] = new List(); + + if (l.IsFlagSet("1024")) + { + for (int i = 0; i <= 4; i++) + { + if (tags[i] == 0 || !sectortags.ContainsKey(tags[i])) continue; + + foreach (Sector s in sectortags[tags[i]]) + sectortags[l.Front.Sector.Tag].Add(s); + } + } + else + { + foreach (Sector s in sectortags[l.Tag]) + { + sectortags[l.Front.Sector.Tag].Add(s); + for (int i = 1; i <= 4; i++) // only iterate over offset/extra tags + { + if (tags[i] != 0) continue; + if (!sectortags.ContainsKey(tags[i])) sectortags[tags[i]] = new List(); + sectortags[tags[i]].Add(s); + } + } + } + } + + if (l.Action == 97 || l.Action == 98 || l.Action == 99) + { + int[] tags = new int[5]; + + tags[0] = l.Tag; + if (l.IsFlagSet("8192")) + { + tags[1] = l.Front.OffsetX; + tags[2] = l.Front.OffsetY; + } + if (l.IsFlagSet("32768") && l.Back != null) + { + tags[3] = l.Back.OffsetX; + tags[4] = l.Back.OffsetY; + } + + foreach (int tag in tags) + { + if (tag == 0) continue; + if (!sectortags.ContainsKey(tag)) sectortags[tag] = new List(); + if (l.Action == 97 || l.Action == 99) sectortags[tag].Add(l.Front.Sector); + if (l.Action == 98 || l.Action == 99) sectortags[tag].Add(l.Back.Sector); + } + } + //MascaraSnake: Flat alignment //With flat offset/rotation fixes by Justburner if (l.IsFlatAlignment) @@ -1029,9 +1098,9 @@ namespace CodeImp.DoomBuilder.BuilderModes ApplyFlatAlignment(l, s, alignfloor, alignceiling, offset, rotation); } } - - //MascaraSnake: Colormap - if (l.IsColormap && l.Front != null && General.Settings.ShowColormaps) + + //MascaraSnake: Colormap + if (l.IsColormap && l.Front != null && General.Settings.ShowColormaps) { int sectortag = l.Tag; int color; @@ -3829,7 +3898,6 @@ namespace CodeImp.DoomBuilder.BuilderModes RebuildElementData(); UpdateChangedObjects(); General.Interface.DisplayStatus(StatusType.Action, "Reset actions and tags for " + selection.Count + (selection.Count == 1 ? " surface." : " surfaces.")); - ClearSelection(); ShowTargetInfo(); } @@ -3873,7 +3941,6 @@ namespace CodeImp.DoomBuilder.BuilderModes //update changed geometry RebuildElementData(); UpdateChangedObjects(); - ClearSelection(); ShowTargetInfo(); General.Interface.DisplayStatus(StatusType.Action, "Reset flags for " + selection.Count + (selection.Count == 1 ? " surface and " : " surfaces and ") + @@ -4215,7 +4282,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { RebuildElementData(); UpdateChangedObjects(); - ClearSelection(); ShowTargetInfo(); } @@ -4245,6 +4311,13 @@ namespace CodeImp.DoomBuilder.BuilderModes { int counter = 0; List selected = GetSelectedObjects(true, true, true, true); + + if (selected.Count == 0) + { + General.Interface.DisplayStatus(StatusType.Warning, "Selecting single-sided lines only requires selected surfaces!"); + return; + } + foreach (IVisualEventReceiver i in selected) if (i is BaseVisualGeometrySidedef) { @@ -4269,6 +4342,13 @@ namespace CodeImp.DoomBuilder.BuilderModes { int counter = 0; List selected = GetSelectedObjects(true, true, true, true); + + if (selected.Count == 0) + { + General.Interface.DisplayStatus(StatusType.Warning, "Selecting double-sided lines only requires selected surfaces!"); + return; + } + foreach (IVisualEventReceiver i in selected) if (i is BaseVisualGeometrySidedef) { @@ -4292,6 +4372,12 @@ namespace CodeImp.DoomBuilder.BuilderModes { int counter = 0; List selected = GetSelectedObjects(true, true, true, true); + + if (selected.Count == 0) + { + General.Interface.DisplayStatus(StatusType.Warning, "Selecting floors only requires selected surfaces!"); + return; + } foreach (IVisualEventReceiver i in selected) if (i is VisualFloor) counter++; @@ -4312,6 +4398,13 @@ namespace CodeImp.DoomBuilder.BuilderModes { int counter = 0; List selected = GetSelectedObjects(true, true, true, true); + + if (selected.Count == 0) + { + General.Interface.DisplayStatus(StatusType.Warning, "Selecting ceilings only requires selected surfaces!"); + return; + } + foreach (IVisualEventReceiver i in selected) if (i is VisualCeiling) counter++;