mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 20:32:55 +08:00
Merge pull request #6249 from bdach/fix-beat-bar-alignment
Fix mania bar line alignment
This commit is contained in:
commit
e3be02a76b
@ -15,7 +15,6 @@ using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Mania.UI;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
@ -67,6 +66,8 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
|
||||
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.TopCentre));
|
||||
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.BottomCentre));
|
||||
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[0], Anchor.TopCentre));
|
||||
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[1], Anchor.BottomCentre));
|
||||
|
||||
AddStep("flip direction", () =>
|
||||
{
|
||||
@ -76,10 +77,14 @@ namespace osu.Game.Rulesets.Mania.Tests
|
||||
|
||||
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[0], Anchor.BottomCentre));
|
||||
AddAssert("check note anchors", () => notesInStageAreAnchored(stages[1], Anchor.TopCentre));
|
||||
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[0], Anchor.BottomCentre));
|
||||
AddAssert("check bar anchors", () => barsInStageAreAnchored(stages[1], Anchor.TopCentre));
|
||||
}
|
||||
|
||||
private bool notesInStageAreAnchored(ManiaStage stage, Anchor anchor) => stage.Columns.SelectMany(c => c.AllHitObjects).All(o => o.Anchor == anchor);
|
||||
|
||||
private bool barsInStageAreAnchored(ManiaStage stage, Anchor anchor) => stage.AllHitObjects.Where(obj => obj is DrawableBarLine).All(o => o.Anchor == anchor);
|
||||
|
||||
private void createNote()
|
||||
{
|
||||
foreach (var stage in stages)
|
||||
|
12
osu.Game.Rulesets.Mania/Objects/BarLine.cs
Normal file
12
osu.Game.Rulesets.Mania/Objects/BarLine.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// 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 osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Objects
|
||||
{
|
||||
public class BarLine : ManiaHitObject, IBarLine
|
||||
{
|
||||
public bool Major { get; set; }
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@
|
||||
using osuTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osuTK.Graphics;
|
||||
|
||||
@ -14,7 +13,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables
|
||||
/// Visualises a <see cref="BarLine"/>. Although this derives DrawableManiaHitObject,
|
||||
/// this does not handle input/sound like a normal hit object.
|
||||
/// </summary>
|
||||
public class DrawableBarLine : DrawableHitObject<BarLine>
|
||||
public class DrawableBarLine : DrawableManiaHitObject<BarLine>
|
||||
{
|
||||
/// <summary>
|
||||
/// Height of major bar line triangles.
|
||||
|
@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
public DrawableManiaRuleset(Ruleset ruleset, IWorkingBeatmap beatmap, IReadOnlyList<Mod> mods)
|
||||
: base(ruleset, beatmap, mods)
|
||||
{
|
||||
BarLines = new BarLineGenerator(Beatmap).BarLines;
|
||||
BarLines = new BarLineGenerator<BarLine>(Beatmap).BarLines;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -8,7 +8,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
using osuTK;
|
||||
|
@ -12,7 +12,6 @@ using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Rulesets.UI.Scrolling;
|
||||
|
@ -53,6 +53,11 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
AddStep("Strong Rim", () => addRimHit(true));
|
||||
AddStep("Add bar line", () => addBarLine(false));
|
||||
AddStep("Add major bar line", () => addBarLine(true));
|
||||
AddStep("Add centre w/ bar line", () =>
|
||||
{
|
||||
addCentreHit(false);
|
||||
addBarLine(true);
|
||||
});
|
||||
AddStep("Height test 1", () => changePlayfieldSize(1));
|
||||
AddStep("Height test 2", () => changePlayfieldSize(2));
|
||||
AddStep("Height test 3", () => changePlayfieldSize(3));
|
||||
|
12
osu.Game.Rulesets.Taiko/Objects/BarLine.cs
Normal file
12
osu.Game.Rulesets.Taiko/Objects/BarLine.cs
Normal file
@ -0,0 +1,12 @@
|
||||
// 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 osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects
|
||||
{
|
||||
public class BarLine : TaikoHitObject, IBarLine
|
||||
{
|
||||
public bool Major { get; set; }
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osuTK;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
new BarLineGenerator(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar.Major ? new DrawableBarLineMajor(bar) : new DrawableBarLine(bar)));
|
||||
new BarLineGenerator<BarLine>(Beatmap).BarLines.ForEach(bar => Playfield.Add(bar.Major ? new DrawableBarLineMajor(bar) : new DrawableBarLine(bar)));
|
||||
}
|
||||
|
||||
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor(this);
|
||||
|
@ -1,16 +0,0 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Rulesets.Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// A hit object representing the end of a bar.
|
||||
/// </summary>
|
||||
public class BarLine : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether this barline is a prominent beat (based on time signature of beatmap).
|
||||
/// </summary>
|
||||
public bool Major;
|
||||
}
|
||||
}
|
@ -10,12 +10,13 @@ using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Rulesets.Objects
|
||||
{
|
||||
public class BarLineGenerator
|
||||
public class BarLineGenerator<TBarLine>
|
||||
where TBarLine : class, IBarLine, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// The generated bar lines.
|
||||
/// </summary>
|
||||
public readonly List<BarLine> BarLines = new List<BarLine>();
|
||||
public readonly List<TBarLine> BarLines = new List<TBarLine>();
|
||||
|
||||
/// <summary>
|
||||
/// Constructs and generates bar lines for provided beatmap.
|
||||
@ -46,7 +47,7 @@ namespace osu.Game.Rulesets.Objects
|
||||
|
||||
for (double t = currentTimingPoint.Time; Precision.DefinitelyBigger(endTime, t); t += barLength, currentBeat++)
|
||||
{
|
||||
BarLines.Add(new BarLine
|
||||
BarLines.Add(new TBarLine
|
||||
{
|
||||
StartTime = t,
|
||||
Major = currentBeat % (int)currentTimingPoint.TimeSignature == 0
|
||||
|
22
osu.Game/Rulesets/Objects/IBarLine.cs
Normal file
22
osu.Game/Rulesets/Objects/IBarLine.cs
Normal file
@ -0,0 +1,22 @@
|
||||
// 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.
|
||||
|
||||
namespace osu.Game.Rulesets.Objects
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for bar line hitobjects.
|
||||
/// Used to decouple bar line generation from ruleset-specific rendering/drawing hierarchies.
|
||||
/// </summary>
|
||||
public interface IBarLine
|
||||
{
|
||||
/// <summary>
|
||||
/// The time position of the bar.
|
||||
/// </summary>
|
||||
double StartTime { set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this bar line is a prominent beat (based on time signature of beatmap).
|
||||
/// </summary>
|
||||
bool Major { set; }
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user