mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:17:23 +08:00
Update dependency
This commit is contained in:
parent
9fd225bda7
commit
18f77008db
@ -11,8 +11,6 @@ using osu.Game.Rulesets.Taiko;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
@ -28,7 +26,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
LeaderboardModSelector modSelector;
|
||||
FillFlowContainer<SpriteText> selectedMods;
|
||||
Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
Add(selectedMods = new FillFlowContainer<SpriteText>
|
||||
{
|
||||
@ -40,7 +37,6 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Ruleset = { BindTarget = ruleset }
|
||||
});
|
||||
|
||||
modSelector.SelectedMods.ItemsAdded += mods =>
|
||||
@ -66,12 +62,12 @@ namespace osu.Game.Tests.Visual.Online
|
||||
});
|
||||
};
|
||||
|
||||
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("osu ruleset", () => modSelector.Ruleset = new OsuRuleset().RulesetInfo);
|
||||
AddStep("mania ruleset", () => modSelector.Ruleset = new ManiaRuleset().RulesetInfo);
|
||||
AddStep("taiko ruleset", () => modSelector.Ruleset = new TaikoRuleset().RulesetInfo);
|
||||
AddStep("catch ruleset", () => modSelector.Ruleset = new CatchRuleset().RulesetInfo);
|
||||
AddStep("Deselect all", () => modSelector.DeselectAll());
|
||||
AddStep("null ruleset", () => ruleset.Value = null);
|
||||
AddStep("null ruleset", () => modSelector.Ruleset = null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,14 +14,40 @@ using osuTK.Graphics;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class LeaderboardModSelector : CompositeDrawable
|
||||
{
|
||||
public readonly BindableList<Mod> SelectedMods = new BindableList<Mod>();
|
||||
public readonly Bindable<RulesetInfo> Ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
private RulesetInfo ruleset;
|
||||
|
||||
public RulesetInfo Ruleset
|
||||
{
|
||||
get => ruleset;
|
||||
set
|
||||
{
|
||||
if (ruleset == value)
|
||||
{
|
||||
DeselectAll();
|
||||
return;
|
||||
}
|
||||
|
||||
ruleset = value;
|
||||
|
||||
SelectedMods.Clear();
|
||||
modsContainer.Clear();
|
||||
|
||||
if (ruleset == null)
|
||||
return;
|
||||
|
||||
modsContainer.Add(new ModButton(new ModNoMod()));
|
||||
modsContainer.AddRange(ruleset.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m)));
|
||||
|
||||
modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly FillFlowContainer<ModButton> modsContainer;
|
||||
|
||||
@ -38,26 +64,6 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
};
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
Ruleset.BindValueChanged(onRulesetChanged, true);
|
||||
}
|
||||
|
||||
private void onRulesetChanged(ValueChangedEvent<RulesetInfo> ruleset)
|
||||
{
|
||||
SelectedMods.Clear();
|
||||
modsContainer.Clear();
|
||||
|
||||
if (ruleset.NewValue == null)
|
||||
return;
|
||||
|
||||
modsContainer.Add(new ModButton(new NoMod()));
|
||||
modsContainer.AddRange(ruleset.NewValue.CreateInstance().GetAllMods().Where(m => m.Ranked).Select(m => new ModButton(m)));
|
||||
|
||||
modsContainer.ForEach(button => button.OnSelectionChanged = selectionChanged);
|
||||
}
|
||||
|
||||
private void selectionChanged(Mod mod, bool selected)
|
||||
{
|
||||
if (selected)
|
||||
@ -139,18 +145,5 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
protected override void OnHighlightedChanged(ValueChangedEvent<bool> highlighted) =>
|
||||
this.FadeColour(highlighted.NewValue ? Color4.White : Color4.Gray, duration, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private class NoMod : Mod
|
||||
{
|
||||
public override string Name => "NoMod";
|
||||
|
||||
public override string Acronym => "NM";
|
||||
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
public override IconUsage Icon => FontAwesome.Solid.Ban;
|
||||
|
||||
public override ModType Type => ModType.System;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,10 +107,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
{
|
||||
Current = { BindTarget = scope }
|
||||
},
|
||||
modSelector = new LeaderboardModSelector
|
||||
{
|
||||
Ruleset = { BindTarget = ruleset }
|
||||
}
|
||||
modSelector = new LeaderboardModSelector()
|
||||
}
|
||||
},
|
||||
new Container
|
||||
@ -190,13 +187,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
|
||||
private void onBeatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap)
|
||||
{
|
||||
var beatmapRuleset = beatmap.NewValue?.Ruleset;
|
||||
|
||||
if (ruleset.Value?.Equals(beatmapRuleset) ?? false)
|
||||
modSelector.DeselectAll();
|
||||
else
|
||||
ruleset.Value = beatmapRuleset;
|
||||
|
||||
ruleset.Value = modSelector.Ruleset = beatmap.NewValue?.Ruleset;
|
||||
scope.Value = BeatmapLeaderboardScope.Global;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
/// <summary>
|
||||
@ -11,5 +13,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
public override string Name => "No Mod";
|
||||
public override string Acronym => "NM";
|
||||
public override double ScoreMultiplier => 1;
|
||||
public override IconUsage Icon => FontAwesome.Solid.Ban;
|
||||
public override ModType Type => ModType.System;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user