Merge branch 'master' into results-screen-sfx

This commit is contained in:
Dean Herbert
2021-06-10 17:25:35 +09:00
committed by GitHub
26 changed files with 584 additions and 153 deletions

View File

@ -8,9 +8,7 @@ namespace osu.Game.Rulesets.Catch
Fruit, Fruit,
Banana, Banana,
Droplet, Droplet,
CatcherIdle, Catcher,
CatcherFail,
CatcherKiai,
CatchComboCounter CatchComboCounter
} }
} }

View File

@ -0,0 +1,54 @@
// 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.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Catch.UI;
namespace osu.Game.Rulesets.Catch.Skinning.Default
{
public class DefaultCatcher : CompositeDrawable, ICatcherSprite
{
public Bindable<CatcherAnimationState> CurrentState { get; } = new Bindable<CatcherAnimationState>();
public Texture CurrentTexture => sprite.Texture;
private readonly Sprite sprite;
private readonly Dictionary<CatcherAnimationState, Texture> textures = new Dictionary<CatcherAnimationState, Texture>();
public DefaultCatcher()
{
RelativeSizeAxes = Axes.Both;
InternalChild = sprite = new Sprite
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit
};
}
[BackgroundDependencyLoader]
private void load(TextureStore store, Bindable<CatcherAnimationState> currentState)
{
CurrentState.BindTo(currentState);
textures[CatcherAnimationState.Idle] = store.Get(@"Gameplay/catch/fruit-catcher-idle");
textures[CatcherAnimationState.Fail] = store.Get(@"Gameplay/catch/fruit-catcher-fail");
textures[CatcherAnimationState.Kiai] = store.Get(@"Gameplay/catch/fruit-catcher-kiai");
}
protected override void LoadComplete()
{
base.LoadComplete();
CurrentState.BindValueChanged(state => sprite.Texture = textures[state.NewValue], true);
}
}
}

View File

@ -0,0 +1,12 @@
// 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 osu.Framework.Graphics.Textures;
namespace osu.Game.Rulesets.Catch.Skinning
{
public interface ICatcherSprite
{
Texture CurrentTexture { get; }
}
}

View File

@ -65,17 +65,21 @@ namespace osu.Game.Rulesets.Catch.Skinning.Legacy
return null; return null;
case CatchSkinComponents.CatcherIdle: case CatchSkinComponents.Catcher:
return this.GetAnimation("fruit-catcher-idle", true, true, true) ?? var version = Source.GetConfig<LegacySkinConfiguration.LegacySetting, decimal>(LegacySkinConfiguration.LegacySetting.Version)?.Value ?? 1;
this.GetAnimation("fruit-ryuuta", true, true, true);
case CatchSkinComponents.CatcherFail: if (version < 2.3m)
return this.GetAnimation("fruit-catcher-fail", true, true, true) ?? {
this.GetAnimation("fruit-ryuuta", true, true, true); if (GetTexture(@"fruit-ryuuta") != null ||
GetTexture(@"fruit-ryuuta-0") != null)
return new LegacyCatcherOld();
}
case CatchSkinComponents.CatcherKiai: if (GetTexture(@"fruit-catcher-idle") != null ||
return this.GetAnimation("fruit-catcher-kiai", true, true, true) ?? GetTexture(@"fruit-catcher-idle-0") != null)
this.GetAnimation("fruit-ryuuta", true, true, true); return new LegacyCatcherNew();
return null;
case CatchSkinComponents.CatchComboCounter: case CatchSkinComponents.CatchComboCounter:
if (providesComboCounter) if (providesComboCounter)

View File

@ -0,0 +1,73 @@
// 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;
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{
public class LegacyCatcherNew : CompositeDrawable, ICatcherSprite
{
[Resolved]
private Bindable<CatcherAnimationState> currentState { get; set; }
public Texture CurrentTexture => (currentDrawable as TextureAnimation)?.CurrentFrame ?? (currentDrawable as Sprite)?.Texture;
private readonly Dictionary<CatcherAnimationState, Drawable> drawables = new Dictionary<CatcherAnimationState, Drawable>();
private Drawable currentDrawable;
public LegacyCatcherNew()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
foreach (var state in Enum.GetValues(typeof(CatcherAnimationState)).Cast<CatcherAnimationState>())
{
AddInternal(drawables[state] = getDrawableFor(state).With(d =>
{
d.Anchor = Anchor.TopCentre;
d.Origin = Anchor.TopCentre;
d.RelativeSizeAxes = Axes.Both;
d.Size = Vector2.One;
d.FillMode = FillMode.Fit;
d.Alpha = 0;
}));
}
currentDrawable = drawables[CatcherAnimationState.Idle];
Drawable getDrawableFor(CatcherAnimationState state) =>
skin.GetAnimation(@$"fruit-catcher-{state.ToString().ToLowerInvariant()}", true, true, true) ??
skin.GetAnimation(@"fruit-catcher-idle", true, true, true);
}
protected override void LoadComplete()
{
base.LoadComplete();
currentState.BindValueChanged(state =>
{
currentDrawable.Alpha = 0;
currentDrawable = drawables[state.NewValue];
currentDrawable.Alpha = 1;
(currentDrawable as IFramedAnimation)?.GotoFrame(0);
}, true);
}
}
}

View File

@ -0,0 +1,37 @@
// 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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Rulesets.Catch.Skinning.Legacy
{
public class LegacyCatcherOld : CompositeDrawable, ICatcherSprite
{
public Texture CurrentTexture => (InternalChild as TextureAnimation)?.CurrentFrame ?? (InternalChild as Sprite)?.Texture;
public LegacyCatcherOld()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
InternalChild = skin.GetAnimation(@"fruit-ryuuta", true, true, true).With(d =>
{
d.Anchor = Anchor.TopCentre;
d.Origin = Anchor.TopCentre;
d.RelativeSizeAxes = Axes.Both;
d.Size = Vector2.One;
d.FillMode = FillMode.Fit;
});
}
}
}

View File

@ -7,9 +7,9 @@ using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Pooling;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Utils; using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -18,6 +18,7 @@ using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects; using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawables; using osu.Game.Rulesets.Catch.Objects.Drawables;
using osu.Game.Rulesets.Catch.Skinning; using osu.Game.Rulesets.Catch.Skinning;
using osu.Game.Rulesets.Catch.Skinning.Default;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -78,17 +79,17 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary> /// </summary>
private readonly Container<CaughtObject> droppedObjectTarget; private readonly Container<CaughtObject> droppedObjectTarget;
public CatcherAnimationState CurrentState { get; private set; } [Cached]
protected readonly Bindable<CatcherAnimationState> CurrentStateBindable = new Bindable<CatcherAnimationState>();
public CatcherAnimationState CurrentState => CurrentStateBindable.Value;
/// <summary> /// <summary>
/// The width of the catcher which can receive fruit. Equivalent to "catchMargin" in osu-stable. /// The width of the catcher which can receive fruit. Equivalent to "catchMargin" in osu-stable.
/// </summary> /// </summary>
public const float ALLOWED_CATCH_RANGE = 0.8f; public const float ALLOWED_CATCH_RANGE = 0.8f;
/// <summary> internal Texture CurrentTexture => ((ICatcherSprite)currentCatcher.Drawable).CurrentTexture;
/// The drawable catcher for <see cref="CurrentState"/>.
/// </summary>
internal Drawable CurrentDrawableCatcher => currentCatcher.Drawable;
private bool dashing; private bool dashing;
@ -110,11 +111,7 @@ namespace osu.Game.Rulesets.Catch.UI
/// </summary> /// </summary>
private readonly float catchWidth; private readonly float catchWidth;
private readonly CatcherSprite catcherIdle; private readonly SkinnableDrawable currentCatcher;
private readonly CatcherSprite catcherKiai;
private readonly CatcherSprite catcherFail;
private CatcherSprite currentCatcher;
private Color4 hyperDashColour = DEFAULT_HYPER_DASH_COLOUR; private Color4 hyperDashColour = DEFAULT_HYPER_DASH_COLOUR;
private Color4 hyperDashEndGlowColour = DEFAULT_HYPER_DASH_COLOUR; private Color4 hyperDashEndGlowColour = DEFAULT_HYPER_DASH_COLOUR;
@ -156,20 +153,12 @@ namespace osu.Game.Rulesets.Catch.UI
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Origin = Anchor.BottomCentre, Origin = Anchor.BottomCentre,
}, },
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle) currentCatcher = new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Catcher),
_ => new DefaultCatcher())
{ {
Anchor = Anchor.TopCentre, Anchor = Anchor.TopCentre,
Alpha = 0, OriginPosition = new Vector2(0.5f, 0.06f) * CatcherArea.CATCHER_SIZE
},
catcherKiai = new CatcherSprite(CatcherAnimationState.Kiai)
{
Anchor = Anchor.TopCentre,
Alpha = 0,
},
catcherFail = new CatcherSprite(CatcherAnimationState.Fail)
{
Anchor = Anchor.TopCentre,
Alpha = 0,
}, },
hitExplosionContainer = new HitExplosionContainer hitExplosionContainer = new HitExplosionContainer
{ {
@ -184,8 +173,6 @@ namespace osu.Game.Rulesets.Catch.UI
{ {
hitLighting = config.GetBindable<bool>(OsuSetting.HitLighting); hitLighting = config.GetBindable<bool>(OsuSetting.HitLighting);
trails = new CatcherTrailDisplay(this); trails = new CatcherTrailDisplay(this);
updateCatcher();
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -436,36 +423,12 @@ namespace osu.Game.Rulesets.Catch.UI
} }
} }
private void updateCatcher()
{
currentCatcher?.Hide();
switch (CurrentState)
{
default:
currentCatcher = catcherIdle;
break;
case CatcherAnimationState.Fail:
currentCatcher = catcherFail;
break;
case CatcherAnimationState.Kiai:
currentCatcher = catcherKiai;
break;
}
currentCatcher.Show();
(currentCatcher.Drawable as IFramedAnimation)?.GotoFrame(0);
}
private void updateState(CatcherAnimationState state) private void updateState(CatcherAnimationState state)
{ {
if (CurrentState == state) if (CurrentState == state)
return; return;
CurrentState = state; CurrentStateBindable.Value = state;
updateCatcher();
} }
private void placeCaughtObject(DrawablePalpableCatchHitObject drawableObject, Vector2 position) private void placeCaughtObject(DrawablePalpableCatchHitObject drawableObject, Vector2 position)

View File

@ -1,59 +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 osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Rulesets.Catch.UI
{
public class CatcherSprite : SkinnableDrawable
{
protected override bool ApplySizeRestrictionsToDefault => true;
public CatcherSprite(CatcherAnimationState state)
: base(new CatchSkinComponent(componentFromState(state)), _ =>
new DefaultCatcherSprite(state), confineMode: ConfineMode.ScaleToFit)
{
RelativeSizeAxes = Axes.None;
Size = new Vector2(CatcherArea.CATCHER_SIZE);
// Sets the origin roughly to the centre of the catcher's plate to allow for correct scaling.
OriginPosition = new Vector2(0.5f, 0.06f) * CatcherArea.CATCHER_SIZE;
}
private static CatchSkinComponents componentFromState(CatcherAnimationState state)
{
switch (state)
{
case CatcherAnimationState.Fail:
return CatchSkinComponents.CatcherFail;
case CatcherAnimationState.Kiai:
return CatchSkinComponents.CatcherKiai;
default:
return CatchSkinComponents.CatcherIdle;
}
}
private class DefaultCatcherSprite : Sprite
{
private readonly CatcherAnimationState state;
public DefaultCatcherSprite(CatcherAnimationState state)
{
this.state = state;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Texture = textures.Get($"Gameplay/catch/fruit-catcher-{state.ToString().ToLower()}");
}
}
}
}

View File

@ -4,10 +4,8 @@
using System; using System;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Pooling;
using osu.Framework.Graphics.Sprites;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
@ -120,11 +118,9 @@ namespace osu.Game.Rulesets.Catch.UI
private CatcherTrailSprite createTrailSprite(Container<CatcherTrailSprite> target) private CatcherTrailSprite createTrailSprite(Container<CatcherTrailSprite> target)
{ {
var texture = (catcher.CurrentDrawableCatcher as TextureAnimation)?.CurrentFrame ?? ((Sprite)catcher.CurrentDrawableCatcher).Texture;
CatcherTrailSprite sprite = trailPool.Get(); CatcherTrailSprite sprite = trailPool.Get();
sprite.Texture = texture; sprite.Texture = catcher.CurrentTexture;
sprite.Anchor = catcher.Anchor; sprite.Anchor = catcher.Anchor;
sprite.Scale = catcher.Scale; sprite.Scale = catcher.Scale;
sprite.Blending = BlendingParameters.Additive; sprite.Blending = BlendingParameters.Additive;

View File

@ -0,0 +1,116 @@
// 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;
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio.Sample;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.OpenGL.Textures;
using osu.Framework.Graphics.Textures;
using osu.Framework.Testing;
using osu.Game.Audio;
using osu.Game.Configuration;
using osu.Game.Rulesets.Osu;
using osu.Game.Skinning;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Visual;
namespace osu.Game.Tests.Skins
{
[TestFixture]
[HeadlessTest]
public class TestSceneBeatmapSkinLookupDisables : OsuTestScene
{
private UserSkinSource userSource;
private BeatmapSkinSource beatmapSource;
private SkinRequester requester;
[Resolved]
private OsuConfigManager config { get; set; }
[SetUp]
public void SetUp() => Schedule(() =>
{
Add(new SkinProvidingContainer(userSource = new UserSkinSource())
.WithChild(new BeatmapSkinProvidingContainer(beatmapSource = new BeatmapSkinSource())
.WithChild(requester = new SkinRequester())));
});
[TestCase(false)]
[TestCase(true)]
public void TestDrawableLookup(bool allowBeatmapLookups)
{
AddStep($"Set beatmap skin enabled to {allowBeatmapLookups}", () => config.SetValue(OsuSetting.BeatmapSkins, allowBeatmapLookups));
string expected = allowBeatmapLookups ? "beatmap" : "user";
AddAssert($"Check lookup is from {expected}", () => requester.GetDrawableComponent(new TestSkinComponent())?.Name == expected);
}
[TestCase(false)]
[TestCase(true)]
public void TestProviderLookup(bool allowBeatmapLookups)
{
AddStep($"Set beatmap skin enabled to {allowBeatmapLookups}", () => config.SetValue(OsuSetting.BeatmapSkins, allowBeatmapLookups));
ISkin expected() => allowBeatmapLookups ? (ISkin)beatmapSource : userSource;
AddAssert("Check lookup is from correct source", () => requester.FindProvider(s => s.GetDrawableComponent(new TestSkinComponent()) != null) == expected());
}
public class UserSkinSource : LegacySkin
{
public UserSkinSource()
: base(new SkinInfo(), null, null, string.Empty)
{
}
public override Drawable GetDrawableComponent(ISkinComponent component)
{
return new Container { Name = "user" };
}
}
public class BeatmapSkinSource : LegacyBeatmapSkin
{
public BeatmapSkinSource()
: base(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo, null, null)
{
}
public override Drawable GetDrawableComponent(ISkinComponent component)
{
return new Container { Name = "beatmap" };
}
}
public class SkinRequester : Drawable, ISkin
{
private ISkinSource skin;
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
this.skin = skin;
}
public Drawable GetDrawableComponent(ISkinComponent component) => skin.GetDrawableComponent(component);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) => skin.GetTexture(componentName, wrapModeS, wrapModeT);
public ISample GetSample(ISampleInfo sampleInfo) => skin.GetSample(sampleInfo);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) => skin.GetConfig<TLookup, TValue>(lookup);
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) => skin.FindProvider(lookupFunction);
}
private class TestSkinComponent : ISkinComponent
{
public string LookupName => string.Empty;
}
}
}

View File

@ -143,6 +143,25 @@ Line after image";
}); });
} }
[Test]
public void TestTableWithImageContent()
{
AddStep("Add Table", () =>
{
markdownContainer.DocumentUrl = "https://dev.ppy.sh";
markdownContainer.Text = @"
| Image | Name | Effect |
| :-: | :-: | :-- |
| ![](/wiki/Skinning/Interface/img/hit300.png ""300"") | 300 | A possible score when tapping a hit circle precisely on time, completing a Slider and keeping the cursor over every tick, or completing a Spinner with the Spinner Metre full. A score of 300 appears in an blue score by default. Scoring nothing except 300s in a beatmap will award the player with the SS or SSH grade. |
| ![](/wiki/Skinning/Interface/img/hit300g.png ""Geki"") | (激) Geki | A term from Ouendan, called Elite Beat! in EBA. Appears when playing the last element in a combo in which the player has scored only 300s. Getting a Geki will give a sizable boost to the Life Bar. By default, it is blue. |
| ![](/wiki/Skinning/Interface/img/hit100.png ""100"") | 100 | A possible score one can get when tapping a Hit Object slightly late or early, completing a Slider and missing a number of ticks, or completing a Spinner with the Spinner Meter almost full. A score of 100 appears in a green score by default. When very skilled players test a beatmap and they get a lot of 100s, this may mean that the beatmap does not have correct timing. |
| ![](/wiki/Skinning/Interface/img/hit300k.png ""300 Katu"") ![](/wiki/Skinning/Interface/img/hit100k.png ""100 Katu"") | (喝) Katu or Katsu | A term from Ouendan, called Beat! in EBA. Appears when playing the last element in a combo in which the player has scored at least one 100, but no 50s or misses. Getting a Katu will give a small boost to the Life Bar. By default, it is coloured green or blue depending on whether the Katu itself is a 100 or a 300. |
| ![](/wiki/Skinning/Interface/img/hit50.png ""50"") | 50 | A possible score one can get when tapping a hit circle rather early or late but not early or late enough to cause a miss, completing a Slider and missing a lot of ticks, or completing a Spinner with the Spinner Metre close to full. A score of 50 appears in a orange score by default. Scoring a 50 in a combo will prevent the appearance of a Katu or a Geki at the combo's end. |
| ![](/wiki/Skinning/Interface/img/hit0.png ""Miss"") | Miss | A possible score one can get when not tapping a hit circle or too early (based on OD and AR, it may *shake* instead), not tapping or holding the Slider at least once, or completing a Spinner with low Spinner Metre fill. Scoring a Miss will reset the current combo to 0 and will prevent the appearance of a Katu or a Geki at the combo's end. |
";
});
}
private class TestMarkdownContainer : WikiMarkdownContainer private class TestMarkdownContainer : WikiMarkdownContainer
{ {
public LinkInline Link; public LinkInline Link;

View File

@ -2,11 +2,14 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Graphics.UserInterfaceV2;
using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Tests.Visual.UserInterface namespace osu.Game.Tests.Visual.UserInterface
@ -21,6 +24,45 @@ namespace osu.Game.Tests.Visual.UserInterface
[TestCase(true)] [TestCase(true)]
public void TestNonPadded(bool hasDescription) => createPaddedComponent(hasDescription, false); public void TestNonPadded(bool hasDescription) => createPaddedComponent(hasDescription, false);
[Test]
public void TestFixedWidth()
{
const float label_width = 200;
AddStep("create components", () => Child = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 10),
Children = new Drawable[]
{
new NonPaddedLabelledDrawable
{
Label = "short",
FixedLabelWidth = label_width
},
new NonPaddedLabelledDrawable
{
Label = "very very very very very very very very very very very long",
FixedLabelWidth = label_width
},
new PaddedLabelledDrawable
{
Label = "short",
FixedLabelWidth = label_width
},
new PaddedLabelledDrawable
{
Label = "very very very very very very very very very very very long",
FixedLabelWidth = label_width
}
}
});
AddStep("unset label width", () => this.ChildrenOfType<LabelledDrawable<Drawable>>().ForEach(d => d.FixedLabelWidth = null));
AddStep("reset label width", () => this.ChildrenOfType<LabelledDrawable<Drawable>>().ForEach(d => d.FixedLabelWidth = label_width));
}
private void createPaddedComponent(bool hasDescription = false, bool padded = true) private void createPaddedComponent(bool hasDescription = false, bool padded = true)
{ {
AddStep("create component", () => AddStep("create component", () =>

View File

@ -0,0 +1,20 @@
// 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 Markdig.Syntax.Inlines;
using osu.Framework.Graphics.Containers.Markdown;
using osu.Framework.Graphics.Cursor;
namespace osu.Game.Graphics.Containers.Markdown
{
public class OsuMarkdownImage : MarkdownImage, IHasTooltip
{
public string TooltipText { get; }
public OsuMarkdownImage(LinkInline linkInline)
: base(linkInline.Url)
{
TooltipText = linkInline.Title;
}
}
}

View File

@ -17,6 +17,8 @@ namespace osu.Game.Graphics.Containers.Markdown
protected override void AddLinkText(string text, LinkInline linkInline) protected override void AddLinkText(string text, LinkInline linkInline)
=> AddDrawable(new OsuMarkdownLinkText(text, linkInline)); => AddDrawable(new OsuMarkdownLinkText(text, linkInline));
protected override void AddImage(LinkInline linkInline) => AddDrawable(new OsuMarkdownImage(linkInline));
// TODO : Change font to monospace // TODO : Change font to monospace
protected override void AddCodeInLine(CodeInline codeInline) => AddDrawable(new OsuMarkdownInlineCode protected override void AddCodeInLine(CodeInline codeInline) => AddDrawable(new OsuMarkdownInlineCode
{ {

View File

@ -14,6 +14,27 @@ namespace osu.Game.Graphics.UserInterfaceV2
public abstract class LabelledDrawable<T> : CompositeDrawable public abstract class LabelledDrawable<T> : CompositeDrawable
where T : Drawable where T : Drawable
{ {
private float? fixedLabelWidth;
/// <summary>
/// The fixed width of the label of this <see cref="LabelledDrawable{T}"/>.
/// If <c>null</c>, the label portion will auto-size to its content.
/// Can be used in layout scenarios where several labels must match in length for the components to be aligned properly.
/// </summary>
public float? FixedLabelWidth
{
get => fixedLabelWidth;
set
{
if (fixedLabelWidth == value)
return;
fixedLabelWidth = value;
updateLabelWidth();
}
}
protected const float CONTENT_PADDING_VERTICAL = 10; protected const float CONTENT_PADDING_VERTICAL = 10;
protected const float CONTENT_PADDING_HORIZONTAL = 15; protected const float CONTENT_PADDING_HORIZONTAL = 15;
protected const float CORNER_RADIUS = 15; protected const float CORNER_RADIUS = 15;
@ -23,6 +44,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
/// </summary> /// </summary>
protected readonly T Component; protected readonly T Component;
private readonly GridContainer grid;
private readonly OsuTextFlowContainer labelText; private readonly OsuTextFlowContainer labelText;
private readonly OsuTextFlowContainer descriptionText; private readonly OsuTextFlowContainer descriptionText;
@ -56,7 +78,7 @@ namespace osu.Game.Graphics.UserInterfaceV2
Spacing = new Vector2(0, 12), Spacing = new Vector2(0, 12),
Children = new Drawable[] Children = new Drawable[]
{ {
new GridContainer grid = new GridContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
@ -69,7 +91,13 @@ namespace osu.Game.Graphics.UserInterfaceV2
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Padding = new MarginPadding { Right = 20 } Padding = new MarginPadding
{
Right = 20,
// ensure that the label is always vertically padded even if the component itself isn't.
// this may become an issue if the label is taller than the component.
Vertical = padded ? 0 : CONTENT_PADDING_VERTICAL
}
}, },
new Container new Container
{ {
@ -87,7 +115,6 @@ namespace osu.Game.Graphics.UserInterfaceV2
}, },
}, },
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }, RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) },
ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
}, },
descriptionText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold, italics: true)) descriptionText = new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold, italics: true))
{ {
@ -99,6 +126,24 @@ namespace osu.Game.Graphics.UserInterfaceV2
} }
} }
}; };
updateLabelWidth();
}
private void updateLabelWidth()
{
if (fixedLabelWidth == null)
{
grid.ColumnDimensions = new[] { new Dimension(GridSizeMode.AutoSize) };
labelText.RelativeSizeAxes = Axes.None;
labelText.AutoSizeAxes = Axes.Both;
}
else
{
grid.ColumnDimensions = new[] { new Dimension(GridSizeMode.Absolute, fixedLabelWidth.Value) };
labelText.AutoSizeAxes = Axes.Y;
labelText.RelativeSizeAxes = Axes.X;
}
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -2,19 +2,15 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using Markdig.Syntax.Inlines; using Markdig.Syntax.Inlines;
using osu.Framework.Graphics.Containers.Markdown; using osu.Game.Graphics.Containers.Markdown;
using osu.Framework.Graphics.Cursor;
namespace osu.Game.Overlays.Wiki.Markdown namespace osu.Game.Overlays.Wiki.Markdown
{ {
public class WikiMarkdownImage : MarkdownImage, IHasTooltip public class WikiMarkdownImage : OsuMarkdownImage
{ {
public string TooltipText { get; }
public WikiMarkdownImage(LinkInline linkInline) public WikiMarkdownImage(LinkInline linkInline)
: base(linkInline.Url) : base(linkInline)
{ {
TooltipText = linkInline.Title;
} }
protected override ImageContainer CreateImageContainer(string url) protected override ImageContainer CreateImageContainer(string url)

View File

@ -25,6 +25,7 @@ namespace osu.Game.Screens.Edit.Setup
comboColours = new LabelledColourPalette comboColours = new LabelledColourPalette
{ {
Label = "Hitcircle / Slider Combos", Label = "Hitcircle / Slider Combos",
FixedLabelWidth = LABEL_WIDTH,
ColourNamePrefix = "Combo" ColourNamePrefix = "Combo"
} }
}; };

View File

@ -28,6 +28,7 @@ namespace osu.Game.Screens.Edit.Setup
circleSizeSlider = new LabelledSliderBar<float> circleSizeSlider = new LabelledSliderBar<float>
{ {
Label = "Object Size", Label = "Object Size",
FixedLabelWidth = LABEL_WIDTH,
Description = "The size of all hit objects", Description = "The size of all hit objects",
Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.CircleSize) Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.CircleSize)
{ {
@ -40,6 +41,7 @@ namespace osu.Game.Screens.Edit.Setup
healthDrainSlider = new LabelledSliderBar<float> healthDrainSlider = new LabelledSliderBar<float>
{ {
Label = "Health Drain", Label = "Health Drain",
FixedLabelWidth = LABEL_WIDTH,
Description = "The rate of passive health drain throughout playable time", Description = "The rate of passive health drain throughout playable time",
Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.DrainRate) Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.DrainRate)
{ {
@ -52,6 +54,7 @@ namespace osu.Game.Screens.Edit.Setup
approachRateSlider = new LabelledSliderBar<float> approachRateSlider = new LabelledSliderBar<float>
{ {
Label = "Approach Rate", Label = "Approach Rate",
FixedLabelWidth = LABEL_WIDTH,
Description = "The speed at which objects are presented to the player", Description = "The speed at which objects are presented to the player",
Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate) Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.ApproachRate)
{ {
@ -64,6 +67,7 @@ namespace osu.Game.Screens.Edit.Setup
overallDifficultySlider = new LabelledSliderBar<float> overallDifficultySlider = new LabelledSliderBar<float>
{ {
Label = "Overall Difficulty", Label = "Overall Difficulty",
FixedLabelWidth = LABEL_WIDTH,
Description = "The harshness of hit windows and difficulty of special objects (ie. spinners)", Description = "The harshness of hit windows and difficulty of special objects (ie. spinners)",
Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty) Current = new BindableFloat(Beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty)
{ {

View File

@ -27,24 +27,28 @@ namespace osu.Game.Screens.Edit.Setup
artistTextBox = new LabelledTextBox artistTextBox = new LabelledTextBox
{ {
Label = "Artist", Label = "Artist",
FixedLabelWidth = LABEL_WIDTH,
Current = { Value = Beatmap.Metadata.Artist }, Current = { Value = Beatmap.Metadata.Artist },
TabbableContentContainer = this TabbableContentContainer = this
}, },
titleTextBox = new LabelledTextBox titleTextBox = new LabelledTextBox
{ {
Label = "Title", Label = "Title",
FixedLabelWidth = LABEL_WIDTH,
Current = { Value = Beatmap.Metadata.Title }, Current = { Value = Beatmap.Metadata.Title },
TabbableContentContainer = this TabbableContentContainer = this
}, },
creatorTextBox = new LabelledTextBox creatorTextBox = new LabelledTextBox
{ {
Label = "Creator", Label = "Creator",
FixedLabelWidth = LABEL_WIDTH,
Current = { Value = Beatmap.Metadata.AuthorString }, Current = { Value = Beatmap.Metadata.AuthorString },
TabbableContentContainer = this TabbableContentContainer = this
}, },
difficultyTextBox = new LabelledTextBox difficultyTextBox = new LabelledTextBox
{ {
Label = "Difficulty Name", Label = "Difficulty Name",
FixedLabelWidth = LABEL_WIDTH,
Current = { Value = Beatmap.BeatmapInfo.Version }, Current = { Value = Beatmap.BeatmapInfo.Version },
TabbableContentContainer = this TabbableContentContainer = this
}, },

View File

@ -54,6 +54,7 @@ namespace osu.Game.Screens.Edit.Setup
backgroundTextBox = new FileChooserLabelledTextBox(".jpg", ".jpeg", ".png") backgroundTextBox = new FileChooserLabelledTextBox(".jpg", ".jpeg", ".png")
{ {
Label = "Background", Label = "Background",
FixedLabelWidth = LABEL_WIDTH,
PlaceholderText = "Click to select a background image", PlaceholderText = "Click to select a background image",
Current = { Value = working.Value.Metadata.BackgroundFile }, Current = { Value = working.Value.Metadata.BackgroundFile },
Target = backgroundFileChooserContainer, Target = backgroundFileChooserContainer,
@ -72,6 +73,7 @@ namespace osu.Game.Screens.Edit.Setup
audioTrackTextBox = new FileChooserLabelledTextBox(".mp3", ".ogg") audioTrackTextBox = new FileChooserLabelledTextBox(".mp3", ".ogg")
{ {
Label = "Audio Track", Label = "Audio Track",
FixedLabelWidth = LABEL_WIDTH,
PlaceholderText = "Click to select a track", PlaceholderText = "Click to select a track",
Current = { Value = working.Value.Metadata.AudioFile }, Current = { Value = working.Value.Metadata.AudioFile },
Target = audioTrackFileChooserContainer, Target = audioTrackFileChooserContainer,

View File

@ -7,6 +7,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterfaceV2;
using osuTK; using osuTK;
namespace osu.Game.Screens.Edit.Setup namespace osu.Game.Screens.Edit.Setup
@ -15,6 +16,11 @@ namespace osu.Game.Screens.Edit.Setup
{ {
private readonly FillFlowContainer flow; private readonly FillFlowContainer flow;
/// <summary>
/// Used to align some of the child <see cref="LabelledDrawable{T}"/>s together to achieve a grid-like look.
/// </summary>
protected const float LABEL_WIDTH = 160;
[Resolved] [Resolved]
protected OsuColour Colours { get; private set; } protected OsuColour Colours { get; private set; }

View File

@ -298,7 +298,7 @@ namespace osu.Game.Screens.Ranking
ScorePanelList.HandleInput = false; ScorePanelList.HandleInput = false;
// Dim background. // Dim background.
ApplyToBackground(b => b.FadeTo(0.1f, 150)); ApplyToBackground(b => b.FadeColour(OsuColour.Gray(0.1f), 150));
detachedPanel = expandedPanel; detachedPanel = expandedPanel;
} }
@ -322,7 +322,7 @@ namespace osu.Game.Screens.Ranking
ScorePanelList.HandleInput = true; ScorePanelList.HandleInput = true;
// Un-dim background. // Un-dim background.
ApplyToBackground(b => b.FadeTo(0.5f, 150)); ApplyToBackground(b => b.FadeColour(OsuColour.Gray(0.5f), 150));
detachedPanel = null; detachedPanel = null;
} }

View File

@ -8,9 +8,11 @@ using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Events;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Scoring; using osu.Game.Scoring;
using osuTK; using osuTK;
using osuTK.Input;
namespace osu.Game.Screens.Ranking namespace osu.Game.Screens.Ranking
{ {
@ -263,6 +265,26 @@ namespace osu.Game.Screens.Ranking
container.Attach(); container.Attach();
} }
protected override bool OnKeyDown(KeyDownEvent e)
{
var expandedPanelIndex = flow.GetPanelIndex(expandedPanel.Score);
switch (e.Key)
{
case Key.Left:
if (expandedPanelIndex > 0)
SelectedScore.Value = flow.Children[expandedPanelIndex - 1].Panel.Score;
return true;
case Key.Right:
if (expandedPanelIndex < flow.Count - 1)
SelectedScore.Value = flow.Children[expandedPanelIndex + 1].Panel.Score;
return true;
}
return base.OnKeyDown(e);
}
private class Flow : FillFlowContainer<ScorePanelTrackingContainer> private class Flow : FillFlowContainer<ScorePanelTrackingContainer>
{ {
public override IEnumerable<Drawable> FlowingChildren => applySorting(AliveInternalChildren); public override IEnumerable<Drawable> FlowingChildren => applySorting(AliveInternalChildren);

View File

@ -53,8 +53,8 @@ namespace osu.Game.Skinning
public event Action SourceChanged public event Action SourceChanged
{ {
add { throw new NotSupportedException(); } add => Source.SourceChanged += value;
remove { } remove => Source.SourceChanged -= value;
} }
} }
} }

View File

@ -50,6 +50,8 @@ namespace osu.Game.Skinning
private readonly Skin defaultLegacySkin; private readonly Skin defaultLegacySkin;
private readonly Skin defaultSkin;
public SkinManager(Storage storage, DatabaseContextFactory contextFactory, GameHost host, IResourceStore<byte[]> resources, AudioManager audio) public SkinManager(Storage storage, DatabaseContextFactory contextFactory, GameHost host, IResourceStore<byte[]> resources, AudioManager audio)
: base(storage, contextFactory, new SkinStore(contextFactory, storage), host) : base(storage, contextFactory, new SkinStore(contextFactory, storage), host)
{ {
@ -58,10 +60,11 @@ namespace osu.Game.Skinning
this.resources = resources; this.resources = resources;
defaultLegacySkin = new DefaultLegacySkin(this); defaultLegacySkin = new DefaultLegacySkin(this);
defaultSkin = new DefaultSkin(this);
CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue); CurrentSkinInfo.ValueChanged += skin => CurrentSkin.Value = GetSkin(skin.NewValue);
CurrentSkin.Value = new DefaultSkin(this); CurrentSkin.Value = defaultSkin;
CurrentSkin.ValueChanged += skin => CurrentSkin.ValueChanged += skin =>
{ {
if (skin.NewValue.SkinInfo != CurrentSkinInfo.Value) if (skin.NewValue.SkinInfo != CurrentSkinInfo.Value)
@ -226,24 +229,26 @@ namespace osu.Game.Skinning
if (CurrentSkin.Value is LegacySkin && lookupFunction(defaultLegacySkin)) if (CurrentSkin.Value is LegacySkin && lookupFunction(defaultLegacySkin))
return defaultLegacySkin; return defaultLegacySkin;
if (lookupFunction(defaultSkin))
return defaultSkin;
return null; return null;
} }
private T lookupWithFallback<T>(Func<ISkin, T> func) private T lookupWithFallback<T>(Func<ISkin, T> lookupFunction)
where T : class where T : class
{ {
var selectedSkin = func(CurrentSkin.Value); if (lookupFunction(CurrentSkin.Value) is T skinSourced)
return skinSourced;
if (selectedSkin != null)
return selectedSkin;
// TODO: we also want to return a DefaultLegacySkin here if the current *beatmap* is providing any skinned elements. // TODO: we also want to return a DefaultLegacySkin here if the current *beatmap* is providing any skinned elements.
// When attempting to address this, we may want to move the full DefaultLegacySkin fallback logic to within Player itself (to better allow // When attempting to address this, we may want to move the full DefaultLegacySkin fallback logic to within Player itself (to better allow
// for beatmap skin visibility). // for beatmap skin visibility).
if (CurrentSkin.Value is LegacySkin) if (CurrentSkin.Value is LegacySkin && lookupFunction(defaultLegacySkin) is T legacySourced)
return func(defaultLegacySkin); return legacySourced;
return null; // Finally fall back to the (non-legacy) default.
return lookupFunction(defaultSkin);
} }
#region IResourceStorageProvider #region IResourceStorageProvider

View File

@ -27,6 +27,8 @@ namespace osu.Game.Skinning
[CanBeNull] [CanBeNull]
private ISkinSource fallbackSource; private ISkinSource fallbackSource;
private readonly NoFallbackProxy noFallbackLookupProxy;
protected virtual bool AllowDrawableLookup(ISkinComponent component) => true; protected virtual bool AllowDrawableLookup(ISkinComponent component) => true;
protected virtual bool AllowTextureLookup(string componentName) => true; protected virtual bool AllowTextureLookup(string componentName) => true;
@ -42,6 +44,11 @@ namespace osu.Game.Skinning
this.skin = skin; this.skin = skin;
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
noFallbackLookupProxy = new NoFallbackProxy(this);
if (skin is ISkinSource source)
source.SourceChanged += TriggerSourceChanged;
} }
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) public ISkin FindProvider(Func<ISkin, bool> lookupFunction)
@ -53,7 +60,8 @@ namespace osu.Game.Skinning
} }
else if (skin != null) else if (skin != null)
{ {
if (lookupFunction(skin)) // a proxy must be used here to correctly pass through the "Allow" checks without implicitly falling back to the fallbackSource.
if (lookupFunction(noFallbackLookupProxy))
return skin; return skin;
} }
@ -61,46 +69,70 @@ namespace osu.Game.Skinning
} }
public Drawable GetDrawableComponent(ISkinComponent component) public Drawable GetDrawableComponent(ISkinComponent component)
=> GetDrawableComponent(component, true);
public Drawable GetDrawableComponent(ISkinComponent component, bool fallback)
{ {
Drawable sourceDrawable; Drawable sourceDrawable;
if (AllowDrawableLookup(component) && (sourceDrawable = skin?.GetDrawableComponent(component)) != null) if (AllowDrawableLookup(component) && (sourceDrawable = skin?.GetDrawableComponent(component)) != null)
return sourceDrawable; return sourceDrawable;
if (!fallback)
return null;
return fallbackSource?.GetDrawableComponent(component); return fallbackSource?.GetDrawableComponent(component);
} }
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT) public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
=> GetTexture(componentName, wrapModeS, wrapModeT, true);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT, bool fallback)
{ {
Texture sourceTexture; Texture sourceTexture;
if (AllowTextureLookup(componentName) && (sourceTexture = skin?.GetTexture(componentName, wrapModeS, wrapModeT)) != null) if (AllowTextureLookup(componentName) && (sourceTexture = skin?.GetTexture(componentName, wrapModeS, wrapModeT)) != null)
return sourceTexture; return sourceTexture;
if (!fallback)
return null;
return fallbackSource?.GetTexture(componentName, wrapModeS, wrapModeT); return fallbackSource?.GetTexture(componentName, wrapModeS, wrapModeT);
} }
public ISample GetSample(ISampleInfo sampleInfo) public ISample GetSample(ISampleInfo sampleInfo)
=> GetSample(sampleInfo, true);
public ISample GetSample(ISampleInfo sampleInfo, bool fallback)
{ {
ISample sourceChannel; ISample sourceChannel;
if (AllowSampleLookup(sampleInfo) && (sourceChannel = skin?.GetSample(sampleInfo)) != null) if (AllowSampleLookup(sampleInfo) && (sourceChannel = skin?.GetSample(sampleInfo)) != null)
return sourceChannel; return sourceChannel;
if (!fallback)
return null;
return fallbackSource?.GetSample(sampleInfo); return fallbackSource?.GetSample(sampleInfo);
} }
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup) public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
=> GetConfig<TLookup, TValue>(lookup, true);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup, bool fallback)
{ {
if (skin != null) if (skin != null)
{ {
if (lookup is GlobalSkinColours || lookup is SkinCustomColourLookup) if (lookup is GlobalSkinColours || lookup is SkinCustomColourLookup)
return lookupWithFallback<TLookup, TValue>(lookup, AllowColourLookup); return lookupWithFallback<TLookup, TValue>(lookup, AllowColourLookup, fallback);
return lookupWithFallback<TLookup, TValue>(lookup, AllowConfigurationLookup); return lookupWithFallback<TLookup, TValue>(lookup, AllowConfigurationLookup, fallback);
} }
if (!fallback)
return null;
return fallbackSource?.GetConfig<TLookup, TValue>(lookup); return fallbackSource?.GetConfig<TLookup, TValue>(lookup);
} }
private IBindable<TValue> lookupWithFallback<TLookup, TValue>(TLookup lookup, bool canUseSkinLookup) private IBindable<TValue> lookupWithFallback<TLookup, TValue>(TLookup lookup, bool canUseSkinLookup, bool canUseFallback)
{ {
if (canUseSkinLookup) if (canUseSkinLookup)
{ {
@ -109,6 +141,9 @@ namespace osu.Game.Skinning
return bindable; return bindable;
} }
if (!canUseFallback)
return null;
return fallbackSource?.GetConfig<TLookup, TValue>(lookup); return fallbackSource?.GetConfig<TLookup, TValue>(lookup);
} }
@ -136,6 +171,40 @@ namespace osu.Game.Skinning
if (fallbackSource != null) if (fallbackSource != null)
fallbackSource.SourceChanged -= TriggerSourceChanged; fallbackSource.SourceChanged -= TriggerSourceChanged;
if (skin is ISkinSource source)
source.SourceChanged -= TriggerSourceChanged;
}
private class NoFallbackProxy : ISkinSource
{
private readonly SkinProvidingContainer provider;
public NoFallbackProxy(SkinProvidingContainer provider)
{
this.provider = provider;
}
public Drawable GetDrawableComponent(ISkinComponent component)
=> provider.GetDrawableComponent(component, false);
public Texture GetTexture(string componentName, WrapMode wrapModeS, WrapMode wrapModeT)
=> provider.GetTexture(componentName, wrapModeS, wrapModeT, false);
public ISample GetSample(ISampleInfo sampleInfo)
=> provider.GetSample(sampleInfo, false);
public IBindable<TValue> GetConfig<TLookup, TValue>(TLookup lookup)
=> provider.GetConfig<TLookup, TValue>(lookup, false);
public event Action SourceChanged
{
add => provider.SourceChanged += value;
remove => provider.SourceChanged -= value;
}
public ISkin FindProvider(Func<ISkin, bool> lookupFunction) =>
provider.FindProvider(lookupFunction);
} }
} }
} }