From cd6d070b4aacc33a880562c928001fdc90dee920 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Wed, 5 May 2021 07:27:57 +0300 Subject: [PATCH] Consider "combo offsets" as legacy logic and separate from combo information --- .../Beatmaps/CatchBeatmapConverter.cs | 3 --- .../Objects/CatchHitObject.cs | 2 -- .../Beatmaps/OsuBeatmapConverter.cs | 6 ++--- osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs | 14 ++++------- .../TestSceneHitObjectAccentColour.cs | 1 - osu.Game/Beatmaps/BeatmapProcessor.cs | 12 +++++++++- .../Beatmaps/Formats/LegacyBeatmapEncoder.cs | 5 ++-- .../Objects/Legacy/Catch/ConvertHit.cs | 2 -- .../Legacy/Catch/ConvertHitObjectParser.cs | 14 ----------- .../Objects/Legacy/Catch/ConvertSlider.cs | 2 -- .../Objects/Legacy/Catch/ConvertSpinner.cs | 2 -- .../Rulesets/Objects/Legacy/Osu/ConvertHit.cs | 6 +++-- .../Legacy/Osu/ConvertHitObjectParser.cs | 4 ++-- .../Objects/Legacy/Osu/ConvertSlider.cs | 6 +++-- .../Objects/Legacy/Osu/ConvertSpinner.cs | 2 -- osu.Game/Rulesets/Objects/Types/IHasCombo.cs | 5 ---- .../Types/IHasLegacyBeatmapComboOffset.cs | 24 +++++++++++++++++++ 17 files changed, 56 insertions(+), 54 deletions(-) create mode 100644 osu.Game/Rulesets/Objects/Types/IHasLegacyBeatmapComboOffset.cs diff --git a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs index 34964fc4ae..8b0213bfeb 100644 --- a/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs +++ b/osu.Game.Rulesets.Catch/Beatmaps/CatchBeatmapConverter.cs @@ -38,7 +38,6 @@ namespace osu.Game.Rulesets.Catch.Beatmaps RepeatCount = curveData.RepeatCount, X = positionData?.X ?? 0, NewCombo = comboData?.NewCombo ?? false, - ComboOffset = comboData?.ComboOffset ?? 0, LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0 }.Yield(); @@ -49,7 +48,6 @@ namespace osu.Game.Rulesets.Catch.Beatmaps Samples = obj.Samples, Duration = endTime.Duration, NewCombo = comboData?.NewCombo ?? false, - ComboOffset = comboData?.ComboOffset ?? 0, }.Yield(); default: @@ -58,7 +56,6 @@ namespace osu.Game.Rulesets.Catch.Beatmaps StartTime = obj.StartTime, Samples = obj.Samples, NewCombo = comboData?.NewCombo ?? false, - ComboOffset = comboData?.ComboOffset ?? 0, X = positionData?.X ?? 0 }.Yield(); } diff --git a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs index ae45182960..ce2da314ca 100644 --- a/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/CatchHitObject.cs @@ -67,8 +67,6 @@ namespace osu.Game.Rulesets.Catch.Objects public virtual bool NewCombo { get; set; } - public int ComboOffset { get; set; } - public Bindable IndexInCurrentComboBindable { get; } = new Bindable(); public int IndexInCurrentCombo diff --git a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs index a2fc4848af..d812f86938 100644 --- a/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs +++ b/osu.Game.Rulesets.Osu/Beatmaps/OsuBeatmapConverter.cs @@ -40,7 +40,7 @@ namespace osu.Game.Rulesets.Osu.Beatmaps RepeatCount = curveData.RepeatCount, Position = positionData?.Position ?? Vector2.Zero, NewCombo = comboData?.NewCombo ?? false, - ComboOffset = comboData?.ComboOffset ?? 0, + LegacyBeatmapComboOffset = (original as IHasLegacyBeatmapComboOffset)?.LegacyBeatmapComboOffset ?? 0, LegacyLastTickOffset = (original as IHasLegacyLastTickOffset)?.LegacyLastTickOffset, // prior to v8, speed multipliers don't adjust for how many ticks are generated over the same distance. // this results in more (or less) ticks being generated in /// The radius of hit objects (ie. the radius of a ). @@ -73,14 +73,6 @@ namespace osu.Game.Rulesets.Osu.Objects public virtual bool NewCombo { get; set; } - public readonly Bindable ComboOffsetBindable = new Bindable(); - - public int ComboOffset - { - get => ComboOffsetBindable.Value; - set => ComboOffsetBindable.Value = value; - } - public Bindable IndexInCurrentComboBindable { get; } = new Bindable(); public virtual int IndexInCurrentCombo @@ -105,6 +97,10 @@ namespace osu.Game.Rulesets.Osu.Objects set => LastInComboBindable.Value = value; } + public int LegacyBeatmapComboOffset { get; set; } + + public int LegacyBeatmapComboIndex { get; set; } + protected OsuHitObject() { StackHeightBindable.BindValueChanged(height => diff --git a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs index d08d08390b..99a681acf8 100644 --- a/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs +++ b/osu.Game.Tests/Gameplay/TestSceneHitObjectAccentColour.cs @@ -82,7 +82,6 @@ namespace osu.Game.Tests.Gameplay private class TestHitObjectWithCombo : ConvertHitObject, IHasComboInformation { public bool NewCombo { get; set; } - public int ComboOffset => 0; public Bindable IndexInCurrentComboBindable { get; } = new Bindable(); diff --git a/osu.Game/Beatmaps/BeatmapProcessor.cs b/osu.Game/Beatmaps/BeatmapProcessor.cs index b7b5adc52e..ac2d7d0fc1 100644 --- a/osu.Game/Beatmaps/BeatmapProcessor.cs +++ b/osu.Game/Beatmaps/BeatmapProcessor.cs @@ -37,7 +37,7 @@ namespace osu.Game.Beatmaps if (obj.NewCombo) { obj.IndexInCurrentCombo = 0; - obj.ComboIndex = (lastObj?.ComboIndex ?? 0) + obj.ComboOffset + 1; + obj.ComboIndex = (lastObj?.ComboIndex ?? 0) + 1; if (lastObj != null) lastObj.LastInCombo = true; @@ -48,6 +48,16 @@ namespace osu.Game.Beatmaps obj.ComboIndex = lastObj.ComboIndex; } + if (obj is IHasLegacyBeatmapComboOffset legacyObj) + { + var lastLegacyObj = (IHasLegacyBeatmapComboOffset)lastObj; + + if (obj.NewCombo) + legacyObj.LegacyBeatmapComboIndex = (lastLegacyObj?.LegacyBeatmapComboIndex ?? 0) + legacyObj.LegacyBeatmapComboOffset + 1; + else if (lastLegacyObj != null) + legacyObj.LegacyBeatmapComboIndex = lastLegacyObj.LegacyBeatmapComboIndex; + } + lastObj = obj; } } diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs index acbf57d25f..e494f6c95c 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapEncoder.cs @@ -292,10 +292,11 @@ namespace osu.Game.Beatmaps.Formats if (hitObject is IHasCombo combo) { - type = (LegacyHitObjectType)(combo.ComboOffset << 4); - if (combo.NewCombo) type |= LegacyHitObjectType.NewCombo; + + if (hitObject is IHasLegacyBeatmapComboOffset comboOffset) + type |= (LegacyHitObjectType)(comboOffset.LegacyBeatmapComboOffset << 4); } switch (hitObject) diff --git a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHit.cs b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHit.cs index 19722fb796..f1a03a03e2 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHit.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHit.cs @@ -13,7 +13,5 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch public float X { get; set; } public bool NewCombo { get; set; } - - public int ComboOffset { get; set; } } } diff --git a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs index c10c8dc30f..d71ddfd05e 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertHitObjectParser.cs @@ -18,21 +18,16 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch } private bool forceNewCombo; - private int extraComboOffset; protected override HitObject CreateHit(Vector2 position, bool newCombo, int comboOffset) { newCombo |= forceNewCombo; - comboOffset += extraComboOffset; - forceNewCombo = false; - extraComboOffset = 0; return new ConvertHit { X = position.X, NewCombo = newCombo, - ComboOffset = comboOffset }; } @@ -40,16 +35,12 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch List> nodeSamples) { newCombo |= forceNewCombo; - comboOffset += extraComboOffset; - forceNewCombo = false; - extraComboOffset = 0; return new ConvertSlider { X = position.X, NewCombo = FirstObject || newCombo, - ComboOffset = comboOffset, Path = new SliderPath(controlPoints, length), NodeSamples = nodeSamples, RepeatCount = repeatCount @@ -58,11 +49,6 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch protected override HitObject CreateSpinner(Vector2 position, bool newCombo, int comboOffset, double duration) { - // Convert spinners don't create the new combo themselves, but force the next non-spinner hitobject to create a new combo - // Their combo offset is still added to that next hitobject's combo index - forceNewCombo |= FormatVersion <= 8 || newCombo; - extraComboOffset += comboOffset; - return new ConvertSpinner { Duration = duration diff --git a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSlider.cs index 56790629b4..8b8bc2f4e1 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSlider.cs @@ -13,7 +13,5 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch public float X { get; set; } public bool NewCombo { get; set; } - - public int ComboOffset { get; set; } } } diff --git a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs index 014494ec54..3355bb3ee5 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Catch/ConvertSpinner.cs @@ -17,7 +17,5 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch public float X => 256; // Required for CatchBeatmapConverter public bool NewCombo { get; set; } - - public int ComboOffset { get; set; } } } diff --git a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHit.cs b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHit.cs index 069366bad3..03b103b8fe 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHit.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHit.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu /// /// Legacy osu! Hit-type, used for parsing Beatmaps. /// - internal sealed class ConvertHit : ConvertHitObject, IHasPosition, IHasCombo + internal sealed class ConvertHit : ConvertHitObject, IHasPosition, IHasCombo, IHasLegacyBeatmapComboOffset { public Vector2 Position { get; set; } @@ -19,6 +19,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu public bool NewCombo { get; set; } - public int ComboOffset { get; set; } + public int LegacyBeatmapComboOffset { get; set; } + + int IHasLegacyBeatmapComboOffset.LegacyBeatmapComboIndex { get; set; } } } diff --git a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs index 75ecab0b8f..451b714266 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertHitObjectParser.cs @@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu { Position = position, NewCombo = FirstObject || newCombo, - ComboOffset = comboOffset + LegacyBeatmapComboOffset = comboOffset }; } @@ -49,7 +49,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu { Position = position, NewCombo = FirstObject || newCombo, - ComboOffset = comboOffset, + LegacyBeatmapComboOffset = comboOffset, Path = new SliderPath(controlPoints, length), NodeSamples = nodeSamples, RepeatCount = repeatCount diff --git a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertSlider.cs b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertSlider.cs index e947690668..c76c5a3f67 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertSlider.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertSlider.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu /// /// Legacy osu! Slider-type, used for parsing Beatmaps. /// - internal sealed class ConvertSlider : Legacy.ConvertSlider, IHasPosition, IHasCombo + internal sealed class ConvertSlider : Legacy.ConvertSlider, IHasPosition, IHasCombo, IHasLegacyBeatmapComboOffset { public Vector2 Position { get; set; } @@ -19,6 +19,8 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu public bool NewCombo { get; set; } - public int ComboOffset { get; set; } + public int LegacyBeatmapComboOffset { get; set; } + + int IHasLegacyBeatmapComboOffset.LegacyBeatmapComboIndex { get; set; } } } diff --git a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertSpinner.cs b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertSpinner.cs index e9e5ca8c94..328a380a96 100644 --- a/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertSpinner.cs +++ b/osu.Game/Rulesets/Objects/Legacy/Osu/ConvertSpinner.cs @@ -22,7 +22,5 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu public float Y => Position.Y; public bool NewCombo { get; set; } - - public int ComboOffset { get; set; } } } diff --git a/osu.Game/Rulesets/Objects/Types/IHasCombo.cs b/osu.Game/Rulesets/Objects/Types/IHasCombo.cs index d1a4683a1d..7288684d27 100644 --- a/osu.Game/Rulesets/Objects/Types/IHasCombo.cs +++ b/osu.Game/Rulesets/Objects/Types/IHasCombo.cs @@ -12,10 +12,5 @@ namespace osu.Game.Rulesets.Objects.Types /// Whether the HitObject starts a new combo. /// bool NewCombo { get; } - - /// - /// When starting a new combo, the offset of the new combo relative to the current one. - /// - int ComboOffset { get; } } } diff --git a/osu.Game/Rulesets/Objects/Types/IHasLegacyBeatmapComboOffset.cs b/osu.Game/Rulesets/Objects/Types/IHasLegacyBeatmapComboOffset.cs new file mode 100644 index 0000000000..1a39192438 --- /dev/null +++ b/osu.Game/Rulesets/Objects/Types/IHasLegacyBeatmapComboOffset.cs @@ -0,0 +1,24 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +namespace osu.Game.Rulesets.Objects.Types +{ + /// + /// A type of that has a combo index with arbitrary offsets applied to use when retrieving legacy beatmap combo colours. + /// This is done in stable for hitobjects to skip combo colours from the beatmap skin (known as "colour hax"). + /// See https://osu.ppy.sh/wiki/en/osu%21_File_Formats/Osu_%28file_format%29#type for more information. + /// + public interface IHasLegacyBeatmapComboOffset + { + /// + /// The legacy offset of the new combo relative to the current one, when starting a new combo. + /// + int LegacyBeatmapComboOffset { get; } + + /// + /// The combo index with the applied, + /// to use for legacy beatmap skins to decide on the combo colour. + /// + int LegacyBeatmapComboIndex { get; set; } + } +}