1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 00:52:56 +08:00

Apply peppy's suggestions

This commit is contained in:
jvyden 2021-04-16 05:53:27 -04:00
parent d760e81a91
commit ec0211809f
No known key found for this signature in database
GPG Key ID: 18BCF2BE0262B278
4 changed files with 21 additions and 18 deletions

View File

@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.Components
private IdleTrackingBox[] boxes;
public SessionStatics sessionStatics;
private SessionStatics sessionStatics;
[SetUp]
public void SetUp() => Schedule(() =>
@ -175,6 +175,7 @@ namespace osu.Game.Tests.Visual.Components
public IdleTrackingBox(int timeToIdle, SessionStatics statics)
{
Box box;
Alpha = 0.6f;
@ -182,7 +183,7 @@ namespace osu.Game.Tests.Visual.Components
InternalChildren = new Drawable[]
{
idleTracker = new GameIdleTracker(timeToIdle, statics),
idleTracker = new GameIdleTracker(timeToIdle),
box = new Box
{
Colour = Color4.White,
@ -190,7 +191,11 @@ namespace osu.Game.Tests.Visual.Components
},
};
idleTracker.IsIdle.BindValueChanged(idle => box.Colour = idle.NewValue ? Color4.White : Color4.Black, true);
idleTracker.IsIdle.BindValueChanged(idle =>
{
box.Colour = idle.NewValue ? Color4.White : Color4.Black;
if (idle.NewValue) statics.ResetValues();
}, true);
}
}
}

View File

@ -23,10 +23,8 @@ namespace osu.Game.Configuration
public void ResetValues()
{
SetValue(Static.LoginOverlayDisplayed, false);
SetValue(Static.MutedAudioNotificationShownOnce, false);
SetValue(Static.LowBatteryNotificationShownOnce, false);
SetValue(Static.LastHoverSoundPlaybackTime, (double?)null);
ConfigStore.Clear();
InitialiseDefaults();
}
}

View File

@ -1,9 +1,7 @@
// 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.
using osu.Framework.Bindables;
using osu.Framework.Input;
using osu.Game.Configuration;
namespace osu.Game.Input
{
@ -11,16 +9,9 @@ namespace osu.Game.Input
{
private InputManager inputManager;
public GameIdleTracker(int time, SessionStatics statics)
public GameIdleTracker(int time)
: base(time)
{
IsIdle.ValueChanged += _ => UpdateStatics(_, statics);
}
protected static void UpdateStatics(ValueChangedEvent<bool> e, SessionStatics statics)
{
if (e.OldValue != e.NewValue && e.NewValue)
statics.ResetValues();
}
protected override void LoadComplete()

View File

@ -575,7 +575,16 @@ namespace osu.Game
Container logoContainer;
BackButton.Receptor receptor;
dependencies.CacheAs(idleTracker = new GameIdleTracker(300_000, Dependencies.Get<SessionStatics>()));
dependencies.CacheAs(idleTracker = new GameIdleTracker(6000));
GameIdleTracker sessionIdleTracker = new GameIdleTracker(300_000);
Add(sessionIdleTracker);
sessionIdleTracker.IsIdle.BindValueChanged((e) =>
{
if (e.NewValue)
Dependencies.Get<SessionStatics>().ResetValues();
});
AddRange(new Drawable[]
{