1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 08:52:58 +08:00

use GameHost to check if caps lock is enabled

This commit is contained in:
Jorolf 2017-08-22 15:43:45 +02:00
parent c29d3437ba
commit d81956e974

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using System; using System;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Platform;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {
@ -65,10 +66,12 @@ namespace osu.Game.Graphics.UserInterface
private class CapsWarning : SpriteIcon, IHasTooltip private class CapsWarning : SpriteIcon, IHasTooltip
{ {
public string TooltipText => Console.CapsLock ? @"Caps lock is active" : string.Empty; public string TooltipText => host.CapsLockEnabled ? @"Caps lock is active" : string.Empty;
public override bool HandleInput => true; public override bool HandleInput => true;
private GameHost host;
public CapsWarning() public CapsWarning()
{ {
Icon = FontAwesome.fa_warning; Icon = FontAwesome.fa_warning;
@ -80,9 +83,10 @@ namespace osu.Game.Graphics.UserInterface
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colour) private void load(OsuColour colour, GameHost host)
{ {
Colour = colour.YellowLight; Colour = colour.YellowLight;
this.host = host;
} }
protected override void Update() protected override void Update()
@ -91,7 +95,7 @@ namespace osu.Game.Graphics.UserInterface
updateVisibility(); updateVisibility();
} }
private void updateVisibility() => this.FadeTo(Console.CapsLock ? 1 : 0, 250, Easing.OutQuint); private void updateVisibility() => this.FadeTo(host.CapsLockEnabled ? 1 : 0, 250, Easing.OutQuint);
} }
} }
} }