Fix mods affecting mania scroll speed

This commit is contained in:
smoogipoo 2020-04-28 19:23:33 +09:00
parent 0ffd9da6a9
commit 1aaab40228
2 changed files with 26 additions and 7 deletions

View File

@ -2,7 +2,9 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Audio.Track;
using osu.Framework.Bindables;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
@ -48,6 +50,10 @@ namespace osu.Game.Rulesets.Mania.UI
protected new ManiaRulesetConfigManager Config => (ManiaRulesetConfigManager)base.Config;
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
private readonly Bindable<double> configTimeRange = new Bindable<double>();
// Stores the current speed adjustment active in gameplay.
private readonly Track speedAdjustmentTrack = new TrackVirtual(1000);
public DrawableManiaRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
: base(ruleset, beatmap, mods)
@ -58,6 +64,9 @@ namespace osu.Game.Rulesets.Mania.UI
[BackgroundDependencyLoader]
private void load()
{
foreach (var mod in Mods.OfType<IApplicableToTrack>())
mod.ApplyToTrack(speedAdjustmentTrack);
bool isForCurrentRuleset = Beatmap.BeatmapInfo.Ruleset.Equals(Ruleset.RulesetInfo);
foreach (var p in ControlPoints)
@ -76,7 +85,8 @@ namespace osu.Game.Rulesets.Mania.UI
Config.BindWith(ManiaRulesetSetting.ScrollDirection, configDirection);
configDirection.BindValueChanged(direction => Direction.Value = (ScrollingDirection)direction.NewValue, true);
Config.BindWith(ManiaRulesetSetting.ScrollTime, TimeRange);
Config.BindWith(ManiaRulesetSetting.ScrollTime, configTimeRange);
configTimeRange.BindValueChanged(_ => updateTimeRange());
}
protected override void AdjustScrollSpeed(int amount)
@ -86,10 +96,19 @@ namespace osu.Game.Rulesets.Mania.UI
private double relativeTimeRange
{
get => MAX_TIME_RANGE / TimeRange.Value;
set => TimeRange.Value = MAX_TIME_RANGE / value;
get => MAX_TIME_RANGE / configTimeRange.Value;
set => configTimeRange.Value = MAX_TIME_RANGE / value;
}
protected override void Update()
{
base.Update();
updateTimeRange();
}
private void updateTimeRange() => TimeRange.Value = configTimeRange.Value * speedAdjustmentTrack.AggregateTempo.Value * speedAdjustmentTrack.AggregateFrequency.Value;
/// <summary>
/// Retrieves the column that intersects a screen-space position.
/// </summary>

View File

@ -107,7 +107,7 @@ namespace osu.Game.Rulesets.UI
/// The mods which are to be applied.
/// </summary>
[Cached(typeof(IReadOnlyList<Mod>))]
private readonly IReadOnlyList<Mod> mods;
protected readonly IReadOnlyList<Mod> Mods;
private FrameStabilityContainer frameStabilityContainer;
@ -129,7 +129,7 @@ namespace osu.Game.Rulesets.UI
throw new ArgumentException($"{GetType()} expected the beatmap to contain hitobjects of type {typeof(TObject)}.", nameof(beatmap));
Beatmap = tBeatmap;
this.mods = mods?.ToArray() ?? Array.Empty<Mod>();
Mods = mods?.ToArray() ?? Array.Empty<Mod>();
RelativeSizeAxes = Axes.Both;
@ -204,7 +204,7 @@ namespace osu.Game.Rulesets.UI
.WithChild(ResumeOverlay)));
}
applyRulesetMods(mods, config);
applyRulesetMods(Mods, config);
loadObjects(cancellationToken);
}
@ -224,7 +224,7 @@ namespace osu.Game.Rulesets.UI
Playfield.PostProcess();
foreach (var mod in mods.OfType<IApplicableToDrawableHitObjects>())
foreach (var mod in Mods.OfType<IApplicableToDrawableHitObjects>())
mod.ApplyToDrawableHitObjects(Playfield.AllHitObjects);
}