mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:28:00 +08:00
Update spotlight info based on selected one
This commit is contained in:
parent
b83ee6dabf
commit
cb30f463fb
@ -26,6 +26,9 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
[JsonProperty(@"end_date")]
|
||||
public DateTimeOffset EndDate;
|
||||
|
||||
[JsonProperty(@"participant_count")]
|
||||
public int? Participants;
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ namespace osu.Game.Overlays.Rankings
|
||||
|
||||
public IEnumerable<APISpotlight> Spotlights
|
||||
{
|
||||
get => spotlightSelector.Spotlights;
|
||||
set => spotlightSelector.Spotlights = value;
|
||||
get => SpotlightSelector.Spotlights;
|
||||
set => SpotlightSelector.Spotlights = value;
|
||||
}
|
||||
|
||||
protected override ScreenTitle CreateTitle() => new RankingsTitle
|
||||
@ -34,7 +34,7 @@ namespace osu.Game.Overlays.Rankings
|
||||
Current = Ruleset
|
||||
};
|
||||
|
||||
private SpotlightSelector spotlightSelector;
|
||||
public SpotlightSelector SpotlightSelector;
|
||||
|
||||
protected override Drawable CreateContent() => new FillFlowContainer
|
||||
{
|
||||
@ -47,7 +47,7 @@ namespace osu.Game.Overlays.Rankings
|
||||
{
|
||||
Current = Country
|
||||
},
|
||||
spotlightSelector = new SpotlightSelector
|
||||
SpotlightSelector = new SpotlightSelector
|
||||
{
|
||||
Current = { BindTarget = Spotlight }
|
||||
}
|
||||
@ -61,7 +61,7 @@ namespace osu.Game.Overlays.Rankings
|
||||
}
|
||||
|
||||
private void onCurrentChanged(ValueChangedEvent<RankingsScope> scope) =>
|
||||
spotlightSelector.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint);
|
||||
SpotlightSelector.FadeTo(scope.NewValue == RankingsScope.Spotlights ? 1 : 0, 200, Easing.OutQuint);
|
||||
|
||||
private class RankingsTitle : ScreenTitle
|
||||
{
|
||||
|
@ -38,6 +38,8 @@ namespace osu.Game.Overlays.Rankings
|
||||
|
||||
private readonly InfoColumn startDateColumn;
|
||||
private readonly InfoColumn endDateColumn;
|
||||
private readonly InfoColumn mapCountColumn;
|
||||
private readonly InfoColumn participantsColumn;
|
||||
|
||||
public SpotlightSelector()
|
||||
{
|
||||
@ -75,6 +77,8 @@ namespace osu.Game.Overlays.Rankings
|
||||
{
|
||||
startDateColumn = new InfoColumn(@"Start Date"),
|
||||
endDateColumn = new InfoColumn(@"End Date"),
|
||||
mapCountColumn = new InfoColumn(@"Map Count"),
|
||||
participantsColumn = new InfoColumn(@"Participants")
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -88,17 +92,12 @@ namespace osu.Game.Overlays.Rankings
|
||||
background.Colour = colourProvider.Dark3;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
public void ShowInfo(APISpotlight spotlight, int mapCount)
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Current.BindValueChanged(onCurrentChanged);
|
||||
}
|
||||
|
||||
private void onCurrentChanged(ValueChangedEvent<APISpotlight> spotlight)
|
||||
{
|
||||
startDateColumn.Value = dateToString(spotlight.NewValue.StartDate);
|
||||
endDateColumn.Value = dateToString(spotlight.NewValue.EndDate);
|
||||
startDateColumn.Value = dateToString(spotlight.StartDate);
|
||||
endDateColumn.Value = dateToString(spotlight.EndDate);
|
||||
mapCountColumn.Value = mapCount.ToString();
|
||||
participantsColumn.Value = spotlight.Participants?.ToString("N0");
|
||||
}
|
||||
|
||||
private string dateToString(DateTimeOffset date) => date.ToString("yyyy-MM-dd");
|
||||
|
@ -36,6 +36,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
private APIRequest lastRequest;
|
||||
private CancellationTokenSource cancellationToken;
|
||||
private GetSpotlightsRequest spotlightsRequest;
|
||||
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; }
|
||||
@ -115,6 +116,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
Scope.BindValueChanged(_ =>
|
||||
{
|
||||
spotlightsRequest?.Cancel();
|
||||
|
||||
// country filtering is only valid for performance scope.
|
||||
if (Scope.Value != RankingsScope.Performance)
|
||||
Country.Value = null;
|
||||
@ -148,9 +151,9 @@ namespace osu.Game.Overlays
|
||||
private void getSpotlights()
|
||||
{
|
||||
loading.Show();
|
||||
var request = new GetSpotlightsRequest();
|
||||
request.Success += response => header.Spotlights = response.Spotlights;
|
||||
api.Queue(request);
|
||||
spotlightsRequest = new GetSpotlightsRequest();
|
||||
spotlightsRequest.Success += response => header.Spotlights = response.Spotlights;
|
||||
api.Queue(spotlightsRequest);
|
||||
}
|
||||
|
||||
private void loadNewContent()
|
||||
@ -214,6 +217,7 @@ namespace osu.Game.Overlays
|
||||
return new CountriesTable(1, countryRequest.Result.Countries);
|
||||
|
||||
case GetSpotlightRankingsRequest spotlightRequest:
|
||||
header.SpotlightSelector.ShowInfo(spotlightRequest.Result.Spotlight, spotlightRequest.Result.BeatmapSets.Count);
|
||||
return new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
|
Loading…
Reference in New Issue
Block a user