mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
Update the component with an abstract RulesetSelector class
This commit is contained in:
parent
e9f3a1ba63
commit
2e49b4ffcd
@ -12,10 +12,8 @@ using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
public class ProfileRulesetSelector : TabControl<RulesetInfo>
|
||||
public class ProfileRulesetSelector : RulesetSelector
|
||||
{
|
||||
protected override Dropdown<RulesetInfo> CreateDropdown() => null;
|
||||
|
||||
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new RulesetTabItem(value)
|
||||
{
|
||||
AccentColour = AccentColour
|
||||
@ -48,13 +46,8 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(RulesetStore rulesets, OsuColour colours)
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
foreach (var r in rulesets.AvailableRulesets)
|
||||
{
|
||||
AddItem(r);
|
||||
}
|
||||
|
||||
AccentColour = colours.Seafoam;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,8 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
base.OnHover(e);
|
||||
|
||||
updateState();
|
||||
if (!Active.Value)
|
||||
hoverAction();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -103,29 +104,40 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
|
||||
updateState();
|
||||
if (!Active.Value)
|
||||
unhoverAction();
|
||||
}
|
||||
|
||||
protected override void OnActivated() => updateState();
|
||||
protected override void OnActivated()
|
||||
{
|
||||
hoverAction();
|
||||
text.Font = text.Font.With(weight: FontWeight.Bold);
|
||||
}
|
||||
|
||||
protected override void OnDeactivated() => updateState();
|
||||
protected override void OnDeactivated()
|
||||
{
|
||||
unhoverAction();
|
||||
text.Font = text.Font.With(weight: FontWeight.Medium);
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
if (Active.Value || IsHovered)
|
||||
{
|
||||
text.FadeColour(Color4.White, 120, Easing.InQuad);
|
||||
icon.FadeColour(Color4.White, 120, Easing.InQuad);
|
||||
|
||||
if (Active.Value)
|
||||
text.Font = text.Font.With(weight: FontWeight.Bold);
|
||||
}
|
||||
if (Active.Value)
|
||||
OnActivated();
|
||||
else
|
||||
{
|
||||
text.FadeColour(AccentColour, 120, Easing.InQuad);
|
||||
icon.FadeColour(AccentColour, 120, Easing.InQuad);
|
||||
text.Font = text.Font.With(weight: FontWeight.Medium);
|
||||
}
|
||||
OnDeactivated();
|
||||
}
|
||||
|
||||
private void hoverAction()
|
||||
{
|
||||
text.FadeColour(Color4.White, 120, Easing.InQuad);
|
||||
icon.FadeColour(Color4.White, 120, Easing.InQuad);
|
||||
}
|
||||
|
||||
private void unhoverAction()
|
||||
{
|
||||
text.FadeColour(AccentColour, 120, Easing.InQuad);
|
||||
icon.FadeColour(AccentColour, 120, Easing.InQuad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user