2021-10-15 06:30:55 +08: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.
|
|
|
|
|
|
2021-10-15 11:34:43 +08:00
|
|
|
|
using System;
|
2021-10-15 06:30:55 +08:00
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2021-10-15 11:34:43 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2021-10-15 06:30:55 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
|
using osu.Framework.Localisation;
|
2021-10-15 13:25:50 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2021-10-15 06:30:55 +08:00
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
|
using osu.Game.Overlays.Settings;
|
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2021-10-15 12:22:57 +08:00
|
|
|
|
public class OsuModNoScope : Mod, IUpdatableByPlayfield, IApplicableToScoreProcessor
|
2021-10-15 06:30:55 +08:00
|
|
|
|
{
|
2021-10-15 13:27:20 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Slightly higher than the cutoff for <see cref="Drawable.IsPresent"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float min_alpha = 0.0002f;
|
|
|
|
|
|
|
|
|
|
private const float transition_duration = 100;
|
2021-10-15 13:25:50 +08:00
|
|
|
|
|
2021-10-15 12:22:57 +08:00
|
|
|
|
public override string Name => "No Scope";
|
|
|
|
|
public override string Acronym => "NS";
|
2021-10-15 06:30:55 +08:00
|
|
|
|
public override ModType Type => ModType.Fun;
|
2021-10-15 12:22:57 +08:00
|
|
|
|
public override IconUsage? Icon => FontAwesome.Solid.EyeSlash;
|
2021-10-15 06:30:55 +08:00
|
|
|
|
public override string Description => "Where's the cursor?";
|
|
|
|
|
public override double ScoreMultiplier => 1;
|
2021-10-15 13:25:50 +08:00
|
|
|
|
|
2021-10-15 06:30:55 +08:00
|
|
|
|
private BindableNumber<int> currentCombo;
|
|
|
|
|
|
2021-10-15 13:25:50 +08:00
|
|
|
|
private float targetAlpha;
|
|
|
|
|
|
2021-10-15 06:30:55 +08:00
|
|
|
|
[SettingSource(
|
|
|
|
|
"Hidden at combo",
|
|
|
|
|
"The combo count at which the cursor becomes completely hidden",
|
|
|
|
|
SettingControlType = typeof(SettingsSlider<int, HiddenComboSlider>)
|
|
|
|
|
)]
|
|
|
|
|
public BindableInt HiddenComboCount { get; } = new BindableInt
|
|
|
|
|
{
|
|
|
|
|
Default = 10,
|
|
|
|
|
Value = 10,
|
|
|
|
|
MinValue = 0,
|
|
|
|
|
MaxValue = 50,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
2021-10-15 11:34:43 +08:00
|
|
|
|
|
2021-10-15 06:30:55 +08:00
|
|
|
|
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
|
|
|
|
{
|
2021-10-15 13:25:50 +08:00
|
|
|
|
if (HiddenComboCount.Value == 0) return;
|
|
|
|
|
|
|
|
|
|
currentCombo = scoreProcessor.Combo.GetBoundCopy();
|
|
|
|
|
currentCombo.BindValueChanged(combo =>
|
2021-10-15 11:34:43 +08:00
|
|
|
|
{
|
2021-10-15 13:25:50 +08:00
|
|
|
|
targetAlpha = Math.Max(min_alpha, 1 - (float)combo.NewValue / HiddenComboCount.Value);
|
|
|
|
|
}, true);
|
2021-10-15 06:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void Update(Playfield playfield)
|
|
|
|
|
{
|
2021-10-15 13:27:20 +08:00
|
|
|
|
playfield.Cursor.Alpha = (float)Interpolation.Lerp(playfield.Cursor.Alpha, targetAlpha, Math.Clamp(playfield.Time.Elapsed / transition_duration, 0, 1));
|
2021-10-15 06:30:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class HiddenComboSlider : OsuSliderBar<int>
|
|
|
|
|
{
|
|
|
|
|
public override LocalisableString TooltipText => Current.Value == 0 ? "always hidden" : base.TooltipText;
|
|
|
|
|
}
|
|
|
|
|
}
|