2019-09-23 13:15:27 +08:00
// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
2023-11-06 14:44:25 +08:00
using osu.Framework ;
2021-01-07 17:47:20 +08:00
using osu.Game.Graphics.UserInterface ;
2023-10-30 21:08:56 +08:00
using osu.Game.Input ;
2020-10-30 00:31:42 +08:00
using osu.Game.Online.API.Requests.Responses ;
2021-01-07 17:47:20 +08:00
using osu.Game.Overlays ;
2023-06-11 18:53:17 +08:00
using osu.Game.Overlays.Mods ;
2020-10-30 00:31:42 +08:00
2019-09-23 13:15:27 +08:00
namespace osu.Game.Configuration
{
2019-09-28 20:21:51 +08:00
/// <summary>
/// Stores global per-session statics. These will not be stored after exiting the game.
/// </summary>
public class SessionStatics : InMemoryConfigManager < Static >
2019-09-23 13:15:27 +08:00
{
2021-12-20 23:51:51 +08:00
protected override void InitialiseDefaults ( )
2021-04-16 17:01:58 +08:00
{
2021-12-21 14:34:32 +08:00
SetDefault ( Static . LoginOverlayDisplayed , false ) ;
SetDefault ( Static . MutedAudioNotificationShownOnce , false ) ;
SetDefault ( Static . LowBatteryNotificationShownOnce , false ) ;
2022-12-15 16:35:39 +08:00
SetDefault ( Static . FeaturedArtistDisclaimerShownOnce , false ) ;
2021-12-21 14:34:32 +08:00
SetDefault ( Static . LastHoverSoundPlaybackTime , ( double? ) null ) ;
2023-06-11 18:53:17 +08:00
SetDefault ( Static . LastModSelectPanelSamplePlaybackTime , ( double? ) null ) ;
2021-12-21 14:34:32 +08:00
SetDefault < APISeasonalBackgrounds > ( Static . SeasonalBackgrounds , null ) ;
2023-11-06 14:44:25 +08:00
SetDefault ( Static . TouchInputActive , RuntimeInfo . IsMobile ) ;
2021-04-16 17:01:58 +08:00
}
2021-04-19 10:25:43 +08:00
2021-12-20 23:51:51 +08:00
/// <summary>
2021-12-21 14:34:32 +08:00
/// Revert statics to their defaults after being idle for appropriate amount of time.
2021-12-20 23:51:51 +08:00
/// </summary>
2021-12-21 14:34:32 +08:00
/// <remarks>
/// This only affects a subset of statics which the user would expect to have reset after a break.
/// </remarks>
public void ResetAfterInactivity ( )
2021-12-20 23:51:51 +08:00
{
2021-12-21 14:34:32 +08:00
GetBindable < bool > ( Static . LoginOverlayDisplayed ) . SetDefault ( ) ;
GetBindable < bool > ( Static . MutedAudioNotificationShownOnce ) . SetDefault ( ) ;
GetBindable < bool > ( Static . LowBatteryNotificationShownOnce ) . SetDefault ( ) ;
2021-12-20 23:51:51 +08:00
}
2019-09-23 13:15:27 +08:00
}
2019-09-28 20:21:51 +08:00
public enum Static
2019-09-23 13:15:27 +08:00
{
2019-09-24 10:45:47 +08:00
LoginOverlayDisplayed ,
2020-10-30 00:31:42 +08:00
MutedAudioNotificationShownOnce ,
2021-04-10 05:55:41 +08:00
LowBatteryNotificationShownOnce ,
2022-12-15 16:35:39 +08:00
FeaturedArtistDisclaimerShownOnce ,
2020-10-31 02:59:52 +08:00
/// <summary>
/// Info about seasonal backgrounds available fetched from API - see <see cref="APISeasonalBackgrounds"/>.
/// Value under this lookup can be <c>null</c> if there are no backgrounds available (or API is not reachable).
/// </summary>
2020-10-31 02:55:17 +08:00
SeasonalBackgrounds ,
2021-01-07 17:47:20 +08:00
/// <summary>
/// The last playback time in milliseconds of a hover sample (from <see cref="HoverSounds"/>).
/// Used to debounce hover sounds game-wide to avoid volume saturation, especially in scrolling views with many UI controls like <see cref="SettingsOverlay"/>.
/// </summary>
2022-12-15 16:35:39 +08:00
LastHoverSoundPlaybackTime ,
2023-06-11 18:53:17 +08:00
/// <summary>
/// The last playback time in milliseconds of an on/off sample (from <see cref="ModSelectPanel"/>).
/// Used to debounce <see cref="ModSelectPanel"/> on/off sounds game-wide to avoid volume saturation, especially in activating mod presets with many mods.
/// </summary>
2023-10-30 21:08:56 +08:00
LastModSelectPanelSamplePlaybackTime ,
/// <summary>
/// Whether the last positional input received was a touch input.
/// Used in touchscreen detection scenarios (<see cref="TouchInputInterceptor"/>).
/// </summary>
TouchInputActive ,
2019-09-23 13:15:27 +08:00
}
}