mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:03:22 +08:00
Apply peppy's suggestions
This commit is contained in:
parent
d760e81a91
commit
ec0211809f
@ -22,7 +22,7 @@ namespace osu.Game.Tests.Visual.Components
|
|||||||
|
|
||||||
private IdleTrackingBox[] boxes;
|
private IdleTrackingBox[] boxes;
|
||||||
|
|
||||||
public SessionStatics sessionStatics;
|
private SessionStatics sessionStatics;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp() => Schedule(() =>
|
public void SetUp() => Schedule(() =>
|
||||||
@ -175,6 +175,7 @@ namespace osu.Game.Tests.Visual.Components
|
|||||||
|
|
||||||
public IdleTrackingBox(int timeToIdle, SessionStatics statics)
|
public IdleTrackingBox(int timeToIdle, SessionStatics statics)
|
||||||
{
|
{
|
||||||
|
|
||||||
Box box;
|
Box box;
|
||||||
|
|
||||||
Alpha = 0.6f;
|
Alpha = 0.6f;
|
||||||
@ -182,7 +183,7 @@ namespace osu.Game.Tests.Visual.Components
|
|||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
{
|
{
|
||||||
idleTracker = new GameIdleTracker(timeToIdle, statics),
|
idleTracker = new GameIdleTracker(timeToIdle),
|
||||||
box = new Box
|
box = new Box
|
||||||
{
|
{
|
||||||
Colour = Color4.White,
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,8 @@ namespace osu.Game.Configuration
|
|||||||
|
|
||||||
public void ResetValues()
|
public void ResetValues()
|
||||||
{
|
{
|
||||||
SetValue(Static.LoginOverlayDisplayed, false);
|
ConfigStore.Clear();
|
||||||
SetValue(Static.MutedAudioNotificationShownOnce, false);
|
InitialiseDefaults();
|
||||||
SetValue(Static.LowBatteryNotificationShownOnce, false);
|
|
||||||
SetValue(Static.LastHoverSoundPlaybackTime, (double?)null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +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.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Configuration;
|
|
||||||
|
|
||||||
namespace osu.Game.Input
|
namespace osu.Game.Input
|
||||||
{
|
{
|
||||||
@ -11,16 +9,9 @@ namespace osu.Game.Input
|
|||||||
{
|
{
|
||||||
private InputManager inputManager;
|
private InputManager inputManager;
|
||||||
|
|
||||||
public GameIdleTracker(int time, SessionStatics statics)
|
public GameIdleTracker(int time)
|
||||||
: base(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()
|
protected override void LoadComplete()
|
||||||
|
@ -575,7 +575,16 @@ namespace osu.Game
|
|||||||
Container logoContainer;
|
Container logoContainer;
|
||||||
BackButton.Receptor receptor;
|
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[]
|
AddRange(new Drawable[]
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user