mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Normalize all the line endings
This commit is contained in:
@ -1,162 +1,162 @@
|
||||
// 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;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
{
|
||||
public class DrawableRecentActivity : DrawableProfileRow
|
||||
{
|
||||
private APIAccess api;
|
||||
|
||||
private readonly RecentActivity activity;
|
||||
|
||||
private LinkFlowContainer content;
|
||||
|
||||
public DrawableRecentActivity(RecentActivity activity)
|
||||
{
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(APIAccess api)
|
||||
{
|
||||
this.api = api;
|
||||
|
||||
LeftFlowContainer.Padding = new MarginPadding { Left = 10, Right = 160 };
|
||||
|
||||
LeftFlowContainer.Add(content = new LinkFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
});
|
||||
|
||||
RightFlowContainer.Add(new DrawableDate(activity.CreatedAt)
|
||||
{
|
||||
TextSize = 13,
|
||||
Colour = OsuColour.Gray(0xAA),
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
});
|
||||
|
||||
var formatted = createMessage();
|
||||
|
||||
content.AddLinks(formatted.Text, formatted.Links);
|
||||
}
|
||||
|
||||
protected override Drawable CreateLeftVisual()
|
||||
{
|
||||
switch (activity.Type)
|
||||
{
|
||||
case RecentActivityType.Rank:
|
||||
return new DrawableRank(activity.ScoreRank)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
|
||||
case RecentActivityType.Achievement:
|
||||
return new MedalIcon(activity.Achievement.Slug)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
|
||||
default:
|
||||
return new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private string toAbsoluteUrl(string url) => $"{api.Endpoint}{url}";
|
||||
|
||||
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)
|
||||
{
|
||||
case RecentActivityType.Achievement:
|
||||
message = $"{userLinkTemplate()} unlocked the {activity.Achievement.Name} medal!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapPlaycount:
|
||||
message = $"{beatmapLinkTemplate()} has been played {activity.Count} times!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetApprove:
|
||||
message = $"{beatmapsetLinkTemplate()} has been {activity.Approval.ToString().ToLowerInvariant()}!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetDelete:
|
||||
message = $"{beatmapsetLinkTemplate()} has been deleted.";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetRevive:
|
||||
message = $"{beatmapsetLinkTemplate()} has been revived from eternal slumber by {userLinkTemplate()}.";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetUpdate:
|
||||
message = $"{userLinkTemplate()} has updated the beatmap {beatmapsetLinkTemplate()}!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetUpload:
|
||||
message = $"{userLinkTemplate()} has submitted a new beatmap {beatmapsetLinkTemplate()}!";
|
||||
break;
|
||||
|
||||
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)
|
||||
message = string.Empty;
|
||||
break;
|
||||
|
||||
case RecentActivityType.Rank:
|
||||
message = $"{userLinkTemplate()} achieved rank #{activity.Rank} on {beatmapLinkTemplate()} ({activity.Mode}!)";
|
||||
break;
|
||||
|
||||
case RecentActivityType.RankLost:
|
||||
message = $"{userLinkTemplate()} has lost first place on {beatmapLinkTemplate()} ({activity.Mode}!)";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportAgain:
|
||||
message = $"{userLinkTemplate()} has once again chosen to support osu! - thanks for your generosity!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportFirst:
|
||||
message = $"{userLinkTemplate()} has become an osu! supporter - thanks for your generosity!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportGift:
|
||||
message = $"{userLinkTemplate()} has received the gift of osu! supporter!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UsernameChange:
|
||||
message = $"{activity.User?.PreviousUsername} has changed their username to {userLinkTemplate()}!";
|
||||
break;
|
||||
|
||||
default:
|
||||
message = string.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
return MessageFormatter.FormatText(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.Chat;
|
||||
using osu.Game.Screens.Select.Leaderboards;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
{
|
||||
public class DrawableRecentActivity : DrawableProfileRow
|
||||
{
|
||||
private APIAccess api;
|
||||
|
||||
private readonly RecentActivity activity;
|
||||
|
||||
private LinkFlowContainer content;
|
||||
|
||||
public DrawableRecentActivity(RecentActivity activity)
|
||||
{
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(APIAccess api)
|
||||
{
|
||||
this.api = api;
|
||||
|
||||
LeftFlowContainer.Padding = new MarginPadding { Left = 10, Right = 160 };
|
||||
|
||||
LeftFlowContainer.Add(content = new LinkFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Y,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
});
|
||||
|
||||
RightFlowContainer.Add(new DrawableDate(activity.CreatedAt)
|
||||
{
|
||||
TextSize = 13,
|
||||
Colour = OsuColour.Gray(0xAA),
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
});
|
||||
|
||||
var formatted = createMessage();
|
||||
|
||||
content.AddLinks(formatted.Text, formatted.Links);
|
||||
}
|
||||
|
||||
protected override Drawable CreateLeftVisual()
|
||||
{
|
||||
switch (activity.Type)
|
||||
{
|
||||
case RecentActivityType.Rank:
|
||||
return new DrawableRank(activity.ScoreRank)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
|
||||
case RecentActivityType.Achievement:
|
||||
return new MedalIcon(activity.Achievement.Slug)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
|
||||
default:
|
||||
return new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 60,
|
||||
FillMode = FillMode.Fit,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private string toAbsoluteUrl(string url) => $"{api.Endpoint}{url}";
|
||||
|
||||
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)
|
||||
{
|
||||
case RecentActivityType.Achievement:
|
||||
message = $"{userLinkTemplate()} unlocked the {activity.Achievement.Name} medal!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapPlaycount:
|
||||
message = $"{beatmapLinkTemplate()} has been played {activity.Count} times!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetApprove:
|
||||
message = $"{beatmapsetLinkTemplate()} has been {activity.Approval.ToString().ToLowerInvariant()}!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetDelete:
|
||||
message = $"{beatmapsetLinkTemplate()} has been deleted.";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetRevive:
|
||||
message = $"{beatmapsetLinkTemplate()} has been revived from eternal slumber by {userLinkTemplate()}.";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetUpdate:
|
||||
message = $"{userLinkTemplate()} has updated the beatmap {beatmapsetLinkTemplate()}!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.BeatmapsetUpload:
|
||||
message = $"{userLinkTemplate()} has submitted a new beatmap {beatmapsetLinkTemplate()}!";
|
||||
break;
|
||||
|
||||
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)
|
||||
message = string.Empty;
|
||||
break;
|
||||
|
||||
case RecentActivityType.Rank:
|
||||
message = $"{userLinkTemplate()} achieved rank #{activity.Rank} on {beatmapLinkTemplate()} ({activity.Mode}!)";
|
||||
break;
|
||||
|
||||
case RecentActivityType.RankLost:
|
||||
message = $"{userLinkTemplate()} has lost first place on {beatmapLinkTemplate()} ({activity.Mode}!)";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportAgain:
|
||||
message = $"{userLinkTemplate()} has once again chosen to support osu! - thanks for your generosity!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportFirst:
|
||||
message = $"{userLinkTemplate()} has become an osu! supporter - thanks for your generosity!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UserSupportGift:
|
||||
message = $"{userLinkTemplate()} has received the gift of osu! supporter!";
|
||||
break;
|
||||
|
||||
case RecentActivityType.UsernameChange:
|
||||
message = $"{activity.User?.PreviousUsername} has changed their username to {userLinkTemplate()}!";
|
||||
break;
|
||||
|
||||
default:
|
||||
message = string.Empty;
|
||||
break;
|
||||
}
|
||||
|
||||
return MessageFormatter.FormatText(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +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
|
||||
{
|
||||
public 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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
|
||||
{
|
||||
public 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +1,48 @@
|
||||
// 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.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Users;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
{
|
||||
public class PaginatedRecentActivityContainer : PaginatedContainer
|
||||
{
|
||||
public PaginatedRecentActivityContainer(Bindable<User> user, string header, string missing)
|
||||
: base(user, header, missing)
|
||||
{
|
||||
ItemsPerPage = 5;
|
||||
}
|
||||
|
||||
protected override void ShowMore()
|
||||
{
|
||||
base.ShowMore();
|
||||
|
||||
var req = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
||||
|
||||
req.Success += activities =>
|
||||
{
|
||||
ShowMoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0);
|
||||
ShowMoreLoading.Hide();
|
||||
|
||||
if (!activities.Any() && VisiblePages == 1)
|
||||
{
|
||||
MissingText.Show();
|
||||
return;
|
||||
}
|
||||
|
||||
MissingText.Hide();
|
||||
|
||||
foreach (RecentActivity activity in activities)
|
||||
{
|
||||
ItemsContainer.Add(new DrawableRecentActivity(activity));
|
||||
}
|
||||
};
|
||||
|
||||
Api.Queue(req);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 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.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Users;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||
{
|
||||
public class PaginatedRecentActivityContainer : PaginatedContainer
|
||||
{
|
||||
public PaginatedRecentActivityContainer(Bindable<User> user, string header, string missing)
|
||||
: base(user, header, missing)
|
||||
{
|
||||
ItemsPerPage = 5;
|
||||
}
|
||||
|
||||
protected override void ShowMore()
|
||||
{
|
||||
base.ShowMore();
|
||||
|
||||
var req = new GetUserRecentActivitiesRequest(User.Value.Id, VisiblePages++ * ItemsPerPage);
|
||||
|
||||
req.Success += activities =>
|
||||
{
|
||||
ShowMoreButton.FadeTo(activities.Count == ItemsPerPage ? 1 : 0);
|
||||
ShowMoreLoading.Hide();
|
||||
|
||||
if (!activities.Any() && VisiblePages == 1)
|
||||
{
|
||||
MissingText.Show();
|
||||
return;
|
||||
}
|
||||
|
||||
MissingText.Hide();
|
||||
|
||||
foreach (RecentActivity activity in activities)
|
||||
{
|
||||
ItemsContainer.Add(new DrawableRecentActivity(activity));
|
||||
}
|
||||
};
|
||||
|
||||
Api.Queue(req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user