mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 00:23:01 +08:00
Make virtual beatmap tracks approximate beatmap length
This commit is contained in:
parent
6eb3e6c541
commit
b88c4464cb
@ -69,7 +69,7 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new TrackVirtual();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public abstract class WorkingBeatmap : IDisposable
|
||||
public abstract partial class WorkingBeatmap : IDisposable
|
||||
{
|
||||
public readonly BeatmapInfo BeatmapInfo;
|
||||
|
||||
@ -145,7 +145,7 @@ namespace osu.Game.Beatmaps
|
||||
private Track populateTrack()
|
||||
{
|
||||
// we want to ensure that we always have a track, even if it's a fake one.
|
||||
var t = GetTrack() ?? new TrackVirtual();
|
||||
var t = GetTrack() ?? new VirtualBeatmapTrack(Beatmap);
|
||||
applyRateAdjustments(t);
|
||||
return t;
|
||||
}
|
||||
|
46
osu.Game/Beatmaps/WorkingBeatmap_VirtualBeatmapTrack.cs
Normal file
46
osu.Game/Beatmaps/WorkingBeatmap_VirtualBeatmapTrack.cs
Normal file
@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
public partial class WorkingBeatmap
|
||||
{
|
||||
private class VirtualBeatmapTrack : TrackVirtual
|
||||
{
|
||||
private readonly IBeatmap beatmap;
|
||||
|
||||
public VirtualBeatmapTrack(IBeatmap beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
}
|
||||
|
||||
protected override void UpdateState()
|
||||
{
|
||||
updateVirtualLength();
|
||||
base.UpdateState();
|
||||
}
|
||||
|
||||
private void updateVirtualLength()
|
||||
{
|
||||
var lastObject = beatmap.HitObjects.LastOrDefault();
|
||||
|
||||
switch (lastObject)
|
||||
{
|
||||
case null:
|
||||
Length = 1000;
|
||||
break;
|
||||
case IHasEndTime endTime:
|
||||
Length = endTime.EndTime + 1000;
|
||||
break;
|
||||
default:
|
||||
Length = lastObject.StartTime + 1000;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -52,8 +52,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
if (Beatmap.Value == null)
|
||||
return;
|
||||
|
||||
if (Beatmap.Value.Track.Length == double.PositiveInfinity) return;
|
||||
|
||||
float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
|
||||
adjustableClock.Seek(markerPos / DrawWidth * Beatmap.Value.Track.Length);
|
||||
}
|
||||
|
@ -47,8 +47,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
return;
|
||||
}
|
||||
|
||||
// Todo: This should be handled more gracefully
|
||||
timeline.RelativeChildSize = Beatmap.Value.Track.Length == double.PositiveInfinity ? Vector2.One : new Vector2((float)Math.Max(1, Beatmap.Value.Track.Length), 1);
|
||||
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, Beatmap.Value.Track.Length), 1);
|
||||
}
|
||||
|
||||
protected void Add(Drawable visualisation) => timeline.Add(visualisation);
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -118,18 +117,15 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
||||
|
||||
private void seekTrackToCurrent()
|
||||
{
|
||||
var track = Beatmap.Value.Track;
|
||||
if (track is TrackVirtual || !track.IsLoaded)
|
||||
if (!Beatmap.Value.TrackLoaded)
|
||||
return;
|
||||
|
||||
if (!(Beatmap.Value.Track is TrackVirtual))
|
||||
adjustableClock.Seek(Current / Content.DrawWidth * Beatmap.Value.Track.Length);
|
||||
adjustableClock.Seek(Current / Content.DrawWidth * Beatmap.Value.Track.Length);
|
||||
}
|
||||
|
||||
private void scrollToTrackTime()
|
||||
{
|
||||
var track = Beatmap.Value.Track;
|
||||
if (track is TrackVirtual || !track.IsLoaded)
|
||||
if (!Beatmap.Value.TrackLoaded)
|
||||
return;
|
||||
|
||||
ScrollTo((float)(adjustableClock.CurrentTime / Beatmap.Value.Track.Length) * Content.DrawWidth, false);
|
||||
|
Loading…
Reference in New Issue
Block a user