mirror of
https://github.com/osukey/osukey.git
synced 2025-05-03 20:57:28 +09:00
Initial removal of TimingSection.
This commit is contained in:
parent
0597a95db0
commit
a25f11e809
@ -7,15 +7,16 @@ using System.Linq;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Timing
|
namespace osu.Game.Rulesets.Mania.Timing
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A container in which the Y-relative coordinate space is spanned by a length of time.
|
/// A container in which the Y-relative coordinate space is spanned by a length of time.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// This container contains <see cref="TimingSection"/>s which scroll inside this container.
|
/// This container contains <see cref="ControlPoint"/>s which scroll inside this container.
|
||||||
/// Drawables added to this container are moved inside the relevant <see cref="TimingSection"/>,
|
/// Drawables added to this container are moved inside the relevant <see cref="ControlPoint"/>,
|
||||||
/// and as such, will scroll along with the <see cref="TimingSection"/>s.
|
/// and as such, will scroll along with the <see cref="ControlPoint"/>s.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class TimeRelativeContainer : Container<Drawable>
|
public class TimeRelativeContainer : Container<Drawable>
|
||||||
@ -31,9 +32,9 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
|
|
||||||
private readonly List<DrawableTimingSection> drawableTimingSections;
|
private readonly List<DrawableTimingSection> drawableTimingSections;
|
||||||
|
|
||||||
public TimeRelativeContainer(IEnumerable<TimingSection> timingSections)
|
public TimeRelativeContainer(IEnumerable<ControlPoint> timingChanges)
|
||||||
{
|
{
|
||||||
drawableTimingSections = timingSections.Select(t => new DrawableTimingSection(t)).ToList();
|
drawableTimingSections = timingChanges.Select(t => new DrawableTimingSection(t)).ToList();
|
||||||
|
|
||||||
Children = drawableTimingSections;
|
Children = drawableTimingSections;
|
||||||
}
|
}
|
||||||
@ -68,13 +69,7 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private class DrawableTimingSection : Container
|
private class DrawableTimingSection : Container
|
||||||
{
|
{
|
||||||
protected override Container<Drawable> Content => content;
|
private readonly ControlPoint timingChange;
|
||||||
/// <summary>
|
|
||||||
/// The container which will scroll relative to the current time.
|
|
||||||
/// </summary>
|
|
||||||
private readonly Container content;
|
|
||||||
|
|
||||||
private readonly TimingSection section;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a drawable timing section. The height of this container will be proportional
|
/// Creates a drawable timing section. The height of this container will be proportional
|
||||||
@ -84,26 +79,17 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
/// which means that the content container will scroll at twice the normal rate.
|
/// which means that the content container will scroll at twice the normal rate.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="section">The section to create the drawable timing section for.</param>
|
/// <param name="timingChange">The timing change to create the drawable timing section for.</param>
|
||||||
public DrawableTimingSection(TimingSection section)
|
public DrawableTimingSection(ControlPoint timingChange)
|
||||||
{
|
{
|
||||||
this.section = section;
|
this.timingChange = timingChange;
|
||||||
|
|
||||||
Anchor = Anchor.BottomCentre;
|
Anchor = Anchor.BottomCentre;
|
||||||
Origin = Anchor.BottomCentre;
|
Origin = Anchor.BottomCentre;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
AddInternal(content = new Container
|
Y = -(float)timingChange.Time;
|
||||||
{
|
|
||||||
Anchor = Anchor.BottomCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
RelativePositionAxes = Axes.Both,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Y = -(float)section.StartTime,
|
|
||||||
Height = (float)section.Duration,
|
|
||||||
RelativeCoordinateSpace = new Vector2(1, (float)section.Duration)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -111,11 +97,11 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
var parent = (TimeRelativeContainer)Parent;
|
var parent = (TimeRelativeContainer)Parent;
|
||||||
|
|
||||||
// Adjust our height to account for the speed changes
|
// Adjust our height to account for the speed changes
|
||||||
Height = (float)(parent.TimeSpan * 1000 / section.BeatLength);
|
Height = (float)(parent.TimeSpan * 1000 / timingChange.BeatLength / timingChange.SpeedMultiplier);
|
||||||
RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan);
|
RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan);
|
||||||
|
|
||||||
// Scroll the content
|
// Scroll the content
|
||||||
content.Y = (float)(Time.Current - section.StartTime);
|
Y = (float)(Time.Current - timingChange.Time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Add(Drawable drawable)
|
public override void Add(Drawable drawable)
|
||||||
@ -124,7 +110,7 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
// we need to offset it back by our position so that it becomes correctly relatively-positioned to us
|
// we need to offset it back by our position so that it becomes correctly relatively-positioned to us
|
||||||
// This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section
|
// This can be removed if hit objects were stored such that either their StartTime or their "beat offset" was relative to the timing section
|
||||||
// they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet
|
// they belonged to, but this requires a radical change to the beatmap format which we're not ready to do just yet
|
||||||
drawable.Y += (float)section.StartTime;
|
drawable.Y += (float)timingChange.Time;
|
||||||
|
|
||||||
base.Add(drawable);
|
base.Add(drawable);
|
||||||
}
|
}
|
||||||
@ -134,7 +120,7 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
/// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity).
|
/// can be placed within the timing section's bounds (in this case, from the start of the timing section up to infinity).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="drawable">The drawable to check.</param>
|
/// <param name="drawable">The drawable to check.</param>
|
||||||
public bool CanContain(Drawable drawable) => content.Y >= drawable.Y;
|
public bool CanContain(Drawable drawable) => Y >= drawable.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,30 +0,0 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using osu.Game.Beatmaps.Timing;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Timing
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A point in the map where the beat length or speed multiplier has changed .
|
|
||||||
/// </summary>
|
|
||||||
public class TimingSection
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// The time at which the change occurred.
|
|
||||||
/// </summary>
|
|
||||||
public double StartTime;
|
|
||||||
/// <summary>
|
|
||||||
/// The duration of this timing section - lasts until the next timing section.
|
|
||||||
/// </summary>
|
|
||||||
public double Duration;
|
|
||||||
/// <summary>
|
|
||||||
/// The beat length, includes any speed multiplier.
|
|
||||||
/// </summary>
|
|
||||||
public double BeatLength;
|
|
||||||
/// <summary>
|
|
||||||
/// The time signature of this timing section.
|
|
||||||
/// </summary>
|
|
||||||
public TimeSignatures TimeSignature;
|
|
||||||
}
|
|
||||||
}
|
|
@ -17,6 +17,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Mania.Judgements;
|
using osu.Game.Rulesets.Mania.Judgements;
|
||||||
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
@ -40,7 +41,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
public readonly TimeRelativeContainer TimingSectionContainer;
|
public readonly TimeRelativeContainer TimingSectionContainer;
|
||||||
|
|
||||||
public Column(IEnumerable<TimingSection> timingSections)
|
public Column(IEnumerable<ControlPoint> timingChanges)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y;
|
RelativeSizeAxes = Axes.Y;
|
||||||
Width = column_width;
|
Width = column_width;
|
||||||
@ -87,7 +88,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TimingSectionContainer = new TimeRelativeContainer(timingSections)
|
TimingSectionContainer = new TimeRelativeContainer(timingChanges)
|
||||||
{
|
{
|
||||||
Name = "Hit objects",
|
Name = "Hit objects",
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
@ -33,53 +33,37 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
protected override Playfield<ManiaHitObject, ManiaJudgement> CreatePlayfield()
|
protected override Playfield<ManiaHitObject, ManiaJudgement> CreatePlayfield()
|
||||||
{
|
{
|
||||||
var timingSections = new List<TimingSection>();
|
ControlPoint firstTimingChange = Beatmap.TimingInfo.ControlPoints.FirstOrDefault(t => t.TimingChange);
|
||||||
|
|
||||||
// Construct all the relevant timing sections
|
if (firstTimingChange == null)
|
||||||
ControlPoint lastTimingChange = Beatmap.TimingInfo.ControlPoints.FirstOrDefault(t => t.TimingChange);
|
|
||||||
|
|
||||||
if (lastTimingChange == null)
|
|
||||||
throw new Exception("The Beatmap contains no timing points!");
|
throw new Exception("The Beatmap contains no timing points!");
|
||||||
|
|
||||||
foreach (ControlPoint point in Beatmap.TimingInfo.ControlPoints)
|
// Generate the timing points, making non-timing changes use the previous timing change
|
||||||
|
var timingChanges = Beatmap.TimingInfo.ControlPoints.Select(c =>
|
||||||
{
|
{
|
||||||
if (point.TimingChange)
|
ControlPoint t = c.Clone();
|
||||||
lastTimingChange = point;
|
|
||||||
|
|
||||||
timingSections.Add(new TimingSection
|
if (c.TimingChange)
|
||||||
{
|
firstTimingChange = c;
|
||||||
StartTime = point.Time,
|
else
|
||||||
BeatLength = lastTimingChange.BeatLength / point.SpeedMultiplier,
|
t.BeatLength = firstTimingChange.BeatLength;
|
||||||
TimeSignature = point.TimeSignature
|
|
||||||
});
|
return t;
|
||||||
}
|
});
|
||||||
|
|
||||||
double lastObjectTime = (Objects.Last() as IHasEndTime)?.EndTime ?? Objects.Last().StartTime;
|
double lastObjectTime = (Objects.Last() as IHasEndTime)?.EndTime ?? Objects.Last().StartTime;
|
||||||
|
|
||||||
// Perform some post processing of the timing sections
|
// Perform some post processing of the timing changes
|
||||||
timingSections = timingSections
|
timingChanges = timingChanges
|
||||||
// Collapse sections after the last hit object
|
// Collapse sections after the last hit object
|
||||||
.Where(s => s.StartTime <= lastObjectTime)
|
.Where(s => s.Time <= lastObjectTime)
|
||||||
// Collapse sections with the same start time
|
// Collapse sections with the same start time
|
||||||
.GroupBy(s => s.StartTime).Select(g => g.Last()).OrderBy(s => s.StartTime)
|
.GroupBy(s => s.Time).Select(g => g.Last()).OrderBy(s => s.Time)
|
||||||
// Collapse sections with the same beat length
|
// Collapse sections with the same beat length
|
||||||
.GroupBy(s => s.BeatLength).Select(g => g.First())
|
.GroupBy(s => s.BeatLength * s.SpeedMultiplier).Select(g => g.First())
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Determine duration of timing sections
|
return new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize), timingChanges)
|
||||||
for (int i = 0; i < timingSections.Count; i++)
|
|
||||||
{
|
|
||||||
if (i < timingSections.Count - 1)
|
|
||||||
timingSections[i].Duration = timingSections[i + 1].StartTime - timingSections[i].StartTime;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Extra length added for the last timing section to extend past the last hitobject
|
|
||||||
double extraLength = timingSections[i].BeatLength * (int)timingSections[i].TimeSignature;
|
|
||||||
timingSections[i].Duration = lastObjectTime + extraLength - timingSections[i].StartTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ManiaPlayfield(Columns ?? (int)Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize), timingSections)
|
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre
|
Origin = Anchor.Centre
|
||||||
|
@ -20,6 +20,7 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
|||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Mania.Timing;
|
using osu.Game.Rulesets.Mania.Timing;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
|
using osu.Game.Beatmaps.Timing;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
@ -62,7 +63,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
private readonly int columnCount;
|
private readonly int columnCount;
|
||||||
|
|
||||||
public ManiaPlayfield(int columnCount, IEnumerable<TimingSection> timingSections)
|
public ManiaPlayfield(int columnCount, IEnumerable<ControlPoint> timingChanges)
|
||||||
{
|
{
|
||||||
this.columnCount = columnCount;
|
this.columnCount = columnCount;
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
Padding = new MarginPadding { Left = 1, Right = 1 },
|
Padding = new MarginPadding { Left = 1, Right = 1 },
|
||||||
Spacing = new Vector2(1, 0)
|
Spacing = new Vector2(1, 0)
|
||||||
},
|
},
|
||||||
barlineContainer = new TimeRelativeContainer(timingSections)
|
barlineContainer = new TimeRelativeContainer(timingChanges)
|
||||||
{
|
{
|
||||||
Name = "Bar lines",
|
Name = "Bar lines",
|
||||||
Anchor = Anchor.BottomCentre,
|
Anchor = Anchor.BottomCentre,
|
||||||
@ -107,7 +108,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < columnCount; i++)
|
for (int i = 0; i < columnCount; i++)
|
||||||
Columns.Add(new Column(timingSections));
|
Columns.Add(new Column(timingChanges));
|
||||||
|
|
||||||
TimeSpan = time_span_default;
|
TimeSpan = time_span_default;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,6 @@
|
|||||||
<Compile Include="Objects\Drawables\Pieces\NotePiece.cs" />
|
<Compile Include="Objects\Drawables\Pieces\NotePiece.cs" />
|
||||||
<Compile Include="Objects\Types\IHasColumn.cs" />
|
<Compile Include="Objects\Types\IHasColumn.cs" />
|
||||||
<Compile Include="Scoring\ManiaScoreProcessor.cs" />
|
<Compile Include="Scoring\ManiaScoreProcessor.cs" />
|
||||||
<Compile Include="Timing\TimingSection.cs" />
|
|
||||||
<Compile Include="Objects\HoldNote.cs" />
|
<Compile Include="Objects\HoldNote.cs" />
|
||||||
<Compile Include="Objects\ManiaHitObject.cs" />
|
<Compile Include="Objects\ManiaHitObject.cs" />
|
||||||
<Compile Include="Objects\Note.cs" />
|
<Compile Include="Objects\Note.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user