1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:17:23 +08:00

Fix achievements parsing and add badges to recent activity.

This commit is contained in:
naoey 2018-02-26 13:08:12 +05:30
parent a20e4bc2c3
commit a77d1eedae
No known key found for this signature in database
GPG Key ID: 3908EC682A3E19C7
4 changed files with 62 additions and 6 deletions

View File

@ -68,8 +68,8 @@ namespace osu.Game.Online.API.Requests
[JsonProperty("user")]
public RecentActivityUser User;
[JsonProperty("achievementName")]
public string AchivementName;
[JsonProperty("achievement")]
public RecentActivityAchievement Achievement;
public class RecentActivityBeatmap
{
@ -91,6 +91,16 @@ namespace osu.Game.Online.API.Requests
[JsonProperty("previousUsername")]
public string PreviousUsername;
}
public class RecentActivityAchievement
{
[JsonProperty("slug")]
public string Slug;
[JsonProperty("name")]
public string Name;
}
}
public enum RecentActivityType

View File

@ -72,8 +72,14 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
FillMode = FillMode.Fit,
};
case RecentActivityType.Medal:
// TODO: add medal visual
case RecentActivityType.Achievement:
return new MedalIcon(activity.Achievement.Slug)
{
RelativeSizeAxes = Axes.Y,
Width = 60,
FillMode = FillMode.Fit,
};
default:
return new Container
{
@ -91,7 +97,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
switch (activity.Type)
{
case RecentActivityType.Achievement:
return $"{userLinkTemplate} unlocked the {activity.AchivementName} achievement!";
return $"{userLinkTemplate} unlocked the {activity.Achievement.Name} medal!";
case RecentActivityType.BeatmapPlaycount:
return $"{beatmapLinkTemplate} has been played {activity.Count} times!";
@ -112,7 +118,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
return $"{userLinkTemplate} has submitted a new beatmap {beatmapsetLinkTemplate}!";
case RecentActivityType.Medal:
return $"{userLinkTemplate} has unlocked the {activity.AchivementName} medal!";
// apparently this shouldn't exist look at achievement instead (https://github.com/ppy/osu-web/blob/master/resources/assets/coffee/react/profile-page/recent-activity.coffee#L111)
return string.Empty;
case RecentActivityType.Rank:
return $"{userLinkTemplate} achieved rank #{activity.Rank} on {beatmapLinkTemplate} ({activity.Mode}!)";

View File

@ -0,0 +1,38 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
namespace osu.Game.Overlays.Profile.Sections.Recent
{
internal class MedalIcon : Container
{
private readonly string slug;
private readonly Sprite sprite;
private string url => $@"https://s.ppy.sh/images/medals-client/{slug}@2x.png";
public MedalIcon(string slug)
{
this.slug = slug;
Child = sprite = new Sprite
{
Height = 40,
Width = 40,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
sprite.Texture = textures.Get(url);
}
}
}

View File

@ -301,6 +301,7 @@
</Compile>
<Compile Include="Migrations\20180131154205_AddMuteBinding.cs" />
<Compile Include="Overlays\Profile\Sections\Recent\DrawableRecentActivity.cs" />
<Compile Include="Overlays\Profile\Sections\Recent\MedalIcon.cs" />
<Compile Include="Overlays\Profile\Sections\Recent\PaginatedRecentActivityContainer.cs" />
<Compile Include="Overlays\Profile\SupporterIcon.cs" />
<Compile Include="Online\API\Requests\GetFriendsRequest.cs" />