1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-21 22:27:23 +08:00

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
commit 996e156fd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 109 additions and 35 deletions

@ -1 +1 @@
Subproject commit b28d4ba82af0138d38ff8b3f4f3392d9d9068da9
Subproject commit 10cae790c6f1d559c326f9438958d0b012d61dc6

@ -1 +1 @@
Subproject commit 4287ee8043fb1419017359bc3a5db5dc06bc643f
Subproject commit e01f71160fb9b3167efcd177c7d7dba9e5d36604

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Audio;
using osu.Framework.Audio.Sample;
using osu.Game.Audio;
@ -13,7 +12,7 @@ namespace osu.Game.Rulesets.Taiko.Audio
public class DrumSampleMapping
{
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)
{
@ -26,17 +25,17 @@ namespace osu.Game.Rulesets.Taiko.Audio
else
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),
Rim = s.GetSampleInfo(SampleInfo.HIT_CLAP).GetChannel(audio.Sample)
Centre = s.GetSampleInfo().GetChannel(audio.Sample, "Taiko"),
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
{

View File

@ -41,6 +41,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
// 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 string SampleNamespace => "Taiko";
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
public abstract bool OnPressed(TaikoAction action);

View File

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

View File

@ -86,7 +86,7 @@ namespace osu.Game.Rulesets.Taiko.Replays
{
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;
}
}

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;
back = centre;
drumSample.Centre.Play();
drumSample.Centre?.Play();
}
else if (action == RimAction)
{
target = rimHit;
back = rim;
drumSample.Rim.Play();
drumSample.Rim?.Play();
}
if (target != null)

View File

@ -83,6 +83,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Scoring\TaikoScoreProcessor.cs" />
<Compile Include="TaikoInputManager.cs" />
<Compile Include="Tests\TestCaseInputDrum.cs" />
<Compile Include="Tests\TestCasePerformancePoints.cs" />
<Compile Include="Tests\TestCaseTaikoPlayfield.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
using System;
using System.IO;
using osu.Framework.Audio.Sample;
namespace osu.Game.Audio
@ -14,10 +15,20 @@ namespace osu.Game.Audio
public const string HIT_NORMAL = @"hitnormal";
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}");
channel.Volume.Value = Volume / 100.0;
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;
return channel;
}

View File

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

View File

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

View File

@ -95,8 +95,8 @@ namespace osu.Game.Overlays.Notifications
protected virtual void Completed()
{
base.Close();
CompletionTarget?.Invoke(CreateCompletionNotification());
base.Close();
}
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 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>();
protected DrawableHitObject(TObject hitObject)
@ -101,7 +104,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
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)
continue;

View File

@ -46,6 +46,8 @@ namespace osu.Game.Screens.Play
public bool HasFailed { get; private set; }
public bool AllowPause { get; set; } = true;
public bool AllowLeadIn { get; set; } = true;
public bool AllowResults { get; set; } = true;
public int RestartCount;
@ -136,7 +138,10 @@ namespace osu.Game.Screens.Play
decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
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();
offsetClock = new FramedOffsetClock(decoupledClock);
@ -273,6 +278,8 @@ namespace osu.Game.Screens.Play
ValidForResume = false;
if (!AllowResults) return;
using (BeginDelayedSequence(1000))
{
onCompletionEvent = Schedule(delegate

View File

@ -19,6 +19,6 @@ namespace osu.Game.Tests.Beatmaps
protected override Beatmap GetBeatmap() => beatmap;
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;
private TestWorkingBeatmap working;
/// <summary>
/// Create a TestCase which runs through the Player screen.
/// </summary>
@ -75,7 +77,7 @@ namespace osu.Game.Tests.Visual
var instance = r.CreateInstance();
WorkingBeatmap working = new TestWorkingBeatmap(beatmap);
working = new TestWorkingBeatmap(beatmap);
working.Mods.Value = new[] { instance.GetAllMods().First(m => m is ModNoFail) };
if (Player != null)
@ -88,10 +90,21 @@ namespace osu.Game.Tests.Visual
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
{
InitialBeatmap = beatmap,
AllowPause = false
AllowPause = false,
AllowLeadIn = false,
AllowResults = false,
};
private const string test_beatmap_data =