mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 09:22:54 +08:00
Remove null checks on ruleset
Add a default ruleset to `OsuTestCase` to cover testing scenarios.
This commit is contained in:
parent
4dd12cedad
commit
4bcc05a7fc
@ -51,8 +51,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
refreshSelectedMods();
|
refreshSelectedMods();
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, Bindable<RulesetInfo> ruleset, RulesetStore rulesets, AudioManager audio)
|
private void load(OsuColour colours, Bindable<RulesetInfo> ruleset, AudioManager audio)
|
||||||
{
|
{
|
||||||
SelectedMods.ValueChanged += selectedModsChanged;
|
SelectedMods.ValueChanged += selectedModsChanged;
|
||||||
|
|
||||||
@ -60,13 +60,8 @@ namespace osu.Game.Overlays.Mods
|
|||||||
HighMultiplierColour = colours.Green;
|
HighMultiplierColour = colours.Green;
|
||||||
UnrankedLabel.Colour = colours.Blue;
|
UnrankedLabel.Colour = colours.Blue;
|
||||||
|
|
||||||
if (ruleset != null)
|
Ruleset.BindTo(ruleset);
|
||||||
Ruleset.BindTo(ruleset);
|
Ruleset.BindValueChanged(rulesetChanged, true);
|
||||||
else
|
|
||||||
Ruleset.Value = rulesets.AvailableRulesets.First();
|
|
||||||
|
|
||||||
Ruleset.ValueChanged += rulesetChanged;
|
|
||||||
Ruleset.TriggerChange();
|
|
||||||
|
|
||||||
sampleOn = audio.Sample.Get(@"UI/check-on");
|
sampleOn = audio.Sample.Get(@"UI/check-on");
|
||||||
sampleOff = audio.Sample.Get(@"UI/check-off");
|
sampleOff = audio.Sample.Get(@"UI/check-off");
|
||||||
|
@ -67,7 +67,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader]
|
||||||
private void load(RulesetStore rulesets, Bindable<RulesetInfo> parentRuleset)
|
private void load(RulesetStore rulesets, Bindable<RulesetInfo> parentRuleset)
|
||||||
{
|
{
|
||||||
this.rulesets = rulesets;
|
this.rulesets = rulesets;
|
||||||
@ -82,11 +82,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
|
|
||||||
ruleset.ValueChanged += rulesetChanged;
|
ruleset.ValueChanged += rulesetChanged;
|
||||||
ruleset.DisabledChanged += disabledChanged;
|
ruleset.DisabledChanged += disabledChanged;
|
||||||
|
ruleset.BindTo(parentRuleset);
|
||||||
if (parentRuleset != null)
|
|
||||||
ruleset.BindTo(parentRuleset);
|
|
||||||
else
|
|
||||||
ruleset.Value = rulesets.AvailableRulesets.FirstOrDefault();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||||
|
@ -84,11 +84,8 @@ namespace osu.Game.Screens
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable<RulesetInfo> ruleset)
|
private void load(BindableBeatmap beatmap, OsuGame osu, AudioManager audio, Bindable<RulesetInfo> ruleset)
|
||||||
{
|
{
|
||||||
if (beatmap != null)
|
Beatmap.BindTo(beatmap);
|
||||||
Beatmap.BindTo(beatmap);
|
Ruleset.BindTo(ruleset);
|
||||||
|
|
||||||
if (ruleset != null)
|
|
||||||
Ruleset.BindTo(ruleset);
|
|
||||||
|
|
||||||
if (osu != null)
|
if (osu != null)
|
||||||
{
|
{
|
||||||
|
@ -55,8 +55,7 @@ namespace osu.Game.Screens.Select
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load([CanBeNull] Bindable<RulesetInfo> parentRuleset)
|
private void load([CanBeNull] Bindable<RulesetInfo> parentRuleset)
|
||||||
{
|
{
|
||||||
if (parentRuleset != null)
|
ruleset.BindTo(parentRuleset);
|
||||||
ruleset.BindTo(parentRuleset);
|
|
||||||
ruleset.ValueChanged += _ => updateDisplay();
|
ruleset.ValueChanged += _ => updateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ namespace osu.Game.Screens.Select
|
|||||||
private readonly TabControl<GroupMode> groupTabs;
|
private readonly TabControl<GroupMode> groupTabs;
|
||||||
|
|
||||||
private SortMode sort = SortMode.Title;
|
private SortMode sort = SortMode.Title;
|
||||||
|
|
||||||
public SortMode Sort
|
public SortMode Sort
|
||||||
{
|
{
|
||||||
get { return sort; }
|
get { return sort; }
|
||||||
@ -43,6 +44,7 @@ namespace osu.Game.Screens.Select
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GroupMode group = GroupMode.All;
|
private GroupMode group = GroupMode.All;
|
||||||
|
|
||||||
public GroupMode Group
|
public GroupMode Group
|
||||||
{
|
{
|
||||||
get { return group; }
|
get { return group; }
|
||||||
@ -69,7 +71,8 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private readonly SearchTextBox searchTextBox;
|
private readonly SearchTextBox searchTextBox;
|
||||||
|
|
||||||
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) => base.ReceiveMouseInputAt(screenSpacePos) || groupTabs.ReceiveMouseInputAt(screenSpacePos) || sortTabs.ReceiveMouseInputAt(screenSpacePos);
|
public override bool ReceiveMouseInputAt(Vector2 screenSpacePos) =>
|
||||||
|
base.ReceiveMouseInputAt(screenSpacePos) || groupTabs.ReceiveMouseInputAt(screenSpacePos) || sortTabs.ReceiveMouseInputAt(screenSpacePos);
|
||||||
|
|
||||||
public FilterControl()
|
public FilterControl()
|
||||||
{
|
{
|
||||||
@ -177,8 +180,7 @@ namespace osu.Game.Screens.Select
|
|||||||
showConverted = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps);
|
showConverted = config.GetBindable<bool>(OsuSetting.ShowConvertedBeatmaps);
|
||||||
showConverted.ValueChanged += val => updateCriteria();
|
showConverted.ValueChanged += val => updateCriteria();
|
||||||
|
|
||||||
if (parentRuleset != null)
|
ruleset.BindTo(parentRuleset);
|
||||||
ruleset.BindTo(parentRuleset);
|
|
||||||
ruleset.ValueChanged += val => updateCriteria();
|
ruleset.ValueChanged += val => updateCriteria();
|
||||||
ruleset.TriggerChange();
|
ruleset.TriggerChange();
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
private ScheduledDelegate showScoresDelegate;
|
private ScheduledDelegate showScoresDelegate;
|
||||||
|
|
||||||
private IEnumerable<Score> scores;
|
private IEnumerable<Score> scores;
|
||||||
|
|
||||||
public IEnumerable<Score> Scores
|
public IEnumerable<Score> Scores
|
||||||
{
|
{
|
||||||
get { return scores; }
|
get { return scores; }
|
||||||
@ -196,9 +197,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
{
|
{
|
||||||
this.api = api;
|
this.api = api;
|
||||||
|
|
||||||
if (parentRuleset != null)
|
ruleset.BindTo(parentRuleset);
|
||||||
ruleset.BindTo(parentRuleset);
|
|
||||||
|
|
||||||
ruleset.ValueChanged += _ => updateScores();
|
ruleset.ValueChanged += _ => updateScores();
|
||||||
|
|
||||||
if (api != null)
|
if (api != null)
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Audio;
|
using osu.Framework.Audio;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -13,6 +16,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
private readonly OsuTestBeatmap beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap());
|
private readonly OsuTestBeatmap beatmap = new OsuTestBeatmap(new DummyWorkingBeatmap());
|
||||||
protected BindableBeatmap Beatmap => beatmap;
|
protected BindableBeatmap Beatmap => beatmap;
|
||||||
|
|
||||||
|
private readonly Bindable<RulesetInfo> ruleset = new Bindable<RulesetInfo>();
|
||||||
|
|
||||||
protected DependencyContainer Dependencies { get; private set; }
|
protected DependencyContainer Dependencies { get; private set; }
|
||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||||
@ -22,13 +27,17 @@ namespace osu.Game.Tests.Visual
|
|||||||
Dependencies.CacheAs<BindableBeatmap>(beatmap);
|
Dependencies.CacheAs<BindableBeatmap>(beatmap);
|
||||||
Dependencies.CacheAs<IBindableBeatmap>(beatmap);
|
Dependencies.CacheAs<IBindableBeatmap>(beatmap);
|
||||||
|
|
||||||
|
Dependencies.CacheAs(ruleset);
|
||||||
|
|
||||||
return Dependencies;
|
return Dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(AudioManager audioManager)
|
private void load(AudioManager audioManager, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
beatmap.SetAudioManager(audioManager);
|
beatmap.SetAudioManager(audioManager);
|
||||||
|
|
||||||
|
ruleset.Value = rulesets.AvailableRulesets.First();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
|
Loading…
Reference in New Issue
Block a user