mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 09:43:10 +08:00
retrieve user's default playmode
This commit is contained in:
parent
0abb48882c
commit
a0f7f69f46
@ -4,6 +4,7 @@
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics;
|
||||
@ -46,7 +47,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
public GamemodeControl()
|
||||
{
|
||||
TabContainer.Masking = false;
|
||||
TabContainer.Spacing = new Vector2(15, 0);
|
||||
TabContainer.Spacing = new Vector2(10, 0);
|
||||
AutoSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
@ -54,7 +55,20 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
private void load(RulesetStore rulesets)
|
||||
{
|
||||
foreach (var r in rulesets.AvailableRulesets)
|
||||
AddItem(r.Name);
|
||||
AddItem(r.ShortName);
|
||||
//AddItem(r.Name);
|
||||
}
|
||||
|
||||
public void SetDefaultGamemode(string gamemode)
|
||||
{
|
||||
foreach (GamemodeTabItem i in TabContainer)
|
||||
{
|
||||
if (i.Value == gamemode)
|
||||
{
|
||||
i.IsDefault = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
||||
@ -66,6 +80,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
private class GamemodeTabItem : TabItem<string>
|
||||
{
|
||||
private readonly OsuSpriteText text;
|
||||
private readonly SpriteIcon icon;
|
||||
|
||||
private Color4 accentColour;
|
||||
|
||||
@ -83,6 +98,22 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
}
|
||||
}
|
||||
|
||||
private bool isDefault;
|
||||
|
||||
public bool IsDefault
|
||||
{
|
||||
get => isDefault;
|
||||
set
|
||||
{
|
||||
if (isDefault == value)
|
||||
return;
|
||||
|
||||
isDefault = value;
|
||||
|
||||
icon.FadeTo(isDefault ? 1 : 0, 100, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
public GamemodeTabItem(string value)
|
||||
: base(value)
|
||||
{
|
||||
@ -90,13 +121,32 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
new FillFlowContainer
|
||||
{
|
||||
Margin = new MarginPadding { Bottom = 10 },
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Text = value,
|
||||
Font = OsuFont.GetFont()
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(3, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
text = new OsuSpriteText
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Text = value,
|
||||
Font = OsuFont.GetFont()
|
||||
},
|
||||
icon = new SpriteIcon
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Anchor = Anchor.Centre,
|
||||
Alpha = 0,
|
||||
AlwaysPresent = true,
|
||||
Icon = FontAwesome.Solid.Star,
|
||||
Size = new Vector2(12),
|
||||
},
|
||||
}
|
||||
},
|
||||
new HoverClickSounds()
|
||||
};
|
||||
@ -127,6 +177,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
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);
|
||||
@ -134,6 +185,7 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
||||
else
|
||||
{
|
||||
text.FadeColour(AccentColour, 120, Easing.InQuad);
|
||||
icon.FadeColour(AccentColour, 120, Easing.InQuad);
|
||||
text.Font = text.Font.With(weight: FontWeight.Medium);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ namespace osu.Game.Overlays.Profile
|
||||
|
||||
Add(gamemodeControl = new GamemodeControl
|
||||
{
|
||||
Alpha = 0,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Y = 100,
|
||||
@ -105,7 +106,16 @@ namespace osu.Game.Overlays.Profile
|
||||
|
||||
protected override ScreenTitle CreateTitle() => new ProfileHeaderTitle();
|
||||
|
||||
private void updateDisplay(User user) => coverContainer.User = user;
|
||||
private void updateDisplay(User user)
|
||||
{
|
||||
coverContainer.User = user;
|
||||
|
||||
string playMode = user.PlayMode;
|
||||
|
||||
gamemodeControl.Current.Value = playMode;
|
||||
gamemodeControl.SetDefaultGamemode(playMode);
|
||||
gamemodeControl.FadeInFromZero(100, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private class ProfileHeaderTitle : ScreenTitle
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user