mirror of
https://github.com/osukey/osukey.git
synced 2025-05-16 11:07:35 +09:00
Merge pull request #8318 from recapitalverb/fix-score-results-mapper
Fix mapper name in score panel
This commit is contained in:
commit
a40e3505f3
@ -3,10 +3,18 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.Osu.Mods;
|
using osu.Game.Rulesets.Osu.Mods;
|
||||||
@ -23,6 +31,9 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
{
|
{
|
||||||
public class TestSceneExpandedPanelMiddleContent : OsuTestScene
|
public class TestSceneExpandedPanelMiddleContent : OsuTestScene
|
||||||
{
|
{
|
||||||
|
[Resolved]
|
||||||
|
private RulesetStore rulesetStore { get; set; }
|
||||||
|
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(ExpandedPanelMiddleContent),
|
typeof(ExpandedPanelMiddleContent),
|
||||||
@ -35,23 +46,36 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
typeof(TotalScoreCounter)
|
typeof(TotalScoreCounter)
|
||||||
};
|
};
|
||||||
|
|
||||||
public TestSceneExpandedPanelMiddleContent()
|
[Test]
|
||||||
|
public void TestMapWithKnownMapper()
|
||||||
{
|
{
|
||||||
Child = new Container
|
var author = new User { Username = "mapper_name" };
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
AddStep("show example score", () => showPanel(createTestBeatmap(author), createTestScore()));
|
||||||
Origin = Anchor.Centre,
|
|
||||||
Size = new Vector2(500, 700),
|
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Text == "mapper_name"));
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
new Box
|
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = Color4Extensions.FromHex("#444"),
|
|
||||||
},
|
|
||||||
new ExpandedPanelMiddleContent(createTestScore())
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
[Test]
|
||||||
|
public void TestMapWithUnknownMapper()
|
||||||
|
{
|
||||||
|
AddStep("show example score", () => showPanel(createTestBeatmap(null), createTestScore()));
|
||||||
|
|
||||||
|
AddAssert("mapped by text not present", () =>
|
||||||
|
this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text, "mapped", "by")));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showPanel(WorkingBeatmap workingBeatmap, ScoreInfo score)
|
||||||
|
{
|
||||||
|
Child = new ExpandedPanelMiddleContentContainer(workingBeatmap, score);
|
||||||
|
}
|
||||||
|
|
||||||
|
private WorkingBeatmap createTestBeatmap(User author)
|
||||||
|
{
|
||||||
|
var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0));
|
||||||
|
beatmap.Metadata.Author = author;
|
||||||
|
|
||||||
|
return new TestWorkingBeatmap(beatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ScoreInfo createTestScore() => new ScoreInfo
|
private ScoreInfo createTestScore() => new ScoreInfo
|
||||||
@ -76,5 +100,31 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
{ HitResult.Great, 300 },
|
{ HitResult.Great, 300 },
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private bool containsAny(string text, params string[] stringsToMatch) => stringsToMatch.Any(text.Contains);
|
||||||
|
|
||||||
|
private class ExpandedPanelMiddleContentContainer : Container
|
||||||
|
{
|
||||||
|
[Cached]
|
||||||
|
private Bindable<WorkingBeatmap> workingBeatmap { get; set; }
|
||||||
|
|
||||||
|
public ExpandedPanelMiddleContentContainer(WorkingBeatmap beatmap, ScoreInfo score)
|
||||||
|
{
|
||||||
|
workingBeatmap = new Bindable<WorkingBeatmap>(beatmap);
|
||||||
|
|
||||||
|
Anchor = Anchor.Centre;
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
Size = new Vector2(500, 700);
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = Color4Extensions.FromHex("#444"),
|
||||||
|
},
|
||||||
|
new ExpandedPanelMiddleContent(score)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,7 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
{
|
{
|
||||||
var beatmap = working.Value.BeatmapInfo;
|
var beatmap = working.Value.BeatmapInfo;
|
||||||
var metadata = beatmap.Metadata;
|
var metadata = beatmap.Metadata;
|
||||||
|
var creator = metadata.Author?.Username;
|
||||||
|
|
||||||
var topStatistics = new List<StatisticDisplay>
|
var topStatistics = new List<StatisticDisplay>
|
||||||
{
|
{
|
||||||
@ -161,9 +162,12 @@ namespace osu.Game.Screens.Ranking.Expanded
|
|||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
}.With(t =>
|
}.With(t =>
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(creator))
|
||||||
{
|
{
|
||||||
t.AddText("mapped by ");
|
t.AddText("mapped by ");
|
||||||
t.AddText(score.UserString, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
|
t.AddText(creator, s => s.Font = s.Font.With(weight: FontWeight.SemiBold));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user