Skip to content

Commit

Permalink
Merge branch 'master' into update-framework
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy authored Sep 16, 2021
2 parents edb1230 + df786af commit fde7c88
Show file tree
Hide file tree
Showing 11 changed files with 427 additions and 107 deletions.
5 changes: 3 additions & 2 deletions osu.Game.Rulesets.Osu.Tests/TestSceneSkinFallbacks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Rulesets.Osu.Skinning.Default;
using osu.Game.Skinning;
using osu.Game.Storyboards;
using osu.Game.Tests.Visual;
Expand Down Expand Up @@ -86,9 +87,9 @@ private void checkNextHitObject(string skin) =>
if (firstObject == null)
return false;

var skinnable = firstObject.ApproachCircle.Child as SkinnableDrawable;
var skinnable = firstObject.ApproachCircle;

if (skin == null && skinnable?.Drawable is Sprite)
if (skin == null && skinnable?.Drawable is DefaultApproachCircle)
// check for default skin provider
return true;

Expand Down
18 changes: 15 additions & 3 deletions osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class DrawableHitCircle : DrawableOsuHitObject, IHasMainCirclePiece, IHas
public OsuAction? HitAction => HitArea.HitAction;
protected virtual OsuSkinComponents CirclePieceComponent => OsuSkinComponents.HitCircle;

public ApproachCircle ApproachCircle { get; private set; }
public SkinnableDrawable ApproachCircle { get; private set; }
public HitReceptor HitArea { get; private set; }
public SkinnableDrawable CirclePiece { get; private set; }

Expand Down Expand Up @@ -75,8 +75,11 @@ private void load()
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
ApproachCircle = new ApproachCircle
ApproachCircle = new ProxyableSkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.ApproachCircle), _ => new DefaultApproachCircle())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Alpha = 0,
Scale = new Vector2(4),
}
Expand All @@ -89,7 +92,6 @@ private void load()
PositionBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
StackHeightBindable.BindValueChanged(_ => Position = HitObject.StackedPosition);
ScaleBindable.BindValueChanged(scale => scaleContainer.Scale = new Vector2(scale.NewValue));
AccentColour.BindValueChanged(accent => ApproachCircle.Colour = accent.NewValue);
}

protected override void LoadComplete()
Expand Down Expand Up @@ -251,5 +253,15 @@ public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)
{
}
}

private class ProxyableSkinnableDrawable : SkinnableDrawable
{
public override bool RemoveWhenNotAlive => false;

public ProxyableSkinnableDrawable(ISkinComponent component, Func<ISkinComponent, Drawable> defaultImplementation = null, ConfineMode confineMode = ConfineMode.NoScaling)
: base(component, defaultImplementation, confineMode)
{
}
}
}
}
1 change: 1 addition & 0 deletions osu.Game.Rulesets.Osu/OsuSkinComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public enum OsuSkinComponents
SliderBall,
SliderBody,
SpinnerBody,
ApproachCircle,
}
}
50 changes: 0 additions & 50 deletions osu.Game.Rulesets.Osu/Skinning/Default/ApproachCircle.cs

This file was deleted.

49 changes: 49 additions & 0 deletions osu.Game.Rulesets.Osu/Skinning/Default/DefaultApproachCircle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Osu.Skinning.Default
{
public class DefaultApproachCircle : SkinnableSprite
{
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();

[Resolved]
private DrawableHitObject drawableObject { get; set; }

public DefaultApproachCircle()
: base("Gameplay/osu/approachcircle")
{
}

[BackgroundDependencyLoader]
private void load()
{
accentColour.BindTo(drawableObject.AccentColour);
}

protected override void LoadComplete()
{
base.LoadComplete();
accentColour.BindValueChanged(colour => Colour = colour.NewValue, true);
}

protected override Drawable CreateDefault(ISkinComponent component)
{
var drawable = base.CreateDefault(component);

// Although this is a non-legacy component, osu-resources currently stores approach circle as a legacy-like texture.
// See LegacyApproachCircle for documentation as to why this is required.
drawable.Scale = new Vector2(128 / 118f);

return drawable;
}
}
}
49 changes: 49 additions & 0 deletions osu.Game.Rulesets.Osu/Skinning/Legacy/LegacyApproachCircle.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
public class LegacyApproachCircle : SkinnableSprite
{
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();

[Resolved]
private DrawableHitObject drawableObject { get; set; }

public LegacyApproachCircle()
: base("Gameplay/osu/approachcircle")
{
}

[BackgroundDependencyLoader]
private void load()
{
accentColour.BindTo(drawableObject.AccentColour);
}

protected override void LoadComplete()
{
base.LoadComplete();
accentColour.BindValueChanged(colour => Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true);
}

protected override Drawable CreateDefault(ISkinComponent component)
{
var drawable = base.CreateDefault(component);

// account for the sprite being used for the default approach circle being taken from stable,
// when hitcircles have 5px padding on each size. this should be removed if we update the sprite.
drawable.Scale = new Vector2(128 / 118f);

return drawable;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ public override Drawable GetDrawableComponent(ISkinComponent component)
return new LegacyOldStyleSpinner();

return null;

case OsuSkinComponents.ApproachCircle:
return new LegacyApproachCircle();
}
}

Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Tests/Visual/Settings/TestSceneKeyBindingPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private void checkBinding(string name, string keyName)
{
AddAssert($"Check {name} is bound to {keyName}", () =>
{
var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text == name));
var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == name));
var firstButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().First();

return firstButton.Text.Text == keyName;
Expand All @@ -247,7 +247,7 @@ private void scrollToAndStartBinding(string name)

AddStep($"Scroll to {name}", () =>
{
var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text == name));
var firstRow = panel.ChildrenOfType<KeyBindingRow>().First(r => r.ChildrenOfType<OsuSpriteText>().Any(s => s.Text.ToString() == name));
firstButton = firstRow.ChildrenOfType<KeyBindingRow.KeyButton>().First();

panel.ChildrenOfType<SettingsPanel.SettingsSectionsContainer>().First().ScrollTo(firstButton);
Expand Down
Loading

0 comments on commit fde7c88

Please sign in to comment.