osu/osu.Game/Screens/Select/FooterButtonMods.cs

66 lines
2.0 KiB
C#
Raw Normal View History

2019-05-08 09:43:15 +00: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-13 23:22:31 +00: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 05:46:25 +00:00
using osu.Framework.Graphics.UserInterface;
using osu.Game.Graphics;
using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Select
{
2019-07-17 05:46:25 +00:00
public class FooterButtonMods : FooterButton, IHasCurrentValue<IReadOnlyList<Mod>>
{
2019-07-17 05:46:25 +00:00
public Bindable<IReadOnlyList<Mod>> Current
{
2019-07-17 05:46:25 +00:00
get => modDisplay.Current;
set => modDisplay.Current = value;
}
private readonly FooterModDisplay modDisplay;
2019-04-13 23:55:15 +00:00
2019-07-17 05:46:25 +00:00
public FooterButtonMods()
{
2019-04-13 23:22:31 +00:00
Add(new Container
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
2019-08-07 03:20:49 +00:00
Shear = -SHEAR,
2019-05-08 09:43:06 +00:00
Child = modDisplay = new FooterModDisplay
{
2019-04-13 23:22:31 +00:00
DisplayUnrankedText = false,
Scale = new Vector2(0.8f)
},
AutoSizeAxes = Axes.Both,
2019-04-13 23:22:31 +00: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-13 23:22:31 +00:00
private class FooterModDisplay : ModDisplay
{
2019-04-13 23:22:31 +00:00
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => Parent?.Parent?.ReceivePositionalInputAt(screenSpacePos) ?? false;
2019-05-08 09:43:15 +00:00
public FooterModDisplay()
{
AllowExpand = false;
}
}
}
}