mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Move Enabled/Disabled state logic to the OverlayRulesetTabItem
This commit is contained in:
parent
ad7f7343d7
commit
4abd9cb89a
@ -18,8 +18,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
||||
|
||||
public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree;
|
||||
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
|
||||
@ -73,17 +71,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
Enabled.Value = beatmapsCount > 0;
|
||||
}, true);
|
||||
|
||||
Enabled.BindValueChanged(enabled =>
|
||||
{
|
||||
if (enabled.NewValue)
|
||||
{
|
||||
UpdateState();
|
||||
return;
|
||||
}
|
||||
|
||||
AccentColour = colourProvider.Foreground1;
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,8 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
public class OverlayRulesetTabItem : TabItem<RulesetInfo>
|
||||
{
|
||||
public override bool PropagatePositionalInputSubTree => Enabled.Value && !Active.Value && base.PropagatePositionalInputSubTree;
|
||||
|
||||
private Color4 accentColour;
|
||||
|
||||
protected virtual Color4 AccentColour
|
||||
@ -61,37 +63,35 @@ namespace osu.Game.Overlays
|
||||
Enabled.Value = true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
UpdateState();
|
||||
base.LoadComplete();
|
||||
Enabled.BindValueChanged(_ => updateState(), true);
|
||||
}
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
base.OnHover(e);
|
||||
UpdateState();
|
||||
updateState();
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override void OnHoverLost(HoverLostEvent e)
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
UpdateState();
|
||||
updateState();
|
||||
}
|
||||
|
||||
protected override void OnActivated() => UpdateState();
|
||||
protected override void OnActivated() => updateState();
|
||||
|
||||
protected override void OnDeactivated() => UpdateState();
|
||||
protected override void OnDeactivated() => updateState();
|
||||
|
||||
protected void UpdateState()
|
||||
private void updateState()
|
||||
{
|
||||
text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Medium);
|
||||
|
||||
if (!Enabled.Value)
|
||||
return;
|
||||
|
||||
AccentColour = IsHovered || Active.Value ? Color4.White : colourProvider.Highlight1;
|
||||
AccentColour = IsHovered || Active.Value ? Color4.White : getStateColour();
|
||||
}
|
||||
|
||||
private Color4 getStateColour() => Enabled.Value ? colourProvider.Highlight1 : colourProvider.Foreground1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user