1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 16:07:25 +08:00

Merge pull request #1559 from FreezyLemon/load-optimization

Reduced usage of AsyncLoadWrapper and merging both load wrappers into a new class LoadWrapper
This commit is contained in:
Dean Herbert 2017-11-23 20:33:59 +09:00 committed by GitHub
commit 69a6905c84
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 68 additions and 76 deletions

@ -1 +1 @@
Subproject commit eea84aaefcc7a1a6732d105ba319272dd9744901 Subproject commit d87dab204b3df50f62e6070b1970c135ea647d78

View File

@ -64,11 +64,7 @@ namespace osu.Game.Beatmaps.Drawables
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
} }, 300),
)
{
TimeBeforeLoad = 300,
},
new FillFlowContainer new FillFlowContainer
{ {
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,

View File

@ -56,20 +56,17 @@ namespace osu.Game.Overlays.BeatmapSet
videoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 1 : 0, transition_duration); videoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 1 : 0, transition_duration);
cover?.FadeOut(400, Easing.Out); cover?.FadeOut(400, Easing.Out);
coverContainer.Add(cover = new DelayedLoadWrapper(new BeatmapSetCover(BeatmapSet) coverContainer.Add(cover = new DelayedLoadWrapper(
new BeatmapSetCover(BeatmapSet)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fill, FillMode = FillMode.Fill,
OnLoadComplete = d => OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
{ }, 300)
d.FadeInFromZero(400, Easing.Out);
},
})
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
TimeBeforeLoad = 300
}); });
} }
} }

View File

@ -212,7 +212,8 @@ namespace osu.Game.Overlays.Direct
return icons; return icons;
} }
protected Drawable CreateBackground() => new DelayedLoadWrapper(new BeatmapSetCover(SetInfo) protected Drawable CreateBackground() => new DelayedLoadWrapper(
new BeatmapSetCover(SetInfo)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -223,10 +224,9 @@ namespace osu.Game.Overlays.Direct
d.FadeInFromZero(400, Easing.Out); d.FadeInFromZero(400, Easing.Out);
BlackBackground.Delay(400).FadeOut(); BlackBackground.Delay(400).FadeOut();
}, },
}) }, 300)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
TimeBeforeLoad = 300
}; };
public class Statistic : FillFlowContainer public class Statistic : FillFlowContainer

View File

@ -146,18 +146,17 @@ namespace osu.Game.Overlays.Direct
loading = true; loading = true;
Add(new AsyncLoadWrapper(trackLoader = new TrackLoader($"https://b.ppy.sh/preview/{BeatmapSet.OnlineBeatmapSetID}.mp3") LoadComponentAsync(trackLoader = new TrackLoader($"https://b.ppy.sh/preview/{BeatmapSet.OnlineBeatmapSetID}.mp3"),
d =>
{ {
OnLoadComplete = d => // We may have been replaced by another loader
{
// we may have been replaced by another loader
if (trackLoader != d) return; if (trackLoader != d) return;
Preview = (d as TrackLoader)?.Preview; Preview = d?.Preview;
Playing.TriggerChange(); Playing.TriggerChange();
loading = false; loading = false;
}, Add(trackLoader);
})); });
} }
private class TrackLoader : Drawable private class TrackLoader : Drawable

View File

@ -316,19 +316,16 @@ namespace osu.Game.Overlays.Profile
private void loadUser() private void loadUser()
{ {
coverContainer.Add(new AsyncLoadWrapper(new UserCoverBackground(user) LoadComponentAsync(new UserCoverBackground(user)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
FillMode = FillMode.Fill, FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(200) OnLoadComplete = d => d.FadeInFromZero(200),
}) Depth = float.MaxValue,
{ },
Masking = true, coverContainer.Add);
RelativeSizeAxes = Axes.Both,
Depth = float.MaxValue
});
if (user.IsSupporter) supporterTag.Show(); if (user.IsSupporter) supporterTag.Show();

View File

@ -228,16 +228,16 @@ namespace osu.Game.Screens.Multiplayer
if (value != null) if (value != null)
{ {
coverContainer.FadeIn(transition_duration); coverContainer.FadeIn(transition_duration);
coverContainer.Children = new[]
{
new AsyncLoadWrapper(new BeatmapSetCover(value.BeatmapSet) LoadComponentAsync(new BeatmapSetCover(value.BeatmapSet)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
FillMode = FillMode.Fill, FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
}) { RelativeSizeAxes = Axes.Both }, },
}; coverContainer.Add);
beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title); beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title);
beatmapDash.Text = @" - "; beatmapDash.Text = @" - ";

View File

@ -329,17 +329,16 @@ namespace osu.Game.Screens.Multiplayer
if (value != null) if (value != null)
{ {
coverContainer.FadeIn(transition_duration); coverContainer.FadeIn(transition_duration);
coverContainer.Children = new[]
{ LoadComponentAsync(new BeatmapSetCover(value.BeatmapSet)
new AsyncLoadWrapper(new BeatmapSetCover(value.BeatmapSet)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
FillMode = FillMode.Fill, FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out), OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
}) { RelativeSizeAxes = Axes.Both }, },
}; coverContainer.Add);
beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title); beatmapTitle.Current = localisation.GetUnicodePreference(value.Metadata.TitleUnicode, value.Metadata.Title);
beatmapDash.Text = @" - "; beatmapDash.Text = @" - ";

View File

@ -248,7 +248,10 @@ namespace osu.Game.Screens.Play
storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value); storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value);
storyboard.Masking = true; storyboard.Masking = true;
storyboardContainer.Add(asyncLoad ? new AsyncLoadWrapper(storyboard) { RelativeSizeAxes = Axes.Both } : (Drawable)storyboard); if (asyncLoad)
LoadComponentAsync(storyboard, storyboardContainer.Add);
else
storyboardContainer.Add(storyboard);
} }
public void Restart() public void Restart()

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Select.Leaderboards
private Box background; private Box background;
private Container content; private Container content;
private Container avatar; private Drawable avatar;
private DrawableRank scoreRank; private DrawableRank scoreRank;
private OsuSpriteText nameLabel; private OsuSpriteText nameLabel;
private GlowingSpriteText scoreLabel; private GlowingSpriteText scoreLabel;
@ -97,7 +97,7 @@ namespace osu.Game.Screens.Select.Leaderboards
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(edge_margin), Padding = new MarginPadding(edge_margin),
Children = new Drawable[] Children = new[]
{ {
avatar = new DelayedLoadWrapper( avatar = new DelayedLoadWrapper(
new Avatar(Score.User) new Avatar(Score.User)
@ -114,7 +114,6 @@ namespace osu.Game.Screens.Select.Leaderboards
}, },
}) })
{ {
TimeBeforeLoad = 500,
RelativeSizeAxes = Axes.None, RelativeSizeAxes = Axes.None,
Size = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2), Size = new Vector2(HEIGHT - edge_margin * 2, HEIGHT - edge_margin * 2),
}, },
@ -211,7 +210,7 @@ namespace osu.Game.Screens.Select.Leaderboards
public override void Show() public override void Show()
{ {
foreach (var d in new Drawable[] { avatar, nameLabel, scoreLabel, scoreRank, flagBadgeContainer, maxCombo, accuracy, modsContainer }) foreach (var d in new[] { avatar, nameLabel, scoreLabel, scoreRank, flagBadgeContainer, maxCombo, accuracy, modsContainer })
d.FadeOut(); d.FadeOut();
Alpha = 0; Alpha = 0;

View File

@ -11,7 +11,7 @@ namespace osu.Game.Users
/// </summary> /// </summary>
public class UpdateableAvatar : Container public class UpdateableAvatar : Container
{ {
private Container displayedAvatar; private Drawable displayedAvatar;
private User user; private User user;
@ -40,11 +40,13 @@ namespace osu.Game.Users
{ {
displayedAvatar?.FadeOut(300); displayedAvatar?.FadeOut(300);
displayedAvatar?.Expire(); displayedAvatar?.Expire();
Add(displayedAvatar = new DelayedLoadWrapper(new Avatar(user) Add(displayedAvatar = new DelayedLoadWrapper(
new Avatar(user)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
OnLoadComplete = d => d.FadeInFromZero(200), OnLoadComplete = d => d.FadeInFromZero(200),
})); })
);
} }
} }
} }

View File

@ -58,14 +58,14 @@ namespace osu.Game.Users
Children = new Drawable[] Children = new Drawable[]
{ {
new AsyncLoadWrapper(new UserCoverBackground(user) new DelayedLoadWrapper(new UserCoverBackground(user)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
FillMode = FillMode.Fill, FillMode = FillMode.Fill,
OnLoadComplete = d => d.FadeInFromZero(200), OnLoadComplete = d => d.FadeInFromZero(200),
}) { RelativeSizeAxes = Axes.Both }, }, 0) { RelativeSizeAxes = Axes.Both },
new Box new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,