mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:52:57 +08:00
Merge branch 'master' into flashlight-mod
This commit is contained in:
commit
57c1ddb1e0
41
osu.Game/Input/IdleTracker.cs
Normal file
41
osu.Game/Input/IdleTracker.cs
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Input;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
|
|
||||||
|
namespace osu.Game.Input
|
||||||
|
{
|
||||||
|
public class IdleTracker : Component, IKeyBindingHandler<PlatformAction>
|
||||||
|
{
|
||||||
|
private double lastInteractionTime;
|
||||||
|
public double IdleTime => Clock.CurrentTime - lastInteractionTime;
|
||||||
|
|
||||||
|
private bool updateLastInteractionTime()
|
||||||
|
{
|
||||||
|
lastInteractionTime = Clock.CurrentTime;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(PlatformAction action) => updateLastInteractionTime();
|
||||||
|
|
||||||
|
public bool OnReleased(PlatformAction action) => updateLastInteractionTime();
|
||||||
|
|
||||||
|
protected override bool Handle(UIEvent e)
|
||||||
|
{
|
||||||
|
switch (e)
|
||||||
|
{
|
||||||
|
case KeyDownEvent _:
|
||||||
|
case KeyUpEvent _:
|
||||||
|
case MouseDownEvent _:
|
||||||
|
case MouseUpEvent _:
|
||||||
|
case MouseMoveEvent _:
|
||||||
|
return updateLastInteractionTime();
|
||||||
|
default:
|
||||||
|
return base.Handle(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,7 @@ using osu.Framework.Platform;
|
|||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Input;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -86,6 +87,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight;
|
public float ToolbarOffset => Toolbar.Position.Y + Toolbar.DrawHeight;
|
||||||
|
|
||||||
|
private IdleTracker idleTracker;
|
||||||
|
|
||||||
public readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
|
public readonly Bindable<OverlayActivation> OverlayActivationMode = new Bindable<OverlayActivation>();
|
||||||
|
|
||||||
private OsuScreen screenStack;
|
private OsuScreen screenStack;
|
||||||
@ -311,6 +314,7 @@ namespace osu.Game
|
|||||||
},
|
},
|
||||||
mainContent = new Container { RelativeSizeAxes = Axes.Both },
|
mainContent = new Container { RelativeSizeAxes = Axes.Both },
|
||||||
overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue },
|
overlayContent = new Container { RelativeSizeAxes = Axes.Both, Depth = float.MinValue },
|
||||||
|
idleTracker = new IdleTracker { RelativeSizeAxes = Axes.Both }
|
||||||
});
|
});
|
||||||
|
|
||||||
loadComponentSingleFile(screenStack = new Loader(), d =>
|
loadComponentSingleFile(screenStack = new Loader(), d =>
|
||||||
@ -372,6 +376,7 @@ namespace osu.Game
|
|||||||
Depth = -6,
|
Depth = -6,
|
||||||
}, overlayContent.Add);
|
}, overlayContent.Add);
|
||||||
|
|
||||||
|
dependencies.Cache(idleTracker);
|
||||||
dependencies.Cache(settings);
|
dependencies.Cache(settings);
|
||||||
dependencies.Cache(onscreenDisplay);
|
dependencies.Cache(onscreenDisplay);
|
||||||
dependencies.Cache(social);
|
dependencies.Cache(social);
|
||||||
|
@ -8,6 +8,10 @@ namespace osu.Game.Overlays.Settings
|
|||||||
{
|
{
|
||||||
public class SettingsTextBox : SettingsItem<string>
|
public class SettingsTextBox : SettingsItem<string>
|
||||||
{
|
{
|
||||||
protected override Drawable CreateControl() => new OsuTextBox();
|
protected override Drawable CreateControl() => new OsuTextBox
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding { Top = 5 },
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Input;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
@ -64,6 +65,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
private SampleChannel sampleBack;
|
private SampleChannel sampleBack;
|
||||||
|
|
||||||
|
private IdleTracker idleTracker;
|
||||||
|
|
||||||
public ButtonSystem()
|
public ButtonSystem()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
@ -102,9 +105,10 @@ namespace osu.Game.Screens.Menu
|
|||||||
private OsuGame game;
|
private OsuGame game;
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(AudioManager audio, OsuGame game)
|
private void load(AudioManager audio, OsuGame game, IdleTracker idleTracker)
|
||||||
{
|
{
|
||||||
this.game = game;
|
this.game = game;
|
||||||
|
this.idleTracker = idleTracker;
|
||||||
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
|
sampleBack = audio.Sample.Get(@"Menu/button-back-select");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,8 +270,8 @@ namespace osu.Game.Screens.Menu
|
|||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
//if (OsuGame.IdleTime > 6000 && State != MenuState.Exit)
|
if (idleTracker?.IdleTime > 6000 && State != ButtonSystemState.Exit)
|
||||||
// State = MenuState.Initial;
|
State = ButtonSystemState.Initial;
|
||||||
|
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user