mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 09:22:54 +08:00
Use bindable flow for event propagation
This commit is contained in:
parent
24eff8c66d
commit
3e326a9234
@ -289,8 +289,11 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Width = 0.25f,
|
Width = 0.25f,
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
X = -100,
|
X = -100,
|
||||||
|
SelectedMods = { BindTarget = SelectedMods },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
((IBindable<bool>)CustomiseButton.Enabled).BindTo(ModSettingsContainer.HasSettingsForSelection);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
@ -399,8 +402,6 @@ namespace osu.Game.Overlays.Mods
|
|||||||
section.SelectTypes(mods.NewValue.Select(m => m.GetType()).ToList());
|
section.SelectTypes(mods.NewValue.Select(m => m.GetType()).ToList());
|
||||||
|
|
||||||
updateMods();
|
updateMods();
|
||||||
|
|
||||||
CustomiseButton.Enabled.Value = ModSettingsContainer.UpdateModSettings(mods);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateMods()
|
private void updateMods()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
@ -18,6 +19,12 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
public class ModSettingsContainer : Container
|
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;
|
private readonly FillFlowContainer<ModControlSection> modSettingsContent;
|
||||||
|
|
||||||
public ModSettingsContainer()
|
public ModSettingsContainer()
|
||||||
@ -45,8 +52,14 @@ namespace osu.Game.Overlays.Mods
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
///<returns>Bool indicating whether any settings are listed</returns>
|
protected override void LoadComplete()
|
||||||
public bool UpdateModSettings(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
SelectedMods.BindValueChanged(modsChanged, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void modsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
||||||
{
|
{
|
||||||
modSettingsContent.Clear();
|
modSettingsContent.Clear();
|
||||||
|
|
||||||
@ -62,7 +75,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
if (!hasSettings)
|
if (!hasSettings)
|
||||||
Hide();
|
Hide();
|
||||||
|
|
||||||
return hasSettings;
|
hasSettingsForSelection.Value = hasSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
protected override bool OnMouseDown(MouseDownEvent e) => true;
|
||||||
|
Loading…
Reference in New Issue
Block a user