Rename method and simplify SetDefault calling code

This commit is contained in:
Dean Herbert
2021-12-21 15:34:32 +09:00
parent 9344897542
commit 981158ed88
3 changed files with 16 additions and 14 deletions

View File

@ -27,7 +27,7 @@ namespace osu.Game.Tests.NonVisual
sessionIdleTracker.IsIdle.BindValueChanged(e => sessionIdleTracker.IsIdle.BindValueChanged(e =>
{ {
if (e.NewValue) if (e.NewValue)
sessionStatics.ResetValues(); sessionStatics.ResetAfterInactivity();
}); });
} }

View File

@ -15,23 +15,25 @@ namespace osu.Game.Configuration
{ {
protected override void InitialiseDefaults() protected override void InitialiseDefaults()
{ {
ensureDefault(SetDefault(Static.LoginOverlayDisplayed, false)); SetDefault(Static.LoginOverlayDisplayed, false);
ensureDefault(SetDefault(Static.MutedAudioNotificationShownOnce, false)); SetDefault(Static.MutedAudioNotificationShownOnce, false);
ensureDefault(SetDefault(Static.LowBatteryNotificationShownOnce, false)); SetDefault(Static.LowBatteryNotificationShownOnce, false);
ensureDefault(SetDefault(Static.LastHoverSoundPlaybackTime, (double?)null)); SetDefault(Static.LastHoverSoundPlaybackTime, (double?)null);
ensureDefault(SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null)); SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null);
} }
/// <summary> /// <summary>
/// Used to revert statics to their defaults after being idle for appropiate amount of time. /// Revert statics to their defaults after being idle for appropriate amount of time.
/// Does not affect loaded seasonal backgrounds.
/// </summary> /// </summary>
public void ResetValues() /// <remarks>
/// This only affects a subset of statics which the user would expect to have reset after a break.
/// </remarks>
public void ResetAfterInactivity()
{ {
ensureDefault(GetBindable<bool>(Static.LoginOverlayDisplayed)); GetBindable<bool>(Static.LoginOverlayDisplayed).SetDefault();
ensureDefault(GetBindable<bool>(Static.MutedAudioNotificationShownOnce)); GetBindable<bool>(Static.MutedAudioNotificationShownOnce).SetDefault();
ensureDefault(GetBindable<bool>(Static.LowBatteryNotificationShownOnce)); GetBindable<bool>(Static.LowBatteryNotificationShownOnce).SetDefault();
ensureDefault(GetBindable<double?>(Static.LastHoverSoundPlaybackTime)); GetBindable<double?>(Static.LastHoverSoundPlaybackTime).SetDefault();
} }
private void ensureDefault<T>(Bindable<T> bindable) => bindable.SetDefault(); private void ensureDefault<T>(Bindable<T> bindable) => bindable.SetDefault();

View File

@ -680,7 +680,7 @@ namespace osu.Game
sessionIdleTracker.IsIdle.BindValueChanged(idle => sessionIdleTracker.IsIdle.BindValueChanged(idle =>
{ {
if (idle.NewValue) if (idle.NewValue)
SessionStatics.ResetValues(); SessionStatics.ResetAfterInactivity();
}); });
Add(sessionIdleTracker); Add(sessionIdleTracker);