1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 20:47:51 +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,
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
}
)
{
TimeBeforeLoad = 300,
},
}, 300),
new FillFlowContainer
{
Direction = FillDirection.Vertical,

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -248,7 +248,10 @@ namespace osu.Game.Screens.Play
storyboard = beatmap.Storyboard.CreateDrawable(Beatmap.Value);
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()

View File

@ -33,7 +33,7 @@ namespace osu.Game.Screens.Select.Leaderboards
private Box background;
private Container content;
private Container avatar;
private Drawable avatar;
private DrawableRank scoreRank;
private OsuSpriteText nameLabel;
private GlowingSpriteText scoreLabel;
@ -97,7 +97,7 @@ namespace osu.Game.Screens.Select.Leaderboards
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(edge_margin),
Children = new Drawable[]
Children = new[]
{
avatar = new DelayedLoadWrapper(
new Avatar(Score.User)
@ -114,7 +114,6 @@ namespace osu.Game.Screens.Select.Leaderboards
},
})
{
TimeBeforeLoad = 500,
RelativeSizeAxes = Axes.None,
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()
{
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();
Alpha = 0;

View File

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

View File

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