From cd5e1bc4b14297e4f4fd694240ab97f5b0f15df8 Mon Sep 17 00:00:00 2001 From: MaxOhnh Date: Mon, 1 Jul 2019 13:55:09 +0200 Subject: [PATCH] Replace deflate progress with modified copy-paste of grow mod --- osu.Game.Rulesets.Osu/Mods/OsuModDeflate.cs | 106 ++++++++++---------- 1 file changed, 53 insertions(+), 53 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModDeflate.cs b/osu.Game.Rulesets.Osu/Mods/OsuModDeflate.cs index 2638d5bf78..56f64d14b8 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModDeflate.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModDeflate.cs @@ -1,84 +1,84 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // 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.Game.Graphics; +using osu.Framework.Graphics.Sprites; +using osu.Game.Configuration; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; -using System.Collections.Generic; -using OpenTK; 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 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 string Description => "Become one with the approach circle..."; + public override double ScoreMultiplier => 1; + private Bindable increaseFirstObjectVisibility = new Bindable(); + + public void ReadFromConfig(OsuConfigManager config) + { + increaseFirstObjectVisibility = config.GetBindable(OsuSetting.IncreaseFirstObjectVisibility); + } + public void ApplyToDrawableHitObjects(IEnumerable drawables) { - foreach (var drawable in drawables) - drawable.ApplyCustomUpdateState += drawableOnApplyCustomUpdateState; + foreach (var drawable in drawables.Skip(increaseFirstObjectVisibility.Value ? 1 : 0)) + { + switch (drawable) + { + case DrawableSpinner _: + continue; + + default: + drawable.ApplyCustomUpdateState += ApplyCustomState; + break; + } + } } - private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedState state) + protected virtual void ApplyCustomState(DrawableHitObject drawable, ArmedState state) { - if (!(drawable is DrawableOsuHitObject d)) - return; - - var h = d.HitObject; - - const float rescale = 2; + var h = (OsuHitObject)drawable.HitObject; + // apply grow effect switch (drawable) { - case DrawableHitCircle c: - c.ApproachCircle.Hide(); - using (d.BeginAbsoluteSequence(h.StartTime - h.TimePreempt)) - { - var origScale = d.Scale; - 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; - } + case DrawableSliderHead _: + case DrawableSliderTail _: + // special cases we should *not* be scaling. break; - case DrawableSlider s: - using (d.BeginAbsoluteSequence(h.StartTime - h.TimePreempt + 1, true)) + case DrawableSlider _: + case DrawableHitCircle _: { - float origPathWidth = s.Body.PathWidth; - var origBodySize = s.Body.Size; - var origBodyDrawPos = s.Body.DrawPosition; - - // 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) + using (drawable.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true)) + drawable.ScaleTo(2f).Then().ScaleTo(1f, h.TimePreempt); // sole difference to grow mod break; - var origSizeRp = rp.Size; - using (d.BeginAbsoluteSequence(h.StartTime - h.TimePreempt + 1, true)) - rp.ResizeTo(origSizeRp * rescale).ResizeTo(origSizeRp, h.TimePreempt); + } + } + + // remove approach circles + switch (drawable) + { + case DrawableHitCircle circle: + // we don't want to see the approach circle + using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true)) + circle.ApproachCircle.Hide(); break; } }