Merge branch 'master' into fix-notification-scheduled-events

This commit is contained in:
Dan Balasescu
2017-12-27 23:27:23 +09:00
committed by GitHub
17 changed files with 109 additions and 35 deletions

View File

@ -2,7 +2,6 @@
// 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 System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
using osu.Game.Audio; using osu.Game.Audio;
@ -13,7 +12,7 @@ namespace osu.Game.Rulesets.Taiko.Audio
public class DrumSampleMapping public class DrumSampleMapping
{ {
private readonly ControlPointInfo controlPoints; private readonly ControlPointInfo controlPoints;
private readonly Dictionary<SampleControlPoint, DrumSample> mappings = new Dictionary<SampleControlPoint, DrumSample>(); private readonly Dictionary<double, DrumSample> mappings = new Dictionary<double, DrumSample>();
public DrumSampleMapping(ControlPointInfo controlPoints, AudioManager audio) public DrumSampleMapping(ControlPointInfo controlPoints, AudioManager audio)
{ {
@ -26,17 +25,17 @@ namespace osu.Game.Rulesets.Taiko.Audio
else else
samplePoints = controlPoints.SamplePoints; samplePoints = controlPoints.SamplePoints;
foreach (var s in samplePoints.Distinct()) foreach (var s in samplePoints)
{ {
mappings[s] = new DrumSample mappings[s.Time] = new DrumSample
{ {
Centre = s.GetSampleInfo().GetChannel(audio.Sample), Centre = s.GetSampleInfo().GetChannel(audio.Sample, "Taiko"),
Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample) Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample, "Taiko")
}; };
} }
} }
public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time)]; public DrumSample SampleAt(double time) => mappings[controlPoints.SamplePointAt(time).Time];
public class DrumSample public class DrumSample
{ {

View File

@ -41,6 +41,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
// Normal and clap samples are handled by the drum // Normal and clap samples are handled by the drum
protected override IEnumerable<SampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != SampleInfo.HIT_NORMAL && s.Name != SampleInfo.HIT_CLAP); protected override IEnumerable<SampleInfo> GetSamples() => HitObject.Samples.Where(s => s.Name != SampleInfo.HIT_NORMAL && s.Name != SampleInfo.HIT_CLAP);
protected override string SampleNamespace => "Taiko";
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece(); protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
public abstract bool OnPressed(TaikoAction action); public abstract bool OnPressed(TaikoAction action);

View File

@ -3,9 +3,6 @@
using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Objects.Types;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
@ -75,13 +72,7 @@ namespace osu.Game.Rulesets.Taiko.Objects
FirstTick = first, FirstTick = first,
TickSpacing = tickSpacing, TickSpacing = tickSpacing,
StartTime = t, StartTime = t,
IsStrong = IsStrong, IsStrong = IsStrong
Samples = new List<SampleInfo>(Samples.Select(s => new SampleInfo
{
Bank = s.Bank,
Name = @"slidertick",
Volume = s.Volume
}))
}); });
first = false; first = false;

View File

@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
{ {
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>()) foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
{ {
Frames.Add(new ReplayFrame(tick.StartTime, null, null, hitButton ? ReplayButtonState.Left1 : ReplayButtonState.Left2)); Frames.Add(new ReplayFrame(tick.StartTime, null, null, hitButton ? ReplayButtonState.Right1 : ReplayButtonState.Right2));
hitButton = !hitButton; hitButton = !hitButton;
} }
} }

View File

@ -0,0 +1,44 @@
// 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;
using System.Collections.Generic;
using NUnit.Framework;
using OpenTK;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Audio;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Rulesets.Taiko.Audio;
using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Tests.Visual;
namespace osu.Game.Rulesets.Taiko.Tests
{
[Ignore("getting CI working")]
public class TestCaseInputDrum : OsuTestCase
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(InputDrum),
typeof(DrumSampleMapping),
typeof(SampleInfo),
typeof(SampleControlPoint)
};
public TestCaseInputDrum()
{
Add(new TaikoInputManager(new RulesetInfo { ID = 1 })
{
RelativeSizeAxes = Axes.Both,
Child = new Container
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(200),
Child = new InputDrum(new ControlPointInfo())
}
});
}
}
}

View File

@ -152,14 +152,14 @@ namespace osu.Game.Rulesets.Taiko.UI
target = centreHit; target = centreHit;
back = centre; back = centre;
drumSample.Centre.Play(); drumSample.Centre?.Play();
} }
else if (action == RimAction) else if (action == RimAction)
{ {
target = rimHit; target = rimHit;
back = rim; back = rim;
drumSample.Rim.Play(); drumSample.Rim?.Play();
} }
if (target != null) if (target != null)

View File

@ -83,6 +83,7 @@
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scoring\TaikoScoreProcessor.cs" /> <Compile Include="Scoring\TaikoScoreProcessor.cs" />
<Compile Include="TaikoInputManager.cs" /> <Compile Include="TaikoInputManager.cs" />
<Compile Include="Tests\TestCaseInputDrum.cs" />
<Compile Include="Tests\TestCasePerformancePoints.cs" /> <Compile Include="Tests\TestCasePerformancePoints.cs" />
<Compile Include="Tests\TestCaseTaikoPlayfield.cs" /> <Compile Include="Tests\TestCaseTaikoPlayfield.cs" />
<Compile Include="UI\HitTarget.cs" /> <Compile Include="UI\HitTarget.cs" />

View File

@ -2,6 +2,7 @@
// 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 System; using System;
using System.IO;
using osu.Framework.Audio.Sample; using osu.Framework.Audio.Sample;
namespace osu.Game.Audio namespace osu.Game.Audio
@ -14,10 +15,20 @@ 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 SampleChannel GetChannel(SampleManager manager) public SampleChannel GetChannel(SampleManager manager, string resourceNamespace = null)
{ {
var channel = manager.Get($"Gameplay/{Bank}-{Name}"); SampleChannel channel = null;
if (resourceNamespace != null)
channel = manager.Get(Path.Combine("Gameplay", resourceNamespace, $"{Bank}-{Name}"));
// try without namespace as a fallback.
if (channel == null)
channel = manager.Get(Path.Combine("Gameplay", $"{Bank}-{Name}"));
if (channel != null)
channel.Volume.Value = Volume / 100.0; channel.Volume.Value = Volume / 100.0;
return channel; return channel;
} }

View File

@ -17,7 +17,7 @@ namespace osu.Game.Beatmaps.ControlPoints
/// <summary> /// <summary>
/// The default sample volume at this control point. /// The default sample volume at this control point.
/// </summary> /// </summary>
public int SampleVolume; public int SampleVolume = 100;
/// <summary> /// <summary>
/// Create a SampleInfo based on the sample settings in this control point. /// Create a SampleInfo based on the sample settings in this control point.

View File

@ -84,10 +84,13 @@ namespace osu.Game.Overlays
private int runningDepth; private int runningDepth;
private void notificationClosed() private void notificationClosed()
{
Schedule(() =>
{ {
// hide ourselves if all notifications have been dismissed. // hide ourselves if all notifications have been dismissed.
if (totalCount == 0) if (totalCount == 0)
State = Visibility.Hidden; State = Visibility.Hidden;
});
updateCounts(); updateCounts();
} }

View File

@ -95,8 +95,8 @@ namespace osu.Game.Overlays.Notifications
protected virtual void Completed() protected virtual void Completed()
{ {
base.Close();
CompletionTarget?.Invoke(CreateCompletionNotification()); CompletionTarget?.Invoke(CreateCompletionNotification());
base.Close();
} }
public override bool DisplayOnTop => false; public override bool DisplayOnTop => false;

View File

@ -74,6 +74,9 @@ namespace osu.Game.Rulesets.Objects.Drawables
protected List<SampleChannel> Samples = new List<SampleChannel>(); protected List<SampleChannel> Samples = new List<SampleChannel>();
protected virtual IEnumerable<SampleInfo> GetSamples() => HitObject.Samples; protected virtual IEnumerable<SampleInfo> GetSamples() => HitObject.Samples;
// Todo: Rulesets should be overriding the resources instead, but we need to figure out where/when to apply overrides first
protected virtual string SampleNamespace => null;
public readonly Bindable<ArmedState> State = new Bindable<ArmedState>(); public readonly Bindable<ArmedState> State = new Bindable<ArmedState>();
protected DrawableHitObject(TObject hitObject) protected DrawableHitObject(TObject hitObject)
@ -101,7 +104,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume Volume = s.Volume > 0 ? s.Volume : HitObject.SampleControlPoint.SampleVolume
}; };
SampleChannel channel = localSampleInfo.GetChannel(audio.Sample); SampleChannel channel = localSampleInfo.GetChannel(audio.Sample, SampleNamespace);
if (channel == null) if (channel == null)
continue; continue;

View File

@ -46,6 +46,8 @@ namespace osu.Game.Screens.Play
public bool HasFailed { get; private set; } public bool HasFailed { get; private set; }
public bool AllowPause { get; set; } = true; public bool AllowPause { get; set; } = true;
public bool AllowLeadIn { get; set; } = true;
public bool AllowResults { get; set; } = true;
public int RestartCount; public int RestartCount;
@ -136,7 +138,10 @@ namespace osu.Game.Screens.Play
decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false }; decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
var firstObjectTime = RulesetContainer.Objects.First().StartTime; var firstObjectTime = RulesetContainer.Objects.First().StartTime;
decoupledClock.Seek(Math.Min(0, firstObjectTime - Math.Max(beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, beatmap.BeatmapInfo.AudioLeadIn))); decoupledClock.Seek(AllowLeadIn
? Math.Min(0, firstObjectTime - Math.Max(beatmap.ControlPointInfo.TimingPointAt(firstObjectTime).BeatLength * 4, beatmap.BeatmapInfo.AudioLeadIn))
: firstObjectTime);
decoupledClock.ProcessFrame(); decoupledClock.ProcessFrame();
offsetClock = new FramedOffsetClock(decoupledClock); offsetClock = new FramedOffsetClock(decoupledClock);
@ -273,6 +278,8 @@ namespace osu.Game.Screens.Play
ValidForResume = false; ValidForResume = false;
if (!AllowResults) return;
using (BeginDelayedSequence(1000)) using (BeginDelayedSequence(1000))
{ {
onCompletionEvent = Schedule(delegate onCompletionEvent = Schedule(delegate

View File

@ -19,6 +19,6 @@ namespace osu.Game.Tests.Beatmaps
protected override Beatmap GetBeatmap() => beatmap; protected override Beatmap GetBeatmap() => beatmap;
protected override Texture GetBackground() => null; protected override Texture GetBackground() => null;
protected override Track GetTrack() => null; protected override Track GetTrack() => new TrackVirtual();
} }
} }

View File

@ -22,6 +22,8 @@ namespace osu.Game.Tests.Visual
protected Player Player; protected Player Player;
private TestWorkingBeatmap working;
/// <summary> /// <summary>
/// Create a TestCase which runs through the Player screen. /// Create a TestCase which runs through the Player screen.
/// </summary> /// </summary>
@ -75,7 +77,7 @@ namespace osu.Game.Tests.Visual
var instance = r.CreateInstance(); var instance = r.CreateInstance();
WorkingBeatmap working = new TestWorkingBeatmap(beatmap); working = new TestWorkingBeatmap(beatmap);
working.Mods.Value = new[] { instance.GetAllMods().First(m => m is ModNoFail) }; working.Mods.Value = new[] { instance.GetAllMods().First(m => m is ModNoFail) };
if (Player != null) if (Player != null)
@ -88,10 +90,21 @@ namespace osu.Game.Tests.Visual
return player; return player;
} }
protected override void Update()
{
base.Update();
if (working != null)
// note that this will override any mod rate application
working.Track.Rate = Clock.Rate;
}
protected virtual Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) => new Player protected virtual Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset) => new Player
{ {
InitialBeatmap = beatmap, InitialBeatmap = beatmap,
AllowPause = false AllowPause = false,
AllowLeadIn = false,
AllowResults = false,
}; };
private const string test_beatmap_data = private const string test_beatmap_data =