From 229c9b5b4ea4a2524b1fc4285bf86ce5d78ef2c5 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Thu, 7 Dec 2017 23:11:34 +0100 Subject: [PATCH] First basic implementation of IKeyBindingHandler for the playfield so it can handle taiko hitsounds --- osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 33 +++++++++++++++++-- .../UI/TaikoRulesetContainer.cs | 2 +- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index ac3796f5b8..c4210dd261 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -16,10 +16,16 @@ using osu.Framework.Extensions.Color4Extensions; using System.Linq; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Taiko.Objects.Drawables; +using osu.Framework.Input.Bindings; +using osu.Game.Beatmaps.ControlPoints; +using osu.Framework.Audio; +using osu.Framework.Audio.Sample; +using System.Collections.Generic; +using osu.Game.Audio; namespace osu.Game.Rulesets.Taiko.UI { - public class TaikoPlayfield : ScrollingPlayfield + public class TaikoPlayfield : ScrollingPlayfield, IKeyBindingHandler { /// /// Default height of a when inside a . @@ -54,9 +60,14 @@ namespace osu.Game.Rulesets.Taiko.UI private readonly Box overlayBackground; private readonly Box background; - public TaikoPlayfield() + private ControlPointInfo controlPointInfo; + private IEnumerable allSamples; + private AudioManager audio; + + public TaikoPlayfield(ControlPointInfo controlPointInfo) : base(Axes.X) { + this.controlPointInfo = controlPointInfo; AddRangeInternal(new Drawable[] { backgroundContainer = new Container @@ -194,8 +205,15 @@ namespace osu.Game.Rulesets.Taiko.UI } [BackgroundDependencyLoader] - private void load(OsuColour colours) + private void load(OsuColour colours, AudioManager audio) { + this.audio = audio; + + foreach (var soundPoint in controlPointInfo.SoundPoints) + { + SampleInfo.FromSoundPoint(soundPoint).GetChannel(audio.Sample); + } + overlayBackgroundContainer.BorderColour = colours.Gray0; overlayBackground.Colour = colours.Gray1; @@ -258,5 +276,14 @@ namespace osu.Game.Rulesets.Taiko.UI kiaiExplosionContainer.Add(new KiaiHitExplosion(judgedObject, isRim)); } } + + public bool OnPressed(TaikoAction action) + { + var soundPoint = controlPointInfo.SoundPointAt(Time.Current); + + return true; + } + + public bool OnReleased(TaikoAction action) => false; } } diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs index 48ee0a5b42..614b446181 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs @@ -93,7 +93,7 @@ namespace osu.Game.Rulesets.Taiko.UI public override PassThroughInputManager CreateInputManager() => new TaikoInputManager(Ruleset.RulesetInfo); - protected override Playfield CreatePlayfield() => new TaikoPlayfield + protected override Playfield CreatePlayfield() => new TaikoPlayfield(Beatmap.ControlPointInfo) { Anchor = Anchor.CentreLeft, Origin = Anchor.CentreLeft