Split session statics reset method to prevent unloading seasonal backgrounds while idle

This commit is contained in:
dekrain
2021-12-20 16:51:51 +01:00
parent 6bbc9ccf97
commit 9344897542

View File

@ -13,9 +13,7 @@ namespace osu.Game.Configuration
/// </summary>
public class SessionStatics : InMemoryConfigManager<Static>
{
protected override void InitialiseDefaults() => ResetValues();
public void ResetValues()
protected override void InitialiseDefaults()
{
ensureDefault(SetDefault(Static.LoginOverlayDisplayed, false));
ensureDefault(SetDefault(Static.MutedAudioNotificationShownOnce, false));
@ -24,6 +22,18 @@ namespace osu.Game.Configuration
ensureDefault(SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null));
}
/// <summary>
/// Used to revert statics to their defaults after being idle for appropiate amount of time.
/// Does not affect loaded seasonal backgrounds.
/// </summary>
public void ResetValues()
{
ensureDefault(GetBindable<bool>(Static.LoginOverlayDisplayed));
ensureDefault(GetBindable<bool>(Static.MutedAudioNotificationShownOnce));
ensureDefault(GetBindable<bool>(Static.LowBatteryNotificationShownOnce));
ensureDefault(GetBindable<double?>(Static.LastHoverSoundPlaybackTime));
}
private void ensureDefault<T>(Bindable<T> bindable) => bindable.SetDefault();
}