1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:52:55 +08:00

Add support for legacy skin "cursormiddle" display (#5465)

Add support for legacy skin "cursormiddle" display

Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
This commit is contained in:
Dean Herbert 2019-07-31 00:26:19 +09:00 committed by GitHub
commit 8caf9ade01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 127 additions and 72 deletions

View File

@ -18,6 +18,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
{
public class OsuCursor : SkinReloadableDrawable
{
private const float size = 28;
private bool cursorExpand;
private Bindable<double> cursorScale;
@ -30,7 +32,8 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
public OsuCursor()
{
Origin = Anchor.Centre;
Size = new Vector2(28);
Size = new Vector2(size);
}
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
@ -46,62 +49,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Child = scaleTarget = new SkinnableDrawable("cursor", _ => new CircularContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = Size.X / 6,
BorderColour = Color4.White,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Colour = Color4.Pink.Opacity(0.5f),
Radius = 5,
},
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = Size.X / 3,
BorderColour = Color4.White.Opacity(0.5f),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
},
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.1f),
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
},
},
}
}, confineMode: ConfineMode.NoScaling)
Child = scaleTarget = new SkinnableDrawable("Play/osu/cursor", _ => new DefaultCursor(), confineMode: ConfineMode.NoScaling)
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
@ -144,5 +92,76 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor
}
public void Contract() => expandTarget.ScaleTo(released_scale, 100, Easing.OutQuad);
private class DefaultCursor : CompositeDrawable
{
public DefaultCursor()
{
RelativeSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
InternalChildren = new Drawable[]
{
new CircularContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = size / 6,
BorderColour = Color4.White,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Colour = Color4.Pink.Opacity(0.5f),
Radius = 5,
},
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = size / 3,
BorderColour = Color4.White.Opacity(0.5f),
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Alpha = 0,
AlwaysPresent = true,
},
},
},
new CircularContainer
{
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Scale = new Vector2(0.1f),
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.White,
},
},
},
}
}
};
}
}
}
}

View File

@ -78,6 +78,12 @@ namespace osu.Game.Skinning
{
switch (componentName)
{
case "Play/osu/cursor":
if (GetTexture("cursor") != null)
return new LegacyCursor();
return null;
case "Play/osu/sliderball":
if (GetTexture("sliderb") != null)
return new LegacySliderBall();
@ -150,20 +156,8 @@ namespace osu.Game.Skinning
}
if (texture != null)
{
texture.ScaleAdjust = ratio;
switch (componentName)
{
case "cursormiddle":
case "cursortrail":
case "cursor":
// apply inverse of adjustment in OsuPlayfieldAdjustmentContainer for non-gameplay-scale textures.
texture.ScaleAdjust *= 1.6f;
break;
}
}
return texture;
}
@ -273,14 +267,42 @@ namespace osu.Game.Skinning
}
}
public class LegacyCursor : CompositeDrawable
{
public LegacyCursor()
{
Size = new Vector2(50);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
InternalChildren = new Drawable[]
{
new NonPlayfieldSprite
{
Texture = skin.GetTexture("cursormiddle"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
new NonPlayfieldSprite
{
Texture = skin.GetTexture("cursor"),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}
};
}
}
public class LegacyMainCirclePiece : CompositeDrawable
{
public LegacyMainCirclePiece()
{
Size = new Vector2(128);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
@ -337,5 +359,19 @@ namespace osu.Game.Skinning
}
}
}
private class NonPlayfieldSprite : Sprite
{
public override Texture Texture
{
get => base.Texture;
set
{
if (value != null)
value.ScaleAdjust *= 2f;
base.Texture = value;
}
}
}
}
}