Rename lookup & field

This commit is contained in:
Bartłomiej Dach 2020-10-30 19:55:17 +01:00
parent 82ef85569b
commit 20c27c6943
2 changed files with 8 additions and 8 deletions

View File

@ -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,
}
}

View File

@ -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]