1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 05:02:55 +08:00

add caps lock warning

This commit is contained in:
Jorolf 2017-06-03 19:21:21 +02:00
parent 3b987e35c9
commit f6e0e0bc38

View File

@ -1,11 +1,14 @@
// Copyright (c) 2007-2017 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.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Sprites;
using System;
namespace osu.Game.Graphics.UserInterface
{
@ -15,6 +18,14 @@ namespace osu.Game.Graphics.UserInterface
public override bool AllowClipboardExport => false;
public OsuPasswordTextBox()
{
Add(new CapsWarning
{
TextSize = 20,
});
}
public class PasswordMaskChar : Container
{
private readonly CircularContainer circle;
@ -51,5 +62,36 @@ namespace osu.Game.Graphics.UserInterface
circle.ResizeTo(new Vector2(0.8f), 500, EasingTypes.OutQuint);
}
}
private class CapsWarning : TextAwesome, IHasTooltip
{
public string TooltipText => Console.CapsLock ? @"Caps lock is active" : string.Empty;
public override bool HandleInput => true;
public CapsWarning()
{
Icon = FontAwesome.fa_warning;
Origin = Anchor.CentreRight;
Anchor = Anchor.CentreRight;
Margin = new MarginPadding { Right = 10 };
AlwaysPresent = true;
Alpha = 0;
}
[BackgroundDependencyLoader]
private void load(OsuColour colour)
{
Colour = colour.YellowLight;
}
protected override void Update()
{
base.Update();
updateVisibility();
}
private void updateVisibility() => FadeTo(Console.CapsLock ? 1 : 0, 250, EasingTypes.OutQuint);
}
}
}