1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 21:03:08 +08:00
osu-lazer/osu.Game/Overlays/BeatmapSet/LeaderboardScopeSelector.cs

120 lines
3.7 KiB
C#
Raw Normal View History

2019-08-07 13:33:55 +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.UserInterface;
using osu.Game.Screens.Select.Leaderboards;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osuTK;
using osu.Game.Graphics.UserInterface;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Framework.Allocation;
using osuTK.Graphics;
using osu.Framework.Graphics.Colour;
2019-08-12 18:16:57 +08:00
using osu.Framework.Input.Events;
2019-08-07 13:33:55 +08:00
namespace osu.Game.Overlays.BeatmapSet
{
2019-08-12 18:16:57 +08:00
public class LeaderboardScopeSelector : PageTabControl<BeatmapLeaderboardScope>
2019-08-07 13:33:55 +08:00
{
2019-08-12 23:14:37 +08:00
protected override bool AddEnumEntriesAutomatically => false;
2019-08-12 18:16:57 +08:00
2019-08-07 13:33:55 +08:00
protected override Dropdown<BeatmapLeaderboardScope> CreateDropdown() => null;
protected override TabItem<BeatmapLeaderboardScope> CreateTabItem(BeatmapLeaderboardScope value) => new ScopeSelectorTabItem(value);
public LeaderboardScopeSelector()
{
RelativeSizeAxes = Axes.X;
AddItem(BeatmapLeaderboardScope.Global);
AddItem(BeatmapLeaderboardScope.Country);
AddItem(BeatmapLeaderboardScope.Friend);
AddInternal(new GradientLine
2019-08-07 13:33:55 +08:00
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
AccentColour = colours.Blue;
}
2019-08-07 13:33:55 +08:00
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
2019-08-12 18:16:57 +08:00
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
2019-08-07 13:33:55 +08:00
Direction = FillDirection.Horizontal,
Spacing = new Vector2(20, 0),
};
2019-08-12 18:16:57 +08:00
private class ScopeSelectorTabItem : PageTabItem
2019-08-07 13:33:55 +08:00
{
public ScopeSelectorTabItem(BeatmapLeaderboardScope value)
: base(value)
{
2019-08-12 18:16:57 +08:00
Text.Font = OsuFont.GetFont(size: 16);
2019-08-07 13:33:55 +08:00
}
protected override bool OnHover(HoverEvent e)
{
Text.FadeColour(AccentColour);
2019-08-07 13:33:55 +08:00
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
Text.FadeColour(Color4.White);
}
}
private class GradientLine : GridContainer
2019-08-07 13:33:55 +08:00
{
public GradientLine()
2019-08-07 13:33:55 +08:00
{
RelativeSizeAxes = Axes.X;
Size = new Vector2(0.8f, 1.5f);
2019-08-07 13:33:55 +08:00
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(mode: GridSizeMode.Relative, size: 0.4f),
new Dimension(),
};
2019-08-07 13:33:55 +08:00
Content = new[]
{
new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientHorizontal(Color4.Transparent, Color4.Gray),
},
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Gray,
},
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = ColourInfo.GradientHorizontal(Color4.Gray, Color4.Transparent),
},
}
};
}
}
}
}