mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Implement RankingsRulesetSelector
This commit is contained in:
parent
c3c2efe35c
commit
581508b8e7
@ -0,0 +1,42 @@
|
||||
// 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.Game.Overlays.Rankings;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public class TestSceneRankingsRulesetSelector : OsuTestScene
|
||||
{
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(RankingsRulesetSelector),
|
||||
};
|
||||
|
||||
public TestSceneRankingsRulesetSelector()
|
||||
{
|
||||
RankingsRulesetSelector selector;
|
||||
var current = new Bindable<RulesetInfo>();
|
||||
|
||||
Add(selector = new RankingsRulesetSelector
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Current = { BindTarget = current }
|
||||
});
|
||||
|
||||
AddStep("Select osu!", () => current.Value = new OsuRuleset().RulesetInfo);
|
||||
AddStep("Select mania", () => current.Value = new ManiaRuleset().RulesetInfo);
|
||||
AddStep("Select taiko", () => current.Value = new TaikoRuleset().RulesetInfo);
|
||||
AddStep("Select catch", () => current.Value = new CatchRuleset().RulesetInfo);
|
||||
}
|
||||
}
|
||||
}
|
56
osu.Game/Overlays/Rankings/RankingsRulesetSelector.cs
Normal file
56
osu.Game/Overlays/Rankings/RankingsRulesetSelector.cs
Normal file
@ -0,0 +1,56 @@
|
||||
// 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.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets;
|
||||
using osuTK;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Overlays.Rankings
|
||||
{
|
||||
public class RankingsRulesetSelector : PageTabControl<RulesetInfo>
|
||||
{
|
||||
protected override TabItem<RulesetInfo> CreateTabItem(RulesetInfo value) => new RankingsTabItem(value);
|
||||
|
||||
protected override Dropdown<RulesetInfo> CreateDropdown() => null;
|
||||
|
||||
public RankingsRulesetSelector()
|
||||
{
|
||||
AutoSizeAxes = Axes.X;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, RulesetStore Rulesets)
|
||||
{
|
||||
foreach (var r in Rulesets.AvailableRulesets)
|
||||
AddItem(r);
|
||||
|
||||
AccentColour = colours.Lime;
|
||||
|
||||
SelectTab(TabContainer.FirstOrDefault());
|
||||
}
|
||||
|
||||
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(20, 0),
|
||||
};
|
||||
|
||||
private class RankingsTabItem : PageTabItem
|
||||
{
|
||||
public RankingsTabItem(RulesetInfo value)
|
||||
: base(value)
|
||||
{
|
||||
}
|
||||
|
||||
protected override string CreateText() => $"{Value.Name}";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user