1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Remove unwanted class and move the bind logic outside the RulesetSelector

This commit is contained in:
Andrei Zavatski 2019-06-24 23:13:28 +03:00
parent 9dedd62d9a
commit 4a05c560cf
3 changed files with 8 additions and 26 deletions

View File

@ -12,6 +12,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Input.Events;
using osu.Game.Rulesets;
namespace osu.Game.Overlays.Toolbar
{
@ -23,6 +24,7 @@ namespace osu.Game.Overlays.Toolbar
public Action OnHome;
private ToolbarUserButton userButton;
private ToolbarRulesetSelector rulesetSelector;
protected override bool BlockPositionalInput => false;
@ -40,7 +42,7 @@ namespace osu.Game.Overlays.Toolbar
}
[BackgroundDependencyLoader(true)]
private void load(OsuGame osuGame)
private void load(OsuGame osuGame, Bindable<RulesetInfo> parentRuleset)
{
Children = new Drawable[]
{
@ -57,7 +59,7 @@ namespace osu.Game.Overlays.Toolbar
{
Action = () => OnHome?.Invoke()
},
new ToolbarRulesetSelector()
rulesetSelector = new ToolbarRulesetSelector()
}
},
new FillFlowContainer
@ -84,6 +86,8 @@ namespace osu.Game.Overlays.Toolbar
}
};
rulesetSelector.Current.BindTarget = parentRuleset;
State.ValueChanged += visibility =>
{
if (overlayActivationMode.Value == OverlayActivation.Disabled)

View File

@ -10,14 +10,13 @@ using osuTK.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Bindables;
using osu.Framework.Input.Events;
using osuTK.Input;
using System.Linq;
namespace osu.Game.Overlays.Toolbar
{
public class ToolbarRulesetSelector : BindableRulesetSelector
public class ToolbarRulesetSelector : RulesetSelector
{
private const float padding = 10;
private readonly Drawable modeButtonLine;
@ -63,6 +62,7 @@ namespace osu.Game.Overlays.Toolbar
});
Current.DisabledChanged += disabledChanged;
Current.ValueChanged += (value) => activeMode.Invalidate();
}
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
@ -92,8 +92,6 @@ namespace osu.Game.Overlays.Toolbar
private readonly Cached activeMode = new Cached();
protected override void OnRulesetChanged(ValueChangedEvent<RulesetInfo> e) => activeMode.Invalidate();
protected override void UpdateAfterChildren()
{
base.UpdateAfterChildren();

View File

@ -1,20 +0,0 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Bindables;
namespace osu.Game.Rulesets
{
public abstract class BindableRulesetSelector : RulesetSelector
{
[BackgroundDependencyLoader]
private void load(Bindable<RulesetInfo> parentRuleset)
{
Current.BindTo(parentRuleset);
Current.BindValueChanged(OnRulesetChanged);
}
protected abstract void OnRulesetChanged(ValueChangedEvent<RulesetInfo> e);
}
}