mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 09:32:55 +08:00
Added a "Adjust pitch" switch
Adjust pitch switch in DoubleTime and HalfTime mods Also Nightcore and Daycore is now inherit from RateAdjust
This commit is contained in:
parent
90dfef2bb9
commit
49598774e0
@ -5,16 +5,26 @@ using osu.Framework.Audio;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModDaycore : ModHalfTime
|
public abstract class ModDaycore : ModRateAdjust
|
||||||
{
|
{
|
||||||
public override string Name => "Daycore";
|
public override string Name => "Daycore";
|
||||||
public override string Acronym => "DC";
|
public override string Acronym => "DC";
|
||||||
public override IconUsage? Icon => null;
|
public override IconUsage? Icon => null;
|
||||||
|
public override ModType Type => ModType.DifficultyReduction;
|
||||||
public override LocalisableString Description => "Whoaaaaa...";
|
public override LocalisableString Description => "Whoaaaaa...";
|
||||||
|
|
||||||
|
[SettingSource("Speed decrease", "The actual decrease to apply")]
|
||||||
|
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble(0.75)
|
||||||
|
{
|
||||||
|
MinValue = 0.5,
|
||||||
|
MaxValue = 0.99,
|
||||||
|
Precision = 0.01,
|
||||||
|
};
|
||||||
|
|
||||||
private readonly BindableNumber<double> tempoAdjust = new BindableDouble(1);
|
private readonly BindableNumber<double> tempoAdjust = new BindableDouble(1);
|
||||||
private readonly BindableNumber<double> freqAdjust = new BindableDouble(1);
|
private readonly BindableNumber<double> freqAdjust = new BindableDouble(1);
|
||||||
|
|
||||||
@ -33,5 +43,19 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
track.AddAdjustment(AdjustableProperty.Frequency, freqAdjust);
|
track.AddAdjustment(AdjustableProperty.Frequency, freqAdjust);
|
||||||
track.AddAdjustment(AdjustableProperty.Tempo, tempoAdjust);
|
track.AddAdjustment(AdjustableProperty.Tempo, tempoAdjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override double ScoreMultiplier
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// Round to the nearest multiple of 0.1.
|
||||||
|
double value = (int)(SpeedChange.Value * 10) / 10.0;
|
||||||
|
|
||||||
|
// Offset back to 0.
|
||||||
|
value -= 1;
|
||||||
|
|
||||||
|
return 1 + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -25,6 +26,31 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
Precision = 0.01,
|
Precision = 0.01,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private IAdjustableAudioComponent? track;
|
||||||
|
|
||||||
|
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
|
||||||
|
public virtual BindableBool AdjustPitch { get; } = new BindableBool(false);
|
||||||
|
|
||||||
|
protected ModDoubleTime()
|
||||||
|
{
|
||||||
|
AdjustPitch.BindValueChanged(adjustPitchChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void adjustPitchChanged(ValueChangedEvent<bool> adjustPitchSetting)
|
||||||
|
{
|
||||||
|
track?.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange);
|
||||||
|
track?.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AdjustableProperty adjustmentForPitchSetting(bool adjustPitchSettingValue)
|
||||||
|
=> adjustPitchSettingValue ? AdjustableProperty.Frequency : AdjustableProperty.Tempo;
|
||||||
|
|
||||||
|
public override void ApplyToTrack(IAdjustableAudioComponent track)
|
||||||
|
{
|
||||||
|
this.track = track;
|
||||||
|
AdjustPitch.TriggerChange();
|
||||||
|
}
|
||||||
|
|
||||||
public override double ScoreMultiplier
|
public override double ScoreMultiplier
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -25,6 +26,31 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
Precision = 0.01,
|
Precision = 0.01,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private IAdjustableAudioComponent? track;
|
||||||
|
|
||||||
|
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
|
||||||
|
public virtual BindableBool AdjustPitch { get; } = new BindableBool(false);
|
||||||
|
|
||||||
|
protected ModHalfTime()
|
||||||
|
{
|
||||||
|
AdjustPitch.BindValueChanged(adjustPitchChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void adjustPitchChanged(ValueChangedEvent<bool> adjustPitchSetting)
|
||||||
|
{
|
||||||
|
track?.RemoveAdjustment(adjustmentForPitchSetting(adjustPitchSetting.OldValue), SpeedChange);
|
||||||
|
track?.AddAdjustment(adjustmentForPitchSetting(adjustPitchSetting.NewValue), SpeedChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
private AdjustableProperty adjustmentForPitchSetting(bool adjustPitchSettingValue)
|
||||||
|
=> adjustPitchSettingValue ? AdjustableProperty.Frequency : AdjustableProperty.Tempo;
|
||||||
|
|
||||||
|
public override void ApplyToTrack(IAdjustableAudioComponent track)
|
||||||
|
{
|
||||||
|
this.track = track;
|
||||||
|
AdjustPitch.TriggerChange();
|
||||||
|
}
|
||||||
|
|
||||||
public override double ScoreMultiplier
|
public override double ScoreMultiplier
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Localisation;
|
|||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
@ -19,12 +20,38 @@ using osu.Game.Skinning;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mods
|
namespace osu.Game.Rulesets.Mods
|
||||||
{
|
{
|
||||||
public abstract class ModNightcore : ModDoubleTime
|
public abstract class ModNightcore : ModRateAdjust
|
||||||
{
|
{
|
||||||
public override string Name => "Nightcore";
|
public override string Name => "Nightcore";
|
||||||
public override string Acronym => "NC";
|
public override string Acronym => "NC";
|
||||||
public override IconUsage? Icon => OsuIcon.ModNightcore;
|
public override IconUsage? Icon => OsuIcon.ModNightcore;
|
||||||
|
public override ModType Type => ModType.DifficultyIncrease;
|
||||||
public override LocalisableString Description => "Uguuuuuuuu...";
|
public override LocalisableString Description => "Uguuuuuuuu...";
|
||||||
|
|
||||||
|
[SettingSource("Speed increase", "The actual increase to apply")]
|
||||||
|
public override BindableNumber<double> SpeedChange { get; } = new BindableDouble(1.5)
|
||||||
|
{
|
||||||
|
MinValue = 1.01,
|
||||||
|
MaxValue = 2,
|
||||||
|
Precision = 0.01,
|
||||||
|
};
|
||||||
|
|
||||||
|
public override double ScoreMultiplier
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
// Round to the nearest multiple of 0.1.
|
||||||
|
double value = (int)(SpeedChange.Value * 10) / 10.0;
|
||||||
|
|
||||||
|
// Offset back to 0.
|
||||||
|
value -= 1;
|
||||||
|
|
||||||
|
// Each 0.1 multiple changes score multiplier by 0.02.
|
||||||
|
value /= 5;
|
||||||
|
|
||||||
|
return 1 + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract partial class ModNightcore<TObject> : ModNightcore, IApplicableToDrawableRuleset<TObject>
|
public abstract partial class ModNightcore<TObject> : ModNightcore, IApplicableToDrawableRuleset<TObject>
|
||||||
|
@ -13,10 +13,7 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
public abstract BindableNumber<double> SpeedChange { get; }
|
public abstract BindableNumber<double> SpeedChange { get; }
|
||||||
|
|
||||||
public virtual void ApplyToTrack(IAdjustableAudioComponent track)
|
public abstract void ApplyToTrack(IAdjustableAudioComponent track);
|
||||||
{
|
|
||||||
track.AddAdjustment(AdjustableProperty.Tempo, SpeedChange);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void ApplyToSample(IAdjustableAudioComponent sample)
|
public virtual void ApplyToSample(IAdjustableAudioComponent sample)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user