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

Replace deflate progress with modified copy-paste of grow mod

This commit is contained in:
MaxOhnh 2019-07-01 13:55:09 +02:00
parent 93b780c9a8
commit cd5e1bc4b1

View File

@ -1,84 +1,84 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Graphics; using osu.Framework.Graphics.Sprites;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables;
using System.Collections.Generic;
using OpenTK;
namespace osu.Game.Rulesets.Osu.Mods namespace osu.Game.Rulesets.Osu.Mods
{ {
public class OsuModDeflate : Mod, IApplicableToDrawableHitObjects public class OsuModDeflate : Mod, IReadFromConfig, IApplicableToDrawableHitObjects
{ {
public override string Name => "Deflate"; public override string Name => "Deflate";
public override string ShortenedName => "DF";
public override FontAwesome Icon => FontAwesome.fa_compress; public override string Acronym => "DF";
public override IconUsage Icon => FontAwesome.Solid.CompressArrowsAlt;
public override ModType Type => ModType.Fun; public override ModType Type => ModType.Fun;
public override string Description => "Become one with the approach circle..."; public override string Description => "Become one with the approach circle...";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;
private Bindable<bool> increaseFirstObjectVisibility = new Bindable<bool>();
public void ReadFromConfig(OsuConfigManager config)
{
increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
}
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables) public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{ {
foreach (var drawable in drawables) foreach (var drawable in drawables.Skip(increaseFirstObjectVisibility.Value ? 1 : 0))
drawable.ApplyCustomUpdateState += drawableOnApplyCustomUpdateState;
}
private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedState state)
{ {
if (!(drawable is DrawableOsuHitObject d))
return;
var h = d.HitObject;
const float rescale = 2;
switch (drawable) switch (drawable)
{ {
case DrawableHitCircle c: case DrawableSpinner _:
c.ApproachCircle.Hide(); continue;
using (d.BeginAbsoluteSequence(h.StartTime - h.TimePreempt))
{ default:
var origScale = d.Scale; drawable.ApplyCustomUpdateState += ApplyCustomState;
d.ScaleTo(1.1f, 1)
.Then()
.ScaleTo(origScale, h.TimePreempt);
}
switch (state)
{
case ArmedState.Miss:
d.FadeOut(100);
break;
case ArmedState.Hit:
d.FadeOut(800)
.ScaleTo(d.Scale * 1.5f, 400, Easing.OutQuad);
break; break;
} }
}
}
protected virtual void ApplyCustomState(DrawableHitObject drawable, ArmedState state)
{
var h = (OsuHitObject)drawable.HitObject;
// apply grow effect
switch (drawable)
{
case DrawableSliderHead _:
case DrawableSliderTail _:
// special cases we should *not* be scaling.
break; break;
case DrawableSlider s: case DrawableSlider _:
using (d.BeginAbsoluteSequence(h.StartTime - h.TimePreempt + 1, true)) case DrawableHitCircle _:
{ {
float origPathWidth = s.Body.PathWidth; using (drawable.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
var origBodySize = s.Body.Size; drawable.ScaleTo(2f).Then().ScaleTo(1f, h.TimePreempt); // sole difference to grow mod
var origBodyDrawPos = s.Body.DrawPosition; break;
// Fits nicely for CS=4, too big on lower CS, too small on higher CS
s.Body.Animate(
b => b.MoveTo(origBodyDrawPos - new Vector2(origPathWidth)).MoveTo(origBodyDrawPos, h.TimePreempt),
b => b.ResizeTo(origBodySize * rescale).ResizeTo(origBodySize, h.TimePreempt),
b => b.TransformTo("PathWidth", origPathWidth * rescale).TransformTo("PathWidth", origPathWidth, h.TimePreempt)
);
} }
break; }
case DrawableRepeatPoint rp:
if (!rp.IsFirstRepeat) // remove approach circles
break; switch (drawable)
var origSizeRp = rp.Size; {
using (d.BeginAbsoluteSequence(h.StartTime - h.TimePreempt + 1, true)) case DrawableHitCircle circle:
rp.ResizeTo(origSizeRp * rescale).ResizeTo(origSizeRp, h.TimePreempt); // we don't want to see the approach circle
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
circle.ApproachCircle.Hide();
break; break;
} }
} }