2019-01-24 16:43:03 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
2019-02-03 19:34:04 +08:00
|
|
|
using osu.Framework.Input.Bindings;
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-04-13 17:19:50 +08:00
|
|
|
using osu.Game.Input.Bindings;
|
|
|
|
using osu.Game.Overlays.KeyBinding;
|
|
|
|
using osu.Game.Overlays.Settings;
|
|
|
|
using osu.Game.Rulesets;
|
2019-02-03 19:34:04 +08:00
|
|
|
using osu.Game.Screens.Ranking;
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
{
|
|
|
|
public class KeyBindingOverlay : SettingsOverlay
|
|
|
|
{
|
|
|
|
protected override Drawable CreateHeader() => new SettingsHeader("key configuration", "Customise your keys!");
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(permitNulls: true)]
|
|
|
|
private void load(RulesetStore rulesets, GlobalActionContainer global)
|
|
|
|
{
|
|
|
|
AddSection(new GlobalKeyBindingsSection(global));
|
|
|
|
|
|
|
|
foreach (var ruleset in rulesets.AvailableRulesets)
|
|
|
|
AddSection(new RulesetBindingsSection(ruleset));
|
2019-02-03 19:34:04 +08:00
|
|
|
|
|
|
|
AddInternal(new BackButton
|
|
|
|
{
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
Origin = Anchor.BottomLeft,
|
2019-02-03 22:09:04 +08:00
|
|
|
Action = Hide
|
2019-02-03 19:34:04 +08:00
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
public KeyBindingOverlay()
|
2019-02-03 19:34:04 +08:00
|
|
|
: base(true)
|
2018-04-13 17:19:50 +08:00
|
|
|
{
|
|
|
|
}
|
2019-02-03 19:34:04 +08:00
|
|
|
|
|
|
|
private class BackButton : OsuClickableContainer, IKeyBindingHandler<GlobalAction>
|
|
|
|
{
|
|
|
|
private AspectContainer aspect;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
Size = new Vector2(Sidebar.DEFAULT_WIDTH);
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
aspect = new AspectContainer
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new SpriteIcon
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Y = -15,
|
|
|
|
Size = new Vector2(15),
|
|
|
|
Shadow = true,
|
|
|
|
Icon = FontAwesome.fa_chevron_left
|
|
|
|
},
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Y = 15,
|
2019-02-12 12:04:46 +08:00
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
2019-02-03 19:34:04 +08:00
|
|
|
Text = @"back",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnMouseDown(MouseDownEvent e)
|
|
|
|
{
|
|
|
|
aspect.ScaleTo(0.75f, 2000, Easing.OutQuint);
|
|
|
|
return base.OnMouseDown(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnMouseUp(MouseUpEvent e)
|
|
|
|
{
|
|
|
|
aspect.ScaleTo(1, 1000, Easing.OutElastic);
|
|
|
|
return base.OnMouseUp(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool OnPressed(GlobalAction action)
|
|
|
|
{
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case GlobalAction.Back:
|
|
|
|
Click();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool OnReleased(GlobalAction action) => false;
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
}
|
|
|
|
}
|