Don't recreate header buttons on beatmap change.

This commit is contained in:
DrabWeb 2017-09-12 23:55:48 -03:00
parent d36fc13487
commit 0e9dc6fb85
2 changed files with 15 additions and 10 deletions

View File

@ -103,7 +103,7 @@ namespace osu.Desktop.Tests.Visual
OnlineInfo = new BeatmapOnlineInfo OnlineInfo = new BeatmapOnlineInfo
{ {
Length = 118000, Length = 118000,
HasVideo = false, HasVideo = true,
CircleCount = 592, CircleCount = 592,
SliderCount = 62, SliderCount = 62,
PlayCount = 162021, PlayCount = 162021,

View File

@ -18,6 +18,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
{ {
public class Header : Container public class Header : Container
{ {
private const float transition_duration = 250;
private const float tabs_height = 50; private const float tabs_height = 50;
private readonly Box tabsBg; private readonly Box tabsBg;
@ -37,7 +38,7 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
Offset = new Vector2(0f, 1f), Offset = new Vector2(0f, 1f),
}; };
FillFlowContainer buttons; DownloadButton noVideo, withVideo, withoutVideo;
Details details; Details details;
Children = new Drawable[] Children = new Drawable[]
{ {
@ -126,15 +127,20 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
Margin = new MarginPadding { Top = 20 }, Margin = new MarginPadding { Top = 20 },
Child = new AuthorInfo(set.OnlineInfo), Child = new AuthorInfo(set.OnlineInfo),
}, },
buttons = new FillFlowContainer new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = 45, Height = 45,
Spacing = new Vector2(5f), Spacing = new Vector2(5f),
Margin = new MarginPadding { Top = 10 }, Margin = new MarginPadding { Top = 10 },
LayoutDuration = transition_duration,
LayoutEasing = Easing.Out,
Children = new HeaderButton[] Children = new HeaderButton[]
{ {
new FavouriteButton(), new FavouriteButton(),
noVideo = new DownloadButton("Download", @""),
withVideo = new DownloadButton("Download", "with Video"),
withoutVideo = new DownloadButton("Download", "without Video"),
}, },
}, },
}, },
@ -154,18 +160,17 @@ namespace osu.Game.Overlays.OnlineBeatmapSet
{ {
details.Beatmap = b; details.Beatmap = b;
buttons.Child = new FavouriteButton();
if (b.OnlineInfo.HasVideo) if (b.OnlineInfo.HasVideo)
{ {
buttons.AddRange(new[] noVideo.FadeOut(transition_duration);
{ withVideo.FadeIn(transition_duration);
new DownloadButton("Download", "with Video"), withoutVideo.FadeIn(transition_duration);
new DownloadButton("Download", "without Video"),
});
} }
else else
{ {
buttons.Add(new DownloadButton("Download", @"")); noVideo.FadeIn(transition_duration);
withVideo.FadeOut(transition_duration);
withoutVideo.FadeOut(transition_duration);
} }
}; };
} }