diff --git a/CentrED/Tools/LandBrushTool.cs b/CentrED/Tools/LandBrushTool.cs index efa564a..000136b 100644 --- a/CentrED/Tools/LandBrushTool.cs +++ b/CentrED/Tools/LandBrushTool.cs @@ -26,6 +26,10 @@ public LandBrushTool() internal override void Draw() { base.Draw(); + if (!ProfileManager.ActiveProfile.LandBrush.ContainsKey(_activeLandBrushName)) + { + _activeLandBrushName = ProfileManager.ActiveProfile.LandBrush.Keys.FirstOrDefault(""); + } _manager.LandBrushCombo(ref _activeLandBrushName); ImGui.Checkbox("Fixed Z", ref _fixedZ); diff --git a/CentrED/UI/Windows/LandBrushManagerWindow.cs b/CentrED/UI/Windows/LandBrushManagerWindow.cs index 4f8ae8e..931cbc1 100644 --- a/CentrED/UI/Windows/LandBrushManagerWindow.cs +++ b/CentrED/UI/Windows/LandBrushManagerWindow.cs @@ -387,10 +387,26 @@ private void DrawBrushPopups() ImGui.Text($"LandBrush: '{Selected.Name}'"); if (ImGui.Button("Yes", new Vector2(100, 0))) { - foreach (var landBrushesValue in _landBrushes.Values) + //Remove all entries that have removed brush as to-transition + foreach (var landBrush in _landBrushes.Values) { - landBrushesValue.Transitions.Remove(Selected.Name); + if(landBrush.Transitions.Remove(Selected.Name, out var removed)) + { + foreach (var transition in removed) + { + RemoveLandBrushEntry(transition.TileID, landBrush.Name, _selectedLandBrushName); + } + } + } + //Remove all entries that have removed brush as from-transition + foreach (var (name, transitions) in Selected.Transitions) + { + foreach (var transition in transitions) + { + RemoveLandBrushEntry(transition.TileID, _selectedLandBrushName, name); + } } + Selected.Tiles.ForEach(t => RemoveLandBrushEntry(t, _selectedLandBrushName, _selectedLandBrushName)); _landBrushes.Remove(Selected.Name); _selectedLandBrushName = _landBrushes.Keys.FirstOrDefault(""); _selectedTransitionBrushName = Selected?.Transitions.Keys.FirstOrDefault("") ?? ""; @@ -439,7 +455,11 @@ private void DrawTransitionPopups() ImGui.Text($"Transition: '{_selectedTransitionBrushName}'"); if (ImGui.Button("Yes", new Vector2(100, 0))) { - Selected!.Transitions.Remove(_selectedTransitionBrushName); + //Remove all entries that have removed brush as to-transition + if (Selected!.Transitions.Remove(_selectedTransitionBrushName, out var removed)) + { + removed.ForEach(t => RemoveLandBrushEntry(t.TileID, Selected.Name, _selectedTransitionBrushName)); + } if(Selected.Transitions.Count > 0) _selectedTransitionBrushName = Selected.Transitions.Keys.FirstOrDefault(""); else