2019-06-13 04:23:01 +08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2019-06-13 04:23:01 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
|
using osu.Framework.Allocation;
|
2022-06-29 17:51:07 +08:00
|
|
|
|
using osu.Framework.Logging;
|
2023-01-13 04:21:33 +08:00
|
|
|
|
using osu.Game.Extensions;
|
2019-06-13 04:23:01 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets
|
|
|
|
|
{
|
|
|
|
|
public abstract partial class RulesetSelector : TabControl<RulesetInfo>
|
|
|
|
|
{
|
2019-06-26 16:52:25 +08:00
|
|
|
|
[Resolved]
|
|
|
|
|
protected RulesetStore Rulesets { get; private set; }
|
2019-06-13 04:23:01 +08:00
|
|
|
|
|
|
|
|
|
protected override Dropdown<RulesetInfo> CreateDropdown() => null;
|
|
|
|
|
|
2023-01-13 03:44:41 +08:00
|
|
|
|
private readonly bool legacyOnly;
|
|
|
|
|
|
|
|
|
|
public RulesetSelector(bool legacyOnly = false)
|
|
|
|
|
{
|
|
|
|
|
this.legacyOnly = legacyOnly;
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-13 04:23:01 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2019-06-26 16:52:25 +08:00
|
|
|
|
private void load()
|
2019-06-13 04:23:01 +08:00
|
|
|
|
{
|
2022-06-29 17:56:15 +08:00
|
|
|
|
foreach (var ruleset in Rulesets.AvailableRulesets)
|
2022-06-29 17:51:07 +08:00
|
|
|
|
{
|
2023-01-13 04:21:33 +08:00
|
|
|
|
if (!ruleset.IsLegacyRuleset() && legacyOnly)
|
2023-01-13 03:44:41 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
2022-06-29 17:51:07 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
2022-06-29 17:56:15 +08:00
|
|
|
|
AddItem(ruleset);
|
2022-06-29 17:51:07 +08:00
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
2022-06-29 17:56:15 +08:00
|
|
|
|
Logger.Log($"Could not create ruleset icon for {ruleset.Name}. Please check for an update from the developer.", level: LogLevel.Error);
|
2022-06-29 17:51:07 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-06-13 04:23:01 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|