1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 12:22:54 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs

81 lines
3.0 KiB
C#
Raw Normal View History

2019-08-07 13:42:43 +08: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 13:42:43 +08: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-11 04:58:07 +08:00
using osu.Framework.Extensions.IEnumerableExtensions;
2019-11-21 23:56:48 +08:00
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
2019-11-25 10:30:55 +08:00
using osu.Game.Graphics.Sprites;
2019-11-21 23:56:48 +08:00
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
2019-08-07 13:42:43 +08:00
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneLeaderboardModSelector : OsuTestScene
{
public TestSceneLeaderboardModSelector()
{
LeaderboardModSelector modSelector;
2019-11-11 04:58:07 +08:00
FillFlowContainer<SpriteText> selectedMods;
var ruleset = new Bindable<IRulesetInfo?>();
2019-08-07 13:42:43 +08:00
2019-11-11 04:58:07 +08:00
Add(selectedMods = new FillFlowContainer<SpriteText>
2019-08-07 13:42:43 +08:00
{
Anchor = Anchor.TopLeft,
Origin = Anchor.TopLeft,
});
Add(modSelector = new LeaderboardModSelector
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
2019-11-21 23:56:48 +08:00
Ruleset = { BindTarget = ruleset }
2019-08-07 13:42:43 +08:00
});
modSelector.SelectedMods.CollectionChanged += (_, args) =>
2019-08-07 13:42:43 +08:00
{
switch (args.Action)
2019-11-11 04:58:07 +08:00
{
case NotifyCollectionChangedAction.Add:
args.NewItems.AsNonNull().Cast<Mod>().ForEach(mod => selectedMods.Add(new OsuSpriteText
{
Text = mod.Acronym,
}));
break;
2019-08-07 13:42:43 +08:00
case NotifyCollectionChangedAction.Remove:
args.OldItems.AsNonNull().Cast<Mod>().ForEach(mod =>
2019-11-11 04:58:07 +08:00
{
foreach (var selected in selectedMods)
{
if (selected.Text == mod.Acronym)
{
selectedMods.Remove(selected);
break;
}
}
});
break;
}
2019-11-11 04:58:07 +08:00
};
2019-08-07 13:42:43 +08:00
2019-11-21 23:56:48 +08: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 13:42:43 +08:00
AddStep("Deselect all", () => modSelector.DeselectAll());
2019-11-21 23:56:48 +08:00
AddStep("null ruleset", () => ruleset.Value = null);
2019-08-07 13:42:43 +08:00
}
}
}