1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:07:52 +08:00

Add and consume passing state in GameplayBeatmap

This commit is contained in:
Dean Herbert 2020-05-01 20:05:56 +09:00
parent 3033ab80ce
commit ff1d63060d
4 changed files with 33 additions and 15 deletions

View File

@ -13,7 +13,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
public TestSceneTaikoScroller() public TestSceneTaikoScroller()
{ {
AddStep("Load scroller", () => SetContents(() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.TaikoScroller), _ => Empty()))); AddStep("Load scroller", () => SetContents(() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.TaikoScroller), _ => Empty())));
AddToggleStep("Toggle passing", passing => this.ChildrenOfType<LegacyTaikoScroller>().ForEach(s => s.Passing = !passing)); AddToggleStep("Toggle passing", passing => this.ChildrenOfType<LegacyTaikoScroller>().ForEach(s => s.Passing.Value = !passing));
} }
} }
} }

View File

@ -3,9 +3,11 @@
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Screens.Play;
using osu.Game.Skinning; using osu.Game.Skinning;
using osuTK; using osuTK;
@ -18,23 +20,26 @@ namespace osu.Game.Rulesets.Taiko.Skinning
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
private bool passing = true; [BackgroundDependencyLoader(true)]
private void load(GameplayBeatmap gameplayBeatmap)
public bool Passing
{ {
get => passing; if (gameplayBeatmap != null)
set ((IBindable<bool>)Passing).BindTo(gameplayBeatmap.Passing);
}
protected override void LoadComplete()
{ {
if (value == passing) base.LoadComplete();
return;
passing = value;
Passing.BindValueChanged(passing =>
{
foreach (var sprite in InternalChildren.OfType<ScrollerSprite>()) foreach (var sprite in InternalChildren.OfType<ScrollerSprite>())
sprite.Passing = passing; sprite.Passing = passing.NewValue;
} }, true);
} }
public Bindable<bool> Passing = new BindableBool(true);
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();

View File

@ -2,11 +2,14 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
@ -38,5 +41,14 @@ namespace osu.Game.Screens.Play
public IEnumerable<BeatmapStatistic> GetStatistics() => PlayableBeatmap.GetStatistics(); public IEnumerable<BeatmapStatistic> GetStatistics() => PlayableBeatmap.GetStatistics();
public IBeatmap Clone() => PlayableBeatmap.Clone(); public IBeatmap Clone() => PlayableBeatmap.Clone();
public IBindable<bool> Passing => passing;
private readonly BindableBool passing = new BindableBool(true);
public void OnNewResult(JudgementResult result)
{
passing.Value = result.Type > HitResult.Miss;
}
} }
} }

View File

@ -193,6 +193,7 @@ namespace osu.Game.Screens.Play
{ {
HealthProcessor.ApplyResult(r); HealthProcessor.ApplyResult(r);
ScoreProcessor.ApplyResult(r); ScoreProcessor.ApplyResult(r);
gameplayBeatmap.OnNewResult(r);
}; };
DrawableRuleset.OnRevertResult += r => DrawableRuleset.OnRevertResult += r =>