1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 18:23:04 +08:00

Merge pull request #13887 from ekrctb/legacy-converted-y

Preserve Y position of hit objects in osu!catch
This commit is contained in:
Dean Herbert 2021-07-19 18:48:23 +09:00 committed by GitHub
commit 23ef666f34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 17 deletions

View File

@ -23,7 +23,8 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
protected override IEnumerable<CatchHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap, CancellationToken cancellationToken) protected override IEnumerable<CatchHitObject> ConvertHitObject(HitObject obj, IBeatmap beatmap, CancellationToken cancellationToken)
{ {
var positionData = obj as IHasXPosition; var xPositionData = obj as IHasXPosition;
var yPositionData = obj as IHasYPosition;
var comboData = obj as IHasCombo; var comboData = obj as IHasCombo;
switch (obj) switch (obj)
@ -36,10 +37,11 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
Path = curveData.Path, Path = curveData.Path,
NodeSamples = curveData.NodeSamples, NodeSamples = curveData.NodeSamples,
RepeatCount = curveData.RepeatCount, RepeatCount = curveData.RepeatCount,
X = positionData?.X ?? 0, X = xPositionData?.X ?? 0,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0, ComboOffset = comboData?.ComboOffset ?? 0,
LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0 LegacyLastTickOffset = (obj as IHasLegacyLastTickOffset)?.LegacyLastTickOffset ?? 0,
LegacyConvertedY = yPositionData?.Y ?? CatchHitObject.DEFAULT_LEGACY_CONVERT_Y
}.Yield(); }.Yield();
case IHasDuration endTime: case IHasDuration endTime:
@ -59,7 +61,8 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
Samples = obj.Samples, Samples = obj.Samples,
NewCombo = comboData?.NewCombo ?? false, NewCombo = comboData?.NewCombo ?? false,
ComboOffset = comboData?.ComboOffset ?? 0, ComboOffset = comboData?.ComboOffset ?? 0,
X = positionData?.X ?? 0 X = xPositionData?.X ?? 0,
LegacyConvertedY = yPositionData?.Y ?? CatchHitObject.DEFAULT_LEGACY_CONVERT_Y
}.Yield(); }.Yield();
} }
} }

View File

@ -9,10 +9,11 @@ using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osuTK;
namespace osu.Game.Rulesets.Catch.Objects namespace osu.Game.Rulesets.Catch.Objects
{ {
public abstract class CatchHitObject : HitObject, IHasXPosition, IHasComboInformation public abstract class CatchHitObject : HitObject, IHasPosition, IHasComboInformation
{ {
public const float OBJECT_RADIUS = 64; public const float OBJECT_RADIUS = 64;
@ -31,8 +32,6 @@ namespace osu.Game.Rulesets.Catch.Objects
set => OriginalXBindable.Value = value; set => OriginalXBindable.Value = value;
} }
float IHasXPosition.X => OriginalXBindable.Value;
public readonly Bindable<float> XOffsetBindable = new Bindable<float>(); public readonly Bindable<float> XOffsetBindable = new Bindable<float>();
/// <summary> /// <summary>
@ -131,5 +130,24 @@ namespace osu.Game.Rulesets.Catch.Objects
} }
protected override HitWindows CreateHitWindows() => HitWindows.Empty; protected override HitWindows CreateHitWindows() => HitWindows.Empty;
#region Hit object conversion
// The half of the height of the osu! playfield.
public const float DEFAULT_LEGACY_CONVERT_Y = 192;
/// <summary>
/// The Y position of the hit object is not used in the normal osu!catch gameplay.
/// It is preserved to maximize the backward compatibility with the legacy editor, in which the mappers use the Y position to organize the patterns.
/// </summary>
public float LegacyConvertedY { get; set; } = DEFAULT_LEGACY_CONVERT_Y;
float IHasXPosition.X => OriginalX;
float IHasYPosition.Y => LegacyConvertedY;
Vector2 IHasPosition.Position => new Vector2(OriginalX, LegacyConvertedY);
#endregion
} }
} }

View File

@ -251,11 +251,8 @@ namespace osu.Game.Beatmaps.Formats
switch (beatmap.BeatmapInfo.RulesetID) switch (beatmap.BeatmapInfo.RulesetID)
{ {
case 0: case 0:
position = ((IHasPosition)hitObject).Position;
break;
case 2: case 2:
position.X = ((IHasXPosition)hitObject).X; position = ((IHasPosition)hitObject).Position;
break; break;
case 3: case 3:

View File

@ -2,15 +2,20 @@
// 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.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Rulesets.Objects.Legacy.Catch namespace osu.Game.Rulesets.Objects.Legacy.Catch
{ {
/// <summary> /// <summary>
/// Legacy osu!catch Hit-type, used for parsing Beatmaps. /// Legacy osu!catch Hit-type, used for parsing Beatmaps.
/// </summary> /// </summary>
internal sealed class ConvertHit : ConvertHitObject, IHasCombo, IHasXPosition internal sealed class ConvertHit : ConvertHitObject, IHasPosition, IHasCombo
{ {
public float X { get; set; } public float X => Position.X;
public float Y => Position.Y;
public Vector2 Position { get; set; }
public bool NewCombo { get; set; } public bool NewCombo { get; set; }

View File

@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
return new ConvertHit return new ConvertHit
{ {
X = position.X, Position = position,
NewCombo = newCombo, NewCombo = newCombo,
ComboOffset = comboOffset ComboOffset = comboOffset
}; };
@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
return new ConvertSlider return new ConvertSlider
{ {
X = position.X, Position = position,
NewCombo = FirstObject || newCombo, NewCombo = FirstObject || newCombo,
ComboOffset = comboOffset, ComboOffset = comboOffset,
Path = new SliderPath(controlPoints, length), Path = new SliderPath(controlPoints, length),

View File

@ -2,15 +2,20 @@
// 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.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using osuTK;
namespace osu.Game.Rulesets.Objects.Legacy.Catch namespace osu.Game.Rulesets.Objects.Legacy.Catch
{ {
/// <summary> /// <summary>
/// Legacy osu!catch Slider-type, used for parsing Beatmaps. /// Legacy osu!catch Slider-type, used for parsing Beatmaps.
/// </summary> /// </summary>
internal sealed class ConvertSlider : Legacy.ConvertSlider, IHasXPosition, IHasCombo internal sealed class ConvertSlider : Legacy.ConvertSlider, IHasPosition, IHasCombo
{ {
public float X { get; set; } public float X => Position.X;
public float Y => Position.Y;
public Vector2 Position { get; set; }
public bool NewCombo { get; set; } public bool NewCombo { get; set; }