mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:32:55 +08:00
Merge pull request #23087 from cdwcgt/gd-onlinesetoverlay
Show guest difficulty author in beatmap overlay
This commit is contained in:
commit
184f6d2dd4
@ -14,6 +14,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.API.Requests;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
@ -26,7 +27,7 @@ using APIUser = osu.Game.Online.API.Requests.Responses.APIUser;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
public partial class TestSceneBeatmapSetOverlay : OsuTestScene
|
||||
public partial class TestSceneBeatmapSetOverlay : OsuManualInputManagerTestScene
|
||||
{
|
||||
private readonly TestBeatmapSetOverlay overlay;
|
||||
|
||||
@ -281,6 +282,22 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddAssert(@"type is correct", () => type == lookupType.ToString());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBeatmapSetWithGuestDifficulty()
|
||||
{
|
||||
AddStep("show map", () => overlay.ShowBeatmapSet(createBeatmapSetWithGuestDifficulty()));
|
||||
AddStep("move mouse to host difficulty", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(overlay.ChildrenOfType<DifficultyIcon>().ElementAt(0));
|
||||
});
|
||||
AddAssert("guest mapper information not shown", () => overlay.ChildrenOfType<BeatmapPicker>().Single().ChildrenOfType<OsuSpriteText>().All(s => s.Text != "BanchoBot"));
|
||||
AddStep("move mouse to guest difficulty", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(overlay.ChildrenOfType<DifficultyIcon>().ElementAt(1));
|
||||
});
|
||||
AddAssert("guest mapper information shown", () => overlay.ChildrenOfType<BeatmapPicker>().Single().ChildrenOfType<OsuSpriteText>().Any(s => s.Text == "BanchoBot"));
|
||||
}
|
||||
|
||||
private APIBeatmapSet createManyDifficultiesBeatmapSet()
|
||||
{
|
||||
var set = getBeatmapSet();
|
||||
@ -320,6 +337,60 @@ namespace osu.Game.Tests.Visual.Online
|
||||
return beatmapSet;
|
||||
}
|
||||
|
||||
private APIBeatmapSet createBeatmapSetWithGuestDifficulty()
|
||||
{
|
||||
var set = getBeatmapSet();
|
||||
|
||||
var beatmaps = new List<APIBeatmap>();
|
||||
|
||||
var guestUser = new APIUser
|
||||
{
|
||||
Username = @"BanchoBot",
|
||||
Id = 3,
|
||||
};
|
||||
|
||||
set.RelatedUsers = new[]
|
||||
{
|
||||
set.Author, guestUser
|
||||
};
|
||||
|
||||
beatmaps.Add(new APIBeatmap
|
||||
{
|
||||
OnlineID = 1145,
|
||||
DifficultyName = "Host Diff",
|
||||
RulesetID = Ruleset.Value.OnlineID,
|
||||
StarRating = 1.4,
|
||||
OverallDifficulty = 3.5f,
|
||||
AuthorID = set.AuthorID,
|
||||
FailTimes = new APIFailTimes
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
},
|
||||
Status = BeatmapOnlineStatus.Graveyard
|
||||
});
|
||||
|
||||
beatmaps.Add(new APIBeatmap
|
||||
{
|
||||
OnlineID = 1919,
|
||||
DifficultyName = "Guest Diff",
|
||||
RulesetID = Ruleset.Value.OnlineID,
|
||||
StarRating = 8.1,
|
||||
OverallDifficulty = 3.5f,
|
||||
AuthorID = 3,
|
||||
FailTimes = new APIFailTimes
|
||||
{
|
||||
Fails = Enumerable.Range(1, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
Retries = Enumerable.Range(-2, 100).Select(j => j % 12 - 6).ToArray(),
|
||||
},
|
||||
Status = BeatmapOnlineStatus.Graveyard
|
||||
});
|
||||
|
||||
set.Beatmaps = beatmaps.ToArray();
|
||||
|
||||
return set;
|
||||
}
|
||||
|
||||
private void downloadAssert(bool shown)
|
||||
{
|
||||
AddAssert($"is download button {(shown ? "shown" : "hidden")}", () => overlay.Header.HeaderContent.DownloadButtonsVisible == shown);
|
||||
|
@ -31,6 +31,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
private const float tile_spacing = 2;
|
||||
|
||||
private readonly OsuSpriteText version, starRating, starRatingText;
|
||||
private readonly LinkFlowContainer guestMapperContainer;
|
||||
private readonly FillFlowContainer starRatingContainer;
|
||||
private readonly Statistic plays, favourites;
|
||||
|
||||
@ -88,6 +89,14 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
Origin = Anchor.BottomLeft,
|
||||
Font = OsuFont.GetFont(size: 17, weight: FontWeight.Bold)
|
||||
},
|
||||
guestMapperContainer = new LinkFlowContainer(s =>
|
||||
s.Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 11))
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Margin = new MarginPadding { Bottom = 1 },
|
||||
},
|
||||
starRatingContainer = new FillFlowContainer
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
@ -198,8 +207,21 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
updateDifficultyButtons();
|
||||
}
|
||||
|
||||
private void showBeatmap(IBeatmapInfo? beatmapInfo)
|
||||
private void showBeatmap(APIBeatmap? beatmapInfo)
|
||||
{
|
||||
guestMapperContainer.Clear();
|
||||
|
||||
if (beatmapInfo?.AuthorID != BeatmapSet?.AuthorID)
|
||||
{
|
||||
APIUser? user = BeatmapSet?.RelatedUsers?.SingleOrDefault(u => u.OnlineID == beatmapInfo?.AuthorID);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
guestMapperContainer.AddText("mapped by ");
|
||||
guestMapperContainer.AddUserLink(user);
|
||||
}
|
||||
}
|
||||
|
||||
version.Text = beatmapInfo?.DifficultyName ?? string.Empty;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user