2019-08-07 05:42:43 +00:00
|
|
|
|
// 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.
|
|
|
|
|
|
|
|
|
|
using osu.Game.Overlays.BeatmapSet;
|
2020-02-17 06:06:14 +00:00
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.Linq;
|
2019-08-07 05:42:43 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
|
using osu.Game.Rulesets.Mania;
|
|
|
|
|
using osu.Game.Rulesets.Taiko;
|
|
|
|
|
using osu.Game.Rulesets.Catch;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2019-11-10 20:58:07 +00:00
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2019-11-21 15:56:48 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2021-05-14 21:52:16 +00:00
|
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2019-11-25 02:30:55 +00:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2019-11-21 15:56:48 +00:00
|
|
|
|
using osu.Game.Rulesets;
|
2020-02-17 06:06:14 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-08-07 05:42:43 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Online
|
|
|
|
|
{
|
|
|
|
|
public class TestSceneLeaderboardModSelector : OsuTestScene
|
|
|
|
|
{
|
|
|
|
|
public TestSceneLeaderboardModSelector()
|
|
|
|
|
{
|
|
|
|
|
LeaderboardModSelector modSelector;
|
2019-11-10 20:58:07 +00:00
|
|
|
|
FillFlowContainer<SpriteText> selectedMods;
|
2019-11-21 15:56:48 +00:00
|
|
|
|
var ruleset = new Bindable<RulesetInfo>();
|
2019-08-07 05:42:43 +00:00
|
|
|
|
|
2019-11-10 20:58:07 +00:00
|
|
|
|
Add(selectedMods = new FillFlowContainer<SpriteText>
|
2019-08-07 05:42:43 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopLeft,
|
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Add(modSelector = new LeaderboardModSelector
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2019-11-21 15:56:48 +00:00
|
|
|
|
Ruleset = { BindTarget = ruleset }
|
2019-08-07 05:42:43 +00:00
|
|
|
|
});
|
|
|
|
|
|
2020-02-17 06:06:14 +00:00
|
|
|
|
modSelector.SelectedMods.CollectionChanged += (_, args) =>
|
2019-08-07 05:42:43 +00:00
|
|
|
|
{
|
2020-02-17 06:06:14 +00:00
|
|
|
|
switch (args.Action)
|
2019-11-10 20:58:07 +00:00
|
|
|
|
{
|
2020-02-17 06:06:14 +00:00
|
|
|
|
case NotifyCollectionChangedAction.Add:
|
2021-05-14 21:52:16 +00:00
|
|
|
|
args.NewItems.AsNonNull().Cast<Mod>().ForEach(mod => selectedMods.Add(new OsuSpriteText
|
2020-02-17 06:06:14 +00:00
|
|
|
|
{
|
|
|
|
|
Text = mod.Acronym,
|
|
|
|
|
}));
|
|
|
|
|
break;
|
2019-08-07 05:42:43 +00:00
|
|
|
|
|
2020-02-17 06:06:14 +00:00
|
|
|
|
case NotifyCollectionChangedAction.Remove:
|
2021-05-14 21:52:16 +00:00
|
|
|
|
args.OldItems.AsNonNull().Cast<Mod>().ForEach(mod =>
|
2019-11-10 20:58:07 +00:00
|
|
|
|
{
|
2020-02-17 06:06:14 +00:00
|
|
|
|
foreach (var selected in selectedMods)
|
|
|
|
|
{
|
|
|
|
|
if (selected.Text == mod.Acronym)
|
|
|
|
|
{
|
|
|
|
|
selectedMods.Remove(selected);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-11-10 20:58:07 +00:00
|
|
|
|
};
|
2019-08-07 05:42:43 +00:00
|
|
|
|
|
2019-11-21 15:56:48 +00:00
|
|
|
|
AddStep("osu ruleset", () => ruleset.Value = new OsuRuleset().RulesetInfo);
|
|
|
|
|
AddStep("mania ruleset", () => ruleset.Value = new ManiaRuleset().RulesetInfo);
|
|
|
|
|
AddStep("taiko ruleset", () => ruleset.Value = new TaikoRuleset().RulesetInfo);
|
|
|
|
|
AddStep("catch ruleset", () => ruleset.Value = new CatchRuleset().RulesetInfo);
|
2019-08-07 05:42:43 +00:00
|
|
|
|
AddStep("Deselect all", () => modSelector.DeselectAll());
|
2019-11-21 15:56:48 +00:00
|
|
|
|
AddStep("null ruleset", () => ruleset.Value = null);
|
2019-08-07 05:42:43 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|