2021-11-09 14:11:19 +00: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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Localisation;
|
2022-09-27 13:25:58 +00:00
|
|
|
using osu.Game.Configuration;
|
2021-11-09 14:11:19 +00:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
2022-09-27 13:25:58 +00:00
|
|
|
using osu.Game.Overlays.Settings;
|
2021-11-09 14:11:19 +00:00
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Scoring;
|
|
|
|
using osu.Game.Screens.Play;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mods
|
|
|
|
{
|
|
|
|
public abstract class ModNoScope : Mod, IApplicableToScoreProcessor, IApplicableToPlayer
|
|
|
|
{
|
|
|
|
public override string Name => "No Scope";
|
|
|
|
public override string Acronym => "NS";
|
|
|
|
public override ModType Type => ModType.Fun;
|
|
|
|
public override IconUsage? Icon => FontAwesome.Solid.EyeSlash;
|
|
|
|
public override double ScoreMultiplier => 1;
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Slightly higher than the cutoff for <see cref="Drawable.IsPresent"/>.
|
|
|
|
/// </summary>
|
|
|
|
protected const float MIN_ALPHA = 0.0002f;
|
|
|
|
|
|
|
|
protected const float TRANSITION_DURATION = 100;
|
|
|
|
|
2022-07-10 15:16:51 +00:00
|
|
|
protected readonly BindableNumber<int> CurrentCombo = new BindableInt();
|
2021-11-09 14:11:19 +00:00
|
|
|
|
2022-07-10 15:16:51 +00:00
|
|
|
protected readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
|
2021-11-09 14:11:19 +00:00
|
|
|
|
|
|
|
protected float ComboBasedAlpha;
|
|
|
|
|
2022-09-27 13:25:58 +00:00
|
|
|
[SettingSource(
|
|
|
|
"Hidden at combo",
|
|
|
|
"The combo count at which the cursor becomes completely hidden",
|
|
|
|
SettingControlType = typeof(SettingsSlider<int, HiddenComboSlider>)
|
|
|
|
)]
|
2021-11-10 00:57:22 +00:00
|
|
|
public abstract BindableInt HiddenComboCount { get; }
|
2021-11-09 14:11:19 +00:00
|
|
|
|
|
|
|
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
|
|
|
|
|
|
|
public void ApplyToPlayer(Player player)
|
|
|
|
{
|
2022-07-10 15:16:51 +00:00
|
|
|
IsBreakTime.BindTo(player.IsBreakTime);
|
2021-11-09 14:11:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
|
|
|
{
|
|
|
|
if (HiddenComboCount.Value == 0) return;
|
|
|
|
|
2022-07-10 15:16:51 +00:00
|
|
|
CurrentCombo.BindTo(scoreProcessor.Combo);
|
2021-11-09 14:11:19 +00:00
|
|
|
CurrentCombo.BindValueChanged(combo =>
|
|
|
|
{
|
|
|
|
ComboBasedAlpha = Math.Max(MIN_ALPHA, 1 - (float)combo.NewValue / HiddenComboCount.Value);
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public partial class HiddenComboSlider : OsuSliderBar<int>
|
|
|
|
{
|
|
|
|
public override LocalisableString TooltipText => Current.Value == 0 ? "always hidden" : base.TooltipText;
|
|
|
|
}
|
|
|
|
}
|