mirror of
https://github.com/ppy/osu
synced 2024-12-14 02:46:27 +00:00
Merge branch 'master' into mod-overlay/delete-preset
This commit is contained in:
commit
4a95638756
@ -83,6 +83,20 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Beatmap = dummyBeatmap,
|
Beatmap = dummyBeatmap,
|
||||||
},
|
},
|
||||||
new APIRecentActivity
|
new APIRecentActivity
|
||||||
|
{
|
||||||
|
User = dummyUser,
|
||||||
|
Type = RecentActivityType.BeatmapsetApprove,
|
||||||
|
Approval = BeatmapApproval.Approved,
|
||||||
|
Beatmapset = dummyBeatmap,
|
||||||
|
},
|
||||||
|
new APIRecentActivity
|
||||||
|
{
|
||||||
|
User = dummyUser,
|
||||||
|
Type = RecentActivityType.BeatmapsetApprove,
|
||||||
|
Approval = BeatmapApproval.Loved,
|
||||||
|
Beatmapset = dummyBeatmap,
|
||||||
|
},
|
||||||
|
new APIRecentActivity
|
||||||
{
|
{
|
||||||
User = dummyUser,
|
User = dummyUser,
|
||||||
Type = RecentActivityType.BeatmapsetApprove,
|
Type = RecentActivityType.BeatmapsetApprove,
|
||||||
@ -90,6 +104,13 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Beatmapset = dummyBeatmap,
|
Beatmapset = dummyBeatmap,
|
||||||
},
|
},
|
||||||
new APIRecentActivity
|
new APIRecentActivity
|
||||||
|
{
|
||||||
|
User = dummyUser,
|
||||||
|
Type = RecentActivityType.BeatmapsetApprove,
|
||||||
|
Approval = BeatmapApproval.Ranked,
|
||||||
|
Beatmapset = dummyBeatmap,
|
||||||
|
},
|
||||||
|
new APIRecentActivity
|
||||||
{
|
{
|
||||||
User = dummyUser,
|
User = dummyUser,
|
||||||
Type = RecentActivityType.BeatmapsetDelete,
|
Type = RecentActivityType.BeatmapsetDelete,
|
||||||
|
@ -120,7 +120,13 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
};
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return Empty();
|
return new RecentActivityIcon(activity)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 11,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
Margin = new MarginPadding { Top = 2, Vertical = 2 }
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
119
osu.Game/Overlays/Profile/Sections/Recent/RecentActivityIcon.cs
Normal file
119
osu.Game/Overlays/Profile/Sections/Recent/RecentActivityIcon.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
// 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 System;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||||
|
{
|
||||||
|
public class RecentActivityIcon : Container
|
||||||
|
{
|
||||||
|
private readonly SpriteIcon icon;
|
||||||
|
private readonly APIRecentActivity activity;
|
||||||
|
|
||||||
|
public RecentActivityIcon(APIRecentActivity activity)
|
||||||
|
{
|
||||||
|
this.activity = activity;
|
||||||
|
Child = icon = new SpriteIcon
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private OsuColour colours { get; set; } = null!;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
// references:
|
||||||
|
// https://github.com/ppy/osu-web/blob/659b371dcadf25b4f601a4c9895a813078301084/resources/assets/lib/profile-page/parse-event.tsx
|
||||||
|
// https://github.com/ppy/osu-web/blob/master/resources/assets/less/bem/profile-extra-entries.less#L98-L128
|
||||||
|
switch (activity.Type)
|
||||||
|
{
|
||||||
|
case RecentActivityType.BeatmapPlaycount:
|
||||||
|
icon.Icon = FontAwesome.Solid.Play;
|
||||||
|
icon.Colour = Color4.White;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapsetApprove:
|
||||||
|
icon.Icon = FontAwesome.Solid.Check;
|
||||||
|
icon.Colour = getColorForApprovalType(activity.Approval);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapsetDelete:
|
||||||
|
icon.Icon = FontAwesome.Solid.TrashAlt;
|
||||||
|
icon.Colour = colours.Red1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapsetRevive:
|
||||||
|
icon.Icon = FontAwesome.Solid.TrashRestore;
|
||||||
|
icon.Colour = Color4.White;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapsetUpdate:
|
||||||
|
icon.Icon = FontAwesome.Solid.SyncAlt;
|
||||||
|
icon.Colour = colours.Green1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.BeatmapsetUpload:
|
||||||
|
icon.Icon = FontAwesome.Solid.ArrowUp;
|
||||||
|
icon.Colour = colours.Orange1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.RankLost:
|
||||||
|
icon.Icon = FontAwesome.Solid.AngleDoubleDown;
|
||||||
|
icon.Colour = Color4.White;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.UserSupportAgain:
|
||||||
|
icon.Icon = FontAwesome.Solid.Heart;
|
||||||
|
icon.Colour = colours.Pink;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.UserSupportFirst:
|
||||||
|
icon.Icon = FontAwesome.Solid.Heart;
|
||||||
|
icon.Colour = colours.Pink;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.UserSupportGift:
|
||||||
|
icon.Icon = FontAwesome.Solid.Gift;
|
||||||
|
icon.Colour = colours.Pink;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RecentActivityType.UsernameChange:
|
||||||
|
icon.Icon = FontAwesome.Solid.Tag;
|
||||||
|
icon.Colour = Color4.White;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Color4 getColorForApprovalType(BeatmapApproval approvalType)
|
||||||
|
{
|
||||||
|
switch (approvalType)
|
||||||
|
{
|
||||||
|
case BeatmapApproval.Approved:
|
||||||
|
case BeatmapApproval.Ranked:
|
||||||
|
return colours.Lime1;
|
||||||
|
|
||||||
|
case BeatmapApproval.Loved:
|
||||||
|
return colours.Pink1;
|
||||||
|
|
||||||
|
case BeatmapApproval.Qualified:
|
||||||
|
return colours.Blue1;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException($"Unsupported {nameof(BeatmapApproval)} type", approvalType, nameof(approvalType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user