mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 19:55:45 +08:00
Fix achievements parsing and add badges to recent activity.
This commit is contained in:
parent
a20e4bc2c3
commit
a77d1eedae
@ -68,8 +68,8 @@ namespace osu.Game.Online.API.Requests
|
|||||||
[JsonProperty("user")]
|
[JsonProperty("user")]
|
||||||
public RecentActivityUser User;
|
public RecentActivityUser User;
|
||||||
|
|
||||||
[JsonProperty("achievementName")]
|
[JsonProperty("achievement")]
|
||||||
public string AchivementName;
|
public RecentActivityAchievement Achievement;
|
||||||
|
|
||||||
public class RecentActivityBeatmap
|
public class RecentActivityBeatmap
|
||||||
{
|
{
|
||||||
@ -91,6 +91,16 @@ namespace osu.Game.Online.API.Requests
|
|||||||
[JsonProperty("previousUsername")]
|
[JsonProperty("previousUsername")]
|
||||||
public string PreviousUsername;
|
public string PreviousUsername;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class RecentActivityAchievement
|
||||||
|
{
|
||||||
|
[JsonProperty("slug")]
|
||||||
|
public string Slug;
|
||||||
|
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum RecentActivityType
|
public enum RecentActivityType
|
||||||
|
@ -72,8 +72,14 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
FillMode = FillMode.Fit,
|
FillMode = FillMode.Fit,
|
||||||
};
|
};
|
||||||
|
|
||||||
case RecentActivityType.Medal:
|
case RecentActivityType.Achievement:
|
||||||
// TODO: add medal visual
|
return new MedalIcon(activity.Achievement.Slug)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Width = 60,
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
};
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return new Container
|
return new Container
|
||||||
{
|
{
|
||||||
@ -91,7 +97,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
switch (activity.Type)
|
switch (activity.Type)
|
||||||
{
|
{
|
||||||
case RecentActivityType.Achievement:
|
case RecentActivityType.Achievement:
|
||||||
return $"{userLinkTemplate} unlocked the {activity.AchivementName} achievement!";
|
return $"{userLinkTemplate} unlocked the {activity.Achievement.Name} medal!";
|
||||||
|
|
||||||
case RecentActivityType.BeatmapPlaycount:
|
case RecentActivityType.BeatmapPlaycount:
|
||||||
return $"{beatmapLinkTemplate} has been played {activity.Count} times!";
|
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}!";
|
return $"{userLinkTemplate} has submitted a new beatmap {beatmapsetLinkTemplate}!";
|
||||||
|
|
||||||
case RecentActivityType.Medal:
|
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:
|
case RecentActivityType.Rank:
|
||||||
return $"{userLinkTemplate} achieved rank #{activity.Rank} on {beatmapLinkTemplate} ({activity.Mode}!)";
|
return $"{userLinkTemplate} achieved rank #{activity.Rank} on {beatmapLinkTemplate} ({activity.Mode}!)";
|
||||||
|
38
osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs
Normal file
38
osu.Game/Overlays/Profile/Sections/Recent/MedalIcon.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -301,6 +301,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Migrations\20180131154205_AddMuteBinding.cs" />
|
<Compile Include="Migrations\20180131154205_AddMuteBinding.cs" />
|
||||||
<Compile Include="Overlays\Profile\Sections\Recent\DrawableRecentActivity.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\Sections\Recent\PaginatedRecentActivityContainer.cs" />
|
||||||
<Compile Include="Overlays\Profile\SupporterIcon.cs" />
|
<Compile Include="Overlays\Profile\SupporterIcon.cs" />
|
||||||
<Compile Include="Online\API\Requests\GetFriendsRequest.cs" />
|
<Compile Include="Online\API\Requests\GetFriendsRequest.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user