1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +08:00

Merge branch 'master' into realm-ruleset-setting-short-name

This commit is contained in:
Dean Herbert 2021-11-23 14:55:36 +09:00
commit f264b128c2
16 changed files with 135 additions and 122 deletions

View File

@ -74,6 +74,24 @@ namespace osu.Game.Tests.Database
}); });
} }
[Test]
public void TestAccessFileAfterImport()
{
RunTestWithRealmAsync(async (realmFactory, storage) =>
{
using var importer = new BeatmapImporter(realmFactory, storage);
using var store = new RealmRulesetStore(realmFactory, storage);
var imported = await LoadOszIntoStore(importer, realmFactory.Context);
var beatmap = imported.Beatmaps.First();
var file = beatmap.File;
Assert.NotNull(file);
Assert.AreEqual(beatmap.Hash, file!.File.Hash);
});
}
[Test] [Test]
public void TestImportThenDelete() public void TestImportThenDelete()
{ {

View File

@ -55,7 +55,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
new Drawable[] new Drawable[]
{ {
recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) recordingManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
Recorder = recorder = new TestReplayRecorder(new Score Recorder = recorder = new TestReplayRecorder(new Score
{ {
@ -89,7 +89,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}, },
new Drawable[] new Drawable[]
{ {
playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) playbackManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
ReplayInputHandler = new TestFramedReplayInputHandler(replay) ReplayInputHandler = new TestFramedReplayInputHandler(replay)
{ {

View File

@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
new Drawable[] new Drawable[]
{ {
recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) recordingManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
Recorder = new TestReplayRecorder(new Score Recorder = new TestReplayRecorder(new Score
{ {
@ -80,7 +80,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}, },
new Drawable[] new Drawable[]
{ {
playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) playbackManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
ReplayInputHandler = new TestFramedReplayInputHandler(replay) ReplayInputHandler = new TestFramedReplayInputHandler(replay)
{ {

View File

@ -109,7 +109,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{ {
new Drawable[] new Drawable[]
{ {
recordingManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) recordingManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
Recorder = recorder = new TestReplayRecorder Recorder = recorder = new TestReplayRecorder
{ {
@ -139,7 +139,7 @@ namespace osu.Game.Tests.Visual.Gameplay
}, },
new Drawable[] new Drawable[]
{ {
playbackManager = new TestRulesetInputManager(new TestSceneModSettings.TestRulesetInfo(), 0, SimultaneousBindingMode.Unique) playbackManager = new TestRulesetInputManager(TestSceneModSettings.CreateTestRulesetInfo(), 0, SimultaneousBindingMode.Unique)
{ {
Clock = new FramedClock(manualClock), Clock = new FramedClock(manualClock),
ReplayInputHandler = replayHandler = new TestFramedReplayInputHandler(replay) ReplayInputHandler = replayHandler = new TestFramedReplayInputHandler(replay)

View File

@ -78,9 +78,9 @@ namespace osu.Game.Tests.Visual.SongSelect
{ {
AddStep("store selection", () => selection = carousel.SelectedBeatmapInfo); AddStep("store selection", () => selection = carousel.SelectedBeatmapInfo);
if (isIterating) if (isIterating)
AddUntilStep("selection changed", () => carousel.SelectedBeatmapInfo != selection); AddUntilStep("selection changed", () => !carousel.SelectedBeatmapInfo.Equals(selection));
else else
AddUntilStep("selection not changed", () => carousel.SelectedBeatmapInfo == selection); AddUntilStep("selection not changed", () => carousel.SelectedBeatmapInfo.Equals(selection));
} }
} }
} }
@ -412,7 +412,8 @@ namespace osu.Game.Tests.Visual.SongSelect
for (int i = 0; i < 20; i++) for (int i = 0; i < 20; i++)
{ {
var set = createTestBeatmapSet(i); // index + 1 because we are using OnlineID which should never be zero.
var set = createTestBeatmapSet(i + 1);
set.Metadata.Artist = "same artist"; set.Metadata.Artist = "same artist";
set.Metadata.Title = "same title"; set.Metadata.Title = "same title";
sets.Add(set); sets.Add(set);
@ -421,10 +422,10 @@ namespace osu.Game.Tests.Visual.SongSelect
loadBeatmaps(sets); loadBeatmaps(sets);
AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false)); AddStep("Sort by artist", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Artist }, false));
AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.ID == index).All(b => b)); AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.OnlineID == index + 1).All(b => b));
AddStep("Sort by title", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Title }, false)); AddStep("Sort by title", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Title }, false));
AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.ID == index).All(b => b)); AddAssert("Items remain in original order", () => carousel.BeatmapSets.Select((set, index) => set.OnlineID == index + 1).All(b => b));
} }
[Test] [Test]
@ -443,12 +444,12 @@ namespace osu.Game.Tests.Visual.SongSelect
loadBeatmaps(sets); loadBeatmaps(sets);
AddStep("Filter to normal", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Normal" }, false)); AddStep("Filter to normal", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Normal" }, false));
AddAssert("Check first set at end", () => carousel.BeatmapSets.First() == sets.Last()); AddAssert("Check first set at end", () => carousel.BeatmapSets.First().Equals(sets.Last()));
AddAssert("Check last set at start", () => carousel.BeatmapSets.Last() == sets.First()); AddAssert("Check last set at start", () => carousel.BeatmapSets.Last().Equals(sets.First()));
AddStep("Filter to insane", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Insane" }, false)); AddStep("Filter to insane", () => carousel.Filter(new FilterCriteria { Sort = SortMode.Difficulty, SearchText = "Insane" }, false));
AddAssert("Check first set at start", () => carousel.BeatmapSets.First() == sets.First()); AddAssert("Check first set at start", () => carousel.BeatmapSets.First().Equals(sets.First()));
AddAssert("Check last set at end", () => carousel.BeatmapSets.Last() == sets.Last()); AddAssert("Check last set at end", () => carousel.BeatmapSets.Last().Equals(sets.Last()));
} }
[Test] [Test]
@ -662,7 +663,7 @@ namespace osu.Game.Tests.Visual.SongSelect
eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID); eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID);
}); });
AddAssert("selection changed", () => carousel.SelectedBeatmapInfo != manySets.First().Beatmaps.First()); AddAssert("selection changed", () => !carousel.SelectedBeatmapInfo.Equals(manySets.First().Beatmaps.First()));
} }
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 2); AddAssert("Selection was random", () => eagerSelectedIDs.Count > 2);
@ -759,13 +760,13 @@ namespace osu.Game.Tests.Visual.SongSelect
} }
private void ensureRandomFetchSuccess() => private void ensureRandomFetchSuccess() =>
AddAssert("ensure prev random fetch worked", () => selectedSets.Peek() == carousel.SelectedBeatmapSet); AddAssert("ensure prev random fetch worked", () => selectedSets.Peek().Equals(carousel.SelectedBeatmapSet));
private void waitForSelection(int set, int? diff = null) => private void waitForSelection(int set, int? diff = null) =>
AddUntilStep($"selected is set{set}{(diff.HasValue ? $" diff{diff.Value}" : "")}", () => AddUntilStep($"selected is set{set}{(diff.HasValue ? $" diff{diff.Value}" : "")}", () =>
{ {
if (diff != null) if (diff != null)
return carousel.SelectedBeatmapInfo == carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Skip(diff.Value - 1).First(); return carousel.SelectedBeatmapInfo.Equals(carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Skip(diff.Value - 1).First());
return carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Contains(carousel.SelectedBeatmapInfo); return carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Contains(carousel.SelectedBeatmapInfo);
}); });

View File

@ -148,7 +148,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select next and enter", () => AddStep("select next and enter", () =>
{ {
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>() InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
.First(b => ((CarouselBeatmap)b.Item).BeatmapInfo != songSelect.Carousel.SelectedBeatmapInfo)); .First(b => !((CarouselBeatmap)b.Item).BeatmapInfo.Equals(songSelect.Carousel.SelectedBeatmapInfo)));
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
@ -175,7 +175,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep("select next and enter", () => AddStep("select next and enter", () =>
{ {
InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>() InputManager.MoveMouseTo(songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>()
.First(b => ((CarouselBeatmap)b.Item).BeatmapInfo != songSelect.Carousel.SelectedBeatmapInfo)); .First(b => !((CarouselBeatmap)b.Item).BeatmapInfo.Equals(songSelect.Carousel.SelectedBeatmapInfo)));
InputManager.PressButton(MouseButton.Left); InputManager.PressButton(MouseButton.Left);
@ -644,7 +644,7 @@ namespace osu.Game.Tests.Visual.SongSelect
InputManager.Click(MouseButton.Left); InputManager.Click(MouseButton.Left);
}); });
AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmapInfo == filteredBeatmap); AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(filteredBeatmap));
} }
[Test] [Test]
@ -858,7 +858,7 @@ namespace osu.Game.Tests.Visual.SongSelect
AddUntilStep("wait for difficulty panels visible", () => songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>().Any()); AddUntilStep("wait for difficulty panels visible", () => songSelect.Carousel.ChildrenOfType<DrawableCarouselBeatmap>().Any());
} }
private int getBeatmapIndex(BeatmapSetInfo set, BeatmapInfo info) => set.Beatmaps.FindIndex(b => b == info); private int getBeatmapIndex(BeatmapSetInfo set, BeatmapInfo info) => set.Beatmaps.IndexOf(info);
private int getCurrentBeatmapIndex() => getBeatmapIndex(songSelect.Carousel.SelectedBeatmapSet, songSelect.Carousel.SelectedBeatmapInfo); private int getCurrentBeatmapIndex() => getBeatmapIndex(songSelect.Carousel.SelectedBeatmapSet, songSelect.Carousel.SelectedBeatmapInfo);

View File

@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual.UserInterface
public void SetUp() => Schedule(() => public void SetUp() => Schedule(() =>
{ {
SelectedMods.Value = Array.Empty<Mod>(); SelectedMods.Value = Array.Empty<Mod>();
Ruleset.Value = new TestRulesetInfo(); Ruleset.Value = CreateTestRulesetInfo();
}); });
[Test] [Test]
@ -170,40 +170,32 @@ namespace osu.Game.Tests.Visual.UserInterface
ModSettingsContainer.Parent.Width = newWidth; ModSettingsContainer.Parent.Width = newWidth;
} }
public class TestRulesetInfo : RulesetInfo public static RulesetInfo CreateTestRulesetInfo() => new TestCustomisableModRuleset().RulesetInfo;
public class TestCustomisableModRuleset : Ruleset
{ {
public override Ruleset CreateInstance() => new TestCustomisableModRuleset(); public override IEnumerable<Mod> GetModsFor(ModType type)
public TestRulesetInfo()
{ {
Available = true; if (type == ModType.Conversion)
}
public class TestCustomisableModRuleset : Ruleset
{
public override IEnumerable<Mod> GetModsFor(ModType type)
{ {
if (type == ModType.Conversion) return new Mod[]
{ {
return new Mod[] new TestModCustomisable1(),
{ new TestModCustomisable2()
new TestModCustomisable1(), };
new TestModCustomisable2()
};
}
return Array.Empty<Mod>();
} }
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => throw new NotImplementedException(); return Array.Empty<Mod>();
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => throw new NotImplementedException();
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => throw new NotImplementedException();
public override string Description { get; } = "test";
public override string ShortName { get; } = "tst";
} }
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => throw new NotImplementedException();
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => throw new NotImplementedException();
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => throw new NotImplementedException();
public override string Description { get; } = "test";
public override string ShortName { get; } = "tst";
} }
private class TestModCustomisable1 : TestModCustomisable private class TestModCustomisable1 : TestModCustomisable

View File

@ -38,7 +38,7 @@ namespace osu.Game.Beatmaps
CircleSize = 0, CircleSize = 0,
OverallDifficulty = 0, OverallDifficulty = 0,
}, },
Ruleset = new DummyRulesetInfo() Ruleset = new DummyRuleset().RulesetInfo
}, audio) }, audio)
{ {
this.textures = textures; this.textures = textures;
@ -54,42 +54,37 @@ namespace osu.Game.Beatmaps
public override Stream GetStream(string storagePath) => null; public override Stream GetStream(string storagePath) => null;
private class DummyRulesetInfo : RulesetInfo private class DummyRuleset : Ruleset
{ {
public override Ruleset CreateInstance() => new DummyRuleset(); public override IEnumerable<Mod> GetModsFor(ModType type) => Array.Empty<Mod>();
private class DummyRuleset : Ruleset public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null)
{ {
public override IEnumerable<Mod> GetModsFor(ModType type) => Array.Empty<Mod>(); throw new NotImplementedException();
}
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new DummyBeatmapConverter { Beatmap = beatmap };
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null;
public override string Description => "dummy";
public override string ShortName => "dummy";
private class DummyBeatmapConverter : IBeatmapConverter
{
public event Action<HitObject, IEnumerable<HitObject>> ObjectConverted;
public IBeatmap Beatmap { get; set; }
public bool CanConvert() => true;
public IBeatmap Convert(CancellationToken cancellationToken = default)
{ {
throw new NotImplementedException(); foreach (var obj in Beatmap.HitObjects)
} ObjectConverted?.Invoke(obj, obj.Yield());
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new DummyBeatmapConverter { Beatmap = beatmap }; return Beatmap;
public override DifficultyCalculator CreateDifficultyCalculator(IWorkingBeatmap beatmap) => null;
public override string Description => "dummy";
public override string ShortName => "dummy";
private class DummyBeatmapConverter : IBeatmapConverter
{
public event Action<HitObject, IEnumerable<HitObject>> ObjectConverted;
public IBeatmap Beatmap { get; set; }
public bool CanConvert() => true;
public IBeatmap Convert(CancellationToken cancellationToken = default)
{
foreach (var obj in Beatmap.HitObjects)
ObjectConverted?.Invoke(obj, obj.Yield());
return Beatmap;
}
} }
} }
} }

View File

@ -26,7 +26,7 @@ namespace osu.Game.Configuration
protected override void InitialiseDefaults() protected override void InitialiseDefaults()
{ {
// UI/selection defaults // UI/selection defaults
SetDefault(OsuSetting.Ruleset, 0, 0, int.MaxValue); SetDefault(OsuSetting.Ruleset, string.Empty);
SetDefault(OsuSetting.Skin, 0, -1, int.MaxValue); SetDefault(OsuSetting.Skin, 0, -1, int.MaxValue);
SetDefault(OsuSetting.BeatmapDetailTab, PlayBeatmapDetailArea.TabType.Details); SetDefault(OsuSetting.BeatmapDetailTab, PlayBeatmapDetailArea.TabType.Details);

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Testing; using osu.Framework.Testing;
@ -35,6 +36,9 @@ namespace osu.Game.Models
public RealmBeatmapSet? BeatmapSet { get; set; } public RealmBeatmapSet? BeatmapSet { get; set; }
[Ignored]
public RealmNamedFileUsage? File => BeatmapSet?.Files.First(f => f.File.Hash == Hash);
public BeatmapSetOnlineStatus Status public BeatmapSetOnlineStatus Status
{ {
get => (BeatmapSetOnlineStatus)StatusInt; get => (BeatmapSetOnlineStatus)StatusInt;

View File

@ -4,59 +4,58 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using osu.Framework.Configuration;
using osu.Framework.Screens;
using osu.Game.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays;
using osu.Framework.Logging;
using osu.Framework.Allocation;
using osu.Game.Overlays.Toolbar;
using osu.Game.Screens;
using osu.Game.Screens.Menu;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Humanizer; using Humanizer;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Configuration;
using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Logging;
using osu.Framework.Screens;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Collections; using osu.Game.Collections;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.UserInterface; using osu.Game.Graphics.UserInterface;
using osu.Game.Input; using osu.Game.Input;
using osu.Game.Overlays.Notifications;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Online.Chat;
using osu.Game.Overlays.Music;
using osu.Game.Skinning;
using osuTK.Graphics;
using osu.Game.Overlays.Volume;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
using osu.Game.Screens.Select;
using osu.Game.Updater;
using osu.Game.Utils;
using LogLevel = osu.Framework.Logging.LogLevel;
using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO; using osu.Game.IO;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses; using osu.Game.Online.API.Requests.Responses;
using osu.Game.Online.Chat;
using osu.Game.Overlays;
using osu.Game.Overlays.Music;
using osu.Game.Overlays.Notifications;
using osu.Game.Overlays.Toolbar;
using osu.Game.Overlays.Volume;
using osu.Game.Performance; using osu.Game.Performance;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens;
using osu.Game.Screens.Menu;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
using osu.Game.Screens.Select;
using osu.Game.Skinning;
using osu.Game.Skinning.Editor; using osu.Game.Skinning.Editor;
using osu.Game.Updater;
using osu.Game.Users; using osu.Game.Users;
using osu.Game.Utils;
using osuTK.Graphics;
namespace osu.Game namespace osu.Game
{ {
@ -158,7 +157,7 @@ namespace osu.Game
[CanBeNull] [CanBeNull]
private IntroScreen introScreen; private IntroScreen introScreen;
private Bindable<int> configRuleset; private Bindable<string> configRuleset;
private Bindable<float> uiScale; private Bindable<float> uiScale;
@ -222,10 +221,13 @@ namespace osu.Game
dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 }); dependencies.Cache(osuLogo = new OsuLogo { Alpha = 0 });
// bind config int to database RulesetInfo // bind config int to database RulesetInfo
configRuleset = LocalConfig.GetBindable<int>(OsuSetting.Ruleset); configRuleset = LocalConfig.GetBindable<string>(OsuSetting.Ruleset);
uiScale = LocalConfig.GetBindable<float>(OsuSetting.UIScale); uiScale = LocalConfig.GetBindable<float>(OsuSetting.UIScale);
var preferredRuleset = RulesetStore.GetRuleset(configRuleset.Value); var preferredRuleset = int.TryParse(configRuleset.Value, out int rulesetId)
// int parsing can be removed 20220522
? RulesetStore.GetRuleset(rulesetId)
: RulesetStore.GetRuleset(configRuleset.Value);
try try
{ {
@ -238,7 +240,7 @@ namespace osu.Game
Ruleset.Value = RulesetStore.AvailableRulesets.First(); Ruleset.Value = RulesetStore.AvailableRulesets.First();
} }
Ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ID ?? 0; Ruleset.ValueChanged += r => configRuleset.Value = r.NewValue.ShortName;
// bind config int to database SkinInfo // bind config int to database SkinInfo
configSkin = LocalConfig.GetBindable<int>(OsuSetting.Skin); configSkin = LocalConfig.GetBindable<int>(OsuSetting.Skin);

View File

@ -5,7 +5,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation; using osu.Framework.Localisation;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Overlays.Settings.Sections.Debug; using osu.Game.Overlays.Settings.Sections.DebugSettings;
namespace osu.Game.Overlays.Settings.Sections namespace osu.Game.Overlays.Settings.Sections
{ {

View File

@ -9,7 +9,7 @@ using osu.Framework.Screens;
using osu.Game.Localisation; using osu.Game.Localisation;
using osu.Game.Screens.Import; using osu.Game.Screens.Import;
namespace osu.Game.Overlays.Settings.Sections.Debug namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{ {
public class GeneralSettings : SettingsSubsection public class GeneralSettings : SettingsSubsection
{ {

View File

@ -8,7 +8,7 @@ using osu.Framework.Localisation;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Localisation; using osu.Game.Localisation;
namespace osu.Game.Overlays.Settings.Sections.Debug namespace osu.Game.Overlays.Settings.Sections.DebugSettings
{ {
public class MemorySettings : SettingsSubsection public class MemorySettings : SettingsSubsection
{ {

View File

@ -39,7 +39,7 @@ namespace osu.Game.Rulesets
{ {
public RulesetInfo RulesetInfo { get; internal set; } public RulesetInfo RulesetInfo { get; internal set; }
private static readonly ConcurrentDictionary<int, IMod[]> mod_reference_cache = new ConcurrentDictionary<int, IMod[]>(); private static readonly ConcurrentDictionary<string, IMod[]> mod_reference_cache = new ConcurrentDictionary<string, IMod[]>();
/// <summary> /// <summary>
/// A queryable source containing all available mods. /// A queryable source containing all available mods.
@ -49,11 +49,12 @@ namespace osu.Game.Rulesets
{ {
get get
{ {
if (!(RulesetInfo.ID is int id)) // Is the case for many test usages.
if (string.IsNullOrEmpty(ShortName))
return CreateAllMods(); return CreateAllMods();
if (!mod_reference_cache.TryGetValue(id, out var mods)) if (!mod_reference_cache.TryGetValue(ShortName, out var mods))
mod_reference_cache[id] = mods = CreateAllMods().Cast<IMod>().ToArray(); mod_reference_cache[ShortName] = mods = CreateAllMods().Cast<IMod>().ToArray();
return mods; return mods;
} }

View File

@ -10,7 +10,7 @@ using osu.Framework.Testing;
namespace osu.Game.Rulesets namespace osu.Game.Rulesets
{ {
[ExcludeFromDynamicCompile] [ExcludeFromDynamicCompile]
public class RulesetInfo : IEquatable<RulesetInfo>, IRulesetInfo public sealed class RulesetInfo : IEquatable<RulesetInfo>, IRulesetInfo
{ {
public int? ID { get; set; } public int? ID { get; set; }
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets
public bool Available { get; set; } public bool Available { get; set; }
// TODO: this should probably be moved to RulesetStore. // TODO: this should probably be moved to RulesetStore.
public virtual Ruleset CreateInstance() public Ruleset CreateInstance()
{ {
if (!Available) return null; if (!Available) return null;