osu/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
3.0 KiB
C#
Raw Normal View History

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;
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;
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;
using osu.Game.Rulesets.Mods;
2019-08-07 05:42:43 +00:00
namespace osu.Game.Tests.Visual.Online
{
public partial class TestSceneLeaderboardModSelector : OsuTestScene
{
public TestSceneLeaderboardModSelector()
{
LeaderboardModSelector modSelector;
2019-11-10 20:58:07 +00:00
FillFlowContainer<SpriteText> selectedMods;
var ruleset = new Bindable<IRulesetInfo?>();
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
});
modSelector.SelectedMods.CollectionChanged += (_, args) =>
2019-08-07 05:42:43 +00:00
{
switch (args.Action)
2019-11-10 20:58:07 +00:00
{
case NotifyCollectionChangedAction.Add:
args.NewItems.AsNonNull().Cast<Mod>().ForEach(mod => selectedMods.Add(new OsuSpriteText
{
Text = mod.Acronym,
}));
break;
2019-08-07 05:42:43 +00:00
case NotifyCollectionChangedAction.Remove:
args.OldItems.AsNonNull().Cast<Mod>().ForEach(mod =>
2019-11-10 20:58:07 +00:00
{
foreach (var selected in selectedMods)
{
if (selected.Text == mod.Acronym)
{
selectedMods.Remove(selected, true);
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
}
}
}