1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 03:47:26 +08:00
osu-lazer/osu.Game/Overlays/Rankings/RankingsHeader.cs

130 lines
4.9 KiB
C#
Raw Normal View History

2019-09-12 10:53:18 +08:00
// 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.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Rulesets;
using osu.Game.Users;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
2019-09-12 11:36:17 +08:00
using osuTK;
using osu.Game.Graphics.UserInterface;
using System.Collections.Generic;
2019-09-12 10:53:18 +08:00
namespace osu.Game.Overlays.Rankings
{
public class RankingsHeader : CompositeDrawable
{
private const int content_height = 250;
2019-09-12 11:36:17 +08:00
public IEnumerable<Spotlight> Spotlights
{
get => dropdown.Items;
set => dropdown.Items = value;
}
2019-09-12 10:53:18 +08:00
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
public readonly Bindable<Country> Country = new Bindable<Country>();
2019-09-12 11:36:17 +08:00
public readonly Bindable<Spotlight> Spotlight = new Bindable<Spotlight>();
private readonly OsuDropdown<Spotlight> dropdown;
2019-09-12 10:53:18 +08:00
public RankingsHeader()
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
AddInternal(new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Children = new Drawable[]
{
new RankingsRulesetSelector
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
2019-09-13 17:10:52 +08:00
Current = Ruleset
2019-09-12 10:53:18 +08:00
},
new Container
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Height = content_height,
Children = new Drawable[]
{
2019-09-12 11:36:17 +08:00
new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
Child = new HeaderBackground(),
},
new FillFlowContainer
2019-09-12 10:53:18 +08:00
{
2019-09-12 11:36:17 +08:00
AutoSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.X,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 20),
2019-09-12 11:36:17 +08:00
Children = new Drawable[]
{
2019-09-13 17:07:52 +08:00
new RankingsScopeSelector
{
Margin = new MarginPadding { Top = 10 },
2019-09-13 17:10:52 +08:00
Current = Scope
2019-09-13 17:07:52 +08:00
},
2019-09-12 11:36:17 +08:00
new HeaderTitle
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
2019-09-13 17:07:52 +08:00
Margin = new MarginPadding { Top = 10 },
2019-09-13 17:10:52 +08:00
Scope = { BindTarget = Scope },
2019-09-12 11:36:17 +08:00
Country = { BindTarget = Country },
},
2019-09-14 11:34:57 +08:00
dropdown = new OsuDropdown<Spotlight>
2019-09-12 11:36:17 +08:00
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Width = 0.8f,
2019-09-14 11:34:57 +08:00
Current = Spotlight,
2019-09-12 11:36:17 +08:00
}
}
},
2019-09-12 10:53:18 +08:00
}
}
}
});
}
2019-09-12 11:36:17 +08:00
protected override void LoadComplete()
{
Scope.BindValueChanged(onScopeChanged, true);
2019-09-12 11:36:17 +08:00
base.LoadComplete();
}
private void onScopeChanged(ValueChangedEvent<RankingsScope> scope) =>
dropdown.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint);
2019-09-12 11:36:17 +08:00
private class HeaderBackground : Sprite
2019-09-12 10:53:18 +08:00
{
public HeaderBackground()
{
2019-09-12 11:36:17 +08:00
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
2019-09-12 10:53:18 +08:00
RelativeSizeAxes = Axes.Both;
FillMode = FillMode.Fill;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get(@"Headers/rankings");
}
}
}
}