From addcef4f5d9e6abca6776149a391401a350f71e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Sun, 17 Oct 2021 12:51:51 +0200 Subject: [PATCH] Recolour text box using `OverlayColourProvider` --- osu.Game/Graphics/UserInterface/OsuTextBox.cs | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/osu.Game/Graphics/UserInterface/OsuTextBox.cs b/osu.Game/Graphics/UserInterface/OsuTextBox.cs index 75af9efc38..b8f8518bb4 100644 --- a/osu.Game/Graphics/UserInterface/OsuTextBox.cs +++ b/osu.Game/Graphics/UserInterface/OsuTextBox.cs @@ -1,6 +1,8 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +#nullable enable + using System.Linq; using osu.Framework.Allocation; using osu.Framework.Audio; @@ -17,18 +19,13 @@ using osu.Framework.Input.Events; using osu.Framework.Utils; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Graphics.Containers; +using osu.Game.Overlays; using osuTK; namespace osu.Game.Graphics.UserInterface { public class OsuTextBox : BasicTextBox { - private readonly Sample[] textAddedSamples = new Sample[4]; - private Sample capsTextAddedSample; - private Sample textRemovedSample; - private Sample textCommittedSample; - private Sample caretMovedSample; - /// /// Whether to allow playing a different samples based on the type of character. /// If set to false, the same sample will be used for all characters. @@ -42,10 +39,15 @@ namespace osu.Game.Graphics.UserInterface protected override SpriteText CreatePlaceholder() => new OsuSpriteText { Font = OsuFont.GetFont(italics: true), - Colour = new Color4(180, 180, 180, 255), Margin = new MarginPadding { Left = 2 }, }; + private readonly Sample?[] textAddedSamples = new Sample[4]; + private Sample? capsTextAddedSample; + private Sample? textRemovedSample; + private Sample? textCommittedSample; + private Sample? caretMovedSample; + public OsuTextBox() { Height = 40; @@ -56,12 +58,14 @@ namespace osu.Game.Graphics.UserInterface Current.DisabledChanged += disabled => { Alpha = disabled ? 0.3f : 1; }; } - [BackgroundDependencyLoader] - private void load(OsuColour colour, AudioManager audio) + [BackgroundDependencyLoader(true)] + private void load(OverlayColourProvider? colourProvider, OsuColour colour, AudioManager audio) { - BackgroundUnfocused = Color4.Black.Opacity(0.5f); - BackgroundFocused = OsuColour.Gray(0.3f).Opacity(0.8f); - BackgroundCommit = BorderColour = colour.Yellow; + BackgroundUnfocused = colourProvider?.Background5 ?? Color4.Black.Opacity(0.5f); + BackgroundFocused = colourProvider?.Background3 ?? OsuColour.Gray(0.3f).Opacity(0.8f); + BackgroundCommit = BorderColour = colourProvider?.Highlight1 ?? colour.Yellow; + + Placeholder.Colour = colourProvider?.Foreground1 ?? new Color4(180, 180, 180, 255); for (int i = 0; i < textAddedSamples.Length; i++) textAddedSamples[i] = audio.Samples.Get($@"Keyboard/key-press-{1 + i}");