1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 06:33:20 +08:00

Add hold note conversion.

This commit is contained in:
smoogipooo 2017-05-12 16:35:57 +09:00
parent fdd98e23bd
commit 17466a662c
10 changed files with 69 additions and 32 deletions

View File

@ -82,6 +82,10 @@ namespace osu.Game.Rulesets.Mania.UI
protected override DrawableHitObject<ManiaHitObject, ManiaJudgement> GetVisualRepresentation(ManiaHitObject h)
{
var holdNote = h as HoldNote;
if (holdNote != null)
return new DrawableHoldNote(holdNote);
var note = h as Note;
if (note != null)
return new DrawableNote(note);

View File

@ -43,5 +43,10 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
EndTime = endTime
};
}
protected override HitObject CreateHold(Vector2 position, bool newCombo, double endTime)
{
return null;
}
}
}

View File

@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Globalization;
using osu.Game.Beatmaps.Formats;
using osu.Game.Audio;
using System.Linq;
namespace osu.Game.Rulesets.Objects.Legacy
{
@ -26,7 +27,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
var soundType = (LegacySoundType)int.Parse(split[4]);
var bankInfo = new SampleBankInfo();
HitObject result;
HitObject result = null;
if ((type & ConvertHitObjectType.Circle) > 0)
{
@ -140,17 +141,19 @@ namespace osu.Game.Rulesets.Objects.Legacy
{
// Note: Hold is generated by BMS converts
// Todo: Apparently end time is determined by samples??
// Shouldn't need implementation until mania
double endTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);
result = new ConvertHold
if (split.Length > 5 && !string.IsNullOrEmpty(split[5]))
{
Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])),
NewCombo = combo
};
endTime = Convert.ToDouble(split[0], CultureInfo.InvariantCulture);
readCustomSampleBanks(string.Join(":", split.Skip(1)), bankInfo);
}
result = CreateHold(new Vector2(int.Parse(split[0]), int.Parse(split[1])), combo, endTime);
}
else
throw new InvalidOperationException($@"Unknown hit object type {type}");
if (result == null)
throw new InvalidOperationException($@"Unknown hit object type {type}.");
result.StartTime = Convert.ToDouble(split[2], CultureInfo.InvariantCulture);
result.Samples = convertSoundType(soundType, bankInfo);
@ -214,6 +217,14 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <returns>The hit object.</returns>
protected abstract HitObject CreateSpinner(Vector2 position, double endTime);
/// <summary>
/// Creates a legacy Hold-type hit object.
/// </summary>
/// <param name="position">The position of the hit object.</param>
/// <param name="newCombo">Whether the hit object creates a new combo.</param>
/// <param name="endTime">The hold end time.</param>
protected abstract HitObject CreateHold(Vector2 position, bool newCombo, double endTime);
private SampleInfoList convertSoundType(LegacySoundType type, SampleBankInfo bankInfo)
{
var soundTypes = new SampleInfoList

View File

@ -1,22 +0,0 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using OpenTK;
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Objects.Legacy
{
/// <summary>
/// Legacy Hold-type, used for parsing "specials" in beatmaps.
/// </summary>
internal sealed class ConvertHold : HitObject, IHasPosition, IHasCombo, IHasHold
{
public Vector2 Position { get; set; }
public float X => Position.X;
public float Y => Position.Y;
public bool NewCombo { get; set; }
}
}

View File

@ -44,5 +44,14 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
EndTime = endTime
};
}
protected override HitObject CreateHold(Vector2 position, bool newCombo, double endTime)
{
return new ConvertHold
{
X = position.X,
EndTime = endTime
};
}
}
}

View File

@ -0,0 +1,16 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Objects.Types;
namespace osu.Game.Rulesets.Objects.Legacy.Mania
{
internal sealed class ConvertHold : HitObject, IHasXPosition, IHasEndTime
{
public float X { get; set; }
public double EndTime { get; set; }
public double Duration => EndTime - StartTime;
}
}

View File

@ -44,5 +44,10 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
EndTime = endTime
};
}
protected override HitObject CreateHold(Vector2 position, bool newCombo, double endTime)
{
return null;
}
}
}

View File

@ -41,5 +41,10 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
EndTime = endTime
};
}
protected override HitObject CreateHold(Vector2 position, bool newCombo, double endTime)
{
return null;
}
}
}

View File

@ -8,5 +8,9 @@ namespace osu.Game.Rulesets.Objects.Types
/// </summary>
public interface IHasHold
{
/// <summary>
/// The time at which the hold ends.
/// </summary>
double EndTime { get; }
}
}

View File

@ -125,6 +125,7 @@
<Compile Include="Rulesets\Objects\Legacy\ConvertSlider.cs" />
<Compile Include="Rulesets\Objects\Legacy\Mania\ConvertHit.cs" />
<Compile Include="Rulesets\Objects\Legacy\Mania\ConvertHitObjectParser.cs" />
<Compile Include="Rulesets\Objects\Legacy\Mania\ConvertHold.cs" />
<Compile Include="Rulesets\Objects\Legacy\Mania\ConvertSlider.cs" />
<Compile Include="Rulesets\Objects\Legacy\Mania\ConvertSpinner.cs" />
<Compile Include="Rulesets\Objects\Legacy\Osu\ConvertHitObjectParser.cs" />
@ -161,7 +162,6 @@
<Compile Include="Rulesets\Objects\CircularArcApproximator.cs" />
<Compile Include="Rulesets\Objects\Legacy\Osu\ConvertHit.cs" />
<Compile Include="Rulesets\Objects\Legacy\ConvertHitObjectParser.cs" />
<Compile Include="Rulesets\Objects\Legacy\ConvertHold.cs" />
<Compile Include="Rulesets\Objects\Legacy\Osu\ConvertSlider.cs" />
<Compile Include="Rulesets\Objects\Legacy\Osu\ConvertSpinner.cs" />
<Compile Include="Rulesets\Objects\SliderCurve.cs" />