mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 09:32:55 +08:00
Implement DashboardNewBeatmapPanel component
This commit is contained in:
parent
74f70136fd
commit
ce47a34991
@ -8,6 +8,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Users;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.Tests.Visual.UserInterface
|
||||
{
|
||||
@ -24,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Origin = Anchor.Centre,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Width = 300,
|
||||
Child = new DashboardBeatmapPanel(beatmap_set)
|
||||
Child = new DashboardNewBeatmapPanel(beatmap_set)
|
||||
});
|
||||
}
|
||||
|
||||
@ -33,7 +34,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Metadata = new BeatmapMetadata
|
||||
{
|
||||
Title = "Very Long Title (TV size) [TATOE]",
|
||||
Artist = "This artist has a really long name how is it possible",
|
||||
Artist = "This artist has a really long name how is this possible",
|
||||
Author = new User
|
||||
{
|
||||
Username = "author",
|
||||
@ -45,7 +46,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Covers = new BeatmapSetOnlineCovers
|
||||
{
|
||||
Cover = "https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg?1595456608",
|
||||
}
|
||||
},
|
||||
Ranked = DateTimeOffset.Now
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -16,22 +16,22 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Overlays.Dashboard.Dashboard
|
||||
{
|
||||
public class DashboardBeatmapPanel : OsuClickableContainer
|
||||
public abstract class DashboardBeatmapPanel : OsuClickableContainer
|
||||
{
|
||||
[Resolved]
|
||||
private OverlayColourProvider colourProvider { get; set; }
|
||||
protected OverlayColourProvider ColourProvider { get; private set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private BeatmapSetOverlay beatmapOverlay { get; set; }
|
||||
|
||||
private readonly BeatmapSetInfo setInfo;
|
||||
protected readonly BeatmapSetInfo SetInfo;
|
||||
|
||||
private Box background;
|
||||
private SpriteIcon chevron;
|
||||
|
||||
public DashboardBeatmapPanel(BeatmapSetInfo setInfo)
|
||||
protected DashboardBeatmapPanel(BeatmapSetInfo setInfo)
|
||||
{
|
||||
this.setInfo = setInfo;
|
||||
SetInfo = setInfo;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
||||
background = new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = colourProvider.Background3,
|
||||
Colour = ColourProvider.Background3,
|
||||
Alpha = 0
|
||||
},
|
||||
new Container
|
||||
@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
BeatmapSet = setInfo
|
||||
BeatmapSet = SetInfo
|
||||
}
|
||||
},
|
||||
new Container
|
||||
@ -99,24 +99,34 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Truncate = true,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold),
|
||||
Text = setInfo.Metadata.Title
|
||||
Text = SetInfo.Metadata.Title
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Truncate = true,
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
||||
Text = setInfo.Metadata.Artist
|
||||
Text = SetInfo.Metadata.Artist
|
||||
},
|
||||
new LinkFlowContainer(f => f.Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold))
|
||||
new FillFlowContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y
|
||||
}.With(c =>
|
||||
{
|
||||
c.AddText("by ");
|
||||
c.AddUserLink(setInfo.Metadata.Author);
|
||||
})
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(5, 0),
|
||||
Margin = new MarginPadding { Top = 2 },
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new LinkFlowContainer(f => f.Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold))
|
||||
{
|
||||
AutoSizeAxes = Axes.Both
|
||||
}.With(c =>
|
||||
{
|
||||
c.AddText("by ");
|
||||
c.AddUserLink(SetInfo.Metadata.Author);
|
||||
}),
|
||||
CreateInfo()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -126,7 +136,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
||||
Origin = Anchor.CentreRight,
|
||||
Size = new Vector2(16),
|
||||
Icon = FontAwesome.Solid.ChevronRight,
|
||||
Colour = colourProvider.Foreground1
|
||||
Colour = ColourProvider.Foreground1
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -136,16 +146,18 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
||||
|
||||
Action = () =>
|
||||
{
|
||||
if (setInfo.OnlineBeatmapSetID.HasValue)
|
||||
beatmapOverlay?.FetchAndShowBeatmapSet(setInfo.OnlineBeatmapSetID.Value);
|
||||
if (SetInfo.OnlineBeatmapSetID.HasValue)
|
||||
beatmapOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value);
|
||||
};
|
||||
}
|
||||
|
||||
protected abstract Drawable CreateInfo();
|
||||
|
||||
protected override bool OnHover(HoverEvent e)
|
||||
{
|
||||
base.OnHover(e);
|
||||
background.FadeIn(200, Easing.OutQuint);
|
||||
chevron.FadeColour(colourProvider.Light1, 200, Easing.OutQuint);
|
||||
chevron.FadeColour(ColourProvider.Light1, 200, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -153,7 +165,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
||||
{
|
||||
base.OnHoverLost(e);
|
||||
background.FadeOut(200, Easing.OutQuint);
|
||||
chevron.FadeColour(colourProvider.Foreground1, 200, Easing.OutQuint);
|
||||
chevron.FadeColour(ColourProvider.Foreground1, 200, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Overlays.Dashboard.Dashboard
|
||||
{
|
||||
public class DashboardNewBeatmapPanel : DashboardBeatmapPanel
|
||||
{
|
||||
public DashboardNewBeatmapPanel(BeatmapSetInfo setInfo)
|
||||
: base(setInfo)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Drawable CreateInfo() => new DrawableDate(SetInfo.OnlineInfo.Ranked.Value, 10, false)
|
||||
{
|
||||
Colour = ColourProvider.Foreground1
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user