mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:07:52 +08:00
Rename SkinnableTarget
to GlobalSkinLookup
This commit is contained in:
parent
c908969d9b
commit
e75c3b3f94
@ -27,11 +27,11 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
||||
|
||||
public override Drawable? GetDrawableComponent(ISkinLookup lookup)
|
||||
{
|
||||
if (lookup is SkinnableTargetLookup targetComponent)
|
||||
if (lookup is GlobalSkinLookup targetComponent)
|
||||
{
|
||||
switch (targetComponent.Target)
|
||||
switch (targetComponent.Lookup)
|
||||
{
|
||||
case SkinnableTarget.MainHUDComponents:
|
||||
case GlobalSkinLookup.LookupType.MainHUDComponents:
|
||||
var components = base.GetDrawableComponent(lookup) as SkinnableTargetComponentsContainer;
|
||||
|
||||
if (providesComboCounter && components != null)
|
||||
|
@ -80,7 +80,7 @@ namespace osu.Game.Tests.Skins
|
||||
var skin = new TestSkin(new SkinInfo(), null, storage);
|
||||
|
||||
Assert.That(skin.DrawableComponentInfo, Has.Count.EqualTo(2));
|
||||
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents], Has.Length.EqualTo(9));
|
||||
Assert.That(skin.DrawableComponentInfo[GlobalSkinLookup.LookupType.MainHUDComponents], Has.Length.EqualTo(9));
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,10 +93,10 @@ namespace osu.Game.Tests.Skins
|
||||
var skin = new TestSkin(new SkinInfo(), null, storage);
|
||||
|
||||
Assert.That(skin.DrawableComponentInfo, Has.Count.EqualTo(2));
|
||||
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents], Has.Length.EqualTo(6));
|
||||
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.SongSelect], Has.Length.EqualTo(1));
|
||||
Assert.That(skin.DrawableComponentInfo[GlobalSkinLookup.LookupType.MainHUDComponents], Has.Length.EqualTo(6));
|
||||
Assert.That(skin.DrawableComponentInfo[GlobalSkinLookup.LookupType.SongSelect], Has.Length.EqualTo(1));
|
||||
|
||||
var skinnableInfo = skin.DrawableComponentInfo[SkinnableTarget.SongSelect].First();
|
||||
var skinnableInfo = skin.DrawableComponentInfo[GlobalSkinLookup.LookupType.SongSelect].First();
|
||||
|
||||
Assert.That(skinnableInfo.Type, Is.EqualTo(typeof(SkinnableSprite)));
|
||||
Assert.That(skinnableInfo.Settings.First().Key, Is.EqualTo("sprite_name"));
|
||||
@ -107,10 +107,10 @@ namespace osu.Game.Tests.Skins
|
||||
using (var storage = new ZipArchiveReader(stream))
|
||||
{
|
||||
var skin = new TestSkin(new SkinInfo(), null, storage);
|
||||
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents], Has.Length.EqualTo(8));
|
||||
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(UnstableRateCounter)));
|
||||
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(ColourHitErrorMeter)));
|
||||
Assert.That(skin.DrawableComponentInfo[SkinnableTarget.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(LegacySongProgress)));
|
||||
Assert.That(skin.DrawableComponentInfo[GlobalSkinLookup.LookupType.MainHUDComponents], Has.Length.EqualTo(8));
|
||||
Assert.That(skin.DrawableComponentInfo[GlobalSkinLookup.LookupType.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(UnstableRateCounter)));
|
||||
Assert.That(skin.DrawableComponentInfo[GlobalSkinLookup.LookupType.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(ColourHitErrorMeter)));
|
||||
Assert.That(skin.DrawableComponentInfo[GlobalSkinLookup.LookupType.MainHUDComponents].Select(i => i.Type), Contains.Item(typeof(LegacySongProgress)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
CreateSkinTest(TrianglesSkin.CreateInfo(), () => new LegacyBeatmapSkin(new BeatmapInfo(), null));
|
||||
AddUntilStep("wait for hud load", () => Player.ChildrenOfType<SkinnableTargetContainer>().All(c => c.ComponentsLoaded));
|
||||
AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(SkinnableTarget.MainHUDComponents, skinManager.CurrentSkin.Value));
|
||||
AddAssert("hud from default skin", () => AssertComponentsFromExpectedSource(GlobalSkinLookup.LookupType.MainHUDComponents, skinManager.CurrentSkin.Value));
|
||||
}
|
||||
|
||||
protected void CreateSkinTest(SkinInfo gameCurrentSkin, Func<ISkin> getBeatmapSkin)
|
||||
@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
});
|
||||
}
|
||||
|
||||
protected bool AssertComponentsFromExpectedSource(SkinnableTarget target, ISkin expectedSource)
|
||||
protected bool AssertComponentsFromExpectedSource(GlobalSkinLookup.LookupType target, ISkin expectedSource)
|
||||
{
|
||||
var actualComponentsContainer = Player.ChildrenOfType<SkinnableTargetContainer>().First(s => s.Target == target)
|
||||
.ChildrenOfType<SkinnableTargetComponentsContainer>().SingleOrDefault();
|
||||
@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
var actualInfo = actualComponentsContainer.CreateSkinnableInfo();
|
||||
|
||||
var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource.GetDrawableComponent(new SkinnableTargetLookup(target));
|
||||
var expectedComponentsContainer = (SkinnableTargetComponentsContainer)expectedSource.GetDrawableComponent(new GlobalSkinLookup(target));
|
||||
if (expectedComponentsContainer == null)
|
||||
return false;
|
||||
|
||||
|
@ -391,7 +391,7 @@ namespace osu.Game.Screens.Play
|
||||
private OsuConfigManager config { get; set; }
|
||||
|
||||
public MainComponentsContainer()
|
||||
: base(SkinnableTarget.MainHUDComponents)
|
||||
: base(GlobalSkinLookup.LookupType.MainHUDComponents)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
},
|
||||
new SkinnableTargetContainer(SkinnableTarget.SongSelect)
|
||||
new SkinnableTargetContainer(GlobalSkinLookup.LookupType.SongSelect)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
|
@ -88,10 +88,10 @@ namespace osu.Game.Skinning
|
||||
|
||||
switch (lookup)
|
||||
{
|
||||
case SkinnableTargetLookup target:
|
||||
switch (target.Target)
|
||||
case GlobalSkinLookup globalLookup:
|
||||
switch (globalLookup.Lookup)
|
||||
{
|
||||
case SkinnableTarget.SongSelect:
|
||||
case GlobalSkinLookup.LookupType.SongSelect:
|
||||
var songSelectComponents = new SkinnableTargetComponentsContainer(_ =>
|
||||
{
|
||||
// do stuff when we need to.
|
||||
@ -99,7 +99,7 @@ namespace osu.Game.Skinning
|
||||
|
||||
return songSelectComponents;
|
||||
|
||||
case SkinnableTarget.MainHUDComponents:
|
||||
case GlobalSkinLookup.LookupType.MainHUDComponents:
|
||||
var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
|
||||
{
|
||||
var score = container.OfType<DefaultScoreCounter>().FirstOrDefault();
|
||||
|
@ -314,7 +314,7 @@ namespace osu.Game.Skinning.Editor
|
||||
|
||||
private ISkinnableTarget getFirstTarget() => availableTargets.FirstOrDefault();
|
||||
|
||||
private ISkinnableTarget getTarget(SkinnableTarget target)
|
||||
private ISkinnableTarget getTarget(GlobalSkinLookup.LookupType target)
|
||||
{
|
||||
return availableTargets.FirstOrDefault(c => c.Target == target);
|
||||
}
|
||||
|
23
osu.Game/Skinning/GlobalSkinLookup.cs
Normal file
23
osu.Game/Skinning/GlobalSkinLookup.cs
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class GlobalSkinLookup : ISkinLookup
|
||||
{
|
||||
public readonly LookupType Lookup;
|
||||
|
||||
public string LookupName => Lookup.ToString();
|
||||
|
||||
public GlobalSkinLookup(LookupType lookup)
|
||||
{
|
||||
Lookup = lookup;
|
||||
}
|
||||
|
||||
public enum LookupType
|
||||
{
|
||||
MainHUDComponents,
|
||||
SongSelect
|
||||
}
|
||||
}
|
||||
}
|
@ -5,12 +5,17 @@ using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Configuration;
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
/// <summary>
|
||||
/// Denotes a drawable which, as a drawable, can be adjusted via skinning specifications.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Attaching this interface to any <see cref="IDrawable"/> will make it serialisable to skin settings.
|
||||
/// Adding <see cref="SettingSourceAttribute"/> annotated bindables will also serialise these settings alongside each instance.
|
||||
/// </remarks>
|
||||
public interface ISkinnableDrawable : IDrawable
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Skinning
|
||||
/// <summary>
|
||||
/// The definition of this target.
|
||||
/// </summary>
|
||||
SkinnableTarget Target { get; }
|
||||
GlobalSkinLookup.LookupType Target { get; }
|
||||
|
||||
/// <summary>
|
||||
/// A bindable list of components which are being tracked by this skinnable target.
|
||||
|
@ -45,11 +45,11 @@ namespace osu.Game.Skinning
|
||||
|
||||
public override Drawable? GetDrawableComponent(ISkinLookup lookup)
|
||||
{
|
||||
if (lookup is SkinnableTargetLookup targetComponent)
|
||||
if (lookup is GlobalSkinLookup targetComponent)
|
||||
{
|
||||
switch (targetComponent.Target)
|
||||
switch (targetComponent.Lookup)
|
||||
{
|
||||
case SkinnableTarget.MainHUDComponents:
|
||||
case GlobalSkinLookup.LookupType.MainHUDComponents:
|
||||
// this should exist in LegacySkin instead, but there isn't a fallback skin for LegacySkins yet.
|
||||
// therefore keep the check here until fallback default legacy skin is supported.
|
||||
if (!this.HasFont(LegacyFont.Score))
|
||||
|
@ -329,10 +329,10 @@ namespace osu.Game.Skinning
|
||||
|
||||
switch (lookup)
|
||||
{
|
||||
case SkinnableTargetLookup target:
|
||||
switch (target.Target)
|
||||
case GlobalSkinLookup target:
|
||||
switch (target.Lookup)
|
||||
{
|
||||
case SkinnableTarget.MainHUDComponents:
|
||||
case GlobalSkinLookup.LookupType.MainHUDComponents:
|
||||
var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
|
||||
{
|
||||
var score = container.OfType<LegacyScoreCounter>().FirstOrDefault();
|
||||
|
@ -37,9 +37,9 @@ namespace osu.Game.Skinning
|
||||
|
||||
public SkinConfiguration Configuration { get; set; }
|
||||
|
||||
public IDictionary<SkinnableTarget, SkinnableInfo[]> DrawableComponentInfo => drawableComponentInfo;
|
||||
public IDictionary<GlobalSkinLookup.LookupType, SkinnableInfo[]> DrawableComponentInfo => drawableComponentInfo;
|
||||
|
||||
private readonly Dictionary<SkinnableTarget, SkinnableInfo[]> drawableComponentInfo = new Dictionary<SkinnableTarget, SkinnableInfo[]>();
|
||||
private readonly Dictionary<GlobalSkinLookup.LookupType, SkinnableInfo[]> drawableComponentInfo = new Dictionary<GlobalSkinLookup.LookupType, SkinnableInfo[]>();
|
||||
|
||||
public abstract ISample? GetSample(ISampleInfo sampleInfo);
|
||||
|
||||
@ -97,7 +97,7 @@ namespace osu.Game.Skinning
|
||||
Configuration = new SkinConfiguration();
|
||||
|
||||
// skininfo files may be null for default skin.
|
||||
foreach (SkinnableTarget skinnableTarget in Enum.GetValues(typeof(SkinnableTarget)))
|
||||
foreach (GlobalSkinLookup.LookupType skinnableTarget in Enum.GetValues(typeof(GlobalSkinLookup.LookupType)))
|
||||
{
|
||||
string filename = $"{skinnableTarget}.json";
|
||||
|
||||
@ -158,8 +158,8 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
switch (lookup)
|
||||
{
|
||||
case SkinnableTargetLookup target:
|
||||
if (!DrawableComponentInfo.TryGetValue(target.Target, out var skinnableInfo))
|
||||
case GlobalSkinLookup target:
|
||||
if (!DrawableComponentInfo.TryGetValue(target.Lookup, out var skinnableInfo))
|
||||
return null;
|
||||
|
||||
var components = new List<Drawable>();
|
||||
|
@ -1,11 +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.
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public enum SkinnableTarget
|
||||
{
|
||||
MainHUDComponents,
|
||||
SongSelect
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
private SkinnableTargetComponentsContainer? content;
|
||||
|
||||
public SkinnableTarget Target { get; }
|
||||
public GlobalSkinLookup.LookupType Target { get; }
|
||||
|
||||
public IBindableList<ISkinnableDrawable> Components => components;
|
||||
|
||||
@ -25,7 +25,7 @@ namespace osu.Game.Skinning
|
||||
|
||||
private CancellationTokenSource? cancellationSource;
|
||||
|
||||
public SkinnableTargetContainer(SkinnableTarget target)
|
||||
public SkinnableTargetContainer(GlobalSkinLookup.LookupType target)
|
||||
{
|
||||
Target = target;
|
||||
}
|
||||
@ -39,7 +39,7 @@ namespace osu.Game.Skinning
|
||||
components.Clear();
|
||||
ComponentsLoaded = false;
|
||||
|
||||
content = CurrentSkin.GetDrawableComponent(new SkinnableTargetLookup(Target)) as SkinnableTargetComponentsContainer;
|
||||
content = CurrentSkin.GetDrawableComponent(new GlobalSkinLookup(Target)) as SkinnableTargetComponentsContainer;
|
||||
|
||||
cancellationSource?.Cancel();
|
||||
cancellationSource = null;
|
||||
|
@ -1,17 +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.
|
||||
|
||||
namespace osu.Game.Skinning
|
||||
{
|
||||
public class SkinnableTargetLookup : ISkinLookup
|
||||
{
|
||||
public readonly SkinnableTarget Target;
|
||||
|
||||
public string LookupName => Target.ToString();
|
||||
|
||||
public SkinnableTargetLookup(SkinnableTarget target)
|
||||
{
|
||||
Target = target;
|
||||
}
|
||||
}
|
||||
}
|
@ -66,10 +66,10 @@ namespace osu.Game.Skinning
|
||||
|
||||
switch (lookup)
|
||||
{
|
||||
case SkinnableTargetLookup target:
|
||||
switch (target.Target)
|
||||
case GlobalSkinLookup target:
|
||||
switch (target.Lookup)
|
||||
{
|
||||
case SkinnableTarget.SongSelect:
|
||||
case GlobalSkinLookup.LookupType.SongSelect:
|
||||
var songSelectComponents = new SkinnableTargetComponentsContainer(_ =>
|
||||
{
|
||||
// do stuff when we need to.
|
||||
@ -77,7 +77,7 @@ namespace osu.Game.Skinning
|
||||
|
||||
return songSelectComponents;
|
||||
|
||||
case SkinnableTarget.MainHUDComponents:
|
||||
case GlobalSkinLookup.LookupType.MainHUDComponents:
|
||||
var skinnableTargetWrapper = new SkinnableTargetComponentsContainer(container =>
|
||||
{
|
||||
var score = container.OfType<DefaultScoreCounter>().FirstOrDefault();
|
||||
|
Loading…
Reference in New Issue
Block a user