2020-01-10 13:33:00 +00: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.Allocation;
|
2020-01-10 14:30:51 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2020-01-10 13:33:00 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Game.Graphics;
|
2020-01-10 14:30:51 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2020-01-10 13:33:00 +00:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-01-10 14:30:51 +00:00
|
|
|
|
using osuTK;
|
|
|
|
|
using System;
|
2020-01-14 04:07:21 +00:00
|
|
|
|
using System.Collections.Generic;
|
2020-01-10 13:33:00 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Rankings
|
|
|
|
|
{
|
|
|
|
|
public class SpotlightSelector : Container
|
|
|
|
|
{
|
|
|
|
|
private readonly Box background;
|
2020-01-10 13:41:17 +00:00
|
|
|
|
private readonly SpotlightsDropdown dropdown;
|
2020-01-10 13:33:00 +00:00
|
|
|
|
|
2020-01-10 14:30:51 +00:00
|
|
|
|
public readonly Bindable<APISpotlight> SelectedSpotlight = new Bindable<APISpotlight>();
|
|
|
|
|
|
2020-01-14 04:07:21 +00:00
|
|
|
|
public IEnumerable<APISpotlight> Spotlights
|
|
|
|
|
{
|
|
|
|
|
get => dropdown.Items;
|
|
|
|
|
set => dropdown.Items = value;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-10 17:46:35 +00:00
|
|
|
|
private readonly InfoColumn startDateColumn;
|
|
|
|
|
private readonly InfoColumn endDateColumn;
|
2020-01-14 04:07:21 +00:00
|
|
|
|
private readonly InfoColumn mapCountColumn;
|
|
|
|
|
private readonly InfoColumn participants;
|
2020-01-10 14:30:51 +00:00
|
|
|
|
|
2020-01-10 13:33:00 +00:00
|
|
|
|
public SpotlightSelector()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2020-01-10 14:30:51 +00:00
|
|
|
|
Height = 100;
|
2020-01-10 13:33:00 +00:00
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
background = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
2020-01-10 14:30:51 +00:00
|
|
|
|
new Container
|
2020-01-10 13:33:00 +00:00
|
|
|
|
{
|
2020-01-10 14:30:51 +00:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Horizontal = UserProfileOverlay.CONTENT_X_MARGIN, Vertical = 10 },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
dropdown = new SpotlightsDropdown
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Current = SelectedSpotlight,
|
|
|
|
|
Depth = -float.MaxValue
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomRight,
|
|
|
|
|
Origin = Anchor.BottomRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(15, 0),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-01-10 17:46:35 +00:00
|
|
|
|
startDateColumn = new InfoColumn(@"Start Date"),
|
|
|
|
|
endDateColumn = new InfoColumn(@"End Date"),
|
2020-01-14 04:07:21 +00:00
|
|
|
|
mapCountColumn = new InfoColumn(@"Map Count"),
|
|
|
|
|
participants = new InfoColumn(@"Participants"),
|
2020-01-10 14:30:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-10 13:33:00 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
background.Colour = colours.GreySeafoam;
|
2020-01-10 14:30:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-14 04:07:21 +00:00
|
|
|
|
public void UpdateInfo(APISpotlight spotlight, int mapCount)
|
2020-01-10 14:30:51 +00:00
|
|
|
|
{
|
2020-01-14 04:07:21 +00:00
|
|
|
|
startDateColumn.Value = dateToString(spotlight.StartDate);
|
|
|
|
|
endDateColumn.Value = dateToString(spotlight.EndDate);
|
|
|
|
|
mapCountColumn.Value = mapCount.ToString();
|
|
|
|
|
participants.Value = spotlight.ParticipantCount?.ToString("N0");
|
2020-01-10 14:30:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-10 17:46:35 +00:00
|
|
|
|
private string dateToString(DateTimeOffset date) => date.ToString("yyyy-MM-dd");
|
2020-01-10 14:30:51 +00:00
|
|
|
|
|
2020-01-10 17:46:35 +00:00
|
|
|
|
private class InfoColumn : FillFlowContainer
|
2020-01-10 14:30:51 +00:00
|
|
|
|
{
|
|
|
|
|
public string Value
|
|
|
|
|
{
|
|
|
|
|
set => valueText.Text = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly OsuSpriteText valueText;
|
|
|
|
|
|
2020-01-10 17:46:35 +00:00
|
|
|
|
public InfoColumn(string name)
|
2020-01-10 14:30:51 +00:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
Direction = FillDirection.Vertical;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = name,
|
|
|
|
|
Font = OsuFont.GetFont(size: 10),
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = 20,
|
|
|
|
|
Child = valueText = new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Light),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
valueText.Colour = colours.GreySeafoamLighter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-10 13:41:17 +00:00
|
|
|
|
private class SpotlightsDropdown : OsuDropdown<APISpotlight>
|
|
|
|
|
{
|
2020-01-10 14:30:51 +00:00
|
|
|
|
private DropdownMenu menu;
|
|
|
|
|
|
|
|
|
|
protected override DropdownMenu CreateMenu() => menu = base.CreateMenu().With(m => m.MaxHeight = 400);
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
menu.BackgroundColour = colours.Gray1;
|
|
|
|
|
AccentColour = colours.GreySeafoamDarker;
|
|
|
|
|
}
|
2020-01-10 13:41:17 +00:00
|
|
|
|
}
|
2020-01-10 13:33:00 +00:00
|
|
|
|
}
|
|
|
|
|
}
|