1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 17:27:24 +08:00

Merge pull request #27424 from frenzibyte/taiko-slider-storyboard

Hide osu!taiko scroller when the beatmap has storyboard
This commit is contained in:
Dean Herbert 2024-03-01 10:49:12 +08:00 committed by GitHub
commit 4b3a5bde28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 91 additions and 12 deletions

View File

@ -0,0 +1,57 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Taiko.Skinning.Legacy;
using osu.Game.Storyboards;
using osu.Game.Tests.Visual;
using osuTK;
namespace osu.Game.Rulesets.Taiko.Tests
{
public partial class TestSceneTaikoPlayerScroller : LegacySkinPlayerTestScene
{
private Storyboard? currentStoryboard;
protected override bool HasCustomSteps => true;
[Test]
public void TestForegroundSpritesHidesScroller()
{
AddStep("load storyboard", () =>
{
currentStoryboard = new Storyboard();
for (int i = 0; i < 10; i++)
currentStoryboard.GetLayer("Foreground").Add(new StoryboardSprite($"test{i}", Anchor.Centre, Vector2.Zero));
});
CreateTest();
AddAssert("taiko scroller not present", () => !this.ChildrenOfType<LegacyTaikoScroller>().Any());
}
[Test]
public void TestOverlaySpritesKeepsScroller()
{
AddStep("load storyboard", () =>
{
currentStoryboard = new Storyboard();
for (int i = 0; i < 10; i++)
currentStoryboard.GetLayer("Overlay").Add(new StoryboardSprite($"test{i}", Anchor.Centre, Vector2.Zero));
});
CreateTest();
AddAssert("taiko scroller present", () => this.ChildrenOfType<LegacyTaikoScroller>().Single().IsPresent);
}
protected override Ruleset CreatePlayerRuleset() => new TaikoRuleset();
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard? storyboard = null)
=> base.CreateWorkingBeatmap(beatmap, currentStoryboard ?? storyboard);
}
}

View File

@ -5,6 +5,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
@ -22,7 +24,9 @@ using osu.Game.Rulesets.Timing;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.UI.Scrolling;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Skinning;
using osu.Game.Storyboards;
using osuTK;
namespace osu.Game.Rulesets.Taiko.UI
@ -39,6 +43,7 @@ namespace osu.Game.Rulesets.Taiko.UI
protected override bool UserScrollSpeedAdjustment => false;
[CanBeNull]
private SkinnableDrawable scroller;
public DrawableTaikoRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
@ -48,16 +53,24 @@ namespace osu.Game.Rulesets.Taiko.UI
VisualisationMethod = ScrollVisualisationMethod.Overlapping;
}
[BackgroundDependencyLoader]
private void load()
[BackgroundDependencyLoader(true)]
private void load([CanBeNull] GameplayState gameplayState)
{
new BarLineGenerator<BarLine>(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar));
FrameStableComponents.Add(scroller = new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Scroller), _ => Empty())
var spriteElements = gameplayState?.Storyboard.Layers.Where(l => l.Name != @"Overlay")
.SelectMany(l => l.Elements)
.OfType<StoryboardSprite>()
.DistinctBy(e => e.Path) ?? Enumerable.Empty<StoryboardSprite>();
if (spriteElements.Count() < 10)
{
RelativeSizeAxes = Axes.X,
Depth = float.MaxValue
});
FrameStableComponents.Add(scroller = new SkinnableDrawable(new TaikoSkinComponentLookup(TaikoSkinComponents.Scroller), _ => Empty())
{
RelativeSizeAxes = Axes.X,
Depth = float.MaxValue,
});
}
KeyBindingInputManager.Add(new DrumTouchInputArea());
}
@ -76,7 +89,9 @@ namespace osu.Game.Rulesets.Taiko.UI
base.UpdateAfterChildren();
var playfieldScreen = Playfield.ScreenSpaceDrawQuad;
scroller.Height = ToLocalSpace(playfieldScreen.TopLeft + new Vector2(0, playfieldScreen.Height / 20)).Y;
if (scroller != null)
scroller.Height = ToLocalSpace(playfieldScreen.TopLeft + new Vector2(0, playfieldScreen.Height / 20)).Y;
}
public MultiplierControlPoint ControlPointAt(double time)

View File

@ -10,6 +10,7 @@ using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Storyboards;
namespace osu.Game.Screens.Play
{
@ -40,6 +41,11 @@ namespace osu.Game.Screens.Play
public readonly ScoreProcessor ScoreProcessor;
/// <summary>
/// The storyboard associated with the beatmap.
/// </summary>
public readonly Storyboard Storyboard;
/// <summary>
/// Whether gameplay completed without the user failing.
/// </summary>
@ -62,7 +68,7 @@ namespace osu.Game.Screens.Play
private readonly Bindable<JudgementResult> lastJudgementResult = new Bindable<JudgementResult>();
public GameplayState(IBeatmap beatmap, Ruleset ruleset, IReadOnlyList<Mod>? mods = null, Score? score = null, ScoreProcessor? scoreProcessor = null)
public GameplayState(IBeatmap beatmap, Ruleset ruleset, IReadOnlyList<Mod>? mods = null, Score? score = null, ScoreProcessor? scoreProcessor = null, Storyboard? storyboard = null)
{
Beatmap = beatmap;
Ruleset = ruleset;
@ -76,6 +82,7 @@ namespace osu.Game.Screens.Play
};
Mods = mods ?? Array.Empty<Mod>();
ScoreProcessor = scoreProcessor ?? ruleset.CreateScoreProcessor();
Storyboard = storyboard ?? new Storyboard();
}
/// <summary>

View File

@ -255,7 +255,7 @@ namespace osu.Game.Screens.Play
Score.ScoreInfo.Ruleset = ruleset.RulesetInfo;
Score.ScoreInfo.Mods = gameplayMods;
dependencies.CacheAs(GameplayState = new GameplayState(playableBeatmap, ruleset, gameplayMods, Score, ScoreProcessor));
dependencies.CacheAs(GameplayState = new GameplayState(playableBeatmap, ruleset, gameplayMods, Score, ScoreProcessor, Beatmap.Value.Storyboard));
var rulesetSkinProvider = new RulesetSkinProvidingContainer(ruleset, playableBeatmap, Beatmap.Value.Skin);
@ -397,7 +397,7 @@ namespace osu.Game.Screens.Play
protected virtual GameplayClockContainer CreateGameplayClockContainer(WorkingBeatmap beatmap, double gameplayStart) => new MasterGameplayClockContainer(beatmap, gameplayStart);
private Drawable createUnderlayComponents() =>
DimmableStoryboard = new DimmableStoryboard(Beatmap.Value.Storyboard, GameplayState.Mods) { RelativeSizeAxes = Axes.Both };
DimmableStoryboard = new DimmableStoryboard(GameplayState.Storyboard, GameplayState.Mods) { RelativeSizeAxes = Axes.Both };
private Drawable createGameplayComponents(IWorkingBeatmap working) => new ScalingContainer(ScalingMode.Gameplay)
{
@ -456,7 +456,7 @@ namespace osu.Game.Screens.Play
{
RequestSkip = performUserRequestedSkip
},
skipOutroOverlay = new SkipOverlay(Beatmap.Value.Storyboard.LatestEventTime ?? 0)
skipOutroOverlay = new SkipOverlay(GameplayState.Storyboard.LatestEventTime ?? 0)
{
RequestSkip = () => progressToResults(false),
Alpha = 0
@ -1088,7 +1088,7 @@ namespace osu.Game.Screens.Play
DimmableStoryboard.IsBreakTime.BindTo(breakTracker.IsBreakTime);
storyboardReplacesBackground.Value = Beatmap.Value.Storyboard.ReplacesBackground && Beatmap.Value.Storyboard.HasDrawable;
storyboardReplacesBackground.Value = GameplayState.Storyboard.ReplacesBackground && GameplayState.Storyboard.HasDrawable;
foreach (var mod in GameplayState.Mods.OfType<IApplicableToPlayer>())
mod.ApplyToPlayer(this);