1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-19 13:20:16 +08:00
Files
osu-lazer/osu.Game/Rulesets/Mods/ModNoScope.cs
T
Linus Genz dfa7ac2082 Specialise mod setting hover text in song select scoreboard (#36391)
- resolves #35992

**Changes**

Introduced GetSettingTooltipText, which returns the value of the
respective setting. The function can be overwritten, allowing to
implement specific behavior. This allows you to define that a value of 0
for the “Muted” mod will instead display “always muted.”
In the same step, I also adjusted the "NoScope" mod, where we had the
same problem.
Wherever we want to implement specialization like this, we can simply
overwrite GetSettingTooltipText to customize the behavior for the mod
settings of the mod.

**Result**
<img width="2560" height="1440" alt="2026-01-19-122307_hyprshot"
src="https://github.com/user-attachments/assets/20e3aa9a-aa6f-4284-9cf1-3092f52c021d"
/>
<img width="2560" height="1440" alt="2026-01-19-122324_hyprshot"
src="https://github.com/user-attachments/assets/6f3fac5b-2a5d-4dd9-a56c-4b09c02cbcca"
/>
<img width="2560" height="1440" alt="2026-01-19-155307_hyprshot"
src="https://github.com/user-attachments/assets/f9ee75d3-c200-4536-9ee9-d20ddbd9fa44"
/>

Signed-off-by: Linus Genz <linuslinuxgenz@gmail.com>
2026-01-20 16:51:23 +09:00

85 lines
2.9 KiB
C#

// 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;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Settings;
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 => OsuIcon.ModNoScope;
public override double ScoreMultiplier => 1;
public override bool Ranked => true;
/// <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;
protected readonly BindableNumber<int> CurrentCombo = new BindableInt();
protected readonly IBindable<bool> IsBreakTime = new Bindable<bool>();
protected float ComboBasedAlpha;
[SettingSource(
"Hidden at combo",
"The combo count at which the cursor becomes completely hidden",
SettingControlType = typeof(SettingsSlider<int, HiddenComboSlider>)
)]
public abstract BindableInt HiddenComboCount { get; }
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
public void ApplyToPlayer(Player player)
{
IsBreakTime.BindTo(player.IsBreakTime);
}
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
if (HiddenComboCount.Value == 0) return;
CurrentCombo.BindTo(scoreProcessor.Combo);
CurrentCombo.BindValueChanged(combo =>
{
ComboBasedAlpha = Math.Max(MIN_ALPHA, 1 - (float)combo.NewValue / HiddenComboCount.Value);
}, true);
}
protected override LocalisableString GetSettingTooltipText(IBindable bindable)
{
if (ReferenceEquals(bindable, HiddenComboCount))
return HiddenComboSlider.FormatHiddenComboValue(HiddenComboCount.Value);
return base.GetSettingTooltipText(bindable);
}
}
public partial class HiddenComboSlider : RoundedSliderBar<int>
{
public override LocalisableString TooltipText => FormatHiddenComboValue(Current.Value);
public static LocalisableString FormatHiddenComboValue(int value)
{
return value == 0 ? "always hidden" : value.ToString();
}
}
}