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

Make locally used things local and rename method.

This commit is contained in:
naoey 2018-03-04 00:01:47 +05:30
parent 66493d200b
commit 9669c5aee3
No known key found for this signature in database
GPG Key ID: 3908EC682A3E19C7

View File

@ -20,10 +20,6 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
private readonly RecentActivity activity; private readonly RecentActivity activity;
private string userLinkTemplate;
private string beatmapLinkTemplate;
private string beatmapsetLinkTemplate;
private LinkFlowContainer content; private LinkFlowContainer content;
public DrawableRecentActivity(RecentActivity activity) public DrawableRecentActivity(RecentActivity activity)
@ -36,10 +32,6 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
{ {
this.api = api; this.api = api;
userLinkTemplate = $"[{toAbsoluteUrl(activity.User?.Url)} {activity.User?.Username}]";
beatmapLinkTemplate = $"[{toAbsoluteUrl(activity.Beatmap?.Url)} {activity.Beatmap?.Title}]";
beatmapsetLinkTemplate = $"[{toAbsoluteUrl(activity.Beatmapset?.Url)} {activity.Beatmapset?.Title}]";
LeftFlowContainer.Padding = new MarginPadding { Left = 10, Right = 160 }; LeftFlowContainer.Padding = new MarginPadding { Left = 10, Right = 160 };
LeftFlowContainer.Add(content = new LinkFlowContainer LeftFlowContainer.Add(content = new LinkFlowContainer
@ -58,7 +50,7 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
Colour = OsuColour.Gray(0xAA), Colour = OsuColour.Gray(0xAA),
}); });
var formatted = MessageFormatter.FormatText(activityToString()); var formatted = createMessage();
content.AddLinks(formatted.Text, formatted.Links); content.AddLinks(formatted.Text, formatted.Links);
} }
@ -95,56 +87,79 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
private string toAbsoluteUrl(string url) => $"{api.Endpoint}{url}"; private string toAbsoluteUrl(string url) => $"{api.Endpoint}{url}";
private string activityToString() private MessageFormatter.MessageFormatterResult createMessage()
{ {
string userLinkTemplate() => $"[{toAbsoluteUrl(activity.User?.Url)} {activity.User?.Username}]";
string beatmapLinkTemplate() => $"[{toAbsoluteUrl(activity.Beatmap?.Url)} {activity.Beatmap?.Title}]";
string beatmapsetLinkTemplate() => $"[{toAbsoluteUrl(activity.Beatmapset?.Url)} {activity.Beatmapset?.Title}]";
string message;
switch (activity.Type) switch (activity.Type)
{ {
case RecentActivityType.Achievement: case RecentActivityType.Achievement:
return $"{userLinkTemplate} unlocked the {activity.Achievement.Name} medal!"; message = $"{userLinkTemplate()} unlocked the {activity.Achievement.Name} medal!";
break;
case RecentActivityType.BeatmapPlaycount: case RecentActivityType.BeatmapPlaycount:
return $"{beatmapLinkTemplate} has been played {activity.Count} times!"; message = $"{beatmapLinkTemplate()} has been played {activity.Count} times!";
break;
case RecentActivityType.BeatmapsetApprove: case RecentActivityType.BeatmapsetApprove:
return $"{beatmapsetLinkTemplate} has been {activity.Approval.ToString().ToLowerInvariant()}!"; message = $"{beatmapsetLinkTemplate()} has been {activity.Approval.ToString().ToLowerInvariant()}!";
break;
case RecentActivityType.BeatmapsetDelete: case RecentActivityType.BeatmapsetDelete:
return $"{beatmapsetLinkTemplate} has been deleted."; message = $"{beatmapsetLinkTemplate()} has been deleted.";
break;
case RecentActivityType.BeatmapsetRevive: case RecentActivityType.BeatmapsetRevive:
return $"{beatmapsetLinkTemplate} has been revived from eternal slumber by {userLinkTemplate}."; message = $"{beatmapsetLinkTemplate()} has been revived from eternal slumber by {userLinkTemplate()}.";
break;
case RecentActivityType.BeatmapsetUpdate: case RecentActivityType.BeatmapsetUpdate:
return $"{userLinkTemplate} has updated the beatmap {beatmapsetLinkTemplate}!"; message = $"{userLinkTemplate()} has updated the beatmap {beatmapsetLinkTemplate()}!";
break;
case RecentActivityType.BeatmapsetUpload: case RecentActivityType.BeatmapsetUpload:
return $"{userLinkTemplate} has submitted a new beatmap {beatmapsetLinkTemplate}!"; message = $"{userLinkTemplate()} has submitted a new beatmap {beatmapsetLinkTemplate()}!";
break;
case RecentActivityType.Medal: case RecentActivityType.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) // 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; message = string.Empty;
break;
case RecentActivityType.Rank: case RecentActivityType.Rank:
return $"{userLinkTemplate} achieved rank #{activity.Rank} on {beatmapLinkTemplate} ({activity.Mode}!)"; message = $"{userLinkTemplate()} achieved rank #{activity.Rank} on {beatmapLinkTemplate()} ({activity.Mode}!)";
break;
case RecentActivityType.RankLost: case RecentActivityType.RankLost:
return $"{userLinkTemplate} has lost first place on {beatmapLinkTemplate} ({activity.Mode}!)"; message = $"{userLinkTemplate()} has lost first place on {beatmapLinkTemplate()} ({activity.Mode}!)";
break;
case RecentActivityType.UserSupportAgain: case RecentActivityType.UserSupportAgain:
return $"{userLinkTemplate} has once again chosen to support osu! - thanks for your generosity!"; message = $"{userLinkTemplate()} has once again chosen to support osu! - thanks for your generosity!";
break;
case RecentActivityType.UserSupportFirst: case RecentActivityType.UserSupportFirst:
return $"{userLinkTemplate} has become an osu! supporter - thanks for your generosity!"; message = $"{userLinkTemplate()} has become an osu! supporter - thanks for your generosity!";
break;
case RecentActivityType.UserSupportGift: case RecentActivityType.UserSupportGift:
return $"{userLinkTemplate} has received the gift of osu! supporter!"; message = $"{userLinkTemplate()} has received the gift of osu! supporter!";
break;
case RecentActivityType.UsernameChange: case RecentActivityType.UsernameChange:
return $"{activity.User.PreviousUsername} has changed their username to {userLinkTemplate}!"; message = $"{activity.User?.PreviousUsername} has changed their username to {userLinkTemplate()}!";
break;
default: default:
return string.Empty; message = string.Empty;
} break;
}
return MessageFormatter.FormatText(message);
} }
} }
} }