mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Merge pull request #2667 from DrabWeb/updateable-beatmap-set-cover
Centralise beatmap set cover update logic
This commit is contained in:
commit
03cc4e878e
79
osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs
Normal file
79
osu.Game/Beatmaps/Drawables/UpdateableBeatmapSetCover.cs
Normal file
@ -0,0 +1,79 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
public class UpdateableBeatmapSetCover : Container
|
||||
{
|
||||
private Drawable displayedCover;
|
||||
|
||||
private BeatmapSetInfo beatmapSet;
|
||||
public BeatmapSetInfo BeatmapSet
|
||||
{
|
||||
get { return beatmapSet; }
|
||||
set
|
||||
{
|
||||
if (value == beatmapSet) return;
|
||||
beatmapSet = value;
|
||||
|
||||
if (IsLoaded)
|
||||
updateCover();
|
||||
}
|
||||
}
|
||||
|
||||
private BeatmapSetCoverType coverType = BeatmapSetCoverType.Cover;
|
||||
public BeatmapSetCoverType CoverType
|
||||
{
|
||||
get { return coverType; }
|
||||
set
|
||||
{
|
||||
if (value == coverType) return;
|
||||
coverType = value;
|
||||
|
||||
if (IsLoaded)
|
||||
updateCover();
|
||||
}
|
||||
}
|
||||
|
||||
public UpdateableBeatmapSetCover()
|
||||
{
|
||||
Child = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateCover();
|
||||
}
|
||||
|
||||
private void updateCover()
|
||||
{
|
||||
displayedCover?.FadeOut(400);
|
||||
displayedCover?.Expire();
|
||||
displayedCover = null;
|
||||
|
||||
if (beatmapSet != null)
|
||||
{
|
||||
Add(displayedCover = new DelayedLoadWrapper(
|
||||
new BeatmapSetCover(beatmapSet, coverType)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fill,
|
||||
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -26,7 +26,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private const float buttons_spacing = 5;
|
||||
|
||||
private readonly Box tabsBg;
|
||||
private readonly Container coverContainer;
|
||||
private readonly UpdateableBeatmapSetCover cover;
|
||||
private readonly OsuSpriteText title, artist;
|
||||
private readonly Container noVideoButtons;
|
||||
private readonly FillFlowContainer videoButtons;
|
||||
@ -36,7 +36,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
public Details Details;
|
||||
|
||||
private BeatmapManager beatmaps;
|
||||
private DelayedLoadWrapper cover;
|
||||
|
||||
public readonly BeatmapPicker Picker;
|
||||
|
||||
@ -62,8 +61,8 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
title.Text = BeatmapSet?.Metadata.Title ?? string.Empty;
|
||||
artist.Text = BeatmapSet?.Metadata.Artist ?? string.Empty;
|
||||
onlineStatusPill.Status = BeatmapSet?.OnlineInfo.Status ?? BeatmapSetOnlineStatus.None;
|
||||
cover.BeatmapSet = BeatmapSet;
|
||||
|
||||
cover?.FadeOut(400, Easing.Out);
|
||||
if (BeatmapSet != null)
|
||||
{
|
||||
downloadButtonsContainer.FadeIn(transition_duration);
|
||||
@ -71,19 +70,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
|
||||
noVideoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 0 : 1, transition_duration);
|
||||
videoButtons.FadeTo(BeatmapSet.OnlineInfo.HasVideo ? 1 : 0, transition_duration);
|
||||
|
||||
coverContainer.Add(cover = new DelayedLoadWrapper(
|
||||
new BeatmapSetCover(BeatmapSet)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
FillMode = FillMode.Fill,
|
||||
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
||||
}, 300)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -130,12 +116,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
coverContainer = new Container
|
||||
cover = new UpdateableBeatmapSetCover
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
|
@ -27,8 +27,6 @@ namespace osu.Game.Overlays.Direct
|
||||
{
|
||||
public readonly BeatmapSetInfo SetInfo;
|
||||
|
||||
protected Box BlackBackground;
|
||||
|
||||
private const double hover_transition_time = 400;
|
||||
|
||||
private Container content;
|
||||
@ -81,12 +79,6 @@ namespace osu.Game.Overlays.Direct
|
||||
EdgeEffect = edgeEffectNormal,
|
||||
Children = new[]
|
||||
{
|
||||
// temporary blackness until the actual background loads.
|
||||
BlackBackground = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
CreateBackground(),
|
||||
progressBar = new ProgressBar
|
||||
{
|
||||
@ -215,21 +207,10 @@ 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 =>
|
||||
{
|
||||
d.FadeInFromZero(400, Easing.Out);
|
||||
BlackBackground.Delay(400).FadeOut();
|
||||
},
|
||||
}, 300)
|
||||
protected Drawable CreateBackground() => new UpdateableBeatmapSetCover
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BeatmapSet = SetInfo,
|
||||
};
|
||||
|
||||
public class Statistic : FillFlowContainer
|
||||
|
@ -24,19 +24,13 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
||||
this.playCount = playCount;
|
||||
}
|
||||
|
||||
protected override Drawable CreateLeftVisual() => new DelayedLoadWrapper(new BeatmapSetCover(beatmap.BeatmapSet, BeatmapSetCoverType.List)
|
||||
protected override Drawable CreateLeftVisual() => new UpdateableBeatmapSetCover
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
FillMode = FillMode.Fit,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
OnLoadComplete = d => d.FadeInFromZero(500, Easing.OutQuint)
|
||||
})
|
||||
{
|
||||
Origin = Anchor.CentreLeft,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
RelativeSizeAxes = Axes.None,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Size = new Vector2(80, 50),
|
||||
BeatmapSet = beatmap.BeatmapSet,
|
||||
CoverType = BeatmapSetCoverType.List,
|
||||
};
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
|
@ -111,7 +111,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
private void load(OsuColour colours, LocalisationEngine localisation)
|
||||
{
|
||||
Box sideStrip;
|
||||
Container coverContainer;
|
||||
UpdateableBeatmapSetCover cover;
|
||||
OsuSpriteText name, status, beatmapTitle, beatmapDash, beatmapArtist;
|
||||
ParticipantInfo participantInfo;
|
||||
ModeTypeInfo modeTypeInfo;
|
||||
@ -146,24 +146,12 @@ namespace osu.Game.Screens.Multi.Components
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = side_strip_width,
|
||||
},
|
||||
new Container
|
||||
cover = new UpdateableBeatmapSetCover
|
||||
{
|
||||
Width = cover_width,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Masking = true,
|
||||
Margin = new MarginPadding { Left = side_strip_width },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
coverContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
},
|
||||
},
|
||||
new Container
|
||||
{
|
||||
@ -263,23 +251,14 @@ namespace osu.Game.Screens.Multi.Components
|
||||
|
||||
if (b != null)
|
||||
{
|
||||
coverContainer.FadeIn(transition_duration);
|
||||
|
||||
LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
FillMode = FillMode.Fill,
|
||||
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
||||
}, coverContainer.Add);
|
||||
|
||||
cover.BeatmapSet = b.BeatmapSet;
|
||||
beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title);
|
||||
beatmapDash.Text = @" - ";
|
||||
beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist);
|
||||
}
|
||||
else
|
||||
{
|
||||
coverContainer.FadeOut(transition_duration);
|
||||
cover.BeatmapSet = null;
|
||||
|
||||
beatmapTitle.Current = null;
|
||||
beatmapArtist.Current = null;
|
||||
|
@ -38,7 +38,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
|
||||
private OsuColour colours;
|
||||
private Box statusStrip;
|
||||
private Container coverContainer;
|
||||
private UpdateableBeatmapSetCover cover;
|
||||
private FillFlowContainer topFlow, participantsFlow, participantNumbersFlow, infoPanelFlow;
|
||||
private OsuSpriteText name, status;
|
||||
private ScrollContainer participantsScroll;
|
||||
@ -105,21 +105,9 @@ namespace osu.Game.Screens.Multi.Components
|
||||
Masking = true,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Container
|
||||
cover = new UpdateableBeatmapSetCover
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
},
|
||||
coverContainer = new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
},
|
||||
},
|
||||
new Box
|
||||
{
|
||||
@ -294,17 +282,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
|
||||
if (b != null)
|
||||
{
|
||||
coverContainer.FadeIn(transition_duration);
|
||||
|
||||
LoadComponentAsync(new BeatmapSetCover(b.BeatmapSet)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
FillMode = FillMode.Fill,
|
||||
OnLoadComplete = d => d.FadeInFromZero(400, Easing.Out),
|
||||
}, coverContainer.Add);
|
||||
|
||||
cover.BeatmapSet = b.BeatmapSet;
|
||||
beatmapTitle.Current = localisation.GetUnicodePreference(b.Metadata.TitleUnicode, b.Metadata.Title);
|
||||
beatmapDash.Text = @" - ";
|
||||
beatmapArtist.Current = localisation.GetUnicodePreference(b.Metadata.ArtistUnicode, b.Metadata.Artist);
|
||||
@ -312,7 +290,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
coverContainer.FadeOut(transition_duration);
|
||||
cover.BeatmapSet = null;
|
||||
|
||||
beatmapTitle.Current = null;
|
||||
beatmapArtist.Current = null;
|
||||
@ -367,7 +345,7 @@ namespace osu.Game.Screens.Multi.Components
|
||||
{
|
||||
if (Room == null)
|
||||
{
|
||||
coverContainer.FadeOut(transition_duration);
|
||||
cover.BeatmapSet = null;
|
||||
participantsFlow.FadeOut(transition_duration);
|
||||
participantNumbersFlow.FadeOut(transition_duration);
|
||||
infoPanelFlow.FadeOut(transition_duration);
|
||||
|
Loading…
Reference in New Issue
Block a user