Ensure toggles are not instantiated more than once for safety

This commit is contained in:
Dean Herbert
2020-09-25 17:40:43 +09:00
parent b8e9f19b92
commit 22511c36c3
3 changed files with 18 additions and 11 deletions

View File

@ -133,7 +133,6 @@ namespace osu.Game.Rulesets.Edit
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5),
ChildrenEnumerable = Toggles.Select(b => new DrawableTernaryButton(b))
},
}
}
@ -145,6 +144,9 @@ namespace osu.Game.Rulesets.Edit
.Select(t => new RadioButton(t.Name, () => toolSelected(t), t.CreateIcon))
.ToList();
Toggles = CreateToggles().ToArray();
togglesCollection.AddRange(Toggles.Select(b => new DrawableTernaryButton(b)));
setSelectTool();
EditorBeatmap.SelectedHitObjects.CollectionChanged += selectionChanged;
@ -176,7 +178,9 @@ namespace osu.Game.Rulesets.Edit
/// A collection of toggles which will be displayed to the user.
/// The display name will be decided by <see cref="Bindable{T}.Description"/>.
/// </summary>
protected virtual IEnumerable<TernaryButton> Toggles => BlueprintContainer.Toggles;
public TernaryButton[] Toggles { get; private set; }
protected virtual IEnumerable<TernaryButton> CreateToggles() => BlueprintContainer.Toggles;
/// <summary>
/// Construct a relevant blueprint container. This will manage hitobject selection/placement input handling and display logic.