1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:47:29 +08:00

Remove HUD skin component lookup in favour of MainHUDComponents target system

This commit is contained in:
Salman Ahmed 2021-05-18 12:37:23 +03:00
parent a96603f025
commit 08ee1e4853
3 changed files with 21 additions and 85 deletions

View File

@ -12,7 +12,6 @@ using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Extensions;
using osu.Game.IO;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
using osuTK;
using osuTK.Graphics;
@ -81,13 +80,12 @@ namespace osu.Game.Skinning
}
})
{
Children = new[]
Children = new Drawable[]
{
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ComboCounter)),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreCounter)),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter)),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.HealthDisplay)),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.SongProgress)),
new DefaultComboCounter(),
new DefaultScoreCounter(),
new DefaultAccuracyCounter(),
new DefaultHealthDisplay(),
}
};
@ -95,29 +93,6 @@ namespace osu.Game.Skinning
}
break;
case HUDSkinComponent hudComponent:
{
switch (hudComponent.Component)
{
case HUDSkinComponents.ComboCounter:
return new DefaultComboCounter();
case HUDSkinComponents.ScoreCounter:
return new DefaultScoreCounter();
case HUDSkinComponents.AccuracyCounter:
return new DefaultAccuracyCounter();
case HUDSkinComponents.HealthDisplay:
return new DefaultHealthDisplay();
case HUDSkinComponents.SongProgress:
return new SongProgress();
}
break;
}
}
return null;

View File

@ -1,22 +0,0 @@
// 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;
namespace osu.Game.Skinning
{
public class HUDSkinComponent : ISkinComponent
{
public readonly HUDSkinComponents Component;
public HUDSkinComponent(HUDSkinComponents component)
{
Component = component;
}
protected virtual string ComponentName => Component.ToString();
public string LookupName =>
string.Join('/', new[] { "HUD", ComponentName }.Where(s => !string.IsNullOrEmpty(s)));
}
}

View File

@ -17,7 +17,6 @@ using osu.Game.Audio;
using osu.Game.Beatmaps.Formats;
using osu.Game.IO;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Play.HUD;
using osuTK.Graphics;
@ -344,15 +343,22 @@ namespace osu.Game.Skinning
}
})
{
Children = new[]
{
// TODO: these should fallback to the osu!classic skin.
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ComboCounter)) ?? new DefaultComboCounter(),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreCounter)) ?? new DefaultScoreCounter(),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.AccuracyCounter)) ?? new DefaultAccuracyCounter(),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.HealthDisplay)) ?? new DefaultHealthDisplay(),
GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.SongProgress)) ?? new SongProgress(),
}
Children = this.HasFont(LegacyFont.Score)
? new Drawable[]
{
new LegacyComboCounter(),
new LegacyScoreCounter(),
new LegacyAccuracyCounter(),
new LegacyHealthDisplay(),
}
: new Drawable[]
{
// TODO: these should fallback to using osu!classic skin textures, rather than doing this.
new DefaultComboCounter(),
new DefaultScoreCounter(),
new DefaultAccuracyCounter(),
new DefaultHealthDisplay(),
}
};
return skinnableTargetWrapper;
@ -360,29 +366,6 @@ namespace osu.Game.Skinning
return null;
case HUDSkinComponent hudComponent:
{
if (!this.HasFont(LegacyFont.Score))
return null;
switch (hudComponent.Component)
{
case HUDSkinComponents.ComboCounter:
return new LegacyComboCounter();
case HUDSkinComponents.ScoreCounter:
return new LegacyScoreCounter();
case HUDSkinComponents.AccuracyCounter:
return new LegacyAccuracyCounter();
case HUDSkinComponents.HealthDisplay:
return new LegacyHealthDisplay();
}
return null;
}
case GameplaySkinComponent<HitResult> resultComponent:
Func<Drawable> createDrawable = () => getJudgementAnimation(resultComponent.Component);