2019-01-24 17:43:03 +09:00
|
|
|
|
// 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.
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
|
|
|
|
using System;
|
2020-12-03 14:28:37 +09:00
|
|
|
|
using System.Diagnostics;
|
2020-11-11 21:46:58 +01:00
|
|
|
|
using System.Linq;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-10-24 21:34:40 -07:00
|
|
|
|
using osu.Framework.Bindables;
|
2022-08-10 16:09:11 -04:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-10-24 21:34:40 -07:00
|
|
|
|
using osu.Game.Configuration;
|
2020-12-03 14:28:37 +09:00
|
|
|
|
using osu.Game.Beatmaps;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-11-25 19:01:24 +09:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2018-06-06 13:51:51 +09:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2021-06-19 20:06:28 +03:00
|
|
|
|
using osu.Game.Rulesets.Osu.Skinning;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2021-06-28 18:54:21 +03:00
|
|
|
|
public class OsuModHidden : ModHidden, IHidesApproachCircles
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2021-10-24 22:52:10 -07:00
|
|
|
|
[SettingSource("Only fade approach circles", "The main object body will not fade when enabled.")]
|
2021-10-26 19:56:54 +09:00
|
|
|
|
public Bindable<bool> OnlyFadeApproachCircles { get; } = new BindableBool();
|
2021-10-24 21:34:40 -07:00
|
|
|
|
|
2022-08-10 16:09:11 -04:00
|
|
|
|
public override LocalisableString Description => @"Play with no approach circles and fading circles/sliders.";
|
2022-07-18 07:22:25 +03:00
|
|
|
|
public override double ScoreMultiplier => UsesDefaultConfiguration ? 1.06 : 1;
|
2019-09-18 19:36:07 +09:00
|
|
|
|
|
2022-10-18 13:39:40 +02:00
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn), typeof(OsuModFreezeFrame) };
|
2019-09-18 19:36:07 +09:00
|
|
|
|
|
2022-05-12 17:19:07 +09:00
|
|
|
|
public const double FADE_IN_DURATION_MULTIPLIER = 0.4;
|
|
|
|
|
public const double FADE_OUT_DURATION_MULTIPLIER = 0.3;
|
2018-04-25 17:15:53 +09:00
|
|
|
|
|
2020-12-03 22:40:30 +01:00
|
|
|
|
protected override bool IsFirstAdjustableObject(HitObject hitObject) => !(hitObject is Spinner || hitObject is SpinnerTick);
|
2020-04-16 14:11:38 +09:00
|
|
|
|
|
2020-12-03 14:28:37 +09:00
|
|
|
|
public override void ApplyToBeatmap(IBeatmap beatmap)
|
2018-06-06 13:51:51 +09:00
|
|
|
|
{
|
2020-12-03 14:28:37 +09:00
|
|
|
|
base.ApplyToBeatmap(beatmap);
|
2018-06-06 13:51:51 +09:00
|
|
|
|
|
2020-12-03 14:28:37 +09:00
|
|
|
|
foreach (var obj in beatmap.HitObjects.OfType<OsuHitObject>())
|
|
|
|
|
applyFadeInAdjustment(obj);
|
2020-11-11 16:35:48 +09:00
|
|
|
|
|
2020-12-03 14:28:37 +09:00
|
|
|
|
static void applyFadeInAdjustment(OsuHitObject osuObject)
|
|
|
|
|
{
|
2022-05-12 17:19:07 +09:00
|
|
|
|
osuObject.TimeFadeIn = osuObject.TimePreempt * FADE_IN_DURATION_MULTIPLIER;
|
2020-12-03 14:28:37 +09:00
|
|
|
|
foreach (var nested in osuObject.NestedHitObjects.OfType<OsuHitObject>())
|
|
|
|
|
applyFadeInAdjustment(nested);
|
|
|
|
|
}
|
2020-11-05 16:12:55 +09:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 15:36:44 +09:00
|
|
|
|
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
|
|
|
|
{
|
2021-10-26 11:42:15 +09:00
|
|
|
|
applyHiddenState(hitObject, true);
|
2020-11-05 15:36:44 +09:00
|
|
|
|
}
|
2020-10-09 03:07:01 +09:00
|
|
|
|
|
2020-11-05 15:36:44 +09:00
|
|
|
|
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
|
|
|
|
{
|
2021-10-26 11:42:15 +09:00
|
|
|
|
applyHiddenState(hitObject, false);
|
2020-11-05 15:36:44 +09:00
|
|
|
|
}
|
2020-10-09 03:07:01 +09:00
|
|
|
|
|
2021-10-26 11:42:15 +09:00
|
|
|
|
private void applyHiddenState(DrawableHitObject drawableObject, bool increaseVisibility)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2020-12-03 14:28:37 +09:00
|
|
|
|
if (!(drawableObject is DrawableOsuHitObject drawableOsuObject))
|
2018-04-13 18:19:50 +09:00
|
|
|
|
return;
|
|
|
|
|
|
2020-12-03 14:28:37 +09:00
|
|
|
|
OsuHitObject hitObject = drawableOsuObject.HitObject;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-05-14 21:56:13 +08:00
|
|
|
|
(double fadeStartTime, double fadeDuration) = getFadeOutParameters(drawableOsuObject);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-10-26 11:42:15 +09:00
|
|
|
|
// process approach circle hiding first (to allow for early return below).
|
|
|
|
|
if (!increaseVisibility)
|
|
|
|
|
{
|
|
|
|
|
if (drawableObject is DrawableHitCircle circle)
|
|
|
|
|
{
|
|
|
|
|
using (circle.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimePreempt))
|
|
|
|
|
circle.ApproachCircle.Hide();
|
|
|
|
|
}
|
2021-10-25 20:16:45 -07:00
|
|
|
|
else if (drawableObject is DrawableSpinner spinner)
|
|
|
|
|
{
|
|
|
|
|
spinner.Body.OnSkinChanged += () => hideSpinnerApproachCircle(spinner);
|
|
|
|
|
hideSpinnerApproachCircle(spinner);
|
|
|
|
|
}
|
2021-10-26 11:42:15 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (OnlyFadeApproachCircles.Value)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
switch (drawableObject)
|
2018-04-13 18:19:50 +09:00
|
|
|
|
{
|
2022-06-24 21:25:23 +09:00
|
|
|
|
case DrawableSliderTail:
|
2021-10-25 14:09:22 -07:00
|
|
|
|
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
|
|
|
|
|
drawableObject.FadeOut(fadeDuration);
|
2020-10-02 18:41:28 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
break;
|
2020-10-02 18:41:28 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
case DrawableSliderRepeat sliderRepeat:
|
|
|
|
|
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
|
|
|
|
|
// only apply to circle piece – reverse arrow is not affected by hidden.
|
|
|
|
|
sliderRepeat.CirclePiece.FadeOut(fadeDuration);
|
2020-10-02 18:41:28 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
break;
|
2020-10-02 18:41:28 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
case DrawableHitCircle circle:
|
|
|
|
|
Drawable fadeTarget = circle;
|
2020-10-09 18:43:16 +09:00
|
|
|
|
|
2021-10-26 11:42:15 +09:00
|
|
|
|
if (increaseVisibility)
|
2021-10-25 14:09:22 -07:00
|
|
|
|
{
|
|
|
|
|
// only fade the circle piece (not the approach circle) for the increased visibility object.
|
|
|
|
|
fadeTarget = circle.CirclePiece;
|
|
|
|
|
}
|
2021-10-25 00:25:32 -07:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
|
|
|
|
|
fadeTarget.FadeOut(fadeDuration);
|
|
|
|
|
break;
|
2019-04-01 12:44:46 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
case DrawableSlider slider:
|
|
|
|
|
using (slider.BeginAbsoluteSequence(fadeStartTime))
|
|
|
|
|
slider.Body.FadeOut(fadeDuration, Easing.Out);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
break;
|
2019-04-01 12:44:46 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
case DrawableSliderTick sliderTick:
|
|
|
|
|
using (sliderTick.BeginAbsoluteSequence(fadeStartTime))
|
|
|
|
|
sliderTick.FadeOut(fadeDuration);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
break;
|
2019-04-01 12:44:46 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
case DrawableSpinner spinner:
|
|
|
|
|
// hide elements we don't care about.
|
|
|
|
|
// todo: hide background
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
using (spinner.BeginAbsoluteSequence(fadeStartTime))
|
|
|
|
|
spinner.FadeOut(fadeDuration);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2021-10-25 14:09:22 -07:00
|
|
|
|
break;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-11 21:46:58 +01:00
|
|
|
|
|
2021-05-15 11:26:16 +08:00
|
|
|
|
private (double fadeStartTime, double fadeDuration) getFadeOutParameters(DrawableOsuHitObject drawableObject)
|
2020-11-11 21:46:58 +01:00
|
|
|
|
{
|
2020-12-03 14:28:37 +09:00
|
|
|
|
switch (drawableObject)
|
2020-11-11 21:46:58 +01:00
|
|
|
|
{
|
2020-12-03 14:28:37 +09:00
|
|
|
|
case DrawableSliderTail tail:
|
|
|
|
|
// Use the same fade sequence as the slider head.
|
|
|
|
|
Debug.Assert(tail.Slider != null);
|
|
|
|
|
return getParameters(tail.Slider.HeadCircle);
|
|
|
|
|
|
|
|
|
|
case DrawableSliderRepeat repeat:
|
|
|
|
|
// Use the same fade sequence as the slider head.
|
|
|
|
|
Debug.Assert(repeat.Slider != null);
|
|
|
|
|
return getParameters(repeat.Slider.HeadCircle);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return getParameters(drawableObject.HitObject);
|
2020-11-11 21:46:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-15 11:26:16 +08:00
|
|
|
|
static (double fadeStartTime, double fadeDuration) getParameters(OsuHitObject hitObject)
|
2020-12-03 14:28:37 +09:00
|
|
|
|
{
|
2021-10-27 13:04:41 +09:00
|
|
|
|
double fadeOutStartTime = hitObject.StartTime - hitObject.TimePreempt + hitObject.TimeFadeIn;
|
2022-05-12 17:19:07 +09:00
|
|
|
|
double fadeOutDuration = hitObject.TimePreempt * FADE_OUT_DURATION_MULTIPLIER;
|
2020-12-03 14:28:37 +09:00
|
|
|
|
|
|
|
|
|
// new duration from completed fade in to end (before fading out)
|
2021-10-27 13:04:41 +09:00
|
|
|
|
double longFadeDuration = hitObject.GetEndTime() - fadeOutStartTime;
|
2020-12-03 14:28:37 +09:00
|
|
|
|
|
|
|
|
|
switch (hitObject)
|
|
|
|
|
{
|
2022-06-24 21:25:23 +09:00
|
|
|
|
case Slider:
|
2020-12-03 14:28:37 +09:00
|
|
|
|
return (fadeOutStartTime, longFadeDuration);
|
|
|
|
|
|
2022-06-24 21:25:23 +09:00
|
|
|
|
case SliderTick:
|
2021-10-27 13:04:41 +09:00
|
|
|
|
double tickFadeOutDuration = Math.Min(hitObject.TimePreempt - DrawableSliderTick.ANIM_DURATION, 1000);
|
2020-12-03 14:28:37 +09:00
|
|
|
|
return (hitObject.StartTime - tickFadeOutDuration, tickFadeOutDuration);
|
|
|
|
|
|
2022-06-24 21:25:23 +09:00
|
|
|
|
case Spinner:
|
2020-12-03 14:28:37 +09:00
|
|
|
|
return (fadeOutStartTime + longFadeDuration, fadeOutDuration);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return (fadeOutStartTime, fadeOutDuration);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-11 21:46:58 +01:00
|
|
|
|
}
|
2021-06-19 20:06:28 +03:00
|
|
|
|
|
|
|
|
|
private static void hideSpinnerApproachCircle(DrawableSpinner spinner)
|
|
|
|
|
{
|
2021-06-21 03:43:11 +03:00
|
|
|
|
var approachCircle = (spinner.Body.Drawable as IHasApproachCircle)?.ApproachCircle;
|
2021-06-19 20:06:28 +03:00
|
|
|
|
if (approachCircle == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
using (spinner.BeginAbsoluteSequence(spinner.HitObject.StartTime - spinner.HitObject.TimePreempt))
|
|
|
|
|
approachCircle.Hide();
|
|
|
|
|
}
|
2018-04-13 18:19:50 +09:00
|
|
|
|
}
|
|
|
|
|
}
|