1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 03:42:58 +08:00

Move input to HudOverlay

This commit is contained in:
Andrey Zavadskiy 2017-04-01 14:46:45 +03:00
parent 06850f7e1f
commit 9d027a61cd
2 changed files with 20 additions and 23 deletions

View File

@ -10,6 +10,8 @@ using osu.Game.Graphics.UserInterface;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using System; using System;
using osu.Game.Modes.Scoring; using osu.Game.Modes.Scoring;
using osu.Framework.Input;
using OpenTK.Input;
namespace osu.Game.Modes.UI namespace osu.Game.Modes.UI
{ {
@ -35,6 +37,7 @@ namespace osu.Game.Modes.UI
protected HudOverlay() protected HudOverlay()
{ {
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
AlwaysPresent = true;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -74,11 +77,6 @@ namespace osu.Game.Modes.UI
Hide(); Hide();
} }
public void ChangeVisibility()
{
showHud.Value = !showHud.Value;
}
public void BindProcessor(ScoreProcessor processor) public void BindProcessor(ScoreProcessor processor)
{ {
//bind processor bindables to combocounter, score display etc. //bind processor bindables to combocounter, score display etc.
@ -93,5 +91,22 @@ namespace osu.Game.Modes.UI
{ {
hitRenderer.InputManager.Add(KeyCounter.GetReceptor()); hitRenderer.InputManager.Add(KeyCounter.GetReceptor());
} }
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return false;
if (state.Keyboard.ShiftPressed)
{
switch (args.Key)
{
case Key.Tab:
showHud.Value = !showHud.Value;
return true;
}
}
return base.OnKeyDown(state, args);
}
} }
} }

View File

@ -24,7 +24,6 @@ using System.Linq;
using osu.Game.Modes.Scoring; using osu.Game.Modes.Scoring;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Notifications; using osu.Game.Overlays.Notifications;
using OpenTK.Input;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -344,22 +343,5 @@ namespace osu.Game.Screens.Play
private Bindable<bool> mouseWheelDisabled; private Bindable<bool> mouseWheelDisabled;
protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused; protected override bool OnWheel(InputState state) => mouseWheelDisabled.Value && !IsPaused;
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return false;
if (state.Keyboard.ShiftPressed)
{
switch (args.Key)
{
case Key.Tab:
hudOverlay.ChangeVisibility();
return true;
}
}
return base.OnKeyDown(state, args);
}
} }
} }