diff --git a/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs index 93615ee2..7d4bdbb6 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/DragSectorsMode.cs @@ -123,6 +123,14 @@ namespace CodeImp.DoomBuilder.BuilderModes { General.Map.Map.ClearSelectedSectors(); General.Map.Map.ClearSelectedLinedefs(); + + //mxd. Also (de)select things? + if(BuilderPlug.Me.SyncronizeThingEdit) + { + Sector s = General.GetByIndex(selectedsectors, 0); + foreach(Thing t in General.Map.Map.Things) + if(t.Sector == s && t.Selected) t.Selected = false; + } } } } diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 32801127..1995c666 100644 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -527,11 +527,8 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Also (de)select things? if(General.Interface.AltState ^ BuilderPlug.Me.SyncronizeThingEdit) { - foreach(Thing t in General.Map.ThingsFilter.VisibleThings) - { - if(t.Sector != s) continue; - t.Selected = s.Selected; - } + foreach(Thing t in General.Map.Map.Things) + if(t.Sector == s && t.Selected != s.Selected) t.Selected = s.Selected; } if(update) @@ -825,7 +822,7 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Thing selection state may've changed if(General.Interface.AltState ^ BuilderPlug.Me.SyncronizeThingEdit) General.Interface.RedrawDisplay(); } - else if(BuilderPlug.Me.AutoClearSelection && (General.Map.Map.SelectedSectorsCount > 0 || (BuilderPlug.Me.SyncronizeThingEdit && General.Map.Map.SelectedThingsCount > 0))) //mxd + else if(BuilderPlug.Me.AutoClearSelection) //mxd { if(General.Map.Map.SelectedSectorsCount > 0) { @@ -916,15 +913,24 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Map.Renderer2D.UpdateExtraFloorFlag(); //mxd // When a single sector was selected, deselect it now - if (selected.Count == 1) + if(selected.Count == 1) { General.Map.Map.ClearSelectedSectors(); General.Map.Map.ClearSelectedLinedefs(); + + //mxd. Also deselect things? + if(BuilderPlug.Me.SyncronizeThingEdit) + { + Sector s = General.GetByIndex(selected, 0); + foreach(Thing t in General.Map.Map.Things) + if(t.Sector == s && t.Selected) t.Selected = false; + } + UpdateEffectLabels(); //mxd } else if(result == DialogResult.Cancel) //mxd. Restore selection... { - foreach (Sector s in selected) SelectSector(s, true, false); + foreach(Sector s in selected) SelectSector(s, true, false); UpdateSelectedLabels(); //mxd } @@ -1634,7 +1640,7 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Add things? if(BuilderPlug.Me.SyncronizeThingEdit) { - foreach(Thing t in General.Map.ThingsFilter.VisibleThings) + foreach(Thing t in General.Map.Map.Things) { if(t.Sector == null) t.DetermineSector(); if(t.Sector == highlighted) selectedthings.Add(t); @@ -1758,19 +1764,25 @@ namespace CodeImp.DoomBuilder.BuilderModes public void JoinSectors() { // Worth our money? - int count = General.Map.Map.GetSelectedSectors(true).Count; - if(count > 1) + ICollection selected = General.Map.Map.GetSelectedSectors(true); //mxd + if(selected.Count > 1) { // Make undo - General.Map.UndoRedo.CreateUndo("Join " + count + " sectors"); - General.Interface.DisplayStatus(StatusType.Action, "Joined " + count + " sectors."); + General.Map.UndoRedo.CreateUndo("Join " + selected.Count + " sectors"); + General.Interface.DisplayStatus(StatusType.Action, "Joined " + selected.Count + " sectors."); + //mxd. Things may require updating + List affectedthings = new List(); + foreach(Thing t in General.Map.Map.Things) + if(t.Sector != null && selected.Contains(t.Sector)) affectedthings.Add(t); + // Merge JoinMergeSectors(false); - // Deselect - General.Map.Map.ClearSelectedSectors(); - General.Map.Map.ClearSelectedLinedefs(); + //mxd. Things may require updating + foreach(Thing t in affectedthings) t.DetermineSector(); + + // Map was changed General.Map.IsChanged = true; //mxd. Clear selection info @@ -1791,19 +1803,25 @@ namespace CodeImp.DoomBuilder.BuilderModes public void MergeSectors() { // Worth our money? - int count = General.Map.Map.GetSelectedSectors(true).Count; - if(count > 1) + ICollection selected = General.Map.Map.GetSelectedSectors(true); //mxd + if(selected.Count > 1) { // Make undo - General.Map.UndoRedo.CreateUndo("Merge " + count + " sectors"); - General.Interface.DisplayStatus(StatusType.Action, "Merged " + count + " sectors."); + General.Map.UndoRedo.CreateUndo("Merge " + selected.Count + " sectors"); + General.Interface.DisplayStatus(StatusType.Action, "Merged " + selected.Count + " sectors."); + + //mxd. Things may require updating + List affectedthings = new List(); + foreach(Thing t in General.Map.Map.Things) + if(t.Sector != null && selected.Contains(t.Sector)) affectedthings.Add(t); // Merge JoinMergeSectors(true); - // Deselect - General.Map.Map.ClearSelectedSectors(); - General.Map.Map.ClearSelectedLinedefs(); + //mxd. Things may require updating + foreach(Thing t in affectedthings) t.DetermineSector(); + + // Map was changed General.Map.IsChanged = true; //mxd. Clear selection info diff --git a/Source/Plugins/BuilderModes/General/CopyStructures.cs b/Source/Plugins/BuilderModes/General/CopyStructures.cs index 8bd673c0..9e4e0f9d 100644 --- a/Source/Plugins/BuilderModes/General/CopyStructures.cs +++ b/Source/Plugins/BuilderModes/General/CopyStructures.cs @@ -485,9 +485,6 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd public class LinedefPropertiesCopySettings : MapElementPropertiesCopySettings { - [FieldDescription(Description = "Sidedef Properties")] - public bool SidedefProperties = true; - [FieldDescription(Description = "Action")] public bool Action = true; @@ -559,7 +556,7 @@ namespace CodeImp.DoomBuilder.BuilderModes //mxd. Applies selected linededf and sidedef settings public void Apply(Linedef l, LinedefPropertiesCopySettings settings, SidedefPropertiesCopySettings sidesettings) { - if(settings.SidedefProperties && sidesettings != null) + if(sidesettings != null) { if((front != null) && (l.Front != null)) front.Apply(l.Front, sidesettings); if((back != null) && (l.Back != null)) back.Apply(l.Back, sidesettings); @@ -859,25 +856,24 @@ namespace CodeImp.DoomBuilder.BuilderModes } } if(linedefflags.Flags && !FlagsMatch(source.GetFlags(), target.GetFlags())) return false; - if(linedefflags.SidedefProperties) + + if(General.Map.UDMF) { - if((source.Front == null && target.Front != null) || (source.Front != null && target.Front == null) || - (source.Back == null && target.Back != null) || (source.Back != null && target.Back == null)) - return false; + // UI fields + if(linedefflags.Alpha && !UniFields.ValuesMatch("alpha", source, target)) return false; + if(linedefflags.RenderStyle && !UniFields.ValuesMatch("renderstyle", source, target)) return false; + if(linedefflags.LockNumber && !UniFields.ValuesMatch("locknumber", source, target)) return false; + if(linedefflags.Comment && !UniFields.ValuesMatch("comment", source, target)) return false; - if(source.Front != null && !PropertiesMatch(sideflags, source.Front, target.Front)) return false; - if(source.Back != null && !PropertiesMatch(sideflags, source.Back, target.Back)) return false; + // Custom fields + if(linedefflags.Fields && !UniFields.CustomFieldsMatch(source.Fields, target.Fields)) return false; } - if(!General.Map.UDMF) return true; - // UI fields - if(linedefflags.Alpha && !UniFields.ValuesMatch("alpha", source, target)) return false; - if(linedefflags.RenderStyle && !UniFields.ValuesMatch("renderstyle", source, target)) return false; - if(linedefflags.LockNumber && !UniFields.ValuesMatch("locknumber", source, target)) return false; - if(linedefflags.Comment && !UniFields.ValuesMatch("comment", source, target)) return false; - - // Custom fields - return !linedefflags.Fields || UniFields.CustomFieldsMatch(source.Fields, target.Fields); + // Sidedef properties + return (source.Front != null && target.Front != null && PropertiesMatch(sideflags, source.Front, target.Front)) || + (source.Front != null && target.Back != null && PropertiesMatch(sideflags, source.Front, target.Back)) || + (source.Back != null && target.Front != null && PropertiesMatch(sideflags, source.Back, target.Front)) || + (source.Back != null && target.Back != null && PropertiesMatch(sideflags, source.Back, target.Back)); } #endregion diff --git a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs index 479ddb5c..a4ab0762 100644 --- a/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs +++ b/Source/Plugins/BuilderModes/VisualModes/BaseVisualGeometrySidedef.cs @@ -1248,7 +1248,7 @@ namespace CodeImp.DoomBuilder.BuilderModes { if(BuilderPlug.Me.CopiedLinedefProps != null) { - bool pastesideprops = (LinedefProperties.CopySettings.SidedefProperties && BuilderPlug.Me.CopiedSidedefProps != null); //mxd + bool pastesideprops = (BuilderPlug.Me.CopiedSidedefProps != null); //mxd string pastetarget = (pastesideprops ? "linedef and sidedef" : "linedef"); //mxd mode.CreateUndo("Paste " + pastetarget + " properties"); mode.SetActionResult("Pasted " + pastetarget + " properties.");