Skip to content

Commit

Permalink
Merge pull request #26131 from smoogipoo/fix-mania-scroll-difference
Browse files Browse the repository at this point in the history
Make mania scroll speed independent of hit position
  • Loading branch information
peppy authored Dec 26, 2023
2 parents ef4191f + 2ec6aa7 commit 92f7a42
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 19 additions & 1 deletion osu.Game.Rulesets.Mania/UI/DrawableManiaRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Replays;
using osu.Game.Rulesets.Mania.Skinning;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Scoring;
using osu.Game.Skinning;

namespace osu.Game.Rulesets.Mania.UI
{
Expand Down Expand Up @@ -57,6 +59,9 @@ public partial class DrawableManiaRuleset : DrawableScrollingRuleset<ManiaHitObj
// Stores the current speed adjustment active in gameplay.
private readonly Track speedAdjustmentTrack = new TrackVirtual(0);

[Resolved]
private ISkinSource skin { get; set; }

public DrawableManiaRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
: base(ruleset, beatmap, mods)
{
Expand Down Expand Up @@ -104,7 +109,20 @@ protected override void Update()
updateTimeRange();
}

private void updateTimeRange() => TimeRange.Value = smoothTimeRange * speedAdjustmentTrack.AggregateTempo.Value * speedAdjustmentTrack.AggregateFrequency.Value;
private void updateTimeRange()
{
float hitPosition = skin.GetConfig<ManiaSkinConfigurationLookup, float>(
new ManiaSkinConfigurationLookup(LegacyManiaSkinConfigurationLookups.HitPosition))?.Value
?? Stage.HIT_TARGET_POSITION;

const float length_to_default_hit_position = 768 - LegacyManiaSkinConfiguration.DEFAULT_HIT_POSITION;
float lengthToHitPosition = 768 - hitPosition;

// This scaling factor preserves the scroll speed as the scroll length varies from changes to the hit position.
float scale = lengthToHitPosition / length_to_default_hit_position;

TimeRange.Value = smoothTimeRange * speedAdjustmentTrack.AggregateTempo.Value * speedAdjustmentTrack.AggregateFrequency.Value * scale;
}

/// <summary>
/// Computes a scroll time (in milliseconds) from a scroll speed in the range of 1-40.
Expand Down
4 changes: 3 additions & 1 deletion osu.Game/Skinning/LegacyManiaSkinConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class LegacyManiaSkinConfiguration : IHasCustomColours
/// </summary>
public const float DEFAULT_COLUMN_SIZE = 30 * POSITION_SCALE_FACTOR;

public const float DEFAULT_HIT_POSITION = (480 - 402) * POSITION_SCALE_FACTOR;

public readonly int Keys;

public Dictionary<string, Color4> CustomColours { get; } = new Dictionary<string, Color4>();
Expand All @@ -35,7 +37,7 @@ public class LegacyManiaSkinConfiguration : IHasCustomColours
public readonly float[] ExplosionWidth;
public readonly float[] HoldNoteLightWidth;

public float HitPosition = (480 - 402) * POSITION_SCALE_FACTOR;
public float HitPosition = DEFAULT_HIT_POSITION;
public float LightPosition = (480 - 413) * POSITION_SCALE_FACTOR;
public float ScorePosition = 300 * POSITION_SCALE_FACTOR;
public bool ShowJudgementLine = true;
Expand Down

0 comments on commit 92f7a42

Please sign in to comment.