1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 17:27:24 +08:00

Merge pull request #11167 from Firmatorenio/mania-legacyskin-scoreposition

Adjust mania judgement position in legacy skins according to their ScorePosition setting
This commit is contained in:
Dean Herbert 2020-12-14 16:36:11 +09:00 committed by GitHub
commit 558955d65d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 123 additions and 34 deletions

View File

@ -0,0 +1,90 @@
// 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.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Rulesets.Scoring;
using osu.Game.Skinning;
using osuTK;
namespace osu.Game.Rulesets.Mania.Skinning.Legacy
{
public class LegacyManiaJudgementPiece : CompositeDrawable, IAnimatableJudgement
{
private readonly HitResult result;
private readonly Drawable animation;
public LegacyManiaJudgementPiece(HitResult result, Drawable animation)
{
this.result = result;
this.animation = animation;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
AutoSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
{
float? scorePosition = skin.GetManiaSkinConfig<float>(LegacyManiaSkinConfigurationLookups.ScorePosition)?.Value;
if (scorePosition != null)
scorePosition -= Stage.HIT_TARGET_POSITION + 150;
Y = scorePosition ?? 0;
if (animation != null)
{
InternalChild = animation.With(d =>
{
d.Anchor = Anchor.Centre;
d.Origin = Anchor.Centre;
});
}
}
public void PlayAnimation()
{
if (animation == null)
return;
(animation as IFramedAnimation)?.GotoFrame(0);
switch (result)
{
case HitResult.None:
break;
case HitResult.Miss:
animation.ScaleTo(1.6f);
animation.ScaleTo(1, 100, Easing.In);
animation.MoveTo(Vector2.Zero);
animation.MoveToOffset(new Vector2(0, 100), 800, Easing.InQuint);
animation.RotateTo(0);
animation.RotateTo(40, 800, Easing.InQuint);
this.FadeOutFromOne(800);
break;
default:
animation.ScaleTo(0.8f);
animation.ScaleTo(1, 250, Easing.OutElastic);
animation.Delay(50).ScaleTo(0.75f, 250);
this.Delay(50).FadeOut(200);
break;
}
}
public Drawable GetAboveHitObjectsProxiedContent() => null;
}
}

View File

@ -136,7 +136,8 @@ namespace osu.Game.Rulesets.Mania.Skinning.Legacy
string filename = this.GetManiaSkinConfig<string>(hitresult_mapping[result])?.Value
?? default_hitresult_skin_filenames[result];
return this.GetAnimation(filename, true, true);
var animation = this.GetAnimation(filename, true, true);
return animation == null ? null : new LegacyManiaJudgementPiece(result, animation);
}
public override SampleChannel GetSample(ISampleInfo sampleInfo)

View File

@ -5,7 +5,6 @@ using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osuTK;
namespace osu.Game.Rulesets.Mania.UI
{
@ -20,37 +19,6 @@ namespace osu.Game.Rulesets.Mania.UI
{
}
protected override void ApplyMissAnimations()
{
if (!(JudgementBody.Drawable is DefaultManiaJudgementPiece))
{
// this is temporary logic until mania's skin transformer returns IAnimatableJudgements
JudgementBody.ScaleTo(1.6f);
JudgementBody.ScaleTo(1, 100, Easing.In);
JudgementBody.MoveTo(Vector2.Zero);
JudgementBody.MoveToOffset(new Vector2(0, 100), 800, Easing.InQuint);
JudgementBody.RotateTo(0);
JudgementBody.RotateTo(40, 800, Easing.InQuint);
JudgementBody.FadeOutFromOne(800);
LifetimeEnd = JudgementBody.LatestTransformEndTime;
}
base.ApplyMissAnimations();
}
protected override void ApplyHitAnimations()
{
JudgementBody.ScaleTo(0.8f);
JudgementBody.ScaleTo(1, 250, Easing.OutElastic);
JudgementBody.Delay(50)
.ScaleTo(0.75f, 250)
.FadeOut(200);
}
protected override Drawable CreateDefaultJudgement(HitResult result) => new DefaultManiaJudgementPiece(result);
private class DefaultManiaJudgementPiece : DefaultJudgementPiece
@ -66,6 +34,27 @@ namespace osu.Game.Rulesets.Mania.UI
JudgementText.Font = JudgementText.Font.With(size: 25);
}
public override void PlayAnimation()
{
base.PlayAnimation();
switch (Result)
{
case HitResult.None:
case HitResult.Miss:
break;
default:
this.ScaleTo(0.8f);
this.ScaleTo(1, 250, Easing.OutElastic);
this.Delay(50)
.ScaleTo(0.75f, 250)
.FadeOut(200);
break;
}
}
}
}
}

View File

@ -106,7 +106,7 @@ namespace osu.Game.Rulesets.Mania.UI
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both,
Y = HIT_TARGET_POSITION + 150,
Y = HIT_TARGET_POSITION + 150
},
topLevelContainer = new Container { RelativeSizeAxes = Axes.Both }
}

View File

@ -35,6 +35,7 @@ namespace osu.Game.Skinning
public float HitPosition = (480 - 402) * POSITION_SCALE_FACTOR;
public float LightPosition = (480 - 413) * POSITION_SCALE_FACTOR;
public float ScorePosition = 300 * POSITION_SCALE_FACTOR;
public bool ShowJudgementLine = true;
public bool KeysUnderNotes;

View File

@ -25,6 +25,7 @@ namespace osu.Game.Skinning
LeftLineWidth,
RightLineWidth,
HitPosition,
ScorePosition,
LightPosition,
HitTargetImage,
ShowJudgementLine,

View File

@ -94,6 +94,10 @@ namespace osu.Game.Skinning
currentConfig.LightPosition = (480 - float.Parse(pair.Value, CultureInfo.InvariantCulture)) * LegacyManiaSkinConfiguration.POSITION_SCALE_FACTOR;
break;
case "ScorePosition":
currentConfig.ScorePosition = (float.Parse(pair.Value, CultureInfo.InvariantCulture)) * LegacyManiaSkinConfiguration.POSITION_SCALE_FACTOR;
break;
case "JudgementLine":
currentConfig.ShowJudgementLine = pair.Value == "1";
break;

View File

@ -169,6 +169,9 @@ namespace osu.Game.Skinning
case LegacyManiaSkinConfigurationLookups.HitPosition:
return SkinUtils.As<TValue>(new Bindable<float>(existing.HitPosition));
case LegacyManiaSkinConfigurationLookups.ScorePosition:
return SkinUtils.As<TValue>(new Bindable<float>(existing.ScorePosition));
case LegacyManiaSkinConfigurationLookups.LightPosition:
return SkinUtils.As<TValue>(new Bindable<float>(existing.LightPosition));