mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 05:52:55 +08:00
cleanup code
This commit is contained in:
parent
d81956e974
commit
f8cc4238ff
@ -7,8 +7,8 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Cursor;
|
using osu.Framework.Graphics.Cursor;
|
||||||
using System;
|
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
|
|
||||||
namespace osu.Game.Graphics.UserInterface
|
namespace osu.Game.Graphics.UserInterface
|
||||||
@ -19,14 +19,35 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
public override bool AllowClipboardExport => false;
|
public override bool AllowClipboardExport => false;
|
||||||
|
|
||||||
|
private readonly CapsWarning warning;
|
||||||
|
|
||||||
|
private GameHost host;
|
||||||
|
|
||||||
public OsuPasswordTextBox()
|
public OsuPasswordTextBox()
|
||||||
{
|
{
|
||||||
Add(new CapsWarning
|
Add(warning = new CapsWarning
|
||||||
{
|
{
|
||||||
Size = new Vector2(20),
|
Size = new Vector2(20),
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Margin = new MarginPadding { Right = 10 },
|
||||||
|
Alpha = 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(GameHost host)
|
||||||
|
{
|
||||||
|
this.host = host;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.Key == OpenTK.Input.Key.CapsLock)
|
||||||
|
warning.FadeTo(host.CapsLockEnabled ? 1 : 0, 250, Easing.OutQuint);
|
||||||
|
return base.OnKeyDown(state, args);
|
||||||
|
}
|
||||||
|
|
||||||
public class PasswordMaskChar : Container
|
public class PasswordMaskChar : Container
|
||||||
{
|
{
|
||||||
private readonly CircularContainer circle;
|
private readonly CircularContainer circle;
|
||||||
@ -66,36 +87,18 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
|
|
||||||
private class CapsWarning : SpriteIcon, IHasTooltip
|
private class CapsWarning : SpriteIcon, IHasTooltip
|
||||||
{
|
{
|
||||||
public string TooltipText => host.CapsLockEnabled ? @"Caps lock is active" : string.Empty;
|
public string TooltipText => @"Caps lock is active";
|
||||||
|
|
||||||
public override bool HandleInput => true;
|
|
||||||
|
|
||||||
private GameHost host;
|
|
||||||
|
|
||||||
public CapsWarning()
|
public CapsWarning()
|
||||||
{
|
{
|
||||||
Icon = FontAwesome.fa_warning;
|
Icon = FontAwesome.fa_warning;
|
||||||
Origin = Anchor.CentreRight;
|
|
||||||
Anchor = Anchor.CentreRight;
|
|
||||||
Margin = new MarginPadding { Right = 10 };
|
|
||||||
AlwaysPresent = true;
|
|
||||||
Alpha = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colour, GameHost host)
|
private void load(OsuColour colour)
|
||||||
{
|
{
|
||||||
Colour = colour.YellowLight;
|
Colour = colour.YellowLight;
|
||||||
this.host = host;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
updateVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateVisibility() => this.FadeTo(host.CapsLockEnabled ? 1 : 0, 250, Easing.OutQuint);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user