1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 14:52:55 +08:00
osu-lazer/osu.Game.Tests/Visual/Online/TestSceneLeaderboardModSelector.cs

79 lines
2.6 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;
using System.Collections.Generic;
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;
2019-08-07 13:42:43 +08:00
namespace osu.Game.Tests.Visual.Online
{
public class TestSceneLeaderboardModSelector : OsuTestScene
{
public override IReadOnlyList<Type> RequiredTypes => new[]
{
typeof(LeaderboardModSelector),
};
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
});
2019-11-11 04:58:07 +08:00
modSelector.SelectedMods.ItemsAdded += mods =>
2019-08-07 13:42:43 +08:00
{
2019-11-25 10:30:55 +08:00
mods.ForEach(mod => selectedMods.Add(new OsuSpriteText
2019-11-11 04:58:07 +08:00
{
Text = mod.Acronym,
}));
};
2019-08-07 13:42:43 +08:00
2019-11-11 04:58:07 +08:00
modSelector.SelectedMods.ItemsRemoved += mods =>
{
mods.ForEach(mod =>
{
foreach (var selected in selectedMods)
2019-08-07 13:42:43 +08:00
{
2019-11-11 04:58:07 +08:00
if (selected.Text == mod.Acronym)
{
selectedMods.Remove(selected);
break;
}
}
});
};
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
}
}
}