1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 01:07:25 +08:00
osu-lazer/osu.Game/Screens/Select/FooterButtonMods.cs

66 lines
2.0 KiB
C#
Raw Normal View History

2019-05-08 17:43:15 +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.
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
2019-04-14 07:22:31 +08:00
using osu.Game.Screens.Play.HUD;
using osu.Game.Rulesets.Mods;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
2019-07-17 13:46:25 +08:00
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Select
{
2019-07-17 13:46:25 +08:00
public class FooterButtonMods : FooterButton, IHasCurrentValue<IReadOnlyList<Mod>>
{
2019-07-17 13:46:25 +08:00
public Bindable<IReadOnlyList<Mod>> Current
{
2019-07-17 13:46:25 +08:00
get => modDisplay.Current;
set => modDisplay.Current = value;
}
private readonly FooterModDisplay modDisplay;
2019-04-14 07:55:15 +08:00
2019-07-17 13:46:25 +08:00
public FooterButtonMods()
{
2019-04-14 07:22:31 +08:00
Add(new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
2019-08-07 11:20:49 +08:00
Shear = -SHEAR,
2019-05-08 17:43:06 +08:00
Child = modDisplay = new FooterModDisplay
{
2019-04-14 07:22:31 +08:00
DisplayUnrankedText = false,
Scale = new Vector2(0.8f)
},
AutoSizeAxes = Axes.Both,
2019-04-14 07:22:31 +08:00
Margin = new MarginPadding { Left = 70 }
});
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
SelectedColour = colours.Yellow;
DeselectedColour = SelectedColour.Opacity(0.5f);
Text = @"mods";
Hotkey = Key.F1;
}
2019-04-14 07:22:31 +08:00
private class FooterModDisplay : ModDisplay
{
2019-04-14 07:22:31 +08:00
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false;
2019-05-08 17:43:15 +08:00
public FooterModDisplay()
{
AllowExpand = false;
}
}
}
}