mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 04:02:59 +08:00
Merge branch 'master' into fix-supporter-naming
This commit is contained in:
commit
be2d3d6ad4
@ -69,11 +69,22 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
catch
|
||||
{
|
||||
return new TrackVirtual();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Waveform GetWaveform() => new Waveform(store.GetStream(getPathForFile(Metadata.AudioFile)));
|
||||
protected override Waveform GetWaveform()
|
||||
{
|
||||
try
|
||||
{
|
||||
var trackData = store.GetStream(getPathForFile(Metadata.AudioFile));
|
||||
return trackData == null ? null : new Waveform(trackData);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected override Storyboard GetStoryboard()
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
protected override Texture GetBackground() => game?.Textures.Get(@"Backgrounds/bg4");
|
||||
|
||||
protected override Track GetTrack() => new TrackVirtual();
|
||||
protected override Track GetTrack() => new TrackVirtual { Length = 1000 };
|
||||
|
||||
private class DummyRulesetInfo : RulesetInfo
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
38
osu.Game/Beatmaps/WorkingBeatmap_VirtualBeatmapTrack.cs
Normal file
38
osu.Game/Beatmaps/WorkingBeatmap_VirtualBeatmapTrack.cs
Normal file
@ -0,0 +1,38 @@
|
||||
// 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
|
||||
{
|
||||
/// <summary>
|
||||
/// A type of <see cref="TrackVirtual"/> which provides a valid length based on the <see cref="HitObject"/>s of an <see cref="IBeatmap"/>.
|
||||
/// </summary>
|
||||
protected class VirtualBeatmapTrack : TrackVirtual
|
||||
{
|
||||
private const double excess_length = 1000;
|
||||
|
||||
public VirtualBeatmapTrack(IBeatmap beatmap)
|
||||
{
|
||||
var lastObject = beatmap.HitObjects.LastOrDefault();
|
||||
|
||||
switch (lastObject)
|
||||
{
|
||||
case null:
|
||||
Length = excess_length;
|
||||
break;
|
||||
case IHasEndTime endTime:
|
||||
Length = endTime.EndTime + excess_length;
|
||||
break;
|
||||
default:
|
||||
Length = lastObject.StartTime + excess_length;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -84,10 +84,11 @@ namespace osu.Game.Rulesets
|
||||
{
|
||||
try
|
||||
{
|
||||
var instance = r.CreateInstance();
|
||||
var instanceInfo = ((Ruleset)Activator.CreateInstance(Type.GetType(r.InstantiationInfo), (RulesetInfo)null)).RulesetInfo;
|
||||
|
||||
r.Name = instance.Description;
|
||||
r.ShortName = instance.ShortName;
|
||||
r.Name = instanceInfo.Name;
|
||||
r.ShortName = instanceInfo.ShortName;
|
||||
r.InstantiationInfo = instanceInfo.InstantiationInfo;
|
||||
|
||||
r.Available = true;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -52,13 +52,11 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
||||
WaveformVisible.ValueChanged += visible => waveform.FadeTo(visible ? 1 : 0, 200, Easing.OutQuint);
|
||||
|
||||
Beatmap.BindTo(beatmap);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Beatmap.BindValueChanged(b => waveform.Waveform = b.Waveform);
|
||||
waveform.Waveform = Beatmap.Value.Waveform;
|
||||
Beatmap.BindValueChanged(b =>
|
||||
{
|
||||
waveform.Waveform = b.Waveform;
|
||||
track = b.Track;
|
||||
}, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -81,6 +79,8 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
||||
/// </summary>
|
||||
private bool trackWasPlaying;
|
||||
|
||||
private Track track;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
@ -118,21 +118,18 @@ namespace osu.Game.Screens.Edit.Screens.Compose.Timeline
|
||||
|
||||
private void seekTrackToCurrent()
|
||||
{
|
||||
var track = Beatmap.Value.Track;
|
||||
if (track is TrackVirtual || !track.IsLoaded)
|
||||
if (!track.IsLoaded)
|
||||
return;
|
||||
|
||||
if (!(Beatmap.Value.Track is TrackVirtual))
|
||||
adjustableClock.Seek(Current / Content.DrawWidth * Beatmap.Value.Track.Length);
|
||||
adjustableClock.Seek(Current / Content.DrawWidth * track.Length);
|
||||
}
|
||||
|
||||
private void scrollToTrackTime()
|
||||
{
|
||||
var track = Beatmap.Value.Track;
|
||||
if (track is TrackVirtual || !track.IsLoaded)
|
||||
if (!track.IsLoaded)
|
||||
return;
|
||||
|
||||
ScrollTo((float)(adjustableClock.CurrentTime / Beatmap.Value.Track.Length) * Content.DrawWidth, false);
|
||||
ScrollTo((float)(adjustableClock.CurrentTime / track.Length) * Content.DrawWidth, false);
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
|
@ -1,12 +1,10 @@
|
||||
// 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.Framework.Graphics.Textures;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
|
||||
namespace osu.Game.Tests.Beatmaps
|
||||
{
|
||||
@ -26,21 +24,6 @@ namespace osu.Game.Tests.Beatmaps
|
||||
private readonly IBeatmap beatmap;
|
||||
protected override IBeatmap GetBeatmap() => beatmap;
|
||||
protected override Texture GetBackground() => null;
|
||||
|
||||
protected override Track GetTrack()
|
||||
{
|
||||
var lastObject = beatmap.HitObjects.LastOrDefault();
|
||||
if (lastObject != null)
|
||||
return new TestTrack(((lastObject as IHasEndTime)?.EndTime ?? lastObject.StartTime) + 1000);
|
||||
return new TrackVirtual();
|
||||
}
|
||||
|
||||
private class TestTrack : TrackVirtual
|
||||
{
|
||||
public TestTrack(double length)
|
||||
{
|
||||
Length = length;
|
||||
}
|
||||
}
|
||||
protected override Track GetTrack() => null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user