mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 10:22:56 +08:00
Merge remote-tracking branch 'origin/master' into beatmap-serialization
This commit is contained in:
commit
dfc10d42e8
@ -1 +1 @@
|
||||
Subproject commit 8c16e6244d8ca884a743a0d5a1f1ee485f18655c
|
||||
Subproject commit 9cd6968a8c4d27415808f5e770d24fec5a44485f
|
@ -41,7 +41,7 @@ namespace osu.Game.Beatmaps
|
||||
protected abstract Track GetTrack();
|
||||
protected virtual Waveform GetWaveform() => new Waveform();
|
||||
|
||||
public bool BeatmapLoaded => beatmap.IsValueCreated;
|
||||
public bool BeatmapLoaded => beatmap.IsResultAvailable;
|
||||
public Beatmap Beatmap => beatmap.Value.Result;
|
||||
public async Task<Beatmap> GetBeatmapAsync() => await beatmap.Value;
|
||||
|
||||
@ -57,14 +57,14 @@ namespace osu.Game.Beatmaps
|
||||
return b;
|
||||
}
|
||||
|
||||
public bool BackgroundLoaded => background.IsValueCreated;
|
||||
public bool BackgroundLoaded => background.IsResultAvailable;
|
||||
public Texture Background => background.Value.Result;
|
||||
public async Task<Texture> GetBackgroundAsync() => await background.Value;
|
||||
private AsyncLazy<Texture> background;
|
||||
|
||||
private Texture populateBackground() => GetBackground();
|
||||
|
||||
public bool TrackLoaded => track.IsValueCreated;
|
||||
public bool TrackLoaded => track.IsResultAvailable;
|
||||
public Track Track => track.Value.Result;
|
||||
public async Task<Track> GetTrackAsync() => await track.Value;
|
||||
private AsyncLazy<Track> track;
|
||||
@ -77,7 +77,7 @@ namespace osu.Game.Beatmaps
|
||||
return t;
|
||||
}
|
||||
|
||||
public bool WaveformLoaded => waveform.IsValueCreated;
|
||||
public bool WaveformLoaded => waveform.IsResultAvailable;
|
||||
public Waveform Waveform => waveform.Value.Result;
|
||||
public async Task<Waveform> GetWaveformAsync() => await waveform.Value;
|
||||
private readonly AsyncLazy<Waveform> waveform;
|
||||
@ -86,10 +86,10 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public void TransferTo(WorkingBeatmap other)
|
||||
{
|
||||
if (track.IsValueCreated && Track != null && BeatmapInfo.AudioEquals(other.BeatmapInfo))
|
||||
if (track.IsResultAvailable && Track != null && BeatmapInfo.AudioEquals(other.BeatmapInfo))
|
||||
other.track = track;
|
||||
|
||||
if (background.IsValueCreated && Background != null && BeatmapInfo.BackgroundEquals(other.BeatmapInfo))
|
||||
if (background.IsResultAvailable && Background != null && BeatmapInfo.BackgroundEquals(other.BeatmapInfo))
|
||||
other.background = background;
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
private void applyRateAdjustments(Track t = null)
|
||||
{
|
||||
if (t == null && track.IsValueCreated) t = Track;
|
||||
if (t == null && track.IsResultAvailable) t = Track;
|
||||
if (t == null) return;
|
||||
|
||||
t.ResetSpeedAdjustments();
|
||||
@ -128,23 +128,23 @@ namespace osu.Game.Beatmaps
|
||||
this.valueFactory = valueFactory;
|
||||
this.stillValidFunction = stillValidFunction;
|
||||
|
||||
init();
|
||||
recreate();
|
||||
}
|
||||
|
||||
public void Recycle()
|
||||
{
|
||||
if (!IsValueCreated) return;
|
||||
if (!IsResultAvailable) return;
|
||||
|
||||
(lazy.Value.Result as IDisposable)?.Dispose();
|
||||
init();
|
||||
recreate();
|
||||
}
|
||||
|
||||
public bool IsValueCreated
|
||||
public bool IsResultAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
ensureValid();
|
||||
return lazy.IsValueCreated;
|
||||
recreateIfInvalid();
|
||||
return lazy.Value.IsCompleted;
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,24 +152,28 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
get
|
||||
{
|
||||
ensureValid();
|
||||
recreateIfInvalid();
|
||||
return lazy.Value;
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureValid()
|
||||
private void recreateIfInvalid()
|
||||
{
|
||||
lock (initLock)
|
||||
{
|
||||
if (!lazy.IsValueCreated || (stillValidFunction?.Invoke(lazy.Value.Result) ?? true)) return;
|
||||
init();
|
||||
if (!lazy.IsValueCreated || !lazy.Value.IsCompleted)
|
||||
// we have not yet been initialised or haven't run the task.
|
||||
return;
|
||||
|
||||
if (stillValidFunction?.Invoke(lazy.Value.Result) ?? true)
|
||||
// we are still in a valid state.
|
||||
return;
|
||||
|
||||
recreate();
|
||||
}
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
lazy = new Lazy<Task<T>>(() => Task.Run(valueFactory));
|
||||
}
|
||||
private void recreate() => lazy = new Lazy<Task<T>>(() => Task.Run(valueFactory));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,11 @@ namespace osu.Game.Overlays.Music
|
||||
set { base.Padding = value; }
|
||||
}
|
||||
|
||||
public IEnumerable<BeatmapSetInfo> BeatmapSets { set { items.Sets = value; } }
|
||||
public IEnumerable<BeatmapSetInfo> BeatmapSets
|
||||
{
|
||||
get { return items.Sets; }
|
||||
set { items.Sets = value; }
|
||||
}
|
||||
|
||||
public BeatmapSetInfo FirstVisibleSet => items.FirstVisibleSet;
|
||||
public BeatmapSetInfo NextSet => items.NextSet;
|
||||
@ -48,7 +52,7 @@ namespace osu.Game.Overlays.Music
|
||||
}
|
||||
|
||||
public void AddBeatmapSet(BeatmapSetInfo beatmapSet) => items.AddBeatmapSet(beatmapSet);
|
||||
public bool RemoveBeatmapSet(BeatmapSetInfo beatmapSet) => items.RemoveBeatmapSet(beatmapSet);
|
||||
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet) => items.RemoveBeatmapSet(beatmapSet);
|
||||
|
||||
public void Filter(string searchTerm) => items.SearchTerm = searchTerm;
|
||||
|
||||
@ -81,6 +85,7 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
public IEnumerable<BeatmapSetInfo> Sets
|
||||
{
|
||||
get { return items.Select(x => x.BeatmapSetInfo).ToList(); }
|
||||
set
|
||||
{
|
||||
items.Clear();
|
||||
@ -103,12 +108,11 @@ namespace osu.Game.Overlays.Music
|
||||
});
|
||||
}
|
||||
|
||||
public bool RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
var itemToRemove = items.FirstOrDefault(i => i.BeatmapSetInfo.ID == beatmapSet.ID);
|
||||
if (itemToRemove == null)
|
||||
return false;
|
||||
return items.Remove(itemToRemove);
|
||||
if (itemToRemove != null)
|
||||
items.Remove(itemToRemove);
|
||||
}
|
||||
|
||||
public BeatmapSetInfo SelectedSet
|
||||
@ -230,6 +234,7 @@ namespace osu.Game.Overlays.Music
|
||||
private class ItemSearchContainer : FillFlowContainer<PlaylistItem>, IHasFilterableChildren
|
||||
{
|
||||
public IEnumerable<string> FilterTerms => new string[] { };
|
||||
|
||||
public bool MatchingFilter
|
||||
{
|
||||
set
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using System.Threading;
|
||||
|
||||
namespace osu.Game.Overlays.Music
|
||||
{
|
||||
@ -29,7 +30,7 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
|
||||
|
||||
public IEnumerable<BeatmapSetInfo> BeatmapSets;
|
||||
public IEnumerable<BeatmapSetInfo> BeatmapSets => list.BeatmapSets;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase game, BeatmapManager beatmaps, OsuColour colours)
|
||||
@ -74,11 +75,10 @@ namespace osu.Game.Overlays.Music
|
||||
},
|
||||
};
|
||||
|
||||
beatmaps.BeatmapSetAdded += s => Schedule(() => list.AddBeatmapSet(s));
|
||||
beatmaps.BeatmapSetRemoved += s => Schedule(() => list.RemoveBeatmapSet(s));
|
||||
|
||||
list.BeatmapSets = BeatmapSets = beatmaps.GetAllUsableBeatmapSets();
|
||||
beatmaps.BeatmapSetAdded += list.AddBeatmapSet;
|
||||
beatmaps.BeatmapSetRemoved += list.RemoveBeatmapSet;
|
||||
|
||||
list.BeatmapSets = beatmaps.GetAllUsableBeatmapSets();
|
||||
|
||||
beatmapBacking.BindTo(game.Beatmap);
|
||||
|
||||
@ -121,7 +121,7 @@ namespace osu.Game.Overlays.Music
|
||||
return;
|
||||
}
|
||||
|
||||
playSpecified(set.Beatmaps[0]);
|
||||
playSpecified(set.Beatmaps.First());
|
||||
}
|
||||
|
||||
public void PlayPrevious()
|
||||
@ -130,7 +130,7 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
if (playable != null)
|
||||
{
|
||||
playSpecified(playable.Beatmaps[0]);
|
||||
playSpecified(playable.Beatmaps.First());
|
||||
list.SelectedSet = playable;
|
||||
}
|
||||
}
|
||||
@ -141,7 +141,7 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
if (playable != null)
|
||||
{
|
||||
playSpecified(playable.Beatmaps[0]);
|
||||
playSpecified(playable.Beatmaps.First());
|
||||
list.SelectedSet = playable;
|
||||
}
|
||||
}
|
||||
@ -149,7 +149,15 @@ namespace osu.Game.Overlays.Music
|
||||
private void playSpecified(BeatmapInfo info)
|
||||
{
|
||||
beatmapBacking.Value = beatmaps.GetWorkingBeatmap(info, beatmapBacking);
|
||||
beatmapBacking.Value.Track.Start();
|
||||
|
||||
var track = beatmapBacking.Value.Track;
|
||||
|
||||
track.Restart();
|
||||
|
||||
// this is temporary until we have blocking (async.Wait()) audio component methods.
|
||||
// then we can call RestartAsync().Wait() or the blocking version above.
|
||||
while (!track.IsRunning)
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,7 +251,7 @@ namespace osu.Game.Overlays
|
||||
|
||||
playButton.Icon = track.IsRunning ? FontAwesome.fa_pause_circle_o : FontAwesome.fa_play_circle_o;
|
||||
|
||||
if (track.HasCompleted && !track.Looping && !beatmapBacking.Disabled)
|
||||
if (track.HasCompleted && !beatmapBacking.Disabled && playlist.BeatmapSets.Any())
|
||||
next();
|
||||
}
|
||||
else
|
||||
|
@ -1,8 +1,12 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shaders;
|
||||
using osu.Game.Screens.Menu;
|
||||
using OpenTK;
|
||||
using osu.Framework.Screens;
|
||||
@ -33,14 +37,28 @@ namespace osu.Game.Screens
|
||||
logo.FadeInFromZero(5000, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private OsuScreen loadScreen;
|
||||
private ShaderPrecompiler precompiler;
|
||||
|
||||
protected override void OnEntering(Screen last)
|
||||
{
|
||||
base.OnEntering(last);
|
||||
|
||||
if (showDisclaimer)
|
||||
LoadComponentAsync(new Disclaimer(), d => Push(d));
|
||||
else
|
||||
LoadComponentAsync(new Intro(), d => Push(d));
|
||||
LoadComponentAsync(precompiler = new ShaderPrecompiler(loadIfReady), Add);
|
||||
LoadComponentAsync(loadScreen = showDisclaimer ? (OsuScreen)new Disclaimer() : new Intro(), s => loadIfReady());
|
||||
}
|
||||
|
||||
private void loadIfReady()
|
||||
{
|
||||
if (ChildScreen == loadScreen) return;
|
||||
|
||||
if (loadScreen.LoadState != LoadState.Ready)
|
||||
return;
|
||||
|
||||
if (!precompiler.FinishedCompiling)
|
||||
return;
|
||||
|
||||
Push(loadScreen);
|
||||
}
|
||||
|
||||
protected override void LogoSuspending(OsuLogo logo)
|
||||
@ -54,5 +72,49 @@ namespace osu.Game.Screens
|
||||
{
|
||||
showDisclaimer = game.IsDeployedBuild;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compiles a set of shaders before continuing. Attempts to draw some frames between compilation by limiting to one compile per draw frame.
|
||||
/// </summary>
|
||||
public class ShaderPrecompiler : Drawable
|
||||
{
|
||||
private readonly Action onLoaded;
|
||||
private readonly List<Shader> loadTargets = new List<Shader>();
|
||||
|
||||
public bool FinishedCompiling { get; private set; }
|
||||
|
||||
public ShaderPrecompiler(Action onLoaded)
|
||||
{
|
||||
this.onLoaded = onLoaded;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ShaderManager manager)
|
||||
{
|
||||
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE_ROUNDED));
|
||||
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.BLUR));
|
||||
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_2, FragmentShaderDescriptor.TEXTURE));
|
||||
|
||||
loadTargets.Add(manager.Load(@"CursorTrail", FragmentShaderDescriptor.TEXTURE));
|
||||
|
||||
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE_ROUNDED));
|
||||
loadTargets.Add(manager.Load(VertexShaderDescriptor.TEXTURE_3, FragmentShaderDescriptor.TEXTURE));
|
||||
}
|
||||
|
||||
private Shader currentLoadTarget;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
// if our target is null we are done.
|
||||
if (loadTargets.All(s => s.Loaded))
|
||||
{
|
||||
FinishedCompiling = true;
|
||||
Expire();
|
||||
onLoaded?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user