1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-01 14:13:16 +08:00

Add completion marker to daily challenge profile counter

This commit is contained in:
Bartłomiej Dach 2025-01-17 10:26:59 +01:00
parent a8456ce9ac
commit b215073957
No known key found for this signature in database
2 changed files with 92 additions and 32 deletions

View File

@ -38,6 +38,10 @@ namespace osu.Game.Tests.Visual.Online
AddSliderStep("top 10%", 0, 999, 0, v => update(s => s.Top10PercentPlacements = v)); AddSliderStep("top 10%", 0, 999, 0, v => update(s => s.Top10PercentPlacements = v));
AddSliderStep("top 50%", 0, 999, 0, v => update(s => s.Top50PercentPlacements = v)); AddSliderStep("top 50%", 0, 999, 0, v => update(s => s.Top50PercentPlacements = v));
AddSliderStep("playcount", 0, 1500, 1, v => update(s => s.PlayCount = v)); AddSliderStep("playcount", 0, 1500, 1, v => update(s => s.PlayCount = v));
AddStep("user played today", () => update(s => s.LastUpdate = DateTimeOffset.UtcNow.Date));
AddStep("user played yesterday", () => update(s => s.LastUpdate = DateTimeOffset.UtcNow.Date.AddDays(-1)));
AddStep("user is local user", () => update(s => s.UserID = API.LocalUser.Value.Id));
AddStep("user is not local user", () => update(s => s.UserID = API.LocalUser.Value.Id + 1000));
AddStep("create", () => AddStep("create", () =>
{ {
Clear(); Clear();

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Extensions.LocalisationExtensions;
@ -8,11 +9,14 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Cursor;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osuTK;
namespace osu.Game.Overlays.Profile.Header.Components namespace osu.Game.Overlays.Profile.Header.Components
{ {
@ -23,6 +27,11 @@ namespace osu.Game.Overlays.Profile.Header.Components
public DailyChallengeTooltipData? TooltipContent { get; private set; } public DailyChallengeTooltipData? TooltipContent { get; private set; }
private OsuSpriteText dailyPlayCount = null!; private OsuSpriteText dailyPlayCount = null!;
private Container content = null!;
private CircularContainer completionMark = null!;
[Resolved]
private IAPIProvider api { get; set; }
[Resolved] [Resolved]
private OsuColour colours { get; set; } = null!; private OsuColour colours { get; set; } = null!;
@ -34,58 +43,91 @@ namespace osu.Game.Overlays.Profile.Header.Components
private void load() private void load()
{ {
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
CornerRadius = 5;
Masking = true;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new Box content = new Container
{ {
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background4,
},
new FillFlowContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Padding = new MarginPadding(5f),
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, CornerRadius = 6,
BorderThickness = 2,
BorderColour = colourProvider.Background4,
Masking = true,
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12)) new Box
{ {
AutoSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
// can't use this because osu-web does weird stuff with \\n. Colour = colourProvider.Background4,
// Text = UsersStrings.ShowDailyChallengeTitle.,
Text = "Daily\nChallenge",
Margin = new MarginPadding { Horizontal = 5f, Bottom = 2f },
}, },
new Container new FillFlowContainer
{ {
AutoSizeAxes = Axes.X, Anchor = Anchor.Centre,
RelativeSizeAxes = Axes.Y, Origin = Anchor.Centre,
CornerRadius = 5f, Padding = new MarginPadding(3f),
Masking = true, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Children = new Drawable[] Children = new Drawable[]
{ {
new Box new OsuTextFlowContainer(s => s.Font = OsuFont.GetFont(size: 12))
{ {
RelativeSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Colour = colourProvider.Background6, // can't use this because osu-web does weird stuff with \\n.
// Text = UsersStrings.ShowDailyChallengeTitle.,
Text = "Daily\nChallenge",
Margin = new MarginPadding { Horizontal = 5f, Bottom = 2f },
}, },
dailyPlayCount = new OsuSpriteText new Container
{ {
Anchor = Anchor.Centre, AutoSizeAxes = Axes.X,
Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y,
UseFullGlyphHeight = false, CornerRadius = 3,
Colour = colourProvider.Content2, Masking = true,
Margin = new MarginPadding { Horizontal = 10f, Vertical = 5f }, Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background6,
},
dailyPlayCount = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
UseFullGlyphHeight = false,
Colour = colourProvider.Content2,
Margin = new MarginPadding { Horizontal = 10f, Vertical = 5f },
},
}
}, },
} }
}, },
} }
}, },
completionMark = new CircularContainer
{
Alpha = 0,
Size = new Vector2(16),
Anchor = Anchor.TopRight,
Origin = Anchor.Centre,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.Lime1,
},
new SpriteIcon
{
Size = new Vector2(8),
Colour = colourProvider.Background6,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Icon = FontAwesome.Solid.Check,
}
}
},
}; };
} }
@ -114,6 +156,20 @@ namespace osu.Game.Overlays.Profile.Header.Components
dailyPlayCount.Text = DailyChallengeStatsDisplayStrings.UnitDay(stats.PlayCount.ToLocalisableString("N0")); dailyPlayCount.Text = DailyChallengeStatsDisplayStrings.UnitDay(stats.PlayCount.ToLocalisableString("N0"));
dailyPlayCount.Colour = colours.ForRankingTier(DailyChallengeStatsTooltip.TierForPlayCount(stats.PlayCount)); dailyPlayCount.Colour = colours.ForRankingTier(DailyChallengeStatsTooltip.TierForPlayCount(stats.PlayCount));
bool playedToday = stats.LastUpdate?.Date == DateTimeOffset.UtcNow.Date;
bool userIsOnOwnProfile = stats.UserID == api.LocalUser.Value.Id;
if (playedToday && userIsOnOwnProfile)
{
completionMark.Alpha = 1;
content.BorderColour = colours.Lime1;
}
else
{
completionMark.Alpha = 0;
content.BorderColour = colourProvider.Background4;
}
TooltipContent = new DailyChallengeTooltipData(colourProvider, stats); TooltipContent = new DailyChallengeTooltipData(colourProvider, stats);
Show(); Show();