1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 05:27:23 +08:00

Use DelayedLoadContainer in more places.

This commit is contained in:
Dean Herbert 2017-03-28 14:35:18 +09:00
parent f690e1d0c4
commit 4042b94e01
No known key found for this signature in database
GPG Key ID: 46D71BF4958ABB49
5 changed files with 124 additions and 125 deletions

View File

@ -33,12 +33,25 @@ namespace osu.Game.Beatmaps.Drawables
Children = new Drawable[] Children = new Drawable[]
{ {
new DelayedLoadContainer
{
RelativeSizeAxes = Axes.Both,
TimeBeforeLoad = 100,
Children = new[]
{
new PanelBackground(beatmap)
{
RelativeSizeAxes = Axes.Both,
Depth = 1,
}
}
},
new FillFlowContainer new FillFlowContainer
{ {
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Padding = new MarginPadding { Top = 5, Left = 18, Right = 10, Bottom = 10 }, Padding = new MarginPadding { Top = 5, Left = 18, Right = 10, Bottom = 10 },
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Children = new[] Children = new Drawable[]
{ {
title = new OsuSpriteText title = new OsuSpriteText
{ {
@ -71,23 +84,13 @@ namespace osu.Game.Beatmaps.Drawables
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuConfigManager config, OsuGameBase game) private void load(OsuConfigManager config)
{ {
this.config = config; this.config = config;
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode); preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode.ValueChanged += preferUnicode_changed; preferUnicode.ValueChanged += preferUnicode_changed;
preferUnicode_changed(preferUnicode, null); preferUnicode_changed(preferUnicode, null);
new PanelBackground(beatmap)
{
RelativeSizeAxes = Axes.Both,
Depth = 1,
}.LoadAsync(game, b =>
{
Add(b);
b.FadeInFromZero(200);
});
} }
private void preferUnicode_changed(object sender, EventArgs e) private void preferUnicode_changed(object sender, EventArgs e)

View File

@ -29,7 +29,7 @@ namespace osu.Game.Overlays
{ {
public class MusicController : FocusedOverlayContainer public class MusicController : FocusedOverlayContainer
{ {
private MusicControllerBackground backgroundSprite; private Drawable currentBackground;
private DragBar progress; private DragBar progress;
private TextAwesome playButton; private TextAwesome playButton;
private SpriteText title, artist; private SpriteText title, artist;
@ -44,7 +44,6 @@ namespace osu.Game.Overlays
private Bindable<bool> preferUnicode; private Bindable<bool> preferUnicode;
private WorkingBeatmap current; private WorkingBeatmap current;
private BeatmapDatabase beatmaps; private BeatmapDatabase beatmaps;
private Framework.Game game;
private Container dragContainer; private Container dragContainer;
@ -78,10 +77,8 @@ namespace osu.Game.Overlays
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuGameBase osuGame, OsuConfigManager config, BeatmapDatabase beatmaps, OsuColour colours) private void load(OsuGameBase game, OsuConfigManager config, BeatmapDatabase beatmaps, OsuColour colours)
{ {
game = osuGame;
unicodeString = config.GetUnicodeString; unicodeString = config.GetUnicodeString;
Children = new Drawable[] Children = new Drawable[]
@ -212,15 +209,15 @@ namespace osu.Game.Overlays
}; };
this.beatmaps = beatmaps; this.beatmaps = beatmaps;
trackManager = osuGame.Audio.Track; trackManager = game.Audio.Track;
preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode); preferUnicode = config.GetBindable<bool>(OsuConfig.ShowUnicode);
preferUnicode.ValueChanged += preferUnicode_changed; preferUnicode.ValueChanged += preferUnicode_changed;
beatmapSource = osuGame.Beatmap ?? new Bindable<WorkingBeatmap>(); beatmapSource = game.Beatmap ?? new Bindable<WorkingBeatmap>();
playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>(); playList = beatmaps.GetAllWithChildren<BeatmapSetInfo>();
backgroundSprite = new MusicControllerBackground(); currentBackground = new MusicControllerBackground();
dragContainer.Add(backgroundSprite); dragContainer.Add(currentBackground);
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -351,29 +348,29 @@ namespace osu.Game.Overlays
} }
}); });
MusicControllerBackground newBackground; dragContainer.Add(new AsyncLoadContainer
{
(newBackground = new MusicControllerBackground(beatmap)).LoadAsync(game, delegate RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue,
Children = new[] { new MusicControllerBackground(beatmap) },
FinishedLoading = d =>
{ {
dragContainer.Add(newBackground);
switch (direction) switch (direction)
{ {
case TransformDirection.Next: case TransformDirection.Next:
newBackground.Position = new Vector2(400, 0); d.Position = new Vector2(400, 0);
newBackground.MoveToX(0, 500, EasingTypes.OutCubic); d.MoveToX(0, 500, EasingTypes.OutCubic);
backgroundSprite.MoveToX(-400, 500, EasingTypes.OutCubic); currentBackground.MoveToX(-400, 500, EasingTypes.OutCubic);
break; break;
case TransformDirection.Prev: case TransformDirection.Prev:
newBackground.Position = new Vector2(-400, 0); d.Position = new Vector2(-400, 0);
newBackground.MoveToX(0, 500, EasingTypes.OutCubic); d.MoveToX(0, 500, EasingTypes.OutCubic);
backgroundSprite.MoveToX(400, 500, EasingTypes.OutCubic); currentBackground.MoveToX(400, 500, EasingTypes.OutCubic);
break; break;
} }
currentBackground.Expire();
backgroundSprite.Expire(); currentBackground = d;
backgroundSprite = newBackground; }
}); });
}; };
} }
@ -422,8 +419,8 @@ namespace osu.Game.Overlays
{ {
this.beatmap = beatmap; this.beatmap = beatmap;
CacheDrawnFrameBuffer = true; CacheDrawnFrameBuffer = true;
RelativeSizeAxes = Axes.Both;
Depth = float.MaxValue; Depth = float.MaxValue;
RelativeSizeAxes = Axes.Both;
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -6,7 +6,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenTK; using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
@ -30,9 +29,7 @@ namespace osu.Game.Screens.Select
{ {
private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0); private static readonly Vector2 wedged_container_shear = new Vector2(0.15f, 0);
private BufferedContainer beatmapInfoContainer; private Drawable beatmapInfoContainer;
private OsuGameBase game;
public BeatmapInfoWedge() public BeatmapInfoWedge()
{ {
@ -49,12 +46,6 @@ namespace osu.Game.Screens.Select
}; };
} }
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
{
this.game = game;
}
protected override bool HideOnEscape => false; protected override bool HideOnEscape => false;
protected override void PopIn() protected override void PopIn()
@ -113,9 +104,21 @@ namespace osu.Game.Screens.Select
labels.AddRange(Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s))); labels.AddRange(Ruleset.GetRuleset(beatmap.BeatmapInfo.Mode).GetBeatmapStatistics(beatmap).Select(s => new InfoLabel(s)));
} }
(beatmapInfoContainer = new BufferedContainer Add(beatmapInfoContainer = new AsyncLoadContainer
{ {
FinishedLoading = d =>
{
FadeIn(250);
lastContainer?.FadeOut(250);
lastContainer?.Expire();
},
Depth = newDepth, Depth = newDepth,
RelativeSizeAxes = Axes.Both,
Children = new[]
{
new BufferedContainer
{
PixelSnapping = true, PixelSnapping = true,
CacheDrawnFrameBuffer = true, CacheDrawnFrameBuffer = true,
Shear = -Shear, Shear = -Shear,
@ -136,7 +139,7 @@ namespace osu.Game.Screens.Select
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
ColourInfo = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0.3f)), ColourInfo = ColourInfo.GradientVertical(Color4.White, Color4.White.Opacity(0.3f)),
Children = new [] Children = new[]
{ {
// Zoomed-in and cropped beatmap background // Zoomed-in and cropped beatmap background
new BeatmapBackgroundSprite(beatmap) new BeatmapBackgroundSprite(beatmap)
@ -176,7 +179,7 @@ namespace osu.Game.Screens.Select
Margin = new MarginPadding { Top = 10 }, Margin = new MarginPadding { Top = 10 },
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Children = new [] Children = new[]
{ {
new OsuSpriteText new OsuSpriteText
{ {
@ -204,14 +207,8 @@ namespace osu.Game.Screens.Select
} }
}, },
} }
}).LoadAsync(game, delegate (Drawable d) }
{ }
FadeIn(250);
lastContainer?.FadeOut(250);
lastContainer?.Expire();
Add(d);
}); });
} }

View File

@ -145,6 +145,7 @@ namespace osu.Game.Screens.Select.Leaderboards
avatar = new DelayedLoadContainer avatar = new DelayedLoadContainer
{ {
TimeBeforeLoad = 500, TimeBeforeLoad = 500,
FinishedLoading = d => d.FadeInFromZero(200),
Size = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2), Size = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2),
Children = new Drawable[] Children = new Drawable[]
{ {

View File

@ -43,6 +43,7 @@ namespace osu.Game.Users
Add(displayedAvatar = new AsyncLoadContainer Add(displayedAvatar = new AsyncLoadContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
FinishedLoading = d => d.FadeInFromZero(200),
Children = new[] Children = new[]
{ {
new Avatar(user) { RelativeSizeAxes = Axes.Both } new Avatar(user) { RelativeSizeAxes = Axes.Both }