mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'master' of github.com:ppy/osu into better-song-select
This commit is contained in:
@ -1,9 +1,8 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using OpenTK;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Background;
|
||||
@ -15,6 +14,7 @@ namespace osu.Game.Screens.Backgrounds
|
||||
private Background background;
|
||||
|
||||
private WorkingBeatmap beatmap;
|
||||
private Vector2 blurTarget;
|
||||
|
||||
public WorkingBeatmap Beatmap
|
||||
{
|
||||
@ -30,20 +30,26 @@ namespace osu.Game.Screens.Backgrounds
|
||||
|
||||
beatmap = value;
|
||||
|
||||
Background oldBackground = background;
|
||||
|
||||
addBackground(background = new Background());
|
||||
background.Sprite.Texture = beatmap.Background;
|
||||
|
||||
if (oldBackground != null)
|
||||
Schedule(() =>
|
||||
{
|
||||
oldBackground.Depth = 1;
|
||||
oldBackground.Flush();
|
||||
oldBackground.FadeOut(250);
|
||||
oldBackground.Expire();
|
||||
Background newBackground = new BeatmapBackground(beatmap);
|
||||
|
||||
background.BlurSigma = oldBackground.BlurSigma;
|
||||
}
|
||||
newBackground.Preload(Game, delegate
|
||||
{
|
||||
Background oldBackground = background;
|
||||
|
||||
Add(background = newBackground);
|
||||
background.BlurSigma = blurTarget;
|
||||
|
||||
if (oldBackground != null)
|
||||
{
|
||||
oldBackground.Depth = 1;
|
||||
oldBackground.Flush();
|
||||
oldBackground.FadeOut(250);
|
||||
oldBackground.Expire();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,20 +58,33 @@ namespace osu.Game.Screens.Backgrounds
|
||||
Beatmap = beatmap;
|
||||
}
|
||||
|
||||
private void addBackground(Background background)
|
||||
{
|
||||
background.CacheDrawnFrameBuffer = true;
|
||||
Add(background);
|
||||
}
|
||||
|
||||
public void BlurTo(Vector2 sigma, double duration)
|
||||
{
|
||||
background?.BlurTo(sigma, duration, EasingTypes.OutExpo);
|
||||
blurTarget = sigma;
|
||||
}
|
||||
|
||||
public override bool Equals(BackgroundMode other)
|
||||
{
|
||||
return base.Equals(other) && beatmap == ((BackgroundModeBeatmap)other).Beatmap;
|
||||
}
|
||||
|
||||
class BeatmapBackground : Background
|
||||
{
|
||||
private WorkingBeatmap beatmap;
|
||||
|
||||
public BeatmapBackground(WorkingBeatmap beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
CacheDrawnFrameBuffer = true;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
Sprite.Texture = beatmap.Background;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,9 +125,9 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
}
|
||||
|
||||
protected override void UpdateMouseState(InputState state)
|
||||
protected override void TransformState(InputState state)
|
||||
{
|
||||
base.UpdateMouseState(state);
|
||||
base.TransformState(state);
|
||||
|
||||
MouseState mouse = (MouseState)state.Mouse;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
@ -44,6 +45,7 @@ namespace osu.Game.Screens.Select
|
||||
private Container wedgedBeatmapInfo;
|
||||
|
||||
private static readonly Vector2 BACKGROUND_BLUR = new Vector2(20);
|
||||
private CancellationTokenSource initialAddSetsTask;
|
||||
|
||||
/// <param name="database">Optionally provide a database to use instead of the OsuGame one.</param>
|
||||
public PlaySongSelect(BeatmapDatabase database = null)
|
||||
@ -153,11 +155,18 @@ namespace osu.Game.Screens.Select
|
||||
if (database == null)
|
||||
database = beatmaps;
|
||||
|
||||
database.BeatmapSetAdded += s => Schedule(() => addBeatmapSet(s, game));
|
||||
database.BeatmapSetAdded += onDatabaseOnBeatmapSetAdded;
|
||||
|
||||
trackManager = audio.Track;
|
||||
|
||||
Task.Factory.StartNew(() => addBeatmapSets(game));
|
||||
initialAddSetsTask = new CancellationTokenSource();
|
||||
|
||||
Task.Factory.StartNew(() => addBeatmapSets(game, initialAddSetsTask.Token), initialAddSetsTask.Token);
|
||||
}
|
||||
|
||||
private void onDatabaseOnBeatmapSetAdded(BeatmapSetInfo s)
|
||||
{
|
||||
Schedule(() => addBeatmapSet(s, Game));
|
||||
}
|
||||
|
||||
protected override void OnEntering(GameMode last)
|
||||
@ -196,6 +205,10 @@ namespace osu.Game.Screens.Select
|
||||
base.Dispose(isDisposing);
|
||||
if (playMode != null)
|
||||
playMode.ValueChanged -= playMode_ValueChanged;
|
||||
|
||||
database.BeatmapSetAdded -= onDatabaseOnBeatmapSetAdded;
|
||||
|
||||
initialAddSetsTask.Cancel();
|
||||
}
|
||||
|
||||
private void playMode_ValueChanged(object sender, EventArgs e)
|
||||
@ -215,6 +228,7 @@ namespace osu.Game.Screens.Select
|
||||
(Background as BackgroundModeBeatmap)?.BlurTo(BACKGROUND_BLUR, 1000);
|
||||
}
|
||||
|
||||
//todo: move to own class and fix async logic (move every call on WorkingBeatmap.* to load() and use Preload to create it.
|
||||
refreshWedgedBeatmapInfo(beatmap);
|
||||
}
|
||||
|
||||
@ -329,6 +343,7 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
base.OnBeatmapChanged(beatmap);
|
||||
|
||||
//todo: change background in selectionChanged instead; support per-difficulty backgrounds.
|
||||
changeBackground(beatmap);
|
||||
|
||||
selectBeatmap(beatmap.BeatmapInfo);
|
||||
@ -372,9 +387,9 @@ namespace osu.Game.Screens.Select
|
||||
beatmapSet.Beatmaps.ForEach(b => database.GetChildren(b));
|
||||
beatmapSet.Beatmaps = beatmapSet.Beatmaps.OrderBy(b => b.BaseDifficulty.OverallDifficulty).ToList();
|
||||
|
||||
var working = database.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault());
|
||||
var beatmap = database.GetWorkingBeatmap(beatmapSet.Beatmaps.FirstOrDefault());
|
||||
|
||||
var group = new BeatmapGroup(beatmapSet, working) { SelectionChanged = selectionChanged };
|
||||
var group = new BeatmapGroup(beatmap) { SelectionChanged = selectionChanged };
|
||||
|
||||
//for the time being, let's completely load the difficulty panels in the background.
|
||||
//this likely won't scale so well, but allows us to completely async the loading flow.
|
||||
@ -393,10 +408,13 @@ namespace osu.Game.Screens.Select
|
||||
}));
|
||||
}
|
||||
|
||||
private void addBeatmapSets(BaseGame game)
|
||||
private void addBeatmapSets(BaseGame game, CancellationToken token)
|
||||
{
|
||||
foreach (var beatmapSet in database.Query<BeatmapSetInfo>())
|
||||
{
|
||||
if (token.IsCancellationRequested) return;
|
||||
addBeatmapSet(beatmapSet, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user