1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Ability to contain multiple sample banks. Get default bank name from control point.

This commit is contained in:
smoogipooo 2017-04-05 21:59:07 +09:00
parent 8d720e39c6
commit d607207b69
11 changed files with 46 additions and 28 deletions

View File

@ -43,7 +43,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
return new Slider
{
StartTime = original.StartTime,
SampleBank = original.SampleBank,
SampleBanks = original.SampleBanks,
CurveObject = curveData,
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false
@ -55,7 +55,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
return new Spinner
{
StartTime = original.StartTime,
SampleBank = original.SampleBank,
SampleBanks = original.SampleBanks,
Position = new Vector2(512, 384) / 2,
EndTime = endTimeData.EndTime
};
@ -64,7 +64,7 @@ namespace osu.Game.Modes.Osu.Beatmaps
return new HitCircle
{
StartTime = original.StartTime,
SampleBank = original.SampleBank,
SampleBanks = original.SampleBanks,
Position = positionData?.Position ?? Vector2.Zero,
NewCombo = comboData?.NewCombo ?? false
};

View File

@ -67,7 +67,7 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
ComboIndex = s.ComboIndex,
Scale = s.Scale,
ComboColour = s.ComboColour,
SampleBank = s.SampleBank,
SampleBanks = s.SampleBanks,
}),
};

View File

@ -12,6 +12,7 @@ using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Osu.Judgements;
using OpenTK;
using OpenTK.Graphics;
using System.Collections.Generic;
namespace osu.Game.Modes.Osu.Objects.Drawables
{
@ -28,6 +29,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
protected override OsuJudgement CreateJudgement() => new OsuJudgement { MaxScore = OsuScoreResult.SliderTick };
private List<SampleChannel> samples = new List<SampleChannel>();
public DrawableSliderTick(SliderTick sliderTick) : base(sliderTick)
{
this.sliderTick = sliderTick;
@ -53,20 +56,18 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
};
}
private SampleChannel sample;
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
sample = audio.Sample.Get($@"Gameplay/{HitObject.SampleBank.Name}-slidertick");
foreach (var bank in HitObject.SampleBanks)
samples.Add(audio.Sample.Get($@"Gameplay/{bank.Name}-slidertick"));
}
protected override void PlaySamples()
{
sample?.Play();
samples.ForEach(s => s?.Play());
}
protected override void CheckJudgement(bool userTriggered)
{
if (Judgement.TimeOffset >= 0)

View File

@ -95,7 +95,7 @@ namespace osu.Game.Modes.Osu.Objects
StackHeight = StackHeight,
Scale = Scale,
ComboColour = ComboColour,
SampleBank = SampleBank
SampleBanks = SampleBanks
};
}
}

View File

@ -57,9 +57,9 @@ namespace osu.Game.Modes.Taiko.Beatmaps
var endTimeData = obj as IHasEndTime;
// Old osu! used hit sounding to determine various hit type information
SampleBank sampleBank = obj.SampleBank;
List<SampleBank> sampleBanks = obj.SampleBanks;
bool strong = sampleBank.Sets.Any(s => s.Type == SampleType.Finish);
bool strong = sampleBanks.Any(b => b.Samples.Any(s => s.Type == SampleType.Finish));
if (distanceData != null)
{
@ -98,7 +98,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
yield return new CentreHit
{
StartTime = j,
SampleBank = obj.SampleBank,
SampleBanks = obj.SampleBanks,
IsStrong = strong,
VelocityMultiplier = legacy_velocity_multiplier
};
@ -109,7 +109,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
yield return new DrumRoll
{
StartTime = obj.StartTime,
SampleBank = obj.SampleBank,
SampleBanks = obj.SampleBanks,
IsStrong = strong,
Distance = distance,
TickRate = beatmap.BeatmapInfo.Difficulty.SliderTickRate == 3 ? 3 : 4,
@ -124,7 +124,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
yield return new Swell
{
StartTime = obj.StartTime,
SampleBank = obj.SampleBank,
SampleBanks = obj.SampleBanks,
IsStrong = strong,
EndTime = endTimeData.EndTime,
RequiredHits = (int)Math.Max(1, endTimeData.Duration / 1000 * hitMultiplier),
@ -133,14 +133,14 @@ namespace osu.Game.Modes.Taiko.Beatmaps
}
else
{
bool isCentre = sampleBank.Sets.Any(s => s.Type == SampleType.Normal);
bool isCentre = sampleBanks.Any(b => b.Samples.Any(s => s.Type == SampleType.Normal));
if (isCentre)
{
yield return new CentreHit
{
StartTime = obj.StartTime,
SampleBank = obj.SampleBank,
SampleBanks = obj.SampleBanks,
IsStrong = strong,
VelocityMultiplier = legacy_velocity_multiplier
};
@ -150,7 +150,7 @@ namespace osu.Game.Modes.Taiko.Beatmaps
yield return new RimHit
{
StartTime = obj.StartTime,
SampleBank = obj.SampleBank,
SampleBanks = obj.SampleBanks,
IsStrong = strong,
VelocityMultiplier = legacy_velocity_multiplier
};

View File

@ -95,7 +95,7 @@ namespace osu.Game.Modes.Taiko.Objects
TickSpacing = tickSpacing,
StartTime = t,
IsStrong = IsStrong,
SampleBank = SampleBank
SampleBanks = SampleBanks
});
first = false;

View File

@ -11,6 +11,7 @@ using osu.Game.Modes;
using osu.Game.Tests.Resources;
using osu.Game.Modes.Osu;
using osu.Game.Modes.Objects.Legacy;
using System.Linq;
namespace osu.Game.Tests.Beatmaps.Formats
{
@ -136,12 +137,12 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.IsNotNull(slider);
Assert.AreEqual(new Vector2(192, 168), slider.Position);
Assert.AreEqual(956, slider.StartTime);
Assert.AreEqual(SampleType.None, slider.SampleBank.Type);
Assert.IsTrue(slider.SampleBanks.Any(b => b.Name == "none"));
var hit = beatmap.HitObjects[1] as LegacyHit;
Assert.IsNotNull(hit);
Assert.AreEqual(new Vector2(304, 56), hit.Position);
Assert.AreEqual(1285, hit.StartTime);
Assert.AreEqual(SampleType.Clap, hit.SampleBank.Type);
Assert.IsTrue(hit.SampleBanks.Any(b => b.Name == "clap"));
}
}
}

View File

@ -13,7 +13,7 @@ namespace osu.Game.Beatmaps.Samples
/// <summary>
/// The list of samples that are to be played to be played from this bank.
/// </summary>
public List<Sample> Sets;
public List<Sample> Samples;
/// <summary>
/// In conversion from osu-stable, this is equivalent to SampleSet (_not_ CustomSampleSet).

View File

@ -13,7 +13,7 @@ namespace osu.Game.Beatmaps.Timing
TimingChange = true,
};
public SampleInfo Sample;
public SampleBank SampleBank;
public TimeSignatures TimeSignature;
public double Time;
public double BeatLength;

View File

@ -59,8 +59,9 @@ namespace osu.Game.Modes.Objects.Drawables
[BackgroundDependencyLoader]
private void load(AudioManager audio)
{
foreach (var sample in HitObject.SampleBank.Sets)
samples.Add(audio.Sample.Get($@"Gameplay/{sample.Type}-hit{HitObject.SampleBank.Name}"));
foreach (var bank in HitObject.SampleBanks)
foreach (var sample in bank.Samples)
samples.Add(audio.Sample.Get($@"Gameplay/{sample.Type}-hit{bank.Name}"));
}
private ArmedState state;

View File

@ -4,6 +4,7 @@
using osu.Game.Beatmaps.Samples;
using osu.Game.Beatmaps.Timing;
using osu.Game.Database;
using System.Collections.Generic;
namespace osu.Game.Modes.Objects
{
@ -21,15 +22,29 @@ namespace osu.Game.Modes.Objects
public double StartTime { get; set; }
/// <summary>
/// The sample bank to be played when this hit object is hit.
/// The sample banks to be played when this hit object is hit.
/// </summary>
public SampleBank SampleBank { get; set; }
public List<SampleBank> SampleBanks = new List<SampleBank>();
/// <summary>
/// Applies default values to this HitObject.
/// </summary>
/// <param name="difficulty">The difficulty settings to use.</param>
/// <param name="timing">The timing settings to use.</param>
public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { }
public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
{
foreach (var bank in SampleBanks)
{
if (!string.IsNullOrEmpty(bank.Name))
continue;
// If the bank is not assigned a name, assign it from the relevant timing point
ControlPoint overridePoint;
ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint);
bank.Name = (overridePoint ?? timingPoint)?.SampleBank.Name ?? string.Empty;
bank.Volume = (overridePoint ?? timingPoint)?.SampleBank.Volume ?? 0;
}
}
}
}