1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 17:32:55 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs

79 lines
2.9 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;
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;
2019-11-21 23:56:48 +08:00
var ruleset = new Bindable<RulesetInfo>();
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.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.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
}
}
}