Merge pull request #663 from smoogipooo/fix-drumroll-conversion

Fix drumroll conversion
This commit is contained in:
Dean Herbert
2017-04-26 19:22:50 +09:00
committed by GitHub
13 changed files with 64 additions and 25 deletions

View File

@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Osu.Objects
set { Curve.Distance = value; } set { Curve.Distance = value; }
} }
public List<List<SampleInfo>> RepeatSamples { get; set; } = new List<List<SampleInfo>>(); public List<SampleInfoList> RepeatSamples { get; set; } = new List<SampleInfoList>();
public int RepeatCount { get; set; } = 1; public int RepeatCount { get; set; } = 1;
private int stackHeight; private int stackHeight;
@ -117,12 +117,12 @@ namespace osu.Game.Rulesets.Osu.Objects
StackHeight = StackHeight, StackHeight = StackHeight,
Scale = Scale, Scale = Scale,
ComboColour = ComboColour, ComboColour = ComboColour,
Samples = Samples.Select(s => new SampleInfo Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
{ {
Bank = s.Bank, Bank = s.Bank,
Name = @"slidertick", Name = @"slidertick",
Volume = s.Volume Volume = s.Volume
}).ToList() }))
}; };
} }
} }

View File

@ -66,9 +66,10 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
var distanceData = obj as IHasDistance; var distanceData = obj as IHasDistance;
var repeatsData = obj as IHasRepeats; var repeatsData = obj as IHasRepeats;
var endTimeData = obj as IHasEndTime; var endTimeData = obj as IHasEndTime;
var curveData = obj as IHasCurve;
// Old osu! used hit sounding to determine various hit type information // Old osu! used hit sounding to determine various hit type information
List<SampleInfo> samples = obj.Samples; SampleInfoList samples = obj.Samples;
bool strong = samples.Any(s => s.Name == SampleInfo.HIT_FINISH); bool strong = samples.Any(s => s.Name == SampleInfo.HIT_FINISH);
@ -102,16 +103,35 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps
if (tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength) if (tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength)
{ {
List<SampleInfoList> allSamples = curveData != null ? curveData.RepeatSamples : new List<SampleInfoList>(new[] { samples });
int i = 0;
for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing) for (double j = obj.StartTime; j <= obj.StartTime + taikoDuration + tickSpacing / 8; j += tickSpacing)
{ {
// Todo: This should generate different type of hits (including strongs) SampleInfoList currentSamples = allSamples[i];
// depending on hitobject sound additions (not implemented fully yet) bool isRim = currentSamples.Any(s => s.Name == SampleInfo.HIT_CLAP || s.Name == SampleInfo.HIT_WHISTLE);
yield return new CentreHit strong = currentSamples.Any(s => s.Name == SampleInfo.HIT_FINISH);
if (isRim)
{ {
StartTime = j, yield return new RimHit
Samples = obj.Samples, {
IsStrong = strong, StartTime = j,
}; Samples = currentSamples,
IsStrong = strong
};
}
else
{
yield return new CentreHit
{
StartTime = j,
Samples = currentSamples,
IsStrong = strong,
};
}
i = (i + 1) % allSamples.Count;
} }
} }
else else

View File

@ -82,12 +82,12 @@ namespace osu.Game.Rulesets.Taiko.Objects
TickSpacing = tickSpacing, TickSpacing = tickSpacing,
StartTime = t, StartTime = t,
IsStrong = IsStrong, IsStrong = IsStrong,
Samples = Samples.Select(s => new SampleInfo Samples = new SampleInfoList(Samples.Select(s => new SampleInfo
{ {
Bank = s.Bank, Bank = s.Bank,
Name = @"slidertick", Name = @"slidertick",
Volume = s.Volume Volume = s.Volume
}).ToList() }))
}); });
first = false; first = false;

View File

@ -0,0 +1,19 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
namespace osu.Game.Audio
{
public class SampleInfoList : List<SampleInfo>
{
public SampleInfoList()
{
}
public SampleInfoList(IEnumerable<SampleInfo> elements)
{
AddRange(elements);
}
}
}

View File

@ -5,7 +5,6 @@ using osu.Game.Audio;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using System.Collections.Generic;
namespace osu.Game.Rulesets.Objects namespace osu.Game.Rulesets.Objects
{ {
@ -29,7 +28,7 @@ namespace osu.Game.Rulesets.Objects
/// and can be treated as the default samples for the hit object. /// and can be treated as the default samples for the hit object.
/// </para> /// </para>
/// </summary> /// </summary>
public List<SampleInfo> Samples = new List<SampleInfo>(); public SampleInfoList Samples = new SampleInfoList();
/// <summary> /// <summary>
/// Applies default values to this HitObject. /// Applies default values to this HitObject.

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Catch
}; };
} }
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples) protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples)
{ {
return new ConvertSlider return new ConvertSlider
{ {

View File

@ -123,7 +123,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
} }
// Generate the final per-node samples // Generate the final per-node samples
var nodeSamples = new List<List<SampleInfo>>(nodes); var nodeSamples = new List<SampleInfoList>(nodes);
for (int i = 0; i <= repeatCount; i++) for (int i = 0; i <= repeatCount; i++)
nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i])); nodeSamples.Add(convertSoundType(nodeSoundTypes[i], nodeBankInfos[i]));
@ -204,7 +204,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <param name="repeatCount">The slider repeat count.</param> /// <param name="repeatCount">The slider repeat count.</param>
/// <param name="repeatSamples">The samples to be played when the repeat nodes are hit. This includes the head and tail of the slider.</param> /// <param name="repeatSamples">The samples to be played when the repeat nodes are hit. This includes the head and tail of the slider.</param>
/// <returns>The hit object.</returns> /// <returns>The hit object.</returns>
protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples); protected abstract HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples);
/// <summary> /// <summary>
/// Creates a legacy Spinner-type hit object. /// Creates a legacy Spinner-type hit object.
@ -214,9 +214,9 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <returns>The hit object.</returns> /// <returns>The hit object.</returns>
protected abstract HitObject CreateSpinner(Vector2 position, double endTime); protected abstract HitObject CreateSpinner(Vector2 position, double endTime);
private List<SampleInfo> convertSoundType(LegacySoundType type, SampleBankInfo bankInfo) private SampleInfoList convertSoundType(LegacySoundType type, SampleBankInfo bankInfo)
{ {
var soundTypes = new List<SampleInfo> var soundTypes = new SampleInfoList
{ {
new SampleInfo new SampleInfo
{ {

View File

@ -15,7 +15,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
public CurveType CurveType { get; set; } public CurveType CurveType { get; set; }
public double Distance { get; set; } public double Distance { get; set; }
public List<List<SampleInfo>> RepeatSamples { get; set; } public List<SampleInfoList> RepeatSamples { get; set; }
public int RepeatCount { get; set; } = 1; public int RepeatCount { get; set; } = 1;
public double EndTime { get; set; } public double EndTime { get; set; }

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Mania
}; };
} }
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples) protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples)
{ {
return new ConvertSlider return new ConvertSlider
{ {

View File

@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Osu
}; };
} }
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples) protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples)
{ {
return new ConvertSlider return new ConvertSlider
{ {

View File

@ -21,7 +21,7 @@ namespace osu.Game.Rulesets.Objects.Legacy.Taiko
}; };
} }
protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<List<SampleInfo>> repeatSamples) protected override HitObject CreateSlider(Vector2 position, bool newCombo, List<Vector2> controlPoints, double length, CurveType curveType, int repeatCount, List<SampleInfoList> repeatSamples)
{ {
return new ConvertSlider return new ConvertSlider
{ {

View File

@ -19,6 +19,6 @@ namespace osu.Game.Rulesets.Objects.Types
/// <summary> /// <summary>
/// The samples to be played when each repeat node is hit (0 -> first repeat node, 1 -> second repeat node, etc). /// The samples to be played when each repeat node is hit (0 -> first repeat node, 1 -> second repeat node, etc).
/// </summary> /// </summary>
List<List<SampleInfo>> RepeatSamples { get; } List<SampleInfoList> RepeatSamples { get; }
} }
} }

View File

@ -71,6 +71,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Audio\SampleInfo.cs" /> <Compile Include="Audio\SampleInfo.cs" />
<Compile Include="Audio\SampleInfoList.cs" />
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" /> <Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
<Compile Include="Beatmaps\DifficultyCalculator.cs" /> <Compile Include="Beatmaps\DifficultyCalculator.cs" />
<Compile Include="Online\API\Requests\PostMessageRequest.cs" /> <Compile Include="Online\API\Requests\PostMessageRequest.cs" />