mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 04:52:57 +08:00
Add short fade to flashlight dimming
This commit is contained in:
parent
69748abedc
commit
d9ed68b189
@ -21,8 +21,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
private const float default_flashlight_size = 180;
|
||||
|
||||
private int trackingSliders;
|
||||
|
||||
private OsuFlashlight flashlight;
|
||||
|
||||
public override Flashlight CreateFlashlight() => flashlight = new OsuFlashlight();
|
||||
@ -31,27 +29,30 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
foreach (DrawableSlider drawable in drawables.OfType<DrawableSlider>())
|
||||
{
|
||||
drawable.Tracking.ValueChanged += updateTrackingSliders;
|
||||
drawable.Tracking.ValueChanged += flashlight.OnSliderTrackingChange;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateTrackingSliders(ValueChangedEvent<bool> value)
|
||||
{
|
||||
if (value.NewValue)
|
||||
trackingSliders++;
|
||||
else
|
||||
trackingSliders--;
|
||||
|
||||
flashlight.FlashlightDim = trackingSliders > 0 ? 0.8f : 0.0f;
|
||||
}
|
||||
|
||||
private class OsuFlashlight : Flashlight, IRequireHighFrequencyMousePosition
|
||||
{
|
||||
private int trackingSliders;
|
||||
|
||||
public OsuFlashlight()
|
||||
{
|
||||
FlashlightSize = new Vector2(0, getSizeFor(0));
|
||||
}
|
||||
|
||||
public void OnSliderTrackingChange(ValueChangedEvent<bool> e)
|
||||
{
|
||||
if (e.NewValue)
|
||||
trackingSliders++;
|
||||
else
|
||||
trackingSliders--;
|
||||
|
||||
// If there are any sliders in a tracking state, apply a dim to the entire playfield over a brief duration.
|
||||
this.TransformTo(nameof(FlashlightDim), trackingSliders > 0 ? 0.8f : 0.0f, 50);
|
||||
}
|
||||
|
||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||
{
|
||||
FlashlightPosition = e.MousePosition;
|
||||
|
Loading…
Reference in New Issue
Block a user