mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 15:53:51 +08:00
Make "Sometimes" setting depend on season end date, rather than chance
This commit is contained in:
parent
fb1e09b3e7
commit
f27ce7521d
@ -1,6 +1,7 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
|
||||
@ -15,6 +16,7 @@ namespace osu.Game.Configuration
|
||||
{
|
||||
Set(Static.LoginOverlayDisplayed, false);
|
||||
Set(Static.MutedAudioNotificationShownOnce, false);
|
||||
Set(Static.SeasonEndDate, DateTimeOffset.MinValue);
|
||||
Set(Static.SeasonalBackgrounds, new List<APISeasonalBackground>());
|
||||
}
|
||||
}
|
||||
@ -23,6 +25,7 @@ namespace osu.Game.Configuration
|
||||
{
|
||||
LoginOverlayDisplayed,
|
||||
MutedAudioNotificationShownOnce,
|
||||
SeasonalBackgrounds
|
||||
SeasonEndDate,
|
||||
SeasonalBackgrounds,
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
@ -18,19 +19,24 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
[LongRunningLoad]
|
||||
public class SeasonalBackgroundLoader : Component
|
||||
{
|
||||
private Bindable<DateTimeOffset> endDate;
|
||||
private Bindable<List<APISeasonalBackground>> backgrounds;
|
||||
private int current;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(SessionStatics sessionStatics, IAPIProvider api)
|
||||
{
|
||||
endDate = sessionStatics.GetBindable<DateTimeOffset>(Static.SeasonEndDate);
|
||||
backgrounds = sessionStatics.GetBindable<List<APISeasonalBackground>>(Static.SeasonalBackgrounds);
|
||||
|
||||
if (backgrounds.Value.Any()) return;
|
||||
|
||||
var request = new GetSeasonalBackgroundsRequest();
|
||||
request.Success += response =>
|
||||
{
|
||||
endDate.Value = response.EndDate;
|
||||
backgrounds.Value = response.Backgrounds ?? backgrounds.Value;
|
||||
|
||||
current = RNG.Next(0, backgrounds.Value.Count);
|
||||
};
|
||||
|
||||
@ -46,6 +52,8 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
|
||||
return new SeasonalBackground(url);
|
||||
}
|
||||
|
||||
public bool IsInSeason() => DateTimeOffset.Now < endDate.Value;
|
||||
}
|
||||
|
||||
[LongRunningLoad]
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
@ -8,6 +9,9 @@ namespace osu.Game.Online.API.Requests.Responses
|
||||
{
|
||||
public class APISeasonalBackgrounds
|
||||
{
|
||||
[JsonProperty("ends_at")]
|
||||
public DateTimeOffset EndDate;
|
||||
|
||||
[JsonProperty("backgrounds")]
|
||||
public List<APISeasonalBackground> Backgrounds { get; set; }
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
switch (showSeasonalBackgrounds.Value)
|
||||
{
|
||||
case SeasonalBackgrounds.Sometimes:
|
||||
if (RNG.NextBool())
|
||||
if (seasonalBackgroundLoader.IsInSeason())
|
||||
goto case SeasonalBackgrounds.Always;
|
||||
break;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user