mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Fix duplicate code in setting default logic
This commit is contained in:
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -12,23 +13,18 @@ namespace osu.Game.Configuration
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SessionStatics : InMemoryConfigManager<Static>
|
public class SessionStatics : InMemoryConfigManager<Static>
|
||||||
{
|
{
|
||||||
protected override void InitialiseDefaults()
|
protected override void InitialiseDefaults() => ResetValues();
|
||||||
{
|
|
||||||
SetDefault(Static.LoginOverlayDisplayed, false);
|
|
||||||
SetDefault(Static.MutedAudioNotificationShownOnce, false);
|
|
||||||
SetDefault(Static.LowBatteryNotificationShownOnce, false);
|
|
||||||
SetDefault(Static.LastHoverSoundPlaybackTime, (double?)null);
|
|
||||||
SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetValues()
|
public void ResetValues()
|
||||||
{
|
{
|
||||||
GetOriginalBindable<bool>(Static.LoginOverlayDisplayed).SetDefault();
|
ensureDefault(SetDefault(Static.LoginOverlayDisplayed, false));
|
||||||
GetOriginalBindable<bool>(Static.MutedAudioNotificationShownOnce).SetDefault();
|
ensureDefault(SetDefault(Static.MutedAudioNotificationShownOnce, false));
|
||||||
GetOriginalBindable<bool>(Static.LowBatteryNotificationShownOnce).SetDefault();
|
ensureDefault(SetDefault(Static.LowBatteryNotificationShownOnce, false));
|
||||||
GetOriginalBindable<double?>(Static.LastHoverSoundPlaybackTime).SetDefault();
|
ensureDefault(SetDefault(Static.LastHoverSoundPlaybackTime, (double?)null));
|
||||||
GetOriginalBindable<APISeasonalBackgrounds>(Static.SeasonalBackgrounds).SetDefault();
|
ensureDefault(SetDefault<APISeasonalBackgrounds>(Static.SeasonalBackgrounds, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ensureDefault<T>(Bindable<T> bindable) => bindable.SetDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Static
|
public enum Static
|
||||||
|
Reference in New Issue
Block a user