<commit_before>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.Mods;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Bindables;
using osu.Framework.Localisation;
using osu.Framework.Utils;
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
{
    public class OsuModGhost : Mod, IUpdatableByPlayfield, IApplicableToScoreProcessor
    {
        public const float CURSOR_ALPHA_TRANSITION_DURATION = 100;
        public override string Name => "Ghost";
        public override string Acronym => "GS";
        public override ModType Type => ModType.Fun;
        public override IconUsage? Icon => FontAwesome.Solid.Ghost;
        public override string Description => "Where's the cursor?";
        public override double ScoreMultiplier => 1;
        private double transitionProgress = 0;
        private float currentCursorAlpha = 1;
        private float startCursorAlpha = 1;
        private float targetCursorAlpha = 0;

        private BindableNumber<int> currentCombo;

        [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;
        public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
        {
            if (HiddenComboCount.Value != 0) {
                currentCombo = scoreProcessor.Combo.GetBoundCopy();
                currentCombo.BindValueChanged(combo =>
                {
                    targetCursorAlpha = 1 - (float)combo.NewValue / HiddenComboCount.Value;
                    startCursorAlpha = currentCursorAlpha;
                    transitionProgress = 0;
                }, true);
            }
        }

        public virtual void Update(Playfield playfield)
        {
            if (transitionProgress < CURSOR_ALPHA_TRANSITION_DURATION) {
                transitionProgress += playfield.Time.Elapsed;
                currentCursorAlpha = (float)Interpolation.Lerp(startCursorAlpha, targetCursorAlpha, transitionProgress/CURSOR_ALPHA_TRANSITION_DURATION);
                playfield.Cursor.Alpha = currentCursorAlpha;
            }
        }
    }

    public class HiddenComboSlider : OsuSliderBar<int>
    {
        public override LocalisableString TooltipText => Current.Value == 0 ? "always hidden" : base.TooltipText;
    }
}<commit_msg>revert interpolation changes + fix cursor trail<commit_after>﻿// Copyright (c) ppy Pty Ltd <<EMAIL>>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.Mods;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Bindables;
using osu.Framework.Localisation;
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
{
    public class OsuModGhost : Mod, IUpdatableByPlayfield, IApplicableToScoreProcessor
    {
        public const float CURSOR_ALPHA_TRANSITION_DURATION = 100;
        public override string Name => "Ghost";
        public override string Acronym => "GS";
        public override ModType Type => ModType.Fun;
        public override IconUsage? Icon => FontAwesome.Solid.Ghost;
        public override string Description => "Where's the cursor?";
        public override double ScoreMultiplier => 1;
        private readonly BindableFloat cursorAlpha = new BindableFloat();
        private BindableNumber<int> currentCombo;

        [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;

        public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
        {
            if (HiddenComboCount.Value != 0)
            {
                currentCombo = scoreProcessor.Combo.GetBoundCopy();
                currentCombo.BindValueChanged(combo =>
                {
                    float targetCursorAlpha = (float)Math.Max(1e-3, 1 - (float)combo.NewValue / HiddenComboCount.Value);
                    scoreProcessor.TransformBindableTo(cursorAlpha, targetCursorAlpha, CURSOR_ALPHA_TRANSITION_DURATION, Easing.OutQuint);
                }, true);
            }
        }

        public virtual void Update(Playfield playfield)
        {
            playfield.Cursor.Alpha = cursorAlpha.Value;
        }
    }

    public class HiddenComboSlider : OsuSliderBar<int>
    {
        public override LocalisableString TooltipText => Current.Value == 0 ? "always hidden" : base.TooltipText;
    }
}
{'fraction_non_alphanumeric': 0.0802579720530276, 'fraction_numerical': 0.006270154066642781, 'mean_word_length': 2.5268477574226154, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '920558', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1507, 'n_words': 382}