mirror of
https://github.com/ppy/osu
synced 2024-12-28 09:52:56 +00:00
Rename lookup & field
This commit is contained in:
parent
82ef85569b
commit
20c27c6943
@ -14,7 +14,7 @@ namespace osu.Game.Configuration
|
||||
{
|
||||
Set(Static.LoginOverlayDisplayed, false);
|
||||
Set(Static.MutedAudioNotificationShownOnce, false);
|
||||
Set<APISeasonalBackgrounds>(Static.SeasonalBackgroundsResponse, null);
|
||||
Set<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,6 +22,6 @@ namespace osu.Game.Configuration
|
||||
{
|
||||
LoginOverlayDisplayed,
|
||||
MutedAudioNotificationShownOnce,
|
||||
SeasonalBackgroundsResponse,
|
||||
SeasonalBackgrounds,
|
||||
}
|
||||
}
|
||||
|
@ -18,20 +18,20 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
[LongRunningLoad]
|
||||
public class SeasonalBackgroundLoader : Component
|
||||
{
|
||||
private Bindable<APISeasonalBackgrounds> cachedResponse;
|
||||
private Bindable<APISeasonalBackgrounds> seasonalBackgrounds;
|
||||
private int current;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(SessionStatics sessionStatics, IAPIProvider api)
|
||||
{
|
||||
cachedResponse = sessionStatics.GetBindable<APISeasonalBackgrounds>(Static.SeasonalBackgroundsResponse);
|
||||
seasonalBackgrounds = sessionStatics.GetBindable<APISeasonalBackgrounds>(Static.SeasonalBackgrounds);
|
||||
|
||||
if (cachedResponse.Value != null) return;
|
||||
if (seasonalBackgrounds.Value != null) return;
|
||||
|
||||
var request = new GetSeasonalBackgroundsRequest();
|
||||
request.Success += response =>
|
||||
{
|
||||
cachedResponse.Value = response;
|
||||
seasonalBackgrounds.Value = response;
|
||||
current = RNG.Next(0, response.Backgrounds?.Count ?? 0);
|
||||
};
|
||||
|
||||
@ -40,7 +40,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
|
||||
public SeasonalBackground LoadBackground()
|
||||
{
|
||||
var backgrounds = cachedResponse.Value.Backgrounds;
|
||||
var backgrounds = seasonalBackgrounds.Value.Backgrounds;
|
||||
if (backgrounds == null || !backgrounds.Any()) return null;
|
||||
|
||||
current = (current + 1) % backgrounds.Count;
|
||||
@ -49,7 +49,7 @@ namespace osu.Game.Graphics.Backgrounds
|
||||
return new SeasonalBackground(url);
|
||||
}
|
||||
|
||||
public bool IsInSeason => cachedResponse.Value != null && DateTimeOffset.Now < cachedResponse.Value.EndDate;
|
||||
public bool IsInSeason => seasonalBackgrounds.Value != null && DateTimeOffset.Now < seasonalBackgrounds.Value.EndDate;
|
||||
}
|
||||
|
||||
[LongRunningLoad]
|
||||
|
Loading…
Reference in New Issue
Block a user