1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:07:25 +08:00

Cleanup spotlight selection

This commit is contained in:
smoogipoo 2020-01-14 14:01:51 +09:00
parent 18ebd30978
commit 7349c023d1
3 changed files with 25 additions and 11 deletions

View File

@ -29,12 +29,12 @@ namespace osu.Game.Tests.Visual.Online
};
AddStep("Load spotlights", () => selector.Spotlights = spotlights);
AddStep("Load info", () => selector.UpdateInfo(new APISpotlight
AddStep("Load info", () => selector.Current.Value = new APISpotlight
{
StartDate = DateTimeOffset.Now,
EndDate = DateTimeOffset.Now,
ParticipantCount = 15155151,
}, 18));
});
}
}
}

View File

@ -27,7 +27,7 @@ namespace osu.Game.Online.API.Requests.Responses
public DateTimeOffset EndDate;
[JsonProperty(@"participant_count")]
public int? ParticipantCount;
public int ParticipantCount;
public override string ToString() => Name;
}

View File

@ -13,15 +13,22 @@ using osu.Game.Online.API.Requests.Responses;
using osuTK;
using System;
using System.Collections.Generic;
using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Overlays.Rankings
{
public class SpotlightSelector : Container
public class SpotlightSelector : Container, IHasCurrentValue<APISpotlight>
{
private readonly Box background;
private readonly SpotlightsDropdown dropdown;
public readonly Bindable<APISpotlight> SelectedSpotlight = new Bindable<APISpotlight>();
private readonly BindableWithCurrent<APISpotlight> current = new BindableWithCurrent<APISpotlight>();
public Bindable<APISpotlight> Current
{
get => current.Current;
set => current.Current = value;
}
public IEnumerable<APISpotlight> Spotlights
{
@ -55,7 +62,7 @@ namespace osu.Game.Overlays.Rankings
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
Current = SelectedSpotlight,
Current = Current,
Depth = -float.MaxValue
},
new FillFlowContainer
@ -84,12 +91,19 @@ namespace osu.Game.Overlays.Rankings
background.Colour = colours.GreySeafoam;
}
public void UpdateInfo(APISpotlight spotlight, int mapCount)
protected override void LoadComplete()
{
startDateColumn.Value = dateToString(spotlight.StartDate);
endDateColumn.Value = dateToString(spotlight.EndDate);
mapCountColumn.Value = mapCount.ToString();
participants.Value = spotlight.ParticipantCount?.ToString("N0");
base.LoadComplete();
Current.BindValueChanged(onCurrentChanged);
}
private void onCurrentChanged(ValueChangedEvent<APISpotlight> spotlight)
{
startDateColumn.Value = dateToString(spotlight.NewValue.StartDate);
endDateColumn.Value = dateToString(spotlight.NewValue.EndDate);
// mapCountColumn.Value = spotlight.NewValue.ParticipantCount.ToString();
participants.Value = spotlight.NewValue.ParticipantCount.ToString();
}
private string dateToString(DateTimeOffset date) => date.ToString("yyyy-MM-dd");