mirror of
https://github.com/ppy/osu.git
synced 2025-01-18 21:02:56 +08:00
Support custom input overlay color
This commit is contained in:
parent
c7b110a471
commit
c52a993607
@ -9,6 +9,7 @@ using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.IO;
|
||||
using osu.Game.Rulesets.Objects.Legacy;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Formats
|
||||
@ -93,14 +94,8 @@ namespace osu.Game.Beatmaps.Formats
|
||||
return line;
|
||||
}
|
||||
|
||||
protected void HandleColours<TModel>(TModel output, string line, bool allowAlpha)
|
||||
private Color4 convertSettingStringToColor4(string[] split, bool allowAlpha, KeyValuePair<string, string> pair)
|
||||
{
|
||||
var pair = SplitKeyVal(line);
|
||||
|
||||
bool isCombo = pair.Key.StartsWith(@"Combo", StringComparison.Ordinal);
|
||||
|
||||
string[] split = pair.Value.Split(',');
|
||||
|
||||
if (split.Length != 3 && split.Length != 4)
|
||||
throw new InvalidOperationException($@"Color specified in incorrect format (should be R,G,B or R,G,B,A): {pair.Value}");
|
||||
|
||||
@ -115,6 +110,17 @@ namespace osu.Game.Beatmaps.Formats
|
||||
{
|
||||
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
|
||||
}
|
||||
return colour;
|
||||
}
|
||||
|
||||
protected void HandleColours<TModel>(TModel output, string line, bool allowAlpha)
|
||||
{
|
||||
var pair = SplitKeyVal(line);
|
||||
|
||||
string[] split = pair.Value.Split(',');
|
||||
Color4 colour = convertSettingStringToColor4(split, allowAlpha, pair);
|
||||
|
||||
bool isCombo = pair.Key.StartsWith(@"Combo", StringComparison.Ordinal);
|
||||
|
||||
if (isCombo)
|
||||
{
|
||||
@ -128,6 +134,13 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
tHasCustomColours.CustomColours[pair.Key] = colour;
|
||||
}
|
||||
bool isInputOverlayText = pair.Key.StartsWith(@"InputOverlayText");
|
||||
|
||||
if (isInputOverlayText)
|
||||
{
|
||||
if (!(output is SkinConfiguration tSkinConfiguration)) return;
|
||||
tSkinConfiguration.InputOverlayText = colour;
|
||||
}
|
||||
}
|
||||
|
||||
protected KeyValuePair<string, string> SplitKeyVal(string line, char separator = ':', bool shouldTrim = true)
|
||||
|
@ -16,13 +16,19 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
public bool UsesFixedAnchor { get; set; }
|
||||
|
||||
public float TransitionDuration { get; set; } = 150f;
|
||||
public float TransitionDuration { get; set; } = 50f;
|
||||
|
||||
public Colour4 KeyTextColour { get; set; } = Colour4.White;
|
||||
public Colour4 KeyTextColour
|
||||
{
|
||||
get => keyTextColour;
|
||||
set
|
||||
{
|
||||
keyTextColour = value;
|
||||
overlayKeyText.Colour = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Colour4 KeyDownBackgroundColour { get; set; } = Colour4.Yellow;
|
||||
|
||||
public Colour4 KeyUpBackgroundColour { get; set; } = Colour4.White;
|
||||
private Colour4 keyTextColour = Colour4.White;
|
||||
|
||||
private float keyTextRotation = 0f;
|
||||
|
||||
@ -66,7 +72,7 @@ namespace osu.Game.Skinning
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = trigger.Name,
|
||||
Colour = KeyTextColour,
|
||||
Colour = keyTextColour,
|
||||
Font = OsuFont.GetFont(size: 20),
|
||||
Rotation = KeyTextRotation
|
||||
},
|
||||
@ -89,8 +95,7 @@ namespace osu.Game.Skinning
|
||||
protected override void Activate(bool forwardPlayback = true)
|
||||
{
|
||||
base.Activate(forwardPlayback);
|
||||
keyContainer.ScaleTo(0.75f, TransitionDuration);
|
||||
keyContainer.FadeColour(KeyDownBackgroundColour, TransitionDuration);
|
||||
keyContainer.ScaleTo(0.8f, TransitionDuration);
|
||||
overlayKeyText.Text = CountPresses.Value.ToString();
|
||||
}
|
||||
|
||||
@ -98,7 +103,6 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
base.Deactivate(forwardPlayback);
|
||||
keyContainer.ScaleTo(1f, TransitionDuration);
|
||||
keyContainer.FadeColour(KeyUpBackgroundColour, TransitionDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
@ -45,10 +44,13 @@ namespace osu.Game.Skinning
|
||||
});
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource source)
|
||||
[Resolved]
|
||||
private ISkinSource source { get; set; } = null!;
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
source.GetConfig<string, Colour4>("InputOverlayText")?.BindValueChanged(v =>
|
||||
base.LoadComplete();
|
||||
source.GetConfig<SkinConfiguration.LegacySetting, Colour4>(SkinConfiguration.LegacySetting.InputOverlayText)?.BindValueChanged(v =>
|
||||
{
|
||||
KeyTextColor = v.NewValue;
|
||||
}, true);
|
||||
@ -69,14 +71,15 @@ namespace osu.Game.Skinning
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// keep the text are always horizontal
|
||||
foreach (var child in KeyFlow.Cast<LegacyKeyCounter>())
|
||||
child.KeyTextRotation = -Rotation;
|
||||
}
|
||||
|
||||
private Color4 keyTextColor = Color4.White;
|
||||
private Colour4 keyTextColor = Colour4.White;
|
||||
|
||||
public Color4 KeyTextColor
|
||||
public Colour4 KeyTextColor
|
||||
{
|
||||
get => keyTextColor;
|
||||
set
|
||||
|
@ -15,6 +15,7 @@ using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osu.Game.Extensions;
|
||||
@ -309,7 +310,8 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
case SkinConfiguration.LegacySetting.Version:
|
||||
return SkinUtils.As<TValue>(new Bindable<decimal>(Configuration.LegacyVersion ?? SkinConfiguration.LATEST_VERSION));
|
||||
|
||||
case SkinConfiguration.LegacySetting.InputOverlayText:
|
||||
return SkinUtils.As<TValue>(new Bindable<Colour4>(Configuration.InputOverlayText ?? Colour4.White));
|
||||
default:
|
||||
return genericLookup<SkinConfiguration.LegacySetting, TValue>(legacySetting);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.Formats;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -38,8 +39,11 @@ namespace osu.Game.Skinning
|
||||
AnimationFramerate,
|
||||
LayeredHitSounds,
|
||||
AllowSliderBallTint,
|
||||
InputOverlayText,
|
||||
}
|
||||
|
||||
public Colour4? InputOverlayText { get; internal set; }
|
||||
|
||||
public static List<Color4> DefaultComboColours { get; } = new List<Color4>
|
||||
{
|
||||
new Color4(255, 192, 0, 255),
|
||||
|
Loading…
Reference in New Issue
Block a user