mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 21:33:22 +08:00
Refactor ruleset presentation
This commit is contained in:
parent
8786d6264f
commit
36116f8c45
@ -136,6 +136,22 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
Beatmap = dummyBeatmap,
|
Beatmap = dummyBeatmap,
|
||||||
},
|
},
|
||||||
new APIRecentActivity
|
new APIRecentActivity
|
||||||
|
{
|
||||||
|
User = dummyUser,
|
||||||
|
Type = RecentActivityType.Rank,
|
||||||
|
Rank = 1,
|
||||||
|
Mode = "vitaru",
|
||||||
|
Beatmap = dummyBeatmap,
|
||||||
|
},
|
||||||
|
new APIRecentActivity
|
||||||
|
{
|
||||||
|
User = dummyUser,
|
||||||
|
Type = RecentActivityType.Rank,
|
||||||
|
Rank = 1,
|
||||||
|
Mode = "fruits",
|
||||||
|
Beatmap = dummyBeatmap,
|
||||||
|
},
|
||||||
|
new APIRecentActivity
|
||||||
{
|
{
|
||||||
User = dummyUser,
|
User = dummyUser,
|
||||||
Type = RecentActivityType.RankLost,
|
Type = RecentActivityType.RankLost,
|
||||||
|
@ -41,37 +41,8 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonProperty("count")]
|
[JsonProperty("count")]
|
||||||
public int Count;
|
public int Count;
|
||||||
|
|
||||||
public string Mode;
|
|
||||||
|
|
||||||
[JsonProperty("mode")]
|
[JsonProperty("mode")]
|
||||||
private string mode
|
public string Mode;
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
switch (value)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
Mode = value;
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "osu":
|
|
||||||
Mode = "osu!";
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "mania":
|
|
||||||
Mode = "osu!mania";
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "taiko":
|
|
||||||
Mode = "osu!taiko";
|
|
||||||
return;
|
|
||||||
|
|
||||||
case "fruits":
|
|
||||||
Mode = "osu!catch";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[JsonProperty("beatmap")]
|
[JsonProperty("beatmap")]
|
||||||
public RecentActivityBeatmap Beatmap;
|
public RecentActivityBeatmap Beatmap;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -12,6 +13,7 @@ using osu.Game.Online.API.Requests;
|
|||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Chat;
|
using osu.Game.Online.Chat;
|
||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Profile.Sections.Recent
|
namespace osu.Game.Overlays.Profile.Sections.Recent
|
||||||
{
|
{
|
||||||
@ -19,7 +21,11 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
{
|
{
|
||||||
private const int font_size = 14;
|
private const int font_size = 14;
|
||||||
|
|
||||||
private IAPIProvider api;
|
[Resolved]
|
||||||
|
private IAPIProvider api { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private RulesetStore rulesets { get; set; }
|
||||||
|
|
||||||
private readonly APIRecentActivity activity;
|
private readonly APIRecentActivity activity;
|
||||||
|
|
||||||
@ -31,10 +37,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(IAPIProvider api, OverlayColourProvider colourProvider)
|
private void load(OverlayColourProvider colourProvider)
|
||||||
{
|
{
|
||||||
this.api = api;
|
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
AddInternal(new GridContainer
|
AddInternal(new GridContainer
|
||||||
@ -118,6 +122,16 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string getRulesetName()
|
||||||
|
{
|
||||||
|
var shortName = activity.Mode;
|
||||||
|
|
||||||
|
if (rulesets.AvailableRulesets.Select(r => r.ShortName).Contains(shortName))
|
||||||
|
return rulesets.AvailableRulesets.FirstOrDefault(r => r.ShortName == shortName).Name;
|
||||||
|
|
||||||
|
return shortName;
|
||||||
|
}
|
||||||
|
|
||||||
private string getLinkArgument(string url) => MessageFormatter.GetLinkDetails($"{api.Endpoint}{url}").Argument;
|
private string getLinkArgument(string url) => MessageFormatter.GetLinkDetails($"{api.Endpoint}{url}").Argument;
|
||||||
|
|
||||||
private FontUsage getLinkFont(FontWeight fontWeight = FontWeight.Regular)
|
private FontUsage getLinkFont(FontWeight fontWeight = FontWeight.Regular)
|
||||||
@ -185,14 +199,14 @@ namespace osu.Game.Overlays.Profile.Sections.Recent
|
|||||||
addUserLink();
|
addUserLink();
|
||||||
addText($" achieved rank #{activity.Rank} on ");
|
addText($" achieved rank #{activity.Rank} on ");
|
||||||
addBeatmapLink();
|
addBeatmapLink();
|
||||||
addText($" ({activity.Mode})");
|
addText($" ({getRulesetName()})");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecentActivityType.RankLost:
|
case RecentActivityType.RankLost:
|
||||||
addUserLink();
|
addUserLink();
|
||||||
addText(" has lost first place on ");
|
addText(" has lost first place on ");
|
||||||
addBeatmapLink();
|
addBeatmapLink();
|
||||||
addText($" ({activity.Mode})");
|
addText($" ({getRulesetName()})");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RecentActivityType.UserSupportAgain:
|
case RecentActivityType.UserSupportAgain:
|
||||||
|
Loading…
Reference in New Issue
Block a user