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
|
|
|
|
private const int dropdown_height = 50;
|
|
|
|
|
|
|
|
|
|
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 Container dropdownPlaceholder;
|
|
|
|
|
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,
|
|
|
|
|
Current = { BindTarget = Ruleset }
|
|
|
|
|
},
|
|
|
|
|
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,
|
2019-09-13 17:09:15 +08:00
|
|
|
|
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 },
|
|
|
|
|
Current = { BindTarget = Scope }
|
|
|
|
|
},
|
2019-09-12 11:36:17 +08:00
|
|
|
|
new HeaderTitle
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
Scope = { BindTarget = Scope },
|
2019-09-13 17:07:52 +08:00
|
|
|
|
Margin = new MarginPadding { Top = 10 },
|
2019-09-12 11:36:17 +08:00
|
|
|
|
Country = { BindTarget = Country },
|
|
|
|
|
},
|
|
|
|
|
dropdownPlaceholder = new Container
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = dropdown_height,
|
|
|
|
|
Width = 0.8f,
|
|
|
|
|
AlwaysPresent = true,
|
|
|
|
|
Child = dropdown = new OsuDropdown<Spotlight>
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Current = { BindTarget = Spotlight },
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-09-12 10:53:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-12 11:36:17 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
2019-09-13 17:09:15 +08:00
|
|
|
|
Scope.BindValueChanged(onScopeChanged, true);
|
2019-09-12 11:36:17 +08:00
|
|
|
|
base.LoadComplete();
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-13 17:09:15 +08:00
|
|
|
|
private void onScopeChanged(ValueChangedEvent<RankingsScope> scope) =>
|
|
|
|
|
dropdownPlaceholder.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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|