mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14: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.Game.Overlays;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.UserInterface
|
namespace osu.Game.Tests.Visual.UserInterface
|
||||||
{
|
{
|
||||||
@ -24,7 +25,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Width = 300,
|
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
|
Metadata = new BeatmapMetadata
|
||||||
{
|
{
|
||||||
Title = "Very Long Title (TV size) [TATOE]",
|
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
|
Author = new User
|
||||||
{
|
{
|
||||||
Username = "author",
|
Username = "author",
|
||||||
@ -45,7 +46,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Covers = new BeatmapSetOnlineCovers
|
Covers = new BeatmapSetOnlineCovers
|
||||||
{
|
{
|
||||||
Cover = "https://assets.ppy.sh/beatmaps/1189904/covers/cover.jpg?1595456608",
|
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
|
namespace osu.Game.Overlays.Dashboard.Dashboard
|
||||||
{
|
{
|
||||||
public class DashboardBeatmapPanel : OsuClickableContainer
|
public abstract class DashboardBeatmapPanel : OsuClickableContainer
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OverlayColourProvider colourProvider { get; set; }
|
protected OverlayColourProvider ColourProvider { get; private set; }
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private BeatmapSetOverlay beatmapOverlay { get; set; }
|
private BeatmapSetOverlay beatmapOverlay { get; set; }
|
||||||
|
|
||||||
private readonly BeatmapSetInfo setInfo;
|
protected readonly BeatmapSetInfo SetInfo;
|
||||||
|
|
||||||
private Box background;
|
private Box background;
|
||||||
private SpriteIcon chevron;
|
private SpriteIcon chevron;
|
||||||
|
|
||||||
public DashboardBeatmapPanel(BeatmapSetInfo setInfo)
|
protected DashboardBeatmapPanel(BeatmapSetInfo setInfo)
|
||||||
{
|
{
|
||||||
this.setInfo = setInfo;
|
SetInfo = setInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -44,7 +44,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
|||||||
background = new Box
|
background = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colourProvider.Background3,
|
Colour = ColourProvider.Background3,
|
||||||
Alpha = 0
|
Alpha = 0
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
BeatmapSet = setInfo
|
BeatmapSet = SetInfo
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
@ -99,24 +99,34 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Truncate = true,
|
Truncate = true,
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.SemiBold),
|
Font = OsuFont.GetFont(weight: FontWeight.SemiBold),
|
||||||
Text = setInfo.Metadata.Title
|
Text = SetInfo.Metadata.Title
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Truncate = true,
|
Truncate = true,
|
||||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
||||||
Text = setInfo.Metadata.Artist
|
Text = SetInfo.Metadata.Artist
|
||||||
},
|
},
|
||||||
|
new FillFlowContainer
|
||||||
|
{
|
||||||
|
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))
|
new LinkFlowContainer(f => f.Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold))
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
AutoSizeAxes = Axes.Both
|
||||||
AutoSizeAxes = Axes.Y
|
|
||||||
}.With(c =>
|
}.With(c =>
|
||||||
{
|
{
|
||||||
c.AddText("by ");
|
c.AddText("by ");
|
||||||
c.AddUserLink(setInfo.Metadata.Author);
|
c.AddUserLink(SetInfo.Metadata.Author);
|
||||||
})
|
}),
|
||||||
|
CreateInfo()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -126,7 +136,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
|||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Size = new Vector2(16),
|
Size = new Vector2(16),
|
||||||
Icon = FontAwesome.Solid.ChevronRight,
|
Icon = FontAwesome.Solid.ChevronRight,
|
||||||
Colour = colourProvider.Foreground1
|
Colour = ColourProvider.Foreground1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,16 +146,18 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
|||||||
|
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
if (setInfo.OnlineBeatmapSetID.HasValue)
|
if (SetInfo.OnlineBeatmapSetID.HasValue)
|
||||||
beatmapOverlay?.FetchAndShowBeatmapSet(setInfo.OnlineBeatmapSetID.Value);
|
beatmapOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract Drawable CreateInfo();
|
||||||
|
|
||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
base.OnHover(e);
|
base.OnHover(e);
|
||||||
background.FadeIn(200, Easing.OutQuint);
|
background.FadeIn(200, Easing.OutQuint);
|
||||||
chevron.FadeColour(colourProvider.Light1, 200, Easing.OutQuint);
|
chevron.FadeColour(ColourProvider.Light1, 200, Easing.OutQuint);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +165,7 @@ namespace osu.Game.Overlays.Dashboard.Dashboard
|
|||||||
{
|
{
|
||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
background.FadeOut(200, Easing.OutQuint);
|
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