mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Mark CreateConfig()
return type as nullable because it's not required all ruleset to implement.
Also, remove nullable disable annotation for all using classes. Setting store can be nullable because `RulesetConfigManager()` can accept null setting store.
This commit is contained in:
parent
857377e145
commit
d39f53f1f0
@ -252,7 +252,7 @@ namespace osu.Game.Rulesets
|
|||||||
/// Creates the <see cref="IRulesetConfigManager"/> for this <see cref="Ruleset"/>.
|
/// Creates the <see cref="IRulesetConfigManager"/> for this <see cref="Ruleset"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="settings">The <see cref="SettingsStore"/> to store the settings.</param>
|
/// <param name="settings">The <see cref="SettingsStore"/> to store the settings.</param>
|
||||||
public virtual IRulesetConfigManager CreateConfig(SettingsStore settings) => null;
|
public virtual IRulesetConfigManager? CreateConfig(SettingsStore? settings) => null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A unique short name to reference this ruleset in online requests.
|
/// A unique short name to reference this ruleset in online requests.
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -18,7 +16,7 @@ namespace osu.Game.Rulesets
|
|||||||
private readonly RealmAccess realm;
|
private readonly RealmAccess realm;
|
||||||
private readonly RulesetStore rulesets;
|
private readonly RulesetStore rulesets;
|
||||||
|
|
||||||
private readonly Dictionary<string, IRulesetConfigManager> configCache = new Dictionary<string, IRulesetConfigManager>();
|
private readonly Dictionary<string, IRulesetConfigManager?> configCache = new Dictionary<string, IRulesetConfigManager?>();
|
||||||
|
|
||||||
public RulesetConfigCache(RealmAccess realm, RulesetStore rulesets)
|
public RulesetConfigCache(RealmAccess realm, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
@ -42,7 +40,7 @@ namespace osu.Game.Rulesets
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IRulesetConfigManager GetConfigFor(Ruleset ruleset)
|
public IRulesetConfigManager? GetConfigFor(Ruleset ruleset)
|
||||||
{
|
{
|
||||||
if (!IsLoaded)
|
if (!IsLoaded)
|
||||||
throw new InvalidOperationException($@"Cannot retrieve {nameof(IRulesetConfigManager)} before {nameof(RulesetConfigCache)} has loaded");
|
throw new InvalidOperationException($@"Cannot retrieve {nameof(IRulesetConfigManager)} before {nameof(RulesetConfigCache)} has loaded");
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Configuration;
|
using osu.Game.Rulesets.Configuration;
|
||||||
@ -14,8 +12,8 @@ namespace osu.Game.Tests.Rulesets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class TestRulesetConfigCache : IRulesetConfigCache
|
public class TestRulesetConfigCache : IRulesetConfigCache
|
||||||
{
|
{
|
||||||
private readonly ConcurrentDictionary<string, IRulesetConfigManager> configCache = new ConcurrentDictionary<string, IRulesetConfigManager>();
|
private readonly ConcurrentDictionary<string, IRulesetConfigManager?> configCache = new ConcurrentDictionary<string, IRulesetConfigManager?>();
|
||||||
|
|
||||||
public IRulesetConfigManager GetConfigFor(Ruleset ruleset) => configCache.GetOrAdd(ruleset.ShortName, _ => ruleset.CreateConfig(null));
|
public IRulesetConfigManager? GetConfigFor(Ruleset ruleset) => configCache.GetOrAdd(ruleset.ShortName, _ => ruleset.CreateConfig(null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user