2018-02-26 01:11:47 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
2018-02-26 03:06:55 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2018-02-26 01:11:47 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2018-02-26 03:06:55 +08:00
|
|
|
|
using osu.Game.Online.API;
|
2018-02-26 01:11:47 +08:00
|
|
|
|
using osu.Game.Online.API.Requests;
|
2018-02-26 03:06:55 +08:00
|
|
|
|
using osu.Game.Online.Chat;
|
2018-02-26 01:11:47 +08:00
|
|
|
|
using osu.Game.Screens.Select.Leaderboards;
|
|
|
|
|
using osu.Game.Users;
|
2018-02-26 03:06:55 +08:00
|
|
|
|
using static osu.Game.Online.API.Requests.RecentActivity;
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Sections.Recent
|
|
|
|
|
{
|
|
|
|
|
public class DrawableRecentActivity : DrawableProfileRow
|
|
|
|
|
{
|
|
|
|
|
private RecentActivity activity;
|
|
|
|
|
private User user;
|
2018-02-26 03:06:55 +08:00
|
|
|
|
private APIAccess api;
|
|
|
|
|
|
|
|
|
|
private string userLinkTemplate;
|
|
|
|
|
private string beatmapLinkTemplate;
|
|
|
|
|
|
|
|
|
|
private LinkFlowContainer content;
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
public DrawableRecentActivity(RecentActivity activity, User user)
|
|
|
|
|
{
|
|
|
|
|
this.activity = activity;
|
|
|
|
|
this.user = user;
|
2018-02-26 03:06:55 +08:00
|
|
|
|
|
2018-02-26 03:28:20 +08:00
|
|
|
|
userLinkTemplate = $"[{urlToAbsolute(activity.User?.Url)} {activity.User?.Username}]";
|
|
|
|
|
beatmapLinkTemplate = $"[{urlToAbsolute(activity.Beatmap?.Url)} {activity.Beatmap?.Title}]";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-02-26 03:06:55 +08:00
|
|
|
|
private void load(APIAccess api)
|
2018-02-26 01:11:47 +08:00
|
|
|
|
{
|
2018-02-26 03:06:55 +08:00
|
|
|
|
this.api = api;
|
|
|
|
|
|
|
|
|
|
LeftFlowContainer.Add(content = new LinkFlowContainer
|
2018-02-26 01:11:47 +08:00
|
|
|
|
{
|
2018-02-26 03:06:55 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2018-02-26 01:11:47 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
RightFlowContainer.Add(new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = activity.CreatedAt.LocalDateTime.ToShortDateString(),
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
Font = "Exo2.0-RegularItalic",
|
|
|
|
|
TextSize = 12,
|
|
|
|
|
Colour = OsuColour.Gray(0xAA),
|
|
|
|
|
});
|
2018-02-26 03:06:55 +08:00
|
|
|
|
|
2018-02-26 03:28:20 +08:00
|
|
|
|
var formatted = MessageFormatter.FormatText(activityToString());
|
2018-02-26 03:06:55 +08:00
|
|
|
|
|
2018-02-26 03:28:20 +08:00
|
|
|
|
content.AddLinks(formatted.Text, formatted.Links);
|
2018-02-26 01:11:47 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Drawable CreateLeftVisual()
|
|
|
|
|
{
|
|
|
|
|
switch (activity.Type)
|
|
|
|
|
{
|
|
|
|
|
case RecentActivityType.Rank:
|
|
|
|
|
return new DrawableRank(activity.ScoreRank)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = 60,
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = 60,
|
|
|
|
|
FillMode = FillMode.Fit,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-26 03:06:55 +08:00
|
|
|
|
private string urlToAbsolute(string url) => $"{api?.Endpoint ?? @"https://osu.ppy.sh"}{url}";
|
|
|
|
|
|
2018-02-26 01:11:47 +08:00
|
|
|
|
private string activityToString()
|
|
|
|
|
{
|
|
|
|
|
switch (activity.Type)
|
|
|
|
|
{
|
|
|
|
|
case RecentActivityType.Achievement:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{userLinkTemplate} unlocked the {activity.AchivementName} achievement!";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.BeatmapPlaycount:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{beatmapLinkTemplate} has been played {activity.Count} times!";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.BeatmapsetDelete:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{beatmapLinkTemplate} has been deleted.";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.BeatmapsetRevive:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{beatmapLinkTemplate} has been revived from eternal slumber by ${userLinkTemplate}";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.BeatmapsetUpdate:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{userLinkTemplate} has updated the beatmap ${beatmapLinkTemplate}";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.BeatmapsetUpload:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{userLinkTemplate} has submitted a new beatmap ${beatmapLinkTemplate}";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.Medal:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{userLinkTemplate} has unlocked the {activity.AchivementName} medal!";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.Rank:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{userLinkTemplate} achieved rank #{activity.Rank} on {beatmapLinkTemplate}";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.RankLost:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{userLinkTemplate} has lost first place on {beatmapLinkTemplate}!";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.UserSupportAgain:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{userLinkTemplate} has once again chosen to support osu! - thanks for your generosity!";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.UserSupportFirst:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{userLinkTemplate} has become an osu! supporter - thanks for your generosity!";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.UsernameChange:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{activity.User.PreviousUsername} has changed their username to {userLinkTemplate}";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
case RecentActivityType.UserSupportGift:
|
2018-02-26 03:06:55 +08:00
|
|
|
|
return $"{userLinkTemplate} has received the gift of osu! supporter!";
|
2018-02-26 01:11:47 +08:00
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return string.Empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|