Merge branch 'master' into slider-ball-scaling

This commit is contained in:
Dean Herbert
2019-07-30 23:19:28 +09:00
committed by GitHub
21 changed files with 362 additions and 174 deletions

View File

@ -9,12 +9,17 @@ using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
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.Framework.IO.Stores;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
using osuTK.Graphics;
@ -38,6 +43,8 @@ namespace osu.Game.Skinning
{
}
private readonly bool hasHitCircle;
protected LegacySkin(SkinInfo skin, IResourceStore<byte[]> storage, AudioManager audioManager, string filename)
: base(skin)
{
@ -51,8 +58,6 @@ namespace osu.Game.Skinning
Samples = audioManager.GetSampleStore(storage);
Textures = new TextureStore(new TextureLoaderStore(storage));
bool hasHitCircle = false;
using (var testStream = storage.GetStream("hitcircle"))
hasHitCircle |= testStream != null;
@ -77,7 +82,13 @@ namespace osu.Game.Skinning
if (GetTexture("sliderb") != null)
return new LegacySliderBall();
break;
return null;
case "Play/osu/hitcircle":
if (hasHitCircle)
return new LegacyMainCirclePiece();
return null;
case "Play/Miss":
componentName = "hit0";
@ -261,5 +272,70 @@ namespace osu.Game.Skinning
return texture;
}
}
public class LegacyMainCirclePiece : CompositeDrawable
{
public LegacyMainCirclePiece()
{
Size = new Vector2(128);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
[BackgroundDependencyLoader]
private void load(DrawableHitObject drawableObject, ISkinSource skin)
{
Sprite hitCircleSprite;
InternalChildren = new Drawable[]
{
hitCircleSprite = new Sprite
{
Texture = skin.GetTexture("hitcircle"),
Colour = drawableObject.AccentColour.Value,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
new SkinnableSpriteText("Play/osu/number-text", _ => new OsuSpriteText
{
Font = OsuFont.Numeric.With(size: 40),
UseFullGlyphHeight = false,
}, confineMode: ConfineMode.NoScaling)
{
Text = (((IHasComboInformation)drawableObject.HitObject).IndexInCurrentCombo + 1).ToString()
},
new Sprite
{
Texture = skin.GetTexture("hitcircleoverlay"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
};
state.BindTo(drawableObject.State);
state.BindValueChanged(updateState, true);
accentColour.BindTo(drawableObject.AccentColour);
accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true);
}
private void updateState(ValueChangedEvent<ArmedState> state)
{
const double legacy_fade_duration = 240;
switch (state.NewValue)
{
case ArmedState.Hit:
this.FadeOut(legacy_fade_duration, Easing.Out);
this.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
break;
}
}
}
}
}