mirror of https://github.com/ppy/osu
Remove `allowFallback` parameters completely
This commit is contained in:
parent
4fd89faaa4
commit
70a844ac10
|
@ -25,9 +25,9 @@ public CatchComboDisplay()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin);
|
||||||
ComboCounter?.UpdateCombo(currentCombo);
|
ComboCounter?.UpdateCombo(currentCombo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -399,9 +399,9 @@ private void runHyperDashStateTransition(bool hyperDashing)
|
||||||
|
|
||||||
private void updateTrailVisibility() => trails.DisplayTrail = Dashing || HyperDashing;
|
private void updateTrailVisibility() => trails.DisplayTrail = Dashing || HyperDashing;
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin);
|
||||||
|
|
||||||
hyperDashColour =
|
hyperDashColour =
|
||||||
skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value ??
|
skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value ??
|
||||||
|
|
|
@ -33,9 +33,9 @@ private void load(IScrollingInfo scrollingInfo)
|
||||||
Direction.BindValueChanged(onDirectionChanged, true);
|
Direction.BindValueChanged(onDirectionChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin);
|
||||||
UpdateHitPosition();
|
UpdateHitPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,9 +18,9 @@ public SkinnableLighting()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin);
|
||||||
updateColour();
|
updateColour();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ public OsuCursor()
|
||||||
Size = new Vector2(size);
|
Size = new Vector2(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
cursorExpand = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorExpand)?.Value ?? true;
|
cursorExpand = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.CursorExpand)?.Value ?? true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,9 +42,9 @@ public void TestConfineScaleDown()
|
||||||
Spacing = new Vector2(10),
|
Spacing = new Vector2(10),
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new ExposedSkinnableDrawable("default", _ => new DefaultBox(), _ => true),
|
new ExposedSkinnableDrawable("default", _ => new DefaultBox()),
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true),
|
new ExposedSkinnableDrawable("available", _ => new DefaultBox()),
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.NoScaling)
|
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), ConfineMode.NoScaling)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -73,9 +73,9 @@ public void TestConfineScaleUp()
|
||||||
Spacing = new Vector2(10),
|
Spacing = new Vector2(10),
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new ExposedSkinnableDrawable("default", _ => new DefaultBox(), _ => true),
|
new ExposedSkinnableDrawable("default", _ => new DefaultBox()),
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.ScaleToFit),
|
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), ConfineMode.ScaleToFit),
|
||||||
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), _ => true, ConfineMode.NoScaling)
|
new ExposedSkinnableDrawable("available", _ => new DefaultBox(), ConfineMode.NoScaling)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -100,7 +100,7 @@ public void TestInitialLoad()
|
||||||
Child = new SkinProvidingContainer(secondarySource)
|
Child = new SkinProvidingContainer(secondarySource)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)
|
Child = consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -129,7 +129,7 @@ public void TestOverride()
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("add permissive", () => target.Add(consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)));
|
AddStep("add permissive", () => target.Add(consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"))));
|
||||||
AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
|
AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
|
||||||
AddAssert("skinchanged only called once", () => consumer.SkinChangedCount == 1);
|
AddAssert("skinchanged only called once", () => consumer.SkinChangedCount == 1);
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ public void TestSwitchOff()
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("add permissive", () => target.Add(consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"), source => true)));
|
AddStep("add permissive", () => target.Add(consumer = new SkinConsumer("test", name => new NamedBox("Default Implementation"))));
|
||||||
AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
|
AddAssert("consumer using override source", () => consumer.Drawable is SecondarySourceBox);
|
||||||
AddStep("disable", () => target.Disable());
|
AddStep("disable", () => target.Disable());
|
||||||
AddAssert("consumer using base source", () => consumer.Drawable is BaseSourceBox);
|
AddAssert("consumer using base source", () => consumer.Drawable is BaseSourceBox);
|
||||||
|
@ -180,9 +180,8 @@ private class ExposedSkinnableDrawable : SkinnableDrawable
|
||||||
{
|
{
|
||||||
public new Drawable Drawable => base.Drawable;
|
public new Drawable Drawable => base.Drawable;
|
||||||
|
|
||||||
public ExposedSkinnableDrawable(string name, Func<ISkinComponent, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null,
|
public ExposedSkinnableDrawable(string name, Func<ISkinComponent, Drawable> defaultImplementation, ConfineMode confineMode = ConfineMode.ScaleToFit)
|
||||||
ConfineMode confineMode = ConfineMode.ScaleToFit)
|
: base(new TestSkinComponent(name), defaultImplementation, confineMode)
|
||||||
: base(new TestSkinComponent(name), defaultImplementation, allowFallback, confineMode)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,14 +249,14 @@ private class SkinConsumer : SkinnableDrawable
|
||||||
public new Drawable Drawable => base.Drawable;
|
public new Drawable Drawable => base.Drawable;
|
||||||
public int SkinChangedCount { get; private set; }
|
public int SkinChangedCount { get; private set; }
|
||||||
|
|
||||||
public SkinConsumer(string name, Func<ISkinComponent, Drawable> defaultImplementation, Func<ISkinSource, bool> allowFallback = null)
|
public SkinConsumer(string name, Func<ISkinComponent, Drawable> defaultImplementation)
|
||||||
: base(new TestSkinComponent(name), defaultImplementation, allowFallback)
|
: base(new TestSkinComponent(name), defaultImplementation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin);
|
||||||
SkinChangedCount++;
|
SkinChangedCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,9 @@ public void Apply(ISampleInfo sampleInfo)
|
||||||
updateSample();
|
updateSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin);
|
||||||
updateSample();
|
updateSample();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,15 +88,6 @@ private void updateSample()
|
||||||
|
|
||||||
var sample = CurrentSkin.GetSample(sampleInfo);
|
var sample = CurrentSkin.GetSample(sampleInfo);
|
||||||
|
|
||||||
if (sample == null && AllowDefaultFallback)
|
|
||||||
{
|
|
||||||
foreach (var lookup in sampleInfo.LookupNames)
|
|
||||||
{
|
|
||||||
if ((sample = sampleStore.Get(lookup)) != null)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sample == null)
|
if (sample == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,9 @@ public SkinManager(Storage storage, DatabaseContextFactory contextFactory, GameH
|
||||||
|
|
||||||
this.legacyDefaultResources = legacyDefaultResources;
|
this.legacyDefaultResources = legacyDefaultResources;
|
||||||
|
|
||||||
CurrentSkin.Value = 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.ValueChanged += skin =>
|
CurrentSkin.ValueChanged += skin =>
|
||||||
{
|
{
|
||||||
if (skin.NewValue.SkinInfo != CurrentSkinInfo.Value)
|
if (skin.NewValue.SkinInfo != CurrentSkinInfo.Value)
|
||||||
|
|
|
@ -22,22 +22,6 @@ public abstract class SkinReloadableDrawable : PoolableDrawable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected ISkinSource CurrentSkin { get; private set; }
|
protected ISkinSource CurrentSkin { get; private set; }
|
||||||
|
|
||||||
private readonly Func<ISkinSource, bool> allowFallback;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether fallback to default skin should be allowed if the custom skin is missing this resource.
|
|
||||||
/// </summary>
|
|
||||||
protected bool AllowDefaultFallback => allowFallback == null || allowFallback.Invoke(CurrentSkin);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create a new <see cref="SkinReloadableDrawable"/>
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="allowFallback">A conditional to decide whether to allow fallback to the default implementation if a skinned element is not present.</param>
|
|
||||||
protected SkinReloadableDrawable(Func<ISkinSource, bool> allowFallback = null)
|
|
||||||
{
|
|
||||||
this.allowFallback = allowFallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource source)
|
private void load(ISkinSource source)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +42,7 @@ protected override void LoadAsyncComplete()
|
||||||
|
|
||||||
private void skinChanged()
|
private void skinChanged()
|
||||||
{
|
{
|
||||||
SkinChanged(CurrentSkin, AllowDefaultFallback);
|
SkinChanged(CurrentSkin);
|
||||||
OnSkinChanged?.Invoke();
|
OnSkinChanged?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +50,7 @@ private void skinChanged()
|
||||||
/// Called when a change is made to the skin.
|
/// Called when a change is made to the skin.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="skin">The new skin.</param>
|
/// <param name="skin">The new skin.</param>
|
||||||
/// <param name="allowFallback">Whether fallback to default skin should be allowed if the custom skin is missing this resource.</param>
|
protected virtual void SkinChanged(ISkinSource skin)
|
||||||
protected virtual void SkinChanged(ISkinSource skin, bool allowFallback)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,17 +40,14 @@ public class SkinnableDrawable : SkinReloadableDrawable
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="component">The namespace-complete resource name for this skinnable element.</param>
|
/// <param name="component">The namespace-complete resource name for this skinnable element.</param>
|
||||||
/// <param name="defaultImplementation">A function to create the default skin implementation of this element.</param>
|
/// <param name="defaultImplementation">A function to create the default skin implementation of this element.</param>
|
||||||
/// <param name="allowFallback">A conditional to decide whether to allow fallback to the default implementation if a skinned element is not present.</param>
|
|
||||||
/// <param name="confineMode">How (if at all) the <see cref="Drawable"/> should be resize to fit within our own bounds.</param>
|
/// <param name="confineMode">How (if at all) the <see cref="Drawable"/> should be resize to fit within our own bounds.</param>
|
||||||
public SkinnableDrawable(ISkinComponent component, Func<ISkinComponent, Drawable> defaultImplementation = null, Func<ISkinSource, bool> allowFallback = null,
|
public SkinnableDrawable(ISkinComponent component, Func<ISkinComponent, Drawable> defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||||
ConfineMode confineMode = ConfineMode.NoScaling)
|
: this(component, confineMode)
|
||||||
: this(component, allowFallback, confineMode)
|
|
||||||
{
|
{
|
||||||
createDefault = defaultImplementation;
|
createDefault = defaultImplementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SkinnableDrawable(ISkinComponent component, Func<ISkinSource, bool> allowFallback = null, ConfineMode confineMode = ConfineMode.NoScaling)
|
protected SkinnableDrawable(ISkinComponent component, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||||
: base(allowFallback)
|
|
||||||
{
|
{
|
||||||
this.component = component;
|
this.component = component;
|
||||||
this.confineMode = confineMode;
|
this.confineMode = confineMode;
|
||||||
|
@ -76,13 +73,13 @@ protected SkinnableDrawable(ISkinComponent component, Func<ISkinSource, bool> al
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool ApplySizeRestrictionsToDefault => false;
|
protected virtual bool ApplySizeRestrictionsToDefault => false;
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
Drawable = skin.GetDrawableComponent(component);
|
Drawable = skin.GetDrawableComponent(component);
|
||||||
|
|
||||||
isDefault = false;
|
isDefault = false;
|
||||||
|
|
||||||
if (Drawable == null && allowFallback)
|
if (Drawable == null)
|
||||||
{
|
{
|
||||||
Drawable = CreateDefault(component);
|
Drawable = CreateDefault(component);
|
||||||
isDefault = true;
|
isDefault = true;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
@ -19,8 +18,8 @@ public class SkinnableSprite : SkinnableDrawable
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private TextureStore textures { get; set; }
|
private TextureStore textures { get; set; }
|
||||||
|
|
||||||
public SkinnableSprite(string textureName, Func<ISkinSource, bool> allowFallback = null, ConfineMode confineMode = ConfineMode.NoScaling)
|
public SkinnableSprite(string textureName, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||||
: base(new SpriteComponent(textureName), allowFallback, confineMode)
|
: base(new SpriteComponent(textureName), confineMode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,14 +9,14 @@ namespace osu.Game.Skinning
|
||||||
{
|
{
|
||||||
public class SkinnableSpriteText : SkinnableDrawable, IHasText
|
public class SkinnableSpriteText : SkinnableDrawable, IHasText
|
||||||
{
|
{
|
||||||
public SkinnableSpriteText(ISkinComponent component, Func<ISkinComponent, SpriteText> defaultImplementation, Func<ISkinSource, bool> allowFallback = null, ConfineMode confineMode = ConfineMode.NoScaling)
|
public SkinnableSpriteText(ISkinComponent component, Func<ISkinComponent, SpriteText> defaultImplementation, ConfineMode confineMode = ConfineMode.NoScaling)
|
||||||
: base(component, defaultImplementation, allowFallback, confineMode)
|
: base(component, defaultImplementation, confineMode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin);
|
||||||
|
|
||||||
if (Drawable is IHasText textDrawable)
|
if (Drawable is IHasText textDrawable)
|
||||||
textDrawable.Text = Text;
|
textDrawable.Text = Text;
|
||||||
|
|
|
@ -73,9 +73,9 @@ public void Remove(ISkinnableDrawable component)
|
||||||
components.Remove(component);
|
components.Remove(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin);
|
||||||
|
|
||||||
Reload();
|
Reload();
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ public DrawableStoryboardSample(StoryboardSampleInfo sampleInfo)
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||||
|
|
||||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
protected override void SkinChanged(ISkinSource skin)
|
||||||
{
|
{
|
||||||
base.SkinChanged(skin, allowFallback);
|
base.SkinChanged(skin);
|
||||||
|
|
||||||
foreach (var mod in mods.Value.OfType<IApplicableToSample>())
|
foreach (var mod in mods.Value.OfType<IApplicableToSample>())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue