mirror of
https://github.com/ppy/osu.git
synced 2026-05-24 06:19:55 +08:00
Merge pull request #33544 from NotStirred/master
Always allow a map's user-tags to be read
This commit is contained in:
@@ -256,6 +256,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Rank = ScoreRank.D;
|
||||
|
||||
setUpTaggingRequests(() => score.BeatmapInfo);
|
||||
AddStep("load panel", () =>
|
||||
{
|
||||
Child = new PopoverContainer
|
||||
@@ -278,6 +279,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
var score = TestResources.CreateTestScoreInfo();
|
||||
score.Ruleset = new ManiaRuleset().RulesetInfo;
|
||||
|
||||
setUpTaggingRequests(() => score.BeatmapInfo);
|
||||
AddStep("load panel", () =>
|
||||
{
|
||||
Child = new PopoverContainer
|
||||
|
||||
@@ -28,11 +28,14 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
|
||||
private DummyAPIAccess dummyAPI => (DummyAPIAccess)API;
|
||||
|
||||
private int writeRequestCount = 0;
|
||||
|
||||
[SetUpSteps]
|
||||
public void SetUpSteps()
|
||||
{
|
||||
AddStep("set up network requests", () =>
|
||||
{
|
||||
writeRequestCount = 0;
|
||||
dummyAPI.HandleRequest = request =>
|
||||
{
|
||||
switch (request)
|
||||
@@ -77,6 +80,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
case AddBeatmapTagRequest:
|
||||
case RemoveBeatmapTagRequest:
|
||||
{
|
||||
writeRequestCount++;
|
||||
Scheduler.AddDelayed(request.TriggerSuccess, 500);
|
||||
return true;
|
||||
}
|
||||
@@ -107,6 +111,31 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNotWritable()
|
||||
{
|
||||
AddStep("show", () =>
|
||||
{
|
||||
var working = CreateWorkingBeatmap(new OsuRuleset().RulesetInfo);
|
||||
working.BeatmapInfo.OnlineID = 42;
|
||||
Beatmap.Value = working;
|
||||
recreateControl(writable: false);
|
||||
});
|
||||
|
||||
AddUntilStep("click tag", () =>
|
||||
{
|
||||
var tag = this.ChildrenOfType<UserTagControl.DrawableUserTag>().FirstOrDefault(t => t.UserTag.Id == 2);
|
||||
if (tag == null)
|
||||
return false;
|
||||
|
||||
InputManager.MoveMouseTo(tag);
|
||||
InputManager.Click(MouseButton.Left);
|
||||
return true;
|
||||
});
|
||||
|
||||
AddAssert("no vote requests send", () => writeRequestCount, () => Is.Zero);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestTagsDoNotMoveUntilMouseMovesAway()
|
||||
{
|
||||
@@ -148,13 +177,14 @@ namespace osu.Game.Tests.Visual.Ranking
|
||||
UserTagControl.DrawableUserTag getDrawableTagById(long id) => getTagFlow().Single(t => t.UserTag.Id == id);
|
||||
}
|
||||
|
||||
private void recreateControl()
|
||||
private void recreateControl(bool writable = true)
|
||||
{
|
||||
Child = new PopoverContainer
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Child = new UserTagControl(Beatmap.Value.BeatmapInfo)
|
||||
{
|
||||
Writable = writable,
|
||||
Width = 700,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
||||
@@ -267,6 +267,7 @@ namespace osu.Game.Screens.Ranking.Statistics
|
||||
{
|
||||
yield return new StatisticItem("Tag the beatmap!", () => new UserTagControl(newScore.BeatmapInfo)
|
||||
{
|
||||
Writable = true,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
@@ -274,12 +275,31 @@ namespace osu.Game.Screens.Ranking.Statistics
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return new StatisticItem("Tag the beatmap!", () => new OsuTextFlowContainer(cp => cp.Font = OsuFont.GetFont(size: StatisticItem.FONT_SIZE, weight: FontWeight.SemiBold))
|
||||
yield return new StatisticItem("Tag the beatmap!", () => new FillFlowContainer<CompositeDrawable>
|
||||
{
|
||||
Children = new CompositeDrawable[]
|
||||
{
|
||||
new OsuTextFlowContainer(cp => cp.Font = OsuFont.GetFont(size: StatisticItem.FONT_SIZE, weight: FontWeight.SemiBold))
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
TextAnchor = Anchor.Centre,
|
||||
Text = preventTaggingReason,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
new UserTagControl(newScore.BeatmapInfo)
|
||||
{
|
||||
Writable = false,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}
|
||||
},
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
TextAnchor = Anchor.Centre,
|
||||
Text = preventTaggingReason,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(4),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,12 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
private readonly Bindable<APIBeatmap?> apiBeatmap = new Bindable<APIBeatmap?>();
|
||||
|
||||
private AddNewTagUserTag addNewTagUserTag = null!;
|
||||
private AddNewTagUserTag? addNewTagUserTag;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the user can modify the contained tags
|
||||
/// </summary>
|
||||
public bool Writable { private get; init; }
|
||||
|
||||
private InputManager inputManager = null!;
|
||||
|
||||
@@ -91,12 +96,17 @@ namespace osu.Game.Screens.Ranking
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Full,
|
||||
Spacing = new Vector2(4),
|
||||
Child = addNewTagUserTag = new AddNewTagUserTag
|
||||
{
|
||||
AvailableTags = { BindTarget = relevantTagsById },
|
||||
OnTagSelected = toggleVote,
|
||||
},
|
||||
},
|
||||
Children = Writable
|
||||
?
|
||||
[
|
||||
addNewTagUserTag = new AddNewTagUserTag
|
||||
{
|
||||
AvailableTags = { BindTarget = relevantTagsById },
|
||||
OnTagSelected = toggleVote,
|
||||
}
|
||||
]
|
||||
: []
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -196,7 +206,7 @@ namespace osu.Game.Screens.Ranking
|
||||
case NotifyCollectionChangedAction.Reset:
|
||||
{
|
||||
tagFlow.Clear();
|
||||
tagFlow.Add(addNewTagUserTag);
|
||||
if (Writable) tagFlow.Add(addNewTagUserTag!);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -204,6 +214,9 @@ namespace osu.Game.Screens.Ranking
|
||||
|
||||
private void toggleVote(UserTag tag)
|
||||
{
|
||||
if (!Writable)
|
||||
return;
|
||||
|
||||
if (tag.Updating.Value)
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user