private void onBeatmapChanged(ValueChangedEvent <BeatmapInfo> beatmap) { var beatmapRuleset = beatmap.NewValue?.Ruleset; if (ruleset.Value?.Equals(beatmapRuleset) ?? false) { modSelector.DeselectAll(); ruleset.TriggerChange(); } else { ruleset.Value = beatmapRuleset; } scope.Value = BeatmapLeaderboardScope.Global; }
public TestSceneLeaderboardModSelector() { LeaderboardModSelector modSelector; FillFlowContainer <SpriteText> selectedMods; var ruleset = new Bindable <IRulesetInfo>(); Add(selectedMods = new FillFlowContainer <SpriteText> { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, }); Add(modSelector = new LeaderboardModSelector { Anchor = Anchor.Centre, Origin = Anchor.Centre, Ruleset = { BindTarget = ruleset } }); modSelector.SelectedMods.CollectionChanged += (_, args) => { switch (args.Action) { case NotifyCollectionChangedAction.Add: args.NewItems.AsNonNull().Cast <Mod>().ForEach(mod => selectedMods.Add(new OsuSpriteText { Text = mod.Acronym, })); break; case NotifyCollectionChangedAction.Remove: args.OldItems.AsNonNull().Cast <Mod>().ForEach(mod => { foreach (var selected in selectedMods) { if (selected.Text == mod.Acronym) { selectedMods.Remove(selected); break; } } }); break; } }; 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); AddStep("Deselect all", () => modSelector.DeselectAll()); AddStep("null ruleset", () => ruleset.Value = null); }
public TestSceneLeaderboardModSelector() { LeaderboardModSelector modSelector; FillFlowContainer <SpriteText> selectedMods; var ruleset = new Bindable <RulesetInfo>(); Add(selectedMods = new FillFlowContainer <SpriteText> { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, }); Add(modSelector = new LeaderboardModSelector { Anchor = Anchor.Centre, Origin = Anchor.Centre, Ruleset = { BindTarget = ruleset } }); modSelector.SelectedMods.ItemsAdded += mods => { mods.ForEach(mod => selectedMods.Add(new OsuSpriteText { Text = mod.Acronym, })); }; modSelector.SelectedMods.ItemsRemoved += mods => { mods.ForEach(mod => { foreach (var selected in selectedMods) { if (selected.Text == mod.Acronym) { selectedMods.Remove(selected); break; } } }); }; 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); AddStep("Deselect all", () => modSelector.DeselectAll()); AddStep("null ruleset", () => ruleset.Value = null); }