mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
Update DirectListPanel to properly handle hiding DownloadButton.
This commit is contained in:
@ -12,28 +12,31 @@ using osu.Game.Graphics.Sprites;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
public class DirectListPanel : DirectPanel
|
public class DirectListPanel : DirectPanel
|
||||||
{
|
{
|
||||||
|
private const float transition_duration = 120;
|
||||||
private const float horizontal_padding = 10;
|
private const float horizontal_padding = 10;
|
||||||
private const float vertical_padding = 5;
|
private const float vertical_padding = 5;
|
||||||
private const float height = 70;
|
private const float height = 70;
|
||||||
|
|
||||||
|
private PlayButton playButton;
|
||||||
|
private Box progressBar;
|
||||||
|
private Container downloadContainer;
|
||||||
|
|
||||||
|
protected override PlayButton PlayButton => playButton;
|
||||||
|
protected override Box PreviewBar => progressBar;
|
||||||
|
|
||||||
public DirectListPanel(BeatmapSetInfo beatmap) : base(beatmap)
|
public DirectListPanel(BeatmapSetInfo beatmap) : base(beatmap)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
Height = height;
|
Height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlayButton playButton;
|
|
||||||
private Box progressBar;
|
|
||||||
|
|
||||||
protected override PlayButton PlayButton => playButton;
|
|
||||||
protected override Box PreviewBar => progressBar;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(LocalisationEngine localisation, OsuColour colours)
|
private void load(LocalisationEngine localisation, OsuColour colours)
|
||||||
{
|
{
|
||||||
@ -59,7 +62,7 @@ namespace osu.Game.Overlays.Direct
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
LayoutEasing = Easing.OutQuint,
|
LayoutEasing = Easing.OutQuint,
|
||||||
LayoutDuration = 120,
|
LayoutDuration = transition_duration,
|
||||||
Spacing = new Vector2(10, 0),
|
Spacing = new Vector2(10, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -104,52 +107,69 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Horizontal,
|
||||||
Margin = new MarginPadding { Right = height - vertical_padding * 2 + vertical_padding },
|
LayoutEasing = Easing.OutQuint,
|
||||||
|
LayoutDuration = transition_duration,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0)
|
downloadContainer = new Container
|
||||||
{
|
{
|
||||||
Margin = new MarginPadding { Right = 1 },
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0,
|
||||||
|
Child = new DownloadButton(SetInfo)
|
||||||
|
{
|
||||||
|
Size = new Vector2(height - vertical_padding * 2),
|
||||||
|
Margin = new MarginPadding { Left = vertical_padding },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0),
|
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopRight,
|
Origin = Anchor.TopRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
new Statistic(FontAwesome.fa_play_circle, SetInfo.OnlineInfo?.PlayCount ?? 0)
|
||||||
{
|
{
|
||||||
Text = "mapped by ",
|
Margin = new MarginPadding { Right = 1 },
|
||||||
TextSize = 14,
|
},
|
||||||
|
new Statistic(FontAwesome.fa_heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0),
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
|
Children = new[]
|
||||||
|
{
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = "mapped by ",
|
||||||
|
TextSize = 14,
|
||||||
|
},
|
||||||
|
new OsuSpriteText
|
||||||
|
{
|
||||||
|
Text = SetInfo.Metadata.Author.Username,
|
||||||
|
TextSize = 14,
|
||||||
|
Font = @"Exo2.0-SemiBoldItalic",
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = SetInfo.Metadata.Author.Username,
|
Text = $"from {SetInfo.Metadata.Source}",
|
||||||
|
Anchor = Anchor.TopRight,
|
||||||
|
Origin = Anchor.TopRight,
|
||||||
TextSize = 14,
|
TextSize = 14,
|
||||||
Font = @"Exo2.0-SemiBoldItalic",
|
Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
|
||||||
{
|
|
||||||
Text = $"from {SetInfo.Metadata.Source}",
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
TextSize = 14,
|
|
||||||
Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new DownloadButton(SetInfo)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopRight,
|
|
||||||
Origin = Anchor.TopRight,
|
|
||||||
Size = new Vector2(height - vertical_padding * 2),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
progressBar = new Box
|
progressBar = new Box
|
||||||
@ -164,5 +184,17 @@ namespace osu.Game.Overlays.Direct
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnHover(InputState state)
|
||||||
|
{
|
||||||
|
downloadContainer.FadeIn(transition_duration, Easing.InOutQuint);
|
||||||
|
return base.OnHover(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnHoverLost(InputState state)
|
||||||
|
{
|
||||||
|
downloadContainer.FadeOut(transition_duration, Easing.InOutQuint);
|
||||||
|
base.OnHoverLost(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user