mirror of
https://github.com/osukey/osukey.git
synced 2025-07-24 11:50:03 +09:00
Make notes scroll with beat length.
This commit is contained in:
@ -29,9 +29,13 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
set { RelativeCoordinateSpace = new Vector2(1, (float)value); }
|
set { RelativeCoordinateSpace = new Vector2(1, (float)value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private readonly List<DrawableTimingSection> drawableTimingSections;
|
||||||
|
|
||||||
public TimeRelativeContainer(IEnumerable<TimingSection> timingSections)
|
public TimeRelativeContainer(IEnumerable<TimingSection> timingSections)
|
||||||
{
|
{
|
||||||
Children = timingSections.Select(t => new DrawableTimingSection(t));
|
drawableTimingSections = timingSections.Select(t => new DrawableTimingSection(t)).ToList();
|
||||||
|
|
||||||
|
Children = drawableTimingSections;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -48,7 +52,7 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var section = (Children.LastOrDefault(t => t.Y >= drawable.Y) ?? Children.First()) as DrawableTimingSection;
|
var section = drawableTimingSections.LastOrDefault(t => t.CanContain(drawable)) ?? drawableTimingSections.First();
|
||||||
|
|
||||||
if (section == null)
|
if (section == null)
|
||||||
throw new Exception("Could not find suitable timing section to add object to.");
|
throw new Exception("Could not find suitable timing section to add object to.");
|
||||||
@ -59,13 +63,28 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A container that contains drawables within the time span of a timing section.
|
/// A container that contains drawables within the time span of a timing section.
|
||||||
/// <para>
|
/// <para>
|
||||||
/// Scrolls relative to the current time.
|
/// The content of this container will scroll relative to the current time.
|
||||||
/// </para>
|
/// </para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private class DrawableTimingSection : Container
|
private class DrawableTimingSection : Container
|
||||||
{
|
{
|
||||||
|
protected override Container<Drawable> Content => content;
|
||||||
|
/// <summary>
|
||||||
|
/// The container which will scroll relative to the current time.
|
||||||
|
/// </summary>
|
||||||
|
private readonly Container content;
|
||||||
|
|
||||||
private readonly TimingSection section;
|
private readonly TimingSection section;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a drawable timing section. The height of this container will be proportional
|
||||||
|
/// to the beat length of the timing section and the timespan of its parent at all times.
|
||||||
|
/// <para>
|
||||||
|
/// This is so that, e.g. a beat length of 500ms results in this container being twice as high as its parent,
|
||||||
|
/// which means that the content container will scroll at twice the normal rate.
|
||||||
|
/// </para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="section">The section to create the drawable timing section for.</param>
|
||||||
public DrawableTimingSection(TimingSection section)
|
public DrawableTimingSection(TimingSection section)
|
||||||
{
|
{
|
||||||
this.section = section;
|
this.section = section;
|
||||||
@ -73,18 +92,30 @@ namespace osu.Game.Rulesets.Mania.Timing
|
|||||||
Anchor = Anchor.BottomCentre;
|
Anchor = Anchor.BottomCentre;
|
||||||
Origin = Anchor.BottomCentre;
|
Origin = Anchor.BottomCentre;
|
||||||
|
|
||||||
RelativePositionAxes = Axes.Y;
|
|
||||||
Y = -(float)section.StartTime;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
Height = (float)section.Duration;
|
|
||||||
|
|
||||||
RelativeCoordinateSpace = new Vector2(1, Height);
|
AddInternal(content = new Container
|
||||||
|
{
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
Y = (float)(Time.Current - section.StartTime);
|
var parent = (TimeRelativeContainer)Parent;
|
||||||
|
|
||||||
|
// Adjust our height to account for the speed changes
|
||||||
|
Height = (float)(parent.TimeSpan * 1000 / section.BeatLength);
|
||||||
|
RelativeCoordinateSpace = new Vector2(1, (float)parent.TimeSpan);
|
||||||
|
|
||||||
|
// Scroll the content
|
||||||
|
content.Y = (float)(Time.Current - section.StartTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Add(Drawable drawable)
|
public override void Add(Drawable drawable)
|
||||||
@ -93,10 +124,12 @@ 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 -= Y;
|
drawable.Y += (float)section.StartTime;
|
||||||
|
|
||||||
base.Add(drawable);
|
base.Add(drawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanContain(Drawable drawable) => content.Y >= drawable.Y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,10 +27,10 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
{
|
{
|
||||||
public const float HIT_TARGET_POSITION = 50;
|
public const float HIT_TARGET_POSITION = 50;
|
||||||
|
|
||||||
private const float time_span_default = 500;
|
private const float time_span_default = 20000;
|
||||||
private const float time_span_min = 10;
|
private const float time_span_min = 10;
|
||||||
private const float time_span_max = 20000;
|
private const float time_span_max = 50000;
|
||||||
private const float time_span_step = 100;
|
private const float time_span_step = 1000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default column keys, expanding outwards from the middle as more column are added.
|
/// Default column keys, expanding outwards from the middle as more column are added.
|
||||||
|
Reference in New Issue
Block a user