mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Merge pull request #14444 from frenzibyte/decouple-ruleset-bindables
Decouple rankings overlay's ruleset selector from the game-wide ruleset bindable
This commit is contained in:
commit
3c9718339c
@ -1,12 +1,15 @@
|
||||
// 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.Allocation;
|
||||
using osu.Game.Overlays;
|
||||
using NUnit.Framework;
|
||||
using osu.Game.Users;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Rankings;
|
||||
using osu.Game.Rulesets.Catch;
|
||||
using osu.Game.Rulesets.Mania;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
@ -14,25 +17,29 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
protected override bool UseOnlineAPI => true;
|
||||
|
||||
[Cached(typeof(RankingsOverlay))]
|
||||
private readonly RankingsOverlay rankingsOverlay;
|
||||
private TestRankingsOverlay rankingsOverlay;
|
||||
|
||||
private readonly Bindable<Country> countryBindable = new Bindable<Country>();
|
||||
private readonly Bindable<RankingsScope> scope = new Bindable<RankingsScope>();
|
||||
|
||||
public TestSceneRankingsOverlay()
|
||||
{
|
||||
Add(rankingsOverlay = new TestRankingsOverlay
|
||||
{
|
||||
Country = { BindTarget = countryBindable },
|
||||
Header = { Current = { BindTarget = scope } },
|
||||
});
|
||||
}
|
||||
[SetUp]
|
||||
public void SetUp() => Schedule(loadRankingsOverlay);
|
||||
|
||||
[Test]
|
||||
public void TestShow()
|
||||
public void TestParentRulesetDecoupledAfterInitialShow()
|
||||
{
|
||||
AddStep("Show", rankingsOverlay.Show);
|
||||
AddStep("enable global ruleset", () => Ruleset.Disabled = false);
|
||||
AddStep("set global ruleset to osu!catch", () => Ruleset.Value = new CatchRuleset().RulesetInfo);
|
||||
AddStep("reload rankings overlay", loadRankingsOverlay);
|
||||
AddAssert("rankings ruleset set to osu!catch", () => rankingsOverlay.Header.Ruleset.Value.ShortName == CatchRuleset.SHORT_NAME);
|
||||
|
||||
AddStep("set global ruleset to osu!", () => Ruleset.Value = new OsuRuleset().RulesetInfo);
|
||||
AddAssert("rankings ruleset still osu!catch", () => rankingsOverlay.Header.Ruleset.Value.ShortName == CatchRuleset.SHORT_NAME);
|
||||
|
||||
AddStep("disable global ruleset", () => Ruleset.Disabled = true);
|
||||
AddAssert("rankings ruleset still enabled", () => rankingsOverlay.Header.Ruleset.Disabled == false);
|
||||
AddStep("set rankings ruleset to osu!mania", () => rankingsOverlay.Header.Ruleset.Value = new ManiaRuleset().RulesetInfo);
|
||||
AddAssert("rankings ruleset set to osu!mania", () => rankingsOverlay.Header.Ruleset.Value.ShortName == ManiaRuleset.SHORT_NAME);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -50,10 +57,14 @@ namespace osu.Game.Tests.Visual.Online
|
||||
AddStep("Show US", () => rankingsOverlay.ShowCountry(us_country));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestHide()
|
||||
private void loadRankingsOverlay()
|
||||
{
|
||||
AddStep("Hide", rankingsOverlay.Hide);
|
||||
Child = rankingsOverlay = new TestRankingsOverlay
|
||||
{
|
||||
Country = { BindTarget = countryBindable },
|
||||
Header = { Current = { BindTarget = scope } },
|
||||
State = { Value = Visibility.Visible },
|
||||
};
|
||||
}
|
||||
|
||||
private static readonly Country us_country = new Country
|
||||
|
@ -23,7 +23,10 @@ namespace osu.Game.Overlays
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Bindable<RulesetInfo> ruleset { get; set; }
|
||||
private IBindable<RulesetInfo> parentRuleset { get; set; }
|
||||
|
||||
[Cached]
|
||||
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||
|
||||
public RankingsOverlay()
|
||||
: base(OverlayColourScheme.Green)
|
||||
@ -54,6 +57,19 @@ namespace osu.Game.Overlays
|
||||
});
|
||||
}
|
||||
|
||||
private bool requiresRulesetUpdate = true;
|
||||
|
||||
protected override void PopIn()
|
||||
{
|
||||
if (requiresRulesetUpdate)
|
||||
{
|
||||
ruleset.Value = parentRuleset.Value;
|
||||
requiresRulesetUpdate = false;
|
||||
}
|
||||
|
||||
base.PopIn();
|
||||
}
|
||||
|
||||
protected override void OnTabChanged(RankingsScope tab)
|
||||
{
|
||||
// country filtering is only valid for performance scope.
|
||||
|
Loading…
Reference in New Issue
Block a user