mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 09:32:54 +08:00
Merge branch 'master' into reset-combo-in-different-way
This commit is contained in:
commit
c7bd12c8f6
110
osu.Game.Rulesets.Catch.Tests/Mods/TestSceneCatchModNoScope.cs
Normal file
110
osu.Game.Rulesets.Catch.Tests/Mods/TestSceneCatchModNoScope.cs
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
// 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.Collections.Generic;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
using osu.Game.Rulesets.Catch.Mods;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Tests.Mods
|
||||||
|
{
|
||||||
|
public class TestSceneCatchModNoScope : ModTestScene
|
||||||
|
{
|
||||||
|
protected override Ruleset CreatePlayerRuleset() => new CatchRuleset();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestVisibleDuringBreak()
|
||||||
|
{
|
||||||
|
CreateModTest(new ModTestData
|
||||||
|
{
|
||||||
|
Mod = new CatchModNoScope
|
||||||
|
{
|
||||||
|
HiddenComboCount = { Value = 0 },
|
||||||
|
},
|
||||||
|
Autoplay = true,
|
||||||
|
PassCondition = () => true,
|
||||||
|
Beatmap = new Beatmap
|
||||||
|
{
|
||||||
|
HitObjects = new List<HitObject>
|
||||||
|
{
|
||||||
|
new Fruit
|
||||||
|
{
|
||||||
|
X = CatchPlayfield.CENTER_X,
|
||||||
|
StartTime = 1000,
|
||||||
|
},
|
||||||
|
new Fruit
|
||||||
|
{
|
||||||
|
X = CatchPlayfield.CENTER_X,
|
||||||
|
StartTime = 5000,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Breaks = new List<BreakPeriod>
|
||||||
|
{
|
||||||
|
new BreakPeriod(2000, 4000),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AddUntilStep("wait for catcher to hide", () => catcherAlphaAlmostEquals(0));
|
||||||
|
AddUntilStep("wait for start of break", isBreak);
|
||||||
|
AddUntilStep("wait for catcher to show", () => catcherAlphaAlmostEquals(1));
|
||||||
|
AddUntilStep("wait for end of break", () => !isBreak());
|
||||||
|
AddUntilStep("wait for catcher to hide", () => catcherAlphaAlmostEquals(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestVisibleAfterComboBreak()
|
||||||
|
{
|
||||||
|
CreateModTest(new ModTestData
|
||||||
|
{
|
||||||
|
Mod = new CatchModNoScope
|
||||||
|
{
|
||||||
|
HiddenComboCount = { Value = 2 },
|
||||||
|
},
|
||||||
|
Autoplay = true,
|
||||||
|
PassCondition = () => true,
|
||||||
|
Beatmap = new Beatmap
|
||||||
|
{
|
||||||
|
HitObjects = new List<HitObject>
|
||||||
|
{
|
||||||
|
new Fruit
|
||||||
|
{
|
||||||
|
X = 0,
|
||||||
|
StartTime = 1000,
|
||||||
|
},
|
||||||
|
new Fruit
|
||||||
|
{
|
||||||
|
X = CatchPlayfield.CENTER_X,
|
||||||
|
StartTime = 3000,
|
||||||
|
},
|
||||||
|
new Fruit
|
||||||
|
{
|
||||||
|
X = CatchPlayfield.WIDTH,
|
||||||
|
StartTime = 5000,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("catcher must start visible", () => catcherAlphaAlmostEquals(1));
|
||||||
|
AddUntilStep("wait for combo", () => Player.ScoreProcessor.Combo.Value >= 2);
|
||||||
|
AddAssert("catcher must dim after combo", () => !catcherAlphaAlmostEquals(1));
|
||||||
|
AddStep("break combo", () => Player.ScoreProcessor.Combo.Value = 0);
|
||||||
|
AddUntilStep("wait for catcher to show", () => catcherAlphaAlmostEquals(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool isBreak() => Player.IsBreakTime.Value;
|
||||||
|
|
||||||
|
private bool catcherAlphaAlmostEquals(float alpha)
|
||||||
|
{
|
||||||
|
var playfield = (CatchPlayfield)Player.DrawableRuleset.Playfield;
|
||||||
|
return Precision.AlmostEquals(playfield.CatcherArea.Alpha, alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -133,6 +133,7 @@ namespace osu.Game.Rulesets.Catch
|
|||||||
new MultiMod(new ModWindUp(), new ModWindDown()),
|
new MultiMod(new ModWindUp(), new ModWindDown()),
|
||||||
new CatchModFloatingFruits(),
|
new CatchModFloatingFruits(),
|
||||||
new CatchModMuted(),
|
new CatchModMuted(),
|
||||||
|
new CatchModNoScope(),
|
||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
40
osu.Game.Rulesets.Catch/Mods/CatchModNoScope.cs
Normal file
40
osu.Game.Rulesets.Catch/Mods/CatchModNoScope.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
// 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.Game.Rulesets.Mods;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Mods
|
||||||
|
{
|
||||||
|
public class CatchModNoScope : ModNoScope, IUpdatableByPlayfield
|
||||||
|
{
|
||||||
|
public override string Description => "Where's the catcher?";
|
||||||
|
|
||||||
|
[SettingSource(
|
||||||
|
"Hidden at combo",
|
||||||
|
"The combo count at which the catcher becomes completely hidden",
|
||||||
|
SettingControlType = typeof(SettingsSlider<int, HiddenComboSlider>)
|
||||||
|
)]
|
||||||
|
public override BindableInt HiddenComboCount { get; } = new BindableInt
|
||||||
|
{
|
||||||
|
Default = 10,
|
||||||
|
Value = 10,
|
||||||
|
MinValue = 0,
|
||||||
|
MaxValue = 50,
|
||||||
|
};
|
||||||
|
|
||||||
|
public void Update(Playfield playfield)
|
||||||
|
{
|
||||||
|
var catchPlayfield = (CatchPlayfield)playfield;
|
||||||
|
bool shouldAlwaysShowCatcher = IsBreakTime.Value;
|
||||||
|
float targetAlpha = shouldAlwaysShowCatcher ? 1 : ComboBasedAlpha;
|
||||||
|
catchPlayfield.CatcherArea.Alpha = (float)Interpolation.Lerp(catchPlayfield.CatcherArea.Alpha, targetAlpha, Math.Clamp(catchPlayfield.Time.Elapsed / TRANSITION_DURATION, 0, 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,52 +4,29 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Localisation;
|
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics.UserInterface;
|
|
||||||
using osu.Game.Overlays.Settings;
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.Scoring;
|
|
||||||
using osu.Game.Scoring;
|
|
||||||
using osu.Game.Screens.Play;
|
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Mods
|
namespace osu.Game.Rulesets.Osu.Mods
|
||||||
{
|
{
|
||||||
public class OsuModNoScope : Mod, IUpdatableByPlayfield, IApplicableToScoreProcessor, IApplicableToPlayer, IApplicableToBeatmap
|
public class OsuModNoScope : ModNoScope, IUpdatableByPlayfield, IApplicableToBeatmap
|
||||||
{
|
{
|
||||||
/// <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;
|
|
||||||
|
|
||||||
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 string Description => "Where's the cursor?";
|
public override string Description => "Where's the cursor?";
|
||||||
public override double ScoreMultiplier => 1;
|
|
||||||
|
|
||||||
private BindableNumber<int> currentCombo;
|
|
||||||
private IBindable<bool> isBreakTime;
|
|
||||||
private PeriodTracker spinnerPeriods;
|
private PeriodTracker spinnerPeriods;
|
||||||
|
|
||||||
private float comboBasedAlpha;
|
|
||||||
|
|
||||||
[SettingSource(
|
[SettingSource(
|
||||||
"Hidden at combo",
|
"Hidden at combo",
|
||||||
"The combo count at which the cursor becomes completely hidden",
|
"The combo count at which the cursor becomes completely hidden",
|
||||||
SettingControlType = typeof(SettingsSlider<int, HiddenComboSlider>)
|
SettingControlType = typeof(SettingsSlider<int, HiddenComboSlider>)
|
||||||
)]
|
)]
|
||||||
public BindableInt HiddenComboCount { get; } = new BindableInt
|
public override BindableInt HiddenComboCount { get; } = new BindableInt
|
||||||
{
|
{
|
||||||
Default = 10,
|
Default = 10,
|
||||||
Value = 10,
|
Value = 10,
|
||||||
@ -57,39 +34,16 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
MaxValue = 50,
|
MaxValue = 50,
|
||||||
};
|
};
|
||||||
|
|
||||||
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
|
||||||
|
|
||||||
public void ApplyToPlayer(Player player)
|
|
||||||
{
|
|
||||||
isBreakTime = player.IsBreakTime.GetBoundCopy();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
spinnerPeriods = new PeriodTracker(beatmap.HitObjects.OfType<Spinner>().Select(b => new Period(b.StartTime - transition_duration, b.EndTime)));
|
spinnerPeriods = new PeriodTracker(beatmap.HitObjects.OfType<Spinner>().Select(b => new Period(b.StartTime - TRANSITION_DURATION, b.EndTime)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
public void Update(Playfield playfield)
|
||||||
{
|
{
|
||||||
if (HiddenComboCount.Value == 0) return;
|
bool shouldAlwaysShowCursor = IsBreakTime.Value || spinnerPeriods.IsInAny(playfield.Clock.CurrentTime);
|
||||||
|
float targetAlpha = shouldAlwaysShowCursor ? 1 : ComboBasedAlpha;
|
||||||
currentCombo = scoreProcessor.Combo.GetBoundCopy();
|
playfield.Cursor.Alpha = (float)Interpolation.Lerp(playfield.Cursor.Alpha, targetAlpha, Math.Clamp(playfield.Time.Elapsed / TRANSITION_DURATION, 0, 1));
|
||||||
currentCombo.BindValueChanged(combo =>
|
|
||||||
{
|
|
||||||
comboBasedAlpha = Math.Max(min_alpha, 1 - (float)combo.NewValue / HiddenComboCount.Value);
|
|
||||||
}, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Update(Playfield playfield)
|
|
||||||
{
|
|
||||||
bool shouldAlwaysShowCursor = isBreakTime.Value || spinnerPeriods.IsInAny(playfield.Clock.CurrentTime);
|
|
||||||
float targetAlpha = shouldAlwaysShowCursor ? 1 : comboBasedAlpha;
|
|
||||||
playfield.Cursor.Alpha = (float)Interpolation.Lerp(playfield.Cursor.Alpha, targetAlpha, Math.Clamp(playfield.Time.Elapsed / transition_duration, 0, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class HiddenComboSlider : OsuSliderBar<int>
|
|
||||||
{
|
|
||||||
public override LocalisableString TooltipText => Current.Value == 0 ? "always hidden" : base.TooltipText;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
62
osu.Game/Rulesets/Mods/ModNoScope.cs
Normal file
62
osu.Game/Rulesets/Mods/ModNoScope.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
// 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.Graphics.UserInterface;
|
||||||
|
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;
|
||||||
|
|
||||||
|
protected BindableNumber<int> CurrentCombo;
|
||||||
|
|
||||||
|
protected IBindable<bool> IsBreakTime;
|
||||||
|
|
||||||
|
protected float ComboBasedAlpha;
|
||||||
|
|
||||||
|
public abstract BindableInt HiddenComboCount { get; }
|
||||||
|
|
||||||
|
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
|
||||||
|
|
||||||
|
public void ApplyToPlayer(Player player)
|
||||||
|
{
|
||||||
|
IsBreakTime = player.IsBreakTime.GetBoundCopy();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
|
||||||
|
{
|
||||||
|
if (HiddenComboCount.Value == 0) return;
|
||||||
|
|
||||||
|
CurrentCombo = scoreProcessor.Combo.GetBoundCopy();
|
||||||
|
CurrentCombo.BindValueChanged(combo =>
|
||||||
|
{
|
||||||
|
ComboBasedAlpha = Math.Max(MIN_ALPHA, 1 - (float)combo.NewValue / HiddenComboCount.Value);
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class HiddenComboSlider : OsuSliderBar<int>
|
||||||
|
{
|
||||||
|
public override LocalisableString TooltipText => Current.Value == 0 ? "always hidden" : base.TooltipText;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user