1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-18 05:52:56 +08:00
osu-lazer/osu.Game/Skinning/LegacyKeyCounterDisplay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

93 lines
2.9 KiB
C#
Raw Normal View History

2024-07-23 19:05:14 +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 System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Screens.Play.HUD;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osuTK;
using osuTK.Graphics;
2024-07-23 19:05:14 +08:00
namespace osu.Game.Skinning
{
public partial class LegacyKeyCounterDisplay : KeyCounterDisplay
{
private static readonly Colour4 active_colour_top = Colour4.FromHex(@"#ffde00");
private static readonly Colour4 active_colour_bottom = Colour4.FromHex(@"#f8009e");
2024-07-23 19:05:14 +08:00
2024-07-24 12:57:30 +08:00
protected override FillFlowContainer<KeyCounter> KeyFlow { get; }
2024-07-23 19:05:14 +08:00
2024-07-24 12:57:30 +08:00
private readonly Sprite backgroundSprite;
2024-07-23 19:05:14 +08:00
public LegacyKeyCounterDisplay()
{
AutoSizeAxes = Axes.Both;
AddRange(new Drawable[]
2024-07-23 19:05:14 +08:00
{
2024-07-24 12:57:30 +08:00
backgroundSprite = new Sprite
{
Anchor = Anchor.TopRight,
2024-07-24 13:09:21 +08:00
Origin = Anchor.TopLeft,
Scale = new Vector2(1.05f, 1),
Rotation = 90,
2024-07-24 12:57:30 +08:00
},
KeyFlow = new FillFlowContainer<KeyCounter>
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
X = -1.5f,
Y = 7,
Spacing = new Vector2(1.8f),
Direction = FillDirection.Vertical,
2024-07-24 12:57:30 +08:00
AutoSizeAxes = Axes.Both,
},
2024-07-23 19:05:14 +08:00
});
}
2024-07-23 23:35:25 +08:00
[Resolved]
private ISkinSource source { get; set; } = null!;
protected override void LoadComplete()
2024-07-23 19:05:14 +08:00
{
2024-07-23 23:35:25 +08:00
base.LoadComplete();
KeyTextColor = source.GetConfig<SkinCustomColourLookup, Color4>(new SkinCustomColourLookup(SkinConfiguration.LegacySetting.InputOverlayText))?.Value ?? Color4.Black;
2024-07-24 12:57:30 +08:00
Texture? backgroundTexture = source.GetTexture(@"inputoverlay-background");
if (backgroundTexture != null)
backgroundSprite.Texture = backgroundTexture;
for (int i = 0; i < KeyFlow.Count; ++i)
{
((LegacyKeyCounter)KeyFlow[i]).ActiveColour = i < 2 ? active_colour_top : active_colour_bottom;
}
2024-07-23 19:05:14 +08:00
}
protected override KeyCounter CreateCounter(InputTrigger trigger) => new LegacyKeyCounter(trigger)
{
TextColour = keyTextColor,
2024-07-23 19:05:14 +08:00
};
2024-07-23 23:35:25 +08:00
private Colour4 keyTextColor = Colour4.White;
2024-07-23 19:05:14 +08:00
2024-07-23 23:35:25 +08:00
public Colour4 KeyTextColor
2024-07-23 19:05:14 +08:00
{
get => keyTextColor;
set
{
if (value != keyTextColor)
{
keyTextColor = value;
foreach (var child in KeyFlow.Cast<LegacyKeyCounter>())
child.TextColour = value;
2024-07-23 19:05:14 +08:00
}
}
}
}
}