mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 17:33:02 +08:00
Implement RankingsHeader component
This commit is contained in:
parent
b657e31f93
commit
0c6c8fdcd0
52
osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs
Normal file
52
osu.Game.Tests/Visual/Online/TestSceneRankingsHeader.cs
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
// 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 System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Overlays.Rankings;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Users;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Online
|
||||||
|
{
|
||||||
|
public class TestSceneRankingsHeader : OsuTestScene
|
||||||
|
{
|
||||||
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
|
{
|
||||||
|
typeof(HeaderFlag),
|
||||||
|
typeof(HeaderTitle),
|
||||||
|
typeof(RankingsRulesetSelector),
|
||||||
|
typeof(RankingsScopeSelector),
|
||||||
|
typeof(RankingsHeader),
|
||||||
|
};
|
||||||
|
|
||||||
|
public TestSceneRankingsHeader()
|
||||||
|
{
|
||||||
|
var countryBindable = new Bindable<Country>();
|
||||||
|
var ruleset = new Bindable<RulesetInfo>();
|
||||||
|
var scope = new Bindable<RankingsScope>();
|
||||||
|
|
||||||
|
Add(new RankingsHeader
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Scope = { BindTarget = scope },
|
||||||
|
Country = { BindTarget = countryBindable },
|
||||||
|
Ruleset = { BindTarget = ruleset },
|
||||||
|
});
|
||||||
|
|
||||||
|
var country = new Country
|
||||||
|
{
|
||||||
|
FlagName = "BY",
|
||||||
|
FullName = "Belarus"
|
||||||
|
};
|
||||||
|
|
||||||
|
AddStep("Set country", () => countryBindable.Value = country);
|
||||||
|
AddAssert("Check scope is Performance", () => scope.Value == RankingsScope.Performance);
|
||||||
|
AddStep("Set scope to Score", () => scope.Value = RankingsScope.Score);
|
||||||
|
AddAssert("Check country is Null", () => countryBindable.Value == null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
84
osu.Game/Overlays/Rankings/RankingsHeader.cs
Normal file
84
osu.Game/Overlays/Rankings/RankingsHeader.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// 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.Graphics.Shapes;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Users;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Textures;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Rankings
|
||||||
|
{
|
||||||
|
public class RankingsHeader : CompositeDrawable
|
||||||
|
{
|
||||||
|
private const int content_height = 250;
|
||||||
|
|
||||||
|
public readonly Bindable<RankingsScope> Scope = new Bindable<RankingsScope>();
|
||||||
|
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||||
|
public readonly Bindable<Country> Country = new Bindable<Country>();
|
||||||
|
|
||||||
|
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[]
|
||||||
|
{
|
||||||
|
new HeaderBackground(),
|
||||||
|
new RankingsScopeSelector
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding { Top = 10 },
|
||||||
|
Current = { BindTarget = Scope }
|
||||||
|
},
|
||||||
|
new HeaderTitle
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Scope = { BindTarget = Scope },
|
||||||
|
Country = { BindTarget = Country },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HeaderBackground : Sprite
|
||||||
|
{
|
||||||
|
public HeaderBackground()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
FillMode = FillMode.Fill;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TextureStore textures)
|
||||||
|
{
|
||||||
|
Texture = textures.Get(@"Headers/rankings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user