mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 14:22:54 +08:00
Merge branch 'master' into mod-key-multiplayer
This commit is contained in:
commit
9308d0b012
@ -59,6 +59,13 @@ namespace osu.Game.Tests
|
|||||||
|
|
||||||
protected override Track GetBeatmapTrack() => trackStore.Get(firstAudioFile);
|
protected override Track GetBeatmapTrack() => trackStore.Get(firstAudioFile);
|
||||||
|
|
||||||
|
public override bool TryTransferTrack(WorkingBeatmap target)
|
||||||
|
{
|
||||||
|
// Our track comes from a local track store that's disposed on finalizer,
|
||||||
|
// therefore it's unsafe to transfer it to another working beatmap.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private string firstAudioFile
|
private string firstAudioFile
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -126,11 +126,19 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Transfer a valid audio track into this working beatmap. Used as an optimisation to avoid reload / track swap
|
/// Attempts to transfer the audio track to a target working beatmap, if valid for transferring.
|
||||||
/// across difficulties in the same beatmap set.
|
/// Used as an optimisation to avoid reload / track swap across difficulties in the same beatmap set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="track">The track to transfer.</param>
|
/// <param name="target">The target working beatmap to transfer this track to.</param>
|
||||||
public void TransferTrack([NotNull] Track track) => this.track = track ?? throw new ArgumentNullException(nameof(track));
|
/// <returns>Whether the track has been transferred to the <paramref name="target"/>.</returns>
|
||||||
|
public virtual bool TryTransferTrack([NotNull] WorkingBeatmap target)
|
||||||
|
{
|
||||||
|
if (BeatmapInfo?.AudioEquals(target.BeatmapInfo) != true || Track.IsDummyDevice)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
target.track = Track;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the loaded audio track instance. <see cref="LoadTrack"/> must have first been called.
|
/// Get the loaded audio track instance. <see cref="LoadTrack"/> must have first been called.
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Colour;
|
using osu.Framework.Graphics.Colour;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -68,6 +69,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private Colour4? lighterColour;
|
private Colour4? lighterColour;
|
||||||
private Colour4? textColour;
|
private Colour4? textColour;
|
||||||
|
|
||||||
|
private readonly Container backgroundLayer;
|
||||||
private readonly Box flashLayer;
|
private readonly Box flashLayer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -85,24 +87,35 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Height = 50;
|
Height = 50;
|
||||||
Padding = new MarginPadding { Horizontal = shear * 50 };
|
Padding = new MarginPadding { Horizontal = shear * 50 };
|
||||||
|
|
||||||
Content.CornerRadius = 7;
|
const float corner_radius = 7;
|
||||||
|
|
||||||
|
Content.CornerRadius = corner_radius;
|
||||||
Content.Shear = new Vector2(shear, 0);
|
Content.Shear = new Vector2(shear, 0);
|
||||||
Content.Masking = true;
|
Content.Masking = true;
|
||||||
Content.BorderThickness = 2;
|
|
||||||
Content.Anchor = Content.Origin = Anchor.Centre;
|
Content.Anchor = Content.Origin = Anchor.Centre;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
background = new Box
|
backgroundLayer = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both,
|
||||||
},
|
CornerRadius = corner_radius,
|
||||||
text = new OsuSpriteText
|
Masking = true,
|
||||||
{
|
BorderThickness = 2,
|
||||||
Anchor = Anchor.Centre,
|
Children = new Drawable[]
|
||||||
Origin = Anchor.Centre,
|
{
|
||||||
Font = OsuFont.TorusAlternate.With(size: 17),
|
background = new Box
|
||||||
Shear = new Vector2(-shear, 0)
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both
|
||||||
|
},
|
||||||
|
text = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
Font = OsuFont.TorusAlternate.With(size: 17),
|
||||||
|
Shear = new Vector2(-shear, 0)
|
||||||
|
},
|
||||||
|
}
|
||||||
},
|
},
|
||||||
flashLayer = new Box
|
flashLayer = new Box
|
||||||
{
|
{
|
||||||
@ -186,7 +199,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
background.FadeColour(colourDark, 150, Easing.OutQuint);
|
background.FadeColour(colourDark, 150, Easing.OutQuint);
|
||||||
Content.TransformTo(nameof(BorderColour), ColourInfo.GradientVertical(colourDark, colourLight), 150, Easing.OutQuint);
|
backgroundLayer.TransformTo(nameof(BorderColour), ColourInfo.GradientVertical(colourDark, colourLight), 150, Easing.OutQuint);
|
||||||
|
|
||||||
if (!Enabled.Value)
|
if (!Enabled.Value)
|
||||||
colourText = colourText.Opacity(0.6f);
|
colourText = colourText.Opacity(0.6f);
|
||||||
|
@ -267,7 +267,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
TrackChangeDirection direction = TrackChangeDirection.None;
|
TrackChangeDirection direction = TrackChangeDirection.None;
|
||||||
|
|
||||||
bool audioEquals = newWorking?.BeatmapInfo?.AudioEquals(current?.BeatmapInfo) ?? false;
|
bool audioEquals = newWorking?.BeatmapInfo?.AudioEquals(current?.BeatmapInfo) == true;
|
||||||
|
|
||||||
if (current != null)
|
if (current != null)
|
||||||
{
|
{
|
||||||
@ -290,15 +290,8 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
current = newWorking;
|
current = newWorking;
|
||||||
|
|
||||||
if (!audioEquals || CurrentTrack.IsDummyDevice)
|
if (lastWorking == null || !lastWorking.TryTransferTrack(current))
|
||||||
{
|
|
||||||
changeTrack();
|
changeTrack();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// transfer still valid track to new working beatmap
|
|
||||||
current.TransferTrack(lastWorking.Track);
|
|
||||||
}
|
|
||||||
|
|
||||||
TrackChanged?.Invoke(current, direction);
|
TrackChanged?.Invoke(current, direction);
|
||||||
|
|
||||||
|
@ -373,6 +373,13 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected override Track GetBeatmapTrack() => track;
|
protected override Track GetBeatmapTrack() => track;
|
||||||
|
|
||||||
|
public override bool TryTransferTrack(WorkingBeatmap target)
|
||||||
|
{
|
||||||
|
// Our track comes from a local track store that's disposed on finalizer,
|
||||||
|
// therefore it's unsafe to transfer it to another working beatmap.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public class TrackVirtualStore : AudioCollectionManager<Track>, ITrackStore
|
public class TrackVirtualStore : AudioCollectionManager<Track>, ITrackStore
|
||||||
{
|
{
|
||||||
private readonly IFrameBasedClock referenceClock;
|
private readonly IFrameBasedClock referenceClock;
|
||||||
|
Loading…
Reference in New Issue
Block a user