mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Simplify and tidy sample retrieval
Less static weirdness
This commit is contained in:
@ -62,7 +62,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
private readonly Box background;
|
private readonly Box background;
|
||||||
|
|
||||||
private readonly ControlPointInfo controlPointInfo;
|
private readonly ControlPointInfo controlPointInfo;
|
||||||
private Dictionary<double, Tuple<SampleChannel, SampleChannel>> allSamples;
|
private Dictionary<SampleControlPoint, Tuple<SampleChannel, SampleChannel>> drumSampleMappings;
|
||||||
|
|
||||||
public TaikoPlayfield(ControlPointInfo controlPointInfo)
|
public TaikoPlayfield(ControlPointInfo controlPointInfo)
|
||||||
: base(Axes.X)
|
: base(Axes.X)
|
||||||
@ -207,12 +207,12 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, AudioManager audio)
|
private void load(OsuColour colours, AudioManager audio)
|
||||||
{
|
{
|
||||||
allSamples = new Dictionary<double, Tuple<SampleChannel, SampleChannel>>();
|
drumSampleMappings = new Dictionary<SampleControlPoint, Tuple<SampleChannel, SampleChannel>>();
|
||||||
foreach (var s in controlPointInfo.SamplePoints)
|
foreach (var s in controlPointInfo.SamplePoints)
|
||||||
{
|
{
|
||||||
var normalSample = SampleInfo.FromSoundPoint(s).GetChannel(audio.Sample);
|
var normalSample = s.GetSampleInfo().GetChannel(audio.Sample);
|
||||||
var clapSample = SampleInfo.FromSoundPoint(s, SampleInfo.HIT_CLAP).GetChannel(audio.Sample);
|
var clapSample = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample);
|
||||||
allSamples.Add(s.Time, new Tuple<SampleChannel, SampleChannel>(normalSample, clapSample));
|
drumSampleMappings.Add(s, new Tuple<SampleChannel, SampleChannel>(normalSample, clapSample));
|
||||||
}
|
}
|
||||||
|
|
||||||
overlayBackgroundContainer.BorderColour = colours.Gray0;
|
overlayBackgroundContainer.BorderColour = colours.Gray0;
|
||||||
@ -268,7 +268,9 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
{
|
{
|
||||||
topLevelHitContainer.Add(judgedObject.CreateProxy());
|
topLevelHitContainer.Add(judgedObject.CreateProxy());
|
||||||
}
|
}
|
||||||
catch { }
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim));
|
hitExplosionContainer.Add(new HitExplosion(judgedObject, isRim));
|
||||||
@ -280,10 +282,9 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
public bool OnPressed(TaikoAction action)
|
public bool OnPressed(TaikoAction action)
|
||||||
{
|
{
|
||||||
var currentTime = Clock.CurrentTime;
|
var samplePoint = controlPointInfo.SamplePointAt(Clock.CurrentTime);
|
||||||
var soundPoint = currentTime < controlPointInfo.SamplePoints[0].Time ? controlPointInfo.SamplePoints[0] : controlPointInfo.SamplePointAt(currentTime);
|
|
||||||
|
|
||||||
if (!allSamples.TryGetValue(soundPoint.Time, out Tuple<SampleChannel, SampleChannel> samples))
|
if (!drumSampleMappings.TryGetValue(samplePoint, out var samples))
|
||||||
throw new InvalidOperationException("Current sample set not found.");
|
throw new InvalidOperationException("Current sample set not found.");
|
||||||
|
|
||||||
if (action == TaikoAction.LeftCentre || action == TaikoAction.RightCentre)
|
if (action == TaikoAction.LeftCentre || action == TaikoAction.RightCentre)
|
||||||
|
@ -5,7 +5,6 @@ using System;
|
|||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Audio.Sample;
|
using osu.Framework.Audio.Sample;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
|
||||||
|
|
||||||
namespace osu.Game.Audio
|
namespace osu.Game.Audio
|
||||||
{
|
{
|
||||||
@ -17,16 +16,6 @@ namespace osu.Game.Audio
|
|||||||
public const string HIT_NORMAL = @"hitnormal";
|
public const string HIT_NORMAL = @"hitnormal";
|
||||||
public const string HIT_CLAP = @"hitclap";
|
public const string HIT_CLAP = @"hitclap";
|
||||||
|
|
||||||
public static SampleInfo FromSoundPoint(SampleControlPoint samplePoint, string sampleName = HIT_NORMAL)
|
|
||||||
{
|
|
||||||
return new SampleInfo
|
|
||||||
{
|
|
||||||
Bank = samplePoint.SampleBank,
|
|
||||||
Name = sampleName,
|
|
||||||
Volume = samplePoint.SampleVolume,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public SampleChannel GetChannel(SampleManager manager)
|
public SampleChannel GetChannel(SampleManager manager)
|
||||||
{
|
{
|
||||||
var channel = manager.Get($"Gameplay/{Bank}-{Name}");
|
var channel = manager.Get($"Gameplay/{Bank}-{Name}");
|
||||||
|
@ -55,7 +55,7 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="time">The time to find the sound control point at.</param>
|
/// <param name="time">The time to find the sound control point at.</param>
|
||||||
/// <returns>The sound control point.</returns>
|
/// <returns>The sound control point.</returns>
|
||||||
public SampleControlPoint SamplePointAt(double time) => binarySearch(SamplePoints, time);
|
public SampleControlPoint SamplePointAt(double time) => binarySearch(SamplePoints, time, SamplePoints.FirstOrDefault());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the timing control point that is active at <paramref name="time"/>.
|
/// Finds the timing control point that is active at <paramref name="time"/>.
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using osu.Game.Audio;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.ControlPoints
|
namespace osu.Game.Beatmaps.ControlPoints
|
||||||
{
|
{
|
||||||
public class SampleControlPoint : ControlPoint
|
public class SampleControlPoint : ControlPoint
|
||||||
@ -16,5 +18,17 @@ namespace osu.Game.Beatmaps.ControlPoints
|
|||||||
/// The default sample volume at this control point.
|
/// The default sample volume at this control point.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int SampleVolume;
|
public int SampleVolume;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a SampleInfo based on the sample settings in this control point.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sampleName">The name of the same.</param>
|
||||||
|
/// <returns>A populated <see cref="SampleInfo"/>.</returns>
|
||||||
|
public SampleInfo GetSampleInfo(string sampleName = SampleInfo.HIT_NORMAL) => new SampleInfo
|
||||||
|
{
|
||||||
|
Bank = SampleBank,
|
||||||
|
Name = sampleName,
|
||||||
|
Volume = SampleVolume,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user