Fix code quality

This commit is contained in:
normalid 2024-07-24 12:57:30 +08:00
parent 56143de2c6
commit b24be96d04
4 changed files with 30 additions and 26 deletions

View File

@ -110,6 +110,7 @@ private Color4 convertSettingStringToColor4(string[] split, bool allowAlpha, Key
{
throw new InvalidOperationException(@"Color must be specified with 8-bit integer components");
}
return colour;
}
@ -134,11 +135,13 @@ protected void HandleColours<TModel>(TModel output, string line, bool allowAlpha
tHasCustomColours.CustomColours[pair.Key] = colour;
}
bool isInputOverlayText = pair.Key.StartsWith(@"InputOverlayText");
bool isInputOverlayText = pair.Key == @"InputOverlayText";
if (isInputOverlayText)
{
if (!(output is SkinConfiguration tSkinConfiguration)) return;
tSkinConfiguration.InputOverlayText = colour;
}
}

View File

@ -30,7 +30,7 @@ public Colour4 KeyTextColour
private Colour4 keyTextColour = Colour4.White;
private float keyTextRotation = 0f;
private float keyTextRotation;
public float KeyTextRotation
{
@ -42,11 +42,11 @@ public float KeyTextRotation
}
}
private Container keyContainer = null!;
private readonly Container keyContainer;
private OsuSpriteText overlayKeyText = null!;
private readonly OsuSpriteText overlayKeyText;
private Sprite keySprite = null!;
private readonly Sprite keySprite;
public LegacyKeyCounter(InputTrigger trigger)
: base(trigger)
@ -86,7 +86,7 @@ public LegacyKeyCounter(InputTrigger trigger)
[BackgroundDependencyLoader]
private void load(ISkinSource source)
{
Texture? keyTexture = source.GetTexture($"inputoverlay-key");
Texture? keyTexture = source.GetTexture(@"inputoverlay-key");
if (keyTexture != null)
keySprite.Texture = keyTexture;

View File

@ -8,7 +8,6 @@
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osuTK;
namespace osu.Game.Skinning
{
@ -16,9 +15,9 @@ public partial class LegacyKeyCounterDisplay : KeyCounterDisplay
{
private const float key_transition_time = 100;
protected override FillFlowContainer<KeyCounter> KeyFlow { get; } = null!;
protected override FillFlowContainer<KeyCounter> KeyFlow { get; }
private Sprite backgroundSprite = null!;
private readonly Sprite backgroundSprite;
public LegacyKeyCounterDisplay()
{
@ -26,22 +25,22 @@ public LegacyKeyCounterDisplay()
AddRangeInternal(new Drawable[]
{
backgroundSprite = new Sprite
{
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
},
KeyFlow = new FillFlowContainer<KeyCounter>
{
// https://osu.ppy.sh/wiki/en/Skinning/Interface#input-overlay
// 24px away from the container, there're 4 counter in legacy, so divide by 4
// "inputoverlay-background.png" are 1.05x in-game. so *1.05f to the X coordinate
X = (24 / 4) * 1f,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
},
backgroundSprite = new Sprite
{
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
},
KeyFlow = new FillFlowContainer<KeyCounter>
{
// https://osu.ppy.sh/wiki/en/Skinning/Interface#input-overlay
// 24px away from the container, there're 4 counter in legacy, so divide by 4
// "inputoverlay-background.png" are 1.05x in-game. so *1.05f to the X coordinate
X = 24f / 4f,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both,
},
});
}
@ -56,7 +55,7 @@ protected override void LoadComplete()
KeyTextColor = v.NewValue;
}, true);
Texture? backgroundTexture = source.GetTexture($"inputoverlay-background");
Texture? backgroundTexture = source.GetTexture(@"inputoverlay-background");
if (backgroundTexture != null)
backgroundSprite.Texture = backgroundTexture;

View File

@ -309,8 +309,10 @@ protected override void ParseConfigurationStream(Stream stream)
{
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);
}