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