Use bindable flow for event propagation

This commit is contained in:
Dean Herbert
2020-10-14 15:21:28 +09:00
parent 24eff8c66d
commit 3e326a9234
2 changed files with 19 additions and 5 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
@ -18,6 +19,12 @@ namespace osu.Game.Overlays.Mods
{
public class ModSettingsContainer : Container
{
public readonly IBindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
public IBindable<bool> HasSettingsForSelection => hasSettingsForSelection;
private readonly Bindable<bool> hasSettingsForSelection = new Bindable<bool>();
private readonly FillFlowContainer<ModControlSection> modSettingsContent;
public ModSettingsContainer()
@ -45,8 +52,14 @@ namespace osu.Game.Overlays.Mods
};
}
///<returns>Bool indicating whether any settings are listed</returns>
public bool UpdateModSettings(ValueChangedEvent<IReadOnlyList<Mod>> mods)
protected override void LoadComplete()
{
base.LoadComplete();
SelectedMods.BindValueChanged(modsChanged, true);
}
private void modsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
{
modSettingsContent.Clear();
@ -62,7 +75,7 @@ namespace osu.Game.Overlays.Mods
if (!hasSettings)
Hide();
return hasSettings;
hasSettingsForSelection.Value = hasSettings;
}
protected override bool OnMouseDown(MouseDownEvent e) => true;