mirror of
https://github.com/ppy/osu.git
synced 2025-02-10 11:42:54 +08:00
Merge branch 'master' into remove-local-realm-thread-switch-handling
This commit is contained in:
commit
57c5be39d3
@ -140,10 +140,10 @@ namespace osu.Desktop
|
|||||||
switch (activity)
|
switch (activity)
|
||||||
{
|
{
|
||||||
case UserActivity.InGame game:
|
case UserActivity.InGame game:
|
||||||
return game.Beatmap.ToString();
|
return game.BeatmapInfo.ToString();
|
||||||
|
|
||||||
case UserActivity.Editing edit:
|
case UserActivity.Editing edit:
|
||||||
return edit.Beatmap.ToString();
|
return edit.BeatmapInfo.ToString();
|
||||||
|
|
||||||
case UserActivity.InLobby lobby:
|
case UserActivity.InLobby lobby:
|
||||||
return privacyMode.Value == DiscordRichPresenceMode.Limited ? string.Empty : lobby.Room.Name.Value;
|
return privacyMode.Value == DiscordRichPresenceMode.Limited ? string.Empty : lobby.Room.Name.Value;
|
||||||
|
@ -71,9 +71,9 @@ namespace osu.Game.Rulesets.Mania.Beatmaps
|
|||||||
originalTargetColumns = TargetColumns;
|
originalTargetColumns = TargetColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetColumnCountForNonConvert(BeatmapInfo beatmap)
|
public static int GetColumnCountForNonConvert(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
var roundedCircleSize = Math.Round(beatmap.BaseDifficulty.CircleSize);
|
var roundedCircleSize = Math.Round(beatmapInfo.BaseDifficulty.CircleSize);
|
||||||
return (int)Math.Max(1, roundedCircleSize);
|
return (int)Math.Max(1, roundedCircleSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ namespace osu.Game.Rulesets.Mania
|
|||||||
{
|
{
|
||||||
private FilterCriteria.OptionalRange<float> keys;
|
private FilterCriteria.OptionalRange<float> keys;
|
||||||
|
|
||||||
public bool Matches(BeatmapInfo beatmap)
|
public bool Matches(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
return !keys.HasFilter || (beatmap.RulesetID == new ManiaRuleset().LegacyID && keys.IsInRange(ManiaBeatmapConverter.GetColumnCountForNonConvert(beatmap)));
|
return !keys.HasFilter || (beatmapInfo.RulesetID == new ManiaRuleset().LegacyID && keys.IsInRange(ManiaBeatmapConverter.GetColumnCountForNonConvert(beatmapInfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryParseCustomKeywordCriteria(string key, Operator op, string value)
|
public bool TryParseCustomKeywordCriteria(string key, Operator op, string value)
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
{
|
{
|
||||||
Position = new Vector2(100, 300),
|
Position = new Vector2(100, 300),
|
||||||
},
|
},
|
||||||
accuracyHeatmap = new TestAccuracyHeatmap(new ScoreInfo { Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo })
|
accuracyHeatmap = new TestAccuracyHeatmap(new ScoreInfo { BeatmapInfo = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo })
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
|
@ -86,7 +86,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
|
|
||||||
var manager = osu.Dependencies.Get<BeatmapManager>();
|
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||||
|
|
||||||
BeatmapSetInfo importedSet;
|
ILive<BeatmapSetInfo> importedSet;
|
||||||
|
|
||||||
using (var stream = File.OpenRead(tempPath))
|
using (var stream = File.OpenRead(tempPath))
|
||||||
{
|
{
|
||||||
@ -97,7 +97,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
Assert.IsTrue(File.Exists(tempPath), "Stream source file somehow went missing");
|
Assert.IsTrue(File.Exists(tempPath), "Stream source file somehow went missing");
|
||||||
File.Delete(tempPath);
|
File.Delete(tempPath);
|
||||||
|
|
||||||
var imported = manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.ID);
|
var imported = manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.Value.ID);
|
||||||
|
|
||||||
deleteBeatmapSet(imported, osu);
|
deleteBeatmapSet(imported, osu);
|
||||||
}
|
}
|
||||||
@ -172,8 +172,8 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
ensureLoaded(osu);
|
ensureLoaded(osu);
|
||||||
|
|
||||||
// but contents doesn't, so existing should still be used.
|
// but contents doesn't, so existing should still be used.
|
||||||
Assert.IsTrue(imported.ID == importedSecondTime.ID);
|
Assert.IsTrue(imported.ID == importedSecondTime.Value.ID);
|
||||||
Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Beatmaps.First().ID);
|
Assert.IsTrue(imported.Beatmaps.First().ID == importedSecondTime.Value.Beatmaps.First().ID);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -226,8 +226,8 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
ensureLoaded(osu);
|
ensureLoaded(osu);
|
||||||
|
|
||||||
// check the newly "imported" beatmap is not the original.
|
// check the newly "imported" beatmap is not the original.
|
||||||
Assert.IsTrue(imported.ID != importedSecondTime.ID);
|
Assert.IsTrue(imported.ID != importedSecondTime.Value.ID);
|
||||||
Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Beatmaps.First().ID);
|
Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Value.Beatmaps.First().ID);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -278,8 +278,8 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
ensureLoaded(osu);
|
ensureLoaded(osu);
|
||||||
|
|
||||||
// check the newly "imported" beatmap is not the original.
|
// check the newly "imported" beatmap is not the original.
|
||||||
Assert.IsTrue(imported.ID != importedSecondTime.ID);
|
Assert.IsTrue(imported.ID != importedSecondTime.Value.ID);
|
||||||
Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Beatmaps.First().ID);
|
Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Value.Beatmaps.First().ID);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -329,8 +329,8 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
ensureLoaded(osu);
|
ensureLoaded(osu);
|
||||||
|
|
||||||
// check the newly "imported" beatmap is not the original.
|
// check the newly "imported" beatmap is not the original.
|
||||||
Assert.IsTrue(imported.ID != importedSecondTime.ID);
|
Assert.IsTrue(imported.ID != importedSecondTime.Value.ID);
|
||||||
Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Beatmaps.First().ID);
|
Assert.IsTrue(imported.Beatmaps.First().ID != importedSecondTime.Value.Beatmaps.First().ID);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -570,8 +570,8 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
var imported = await manager.Import(toImport);
|
var imported = await manager.Import(toImport);
|
||||||
|
|
||||||
Assert.NotNull(imported);
|
Assert.NotNull(imported);
|
||||||
Assert.AreEqual(null, imported.Beatmaps[0].OnlineBeatmapID);
|
Assert.AreEqual(null, imported.Value.Beatmaps[0].OnlineBeatmapID);
|
||||||
Assert.AreEqual(null, imported.Beatmaps[1].OnlineBeatmapID);
|
Assert.AreEqual(null, imported.Value.Beatmaps[1].OnlineBeatmapID);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -706,7 +706,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
|
|
||||||
ensureLoaded(osu);
|
ensureLoaded(osu);
|
||||||
|
|
||||||
Assert.IsFalse(imported.Files.Any(f => f.Filename.Contains("subfolder")), "Files contain common subfolder");
|
Assert.IsFalse(imported.Value.Files.Any(f => f.Filename.Contains("subfolder")), "Files contain common subfolder");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -759,8 +759,8 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
|
|
||||||
ensureLoaded(osu);
|
ensureLoaded(osu);
|
||||||
|
|
||||||
Assert.IsFalse(imported.Files.Any(f => f.Filename.Contains("__MACOSX")), "Files contain resource fork folder, which should be ignored");
|
Assert.IsFalse(imported.Value.Files.Any(f => f.Filename.Contains("__MACOSX")), "Files contain resource fork folder, which should be ignored");
|
||||||
Assert.IsFalse(imported.Files.Any(f => f.Filename.Contains("actual_data")), "Files contain common subfolder");
|
Assert.IsFalse(imported.Value.Files.Any(f => f.Filename.Contains("actual_data")), "Files contain common subfolder");
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@ -915,7 +915,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
|
|
||||||
waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
|
waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
|
||||||
|
|
||||||
return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.ID);
|
return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.Value.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<BeatmapSetInfo> LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false)
|
public static async Task<BeatmapSetInfo> LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false)
|
||||||
@ -930,7 +930,7 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
|
|
||||||
waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
|
waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
|
||||||
|
|
||||||
return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.ID);
|
return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.Value.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteBeatmapSet(BeatmapSetInfo imported, OsuGameBase osu)
|
private void deleteBeatmapSet(BeatmapSetInfo imported, OsuGameBase osu)
|
||||||
@ -945,13 +945,13 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
Assert.IsTrue(manager.QueryBeatmapSets(_ => true).First().DeletePending);
|
Assert.IsTrue(manager.QueryBeatmapSets(_ => true).First().DeletePending);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Task createScoreForBeatmap(OsuGameBase osu, BeatmapInfo beatmap)
|
private static Task createScoreForBeatmap(OsuGameBase osu, BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
return ImportScoreTest.LoadScoreIntoOsu(osu, new ScoreInfo
|
return ImportScoreTest.LoadScoreIntoOsu(osu, new ScoreInfo
|
||||||
{
|
{
|
||||||
OnlineScoreID = 2,
|
OnlineScoreID = 2,
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
BeatmapInfoID = beatmap.ID
|
BeatmapInfoID = beatmapInfo.ID
|
||||||
}, new ImportScoreTest.TestArchiveReader());
|
}, new ImportScoreTest.TestArchiveReader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
|||||||
match = shouldMatch;
|
match = shouldMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Matches(BeatmapInfo beatmap) => match;
|
public bool Matches(BeatmapInfo beatmapInfo) => match;
|
||||||
public bool TryParseCustomKeywordCriteria(string key, Operator op, string value) => false;
|
public bool TryParseCustomKeywordCriteria(string key, Operator op, string value) => false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ namespace osu.Game.Tests.NonVisual.Filtering
|
|||||||
{
|
{
|
||||||
public string CustomValue { get; set; }
|
public string CustomValue { get; set; }
|
||||||
|
|
||||||
public bool Matches(BeatmapInfo beatmap) => true;
|
public bool Matches(BeatmapInfo beatmapInfo) => true;
|
||||||
|
|
||||||
public bool TryParseCustomKeywordCriteria(string key, Operator op, string value)
|
public bool TryParseCustomKeywordCriteria(string key, Operator op, string value)
|
||||||
{
|
{
|
||||||
|
@ -156,7 +156,7 @@ namespace osu.Game.Tests.Online
|
|||||||
{
|
{
|
||||||
public TaskCompletionSource<bool> AllowImport = new TaskCompletionSource<bool>();
|
public TaskCompletionSource<bool> AllowImport = new TaskCompletionSource<bool>();
|
||||||
|
|
||||||
public Task<BeatmapSetInfo> CurrentImportTask { get; private set; }
|
public Task<ILive<BeatmapSetInfo>> CurrentImportTask { get; private set; }
|
||||||
|
|
||||||
public TestBeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host = null, WorkingBeatmap defaultBeatmap = null)
|
public TestBeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host = null, WorkingBeatmap defaultBeatmap = null)
|
||||||
: base(storage, contextFactory, rulesets, api, audioManager, resources, host, defaultBeatmap)
|
: base(storage, contextFactory, rulesets, api, audioManager, resources, host, defaultBeatmap)
|
||||||
@ -194,7 +194,7 @@ namespace osu.Game.Tests.Online
|
|||||||
this.testBeatmapManager = testBeatmapManager;
|
this.testBeatmapManager = testBeatmapManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override async Task<BeatmapSetInfo> Import(BeatmapSetInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
public override async Task<ILive<BeatmapSetInfo>> Import(BeatmapSetInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
await testBeatmapManager.AllowImport.Task.ConfigureAwait(false);
|
await testBeatmapManager.AllowImport.Task.ConfigureAwait(false);
|
||||||
return await (testBeatmapManager.CurrentImportTask = base.Import(item, archive, lowPriority, cancellationToken)).ConfigureAwait(false);
|
return await (testBeatmapManager.CurrentImportTask = base.Import(item, archive, lowPriority, cancellationToken)).ConfigureAwait(false);
|
||||||
|
@ -141,7 +141,7 @@ namespace osu.Game.Tests.Scores.IO
|
|||||||
var beatmapManager = osu.Dependencies.Get<BeatmapManager>();
|
var beatmapManager = osu.Dependencies.Get<BeatmapManager>();
|
||||||
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
||||||
|
|
||||||
beatmapManager.Delete(beatmapManager.QueryBeatmapSet(s => s.Beatmaps.Any(b => b.ID == imported.Beatmap.ID)));
|
beatmapManager.Delete(beatmapManager.QueryBeatmapSet(s => s.Beatmaps.Any(b => b.ID == imported.BeatmapInfo.ID)));
|
||||||
Assert.That(scoreManager.Query(s => s.ID == imported.ID).DeletePending, Is.EqualTo(true));
|
Assert.That(scoreManager.Query(s => s.ID == imported.ID).DeletePending, Is.EqualTo(true));
|
||||||
|
|
||||||
var secondImport = await LoadScoreIntoOsu(osu, imported);
|
var secondImport = await LoadScoreIntoOsu(osu, imported);
|
||||||
@ -181,7 +181,7 @@ namespace osu.Game.Tests.Scores.IO
|
|||||||
{
|
{
|
||||||
var beatmapManager = osu.Dependencies.Get<BeatmapManager>();
|
var beatmapManager = osu.Dependencies.Get<BeatmapManager>();
|
||||||
|
|
||||||
score.Beatmap ??= beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
|
score.BeatmapInfo ??= beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
|
||||||
score.Ruleset ??= new OsuRuleset().RulesetInfo;
|
score.Ruleset ??= new OsuRuleset().RulesetInfo;
|
||||||
|
|
||||||
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
||||||
|
@ -196,7 +196,7 @@ namespace osu.Game.Tests.Skins.IO
|
|||||||
private async Task<SkinInfo> loadSkinIntoOsu(OsuGameBase osu, ArchiveReader archive = null)
|
private async Task<SkinInfo> loadSkinIntoOsu(OsuGameBase osu, ArchiveReader archive = null)
|
||||||
{
|
{
|
||||||
var skinManager = osu.Dependencies.Get<SkinManager>();
|
var skinManager = osu.Dependencies.Get<SkinManager>();
|
||||||
return await skinManager.Import(archive);
|
return (await skinManager.Import(archive)).Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
var imported = beatmaps.Import(new ZipArchiveReader(TestResources.OpenResource("Archives/ogg-beatmap.osz"))).Result;
|
var imported = beatmaps.Import(new ZipArchiveReader(TestResources.OpenResource("Archives/ogg-beatmap.osz"))).Result;
|
||||||
beatmap = beatmaps.GetWorkingBeatmap(imported.Beatmaps[0]);
|
beatmap = beatmaps.GetWorkingBeatmap(imported.Value.Beatmaps[0]);
|
||||||
beatmap.LoadTrack();
|
beatmap.LoadTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Tests.Skins
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
var imported = skins.Import(new ZipArchiveReader(TestResources.OpenResource("Archives/ogg-skin.osk"))).Result;
|
var imported = skins.Import(new ZipArchiveReader(TestResources.OpenResource("Archives/ogg-skin.osk"))).Result;
|
||||||
skin = skins.GetSkin(imported);
|
skin = skins.GetSkin(imported.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
@ -232,7 +232,7 @@ namespace osu.Game.Tests.Visual.Background
|
|||||||
AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo
|
AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo
|
||||||
{
|
{
|
||||||
User = new User { Username = "osu!" },
|
User = new User { Username = "osu!" },
|
||||||
Beatmap = new TestBeatmap(Ruleset.Value).BeatmapInfo,
|
BeatmapInfo = new TestBeatmap(Ruleset.Value).BeatmapInfo,
|
||||||
Ruleset = Ruleset.Value,
|
Ruleset = Ruleset.Value,
|
||||||
})));
|
})));
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ namespace osu.Game.Tests.Visual.Background
|
|||||||
private void setupUserSettings()
|
private void setupUserSettings()
|
||||||
{
|
{
|
||||||
AddUntilStep("Song select is current", () => songSelect.IsCurrentScreen());
|
AddUntilStep("Song select is current", () => songSelect.IsCurrentScreen());
|
||||||
AddUntilStep("Song select has selection", () => songSelect.Carousel?.SelectedBeatmap != null);
|
AddUntilStep("Song select has selection", () => songSelect.Carousel?.SelectedBeatmapInfo != null);
|
||||||
AddStep("Set default user settings", () =>
|
AddStep("Set default user settings", () =>
|
||||||
{
|
{
|
||||||
SelectedMods.Value = SelectedMods.Value.Concat(new[] { new OsuModNoFail() }).ToArray();
|
SelectedMods.Value = SelectedMods.Value.Concat(new[] { new OsuModNoFail() }).ToArray();
|
||||||
|
@ -60,7 +60,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Recorder = recorder = new TestReplayRecorder(new Score
|
Recorder = recorder = new TestReplayRecorder(new Score
|
||||||
{
|
{
|
||||||
Replay = replay,
|
Replay = replay,
|
||||||
ScoreInfo = { Beatmap = gameplayState.Beatmap.BeatmapInfo }
|
ScoreInfo = { BeatmapInfo = gameplayState.Beatmap.BeatmapInfo }
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos),
|
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos),
|
||||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
Recorder = new TestReplayRecorder(new Score
|
Recorder = new TestReplayRecorder(new Score
|
||||||
{
|
{
|
||||||
Replay = replay,
|
Replay = replay,
|
||||||
ScoreInfo = { Beatmap = gameplayState.Beatmap.BeatmapInfo }
|
ScoreInfo = { BeatmapInfo = gameplayState.Beatmap.BeatmapInfo }
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos)
|
ScreenSpaceToGamefield = pos => recordingManager.ToLocalSpace(pos)
|
||||||
|
@ -356,7 +356,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
|||||||
internal class TestReplayRecorder : ReplayRecorder<TestAction>
|
internal class TestReplayRecorder : ReplayRecorder<TestAction>
|
||||||
{
|
{
|
||||||
public TestReplayRecorder()
|
public TestReplayRecorder()
|
||||||
: base(new Score { ScoreInfo = { Beatmap = new BeatmapInfo() } })
|
: base(new Score { ScoreInfo = { BeatmapInfo = new BeatmapInfo() } })
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Overlays.Login;
|
using osu.Game.Overlays.Login;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Menus
|
namespace osu.Game.Tests.Visual.Menus
|
||||||
@ -30,12 +31,25 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBasicLogin()
|
public void TestLoginSuccess()
|
||||||
{
|
{
|
||||||
AddStep("logout", () => API.Logout());
|
AddStep("logout", () => API.Logout());
|
||||||
|
|
||||||
AddStep("enter password", () => loginPanel.ChildrenOfType<OsuPasswordTextBox>().First().Text = "password");
|
AddStep("enter password", () => loginPanel.ChildrenOfType<OsuPasswordTextBox>().First().Text = "password");
|
||||||
AddStep("submit", () => loginPanel.ChildrenOfType<OsuButton>().First(b => b.Text.ToString() == "Sign in").TriggerClick());
|
AddStep("submit", () => loginPanel.ChildrenOfType<OsuButton>().First(b => b.Text.ToString() == "Sign in").TriggerClick());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestLoginFailure()
|
||||||
|
{
|
||||||
|
AddStep("logout", () =>
|
||||||
|
{
|
||||||
|
API.Logout();
|
||||||
|
((DummyAPIAccess)API).FailNextLogin();
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("enter password", () => loginPanel.ChildrenOfType<OsuPasswordTextBox>().First().Text = "password");
|
||||||
|
AddStep("submit", () => loginPanel.ChildrenOfType<OsuButton>().First(b => b.Text.ToString() == "Sign in").TriggerClick());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
AddStep("import beatmap with track", () =>
|
AddStep("import beatmap with track", () =>
|
||||||
{
|
{
|
||||||
var setWithTrack = Game.BeatmapManager.Import(new ImportTask(TestResources.GetTestBeatmapForImport())).Result;
|
var setWithTrack = Game.BeatmapManager.Import(new ImportTask(TestResources.GetTestBeatmapForImport())).Result;
|
||||||
Beatmap.Value = Game.BeatmapManager.GetWorkingBeatmap(setWithTrack.Beatmaps.First());
|
Beatmap.Value = Game.BeatmapManager.GetWorkingBeatmap(setWithTrack.Value.Beatmaps.First());
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("bind to track change", () =>
|
AddStep("bind to track change", () =>
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Accuracy = 0.8,
|
Accuracy = 0.8,
|
||||||
MaxCombo = 500,
|
MaxCombo = 500,
|
||||||
Combo = 250,
|
Combo = 250,
|
||||||
Beatmap = beatmapInfo,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User { Username = "Test user" },
|
User = new User { Username = "Test user" },
|
||||||
Date = DateTimeOffset.Now,
|
Date = DateTimeOffset.Now,
|
||||||
OnlineScoreID = 12345,
|
OnlineScoreID = 12345,
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
Accuracy = 0.8,
|
Accuracy = 0.8,
|
||||||
MaxCombo = 500,
|
MaxCombo = 500,
|
||||||
Combo = 250,
|
Combo = 250,
|
||||||
Beatmap = beatmapInfo,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User { Username = "Test user" },
|
User = new User { Username = "Test user" },
|
||||||
Date = DateTimeOffset.Now,
|
Date = DateTimeOffset.Now,
|
||||||
OnlineScoreID = 12345,
|
OnlineScoreID = 12345,
|
||||||
|
@ -126,7 +126,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}).Result;
|
}).Result.Value;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert($"import {i} succeeded", () => imported != null);
|
AddAssert($"import {i} succeeded", () => imported != null);
|
||||||
|
@ -58,7 +58,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
Ruleset = new OsuRuleset().RulesetInfo
|
Ruleset = new OsuRuleset().RulesetInfo
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}).Result;
|
}).Result.Value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,9 +130,9 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
{
|
{
|
||||||
Hash = Guid.NewGuid().ToString(),
|
Hash = Guid.NewGuid().ToString(),
|
||||||
OnlineScoreID = i,
|
OnlineScoreID = i,
|
||||||
Beatmap = beatmap.Beatmaps.First(),
|
BeatmapInfo = beatmap.Beatmaps.First(),
|
||||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||||
}).Result;
|
}).Result.Value;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert($"import {i} succeeded", () => imported != null);
|
AddAssert($"import {i} succeeded", () => imported != null);
|
||||||
|
@ -233,7 +233,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("shown beatmaps of current ruleset", () => overlay.Header.HeaderContent.Picker.Difficulties.All(b => b.Beatmap.Ruleset.Equals(overlay.Header.RulesetSelector.Current.Value)));
|
AddAssert("shown beatmaps of current ruleset", () => overlay.Header.HeaderContent.Picker.Difficulties.All(b => b.BeatmapInfo.Ruleset.Equals(overlay.Header.RulesetSelector.Current.Value)));
|
||||||
AddAssert("left-most beatmap selected", () => overlay.Header.HeaderContent.Picker.Difficulties.First().State == BeatmapPicker.DifficultySelectorState.Selected);
|
AddAssert("left-most beatmap selected", () => overlay.Header.HeaderContent.Picker.Difficulties.First().State == BeatmapPicker.DifficultySelectorState.Selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,10 +58,10 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
var firstBeatmap = createBeatmap();
|
var firstBeatmap = createBeatmap();
|
||||||
var secondBeatmap = createBeatmap();
|
var secondBeatmap = createBeatmap();
|
||||||
|
|
||||||
AddStep("set first set", () => successRate.Beatmap = firstBeatmap);
|
AddStep("set first set", () => successRate.BeatmapInfo = firstBeatmap);
|
||||||
AddAssert("ratings set", () => successRate.Graph.Metrics == firstBeatmap.Metrics);
|
AddAssert("ratings set", () => successRate.Graph.Metrics == firstBeatmap.Metrics);
|
||||||
|
|
||||||
AddStep("set second set", () => successRate.Beatmap = secondBeatmap);
|
AddStep("set second set", () => successRate.BeatmapInfo = secondBeatmap);
|
||||||
AddAssert("ratings set", () => successRate.Graph.Metrics == secondBeatmap.Metrics);
|
AddAssert("ratings set", () => successRate.Graph.Metrics == secondBeatmap.Metrics);
|
||||||
|
|
||||||
static BeatmapInfo createBeatmap() => new BeatmapInfo
|
static BeatmapInfo createBeatmap() => new BeatmapInfo
|
||||||
@ -77,7 +77,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestOnlyFailMetrics()
|
public void TestOnlyFailMetrics()
|
||||||
{
|
{
|
||||||
AddStep("set beatmap", () => successRate.Beatmap = new BeatmapInfo
|
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapMetrics
|
Metrics = new BeatmapMetrics
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestEmptyMetrics()
|
public void TestEmptyMetrics()
|
||||||
{
|
{
|
||||||
AddStep("set beatmap", () => successRate.Beatmap = new BeatmapInfo
|
AddStep("set beatmap", () => successRate.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metrics = new BeatmapMetrics()
|
Metrics = new BeatmapMetrics()
|
||||||
});
|
});
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
PP = 1047.21,
|
PP = 1047.21,
|
||||||
Rank = ScoreRank.SH,
|
Rank = ScoreRank.SH,
|
||||||
Beatmap = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
PP = 134.32,
|
PP = 134.32,
|
||||||
Rank = ScoreRank.A,
|
Rank = ScoreRank.A,
|
||||||
Beatmap = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
PP = 96.83,
|
PP = 96.83,
|
||||||
Rank = ScoreRank.S,
|
Rank = ScoreRank.S,
|
||||||
Beatmap = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
{
|
{
|
||||||
@ -84,7 +84,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
var noPPScore = new ScoreInfo
|
var noPPScore = new ScoreInfo
|
||||||
{
|
{
|
||||||
Rank = ScoreRank.B,
|
Rank = ScoreRank.B,
|
||||||
Beatmap = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
{
|
{
|
||||||
|
@ -117,7 +117,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
|||||||
{
|
{
|
||||||
beatmap.BeatmapInfo.BaseDifficulty.CircleSize = 1;
|
beatmap.BeatmapInfo.BaseDifficulty.CircleSize = 1;
|
||||||
|
|
||||||
importedSet = manager.Import(beatmap.BeatmapInfo.BeatmapSet).Result;
|
importedSet = manager.Import(beatmap.BeatmapInfo.BeatmapSet).Result.Value;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("load room", () =>
|
AddStep("load room", () =>
|
||||||
|
@ -71,7 +71,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
Id = 2,
|
Id = 2,
|
||||||
Username = "peppy",
|
Username = "peppy",
|
||||||
},
|
},
|
||||||
Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo,
|
BeatmapInfo = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo,
|
||||||
Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() },
|
Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() },
|
||||||
TotalScore = 2845370,
|
TotalScore = 2845370,
|
||||||
Accuracy = accuracy,
|
Accuracy = accuracy,
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
|
|
||||||
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||||
{
|
{
|
||||||
Beatmap = createTestBeatmap(author)
|
BeatmapInfo = createTestBeatmap(author)
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
|
|
||||||
AddStep("show excess mods score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo, true)
|
AddStep("show excess mods score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo, true)
|
||||||
{
|
{
|
||||||
Beatmap = createTestBeatmap(author)
|
BeatmapInfo = createTestBeatmap(author)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Current.Value == "mapper_name"));
|
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Current.Value == "mapper_name"));
|
||||||
@ -57,7 +57,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
{
|
{
|
||||||
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
|
||||||
{
|
{
|
||||||
Beatmap = createTestBeatmap(null)
|
BeatmapInfo = createTestBeatmap(null)
|
||||||
}));
|
}));
|
||||||
|
|
||||||
AddAssert("mapped by text not present", () =>
|
AddAssert("mapped by text not present", () =>
|
||||||
@ -79,7 +79,7 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
showPanel(new TestScoreInfo(ruleset.RulesetInfo)
|
showPanel(new TestScoreInfo(ruleset.RulesetInfo)
|
||||||
{
|
{
|
||||||
Mods = mods,
|
Mods = mods,
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmap,
|
||||||
Date = default,
|
Date = default,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -337,8 +337,8 @@ namespace osu.Game.Tests.Visual.Ranking
|
|||||||
public UnrankedSoloResultsScreen(ScoreInfo score)
|
public UnrankedSoloResultsScreen(ScoreInfo score)
|
||||||
: base(score, true)
|
: base(score, true)
|
||||||
{
|
{
|
||||||
Score.Beatmap.OnlineBeatmapID = 0;
|
Score.BeatmapInfo.OnlineBeatmapID = 0;
|
||||||
Score.Beatmap.Status = BeatmapSetOnlineStatus.Pending;
|
Score.BeatmapInfo.Status = BeatmapSetOnlineStatus.Pending;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
@ -51,7 +51,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestNoMod()
|
public void TestNoMod()
|
||||||
{
|
{
|
||||||
AddStep("set beatmap", () => advancedStats.Beatmap = exampleBeatmapInfo);
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
||||||
|
|
||||||
AddStep("no mods selected", () => SelectedMods.Value = Array.Empty<Mod>());
|
AddStep("no mods selected", () => SelectedMods.Value = Array.Empty<Mod>());
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestManiaFirstBarText()
|
public void TestManiaFirstBarText()
|
||||||
{
|
{
|
||||||
AddStep("set beatmap", () => advancedStats.Beatmap = new BeatmapInfo
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Ruleset = rulesets.GetRuleset(3),
|
Ruleset = rulesets.GetRuleset(3),
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
BaseDifficulty = new BeatmapDifficulty
|
||||||
@ -84,11 +84,11 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestEasyMod()
|
public void TestEasyMod()
|
||||||
{
|
{
|
||||||
AddStep("set beatmap", () => advancedStats.Beatmap = exampleBeatmapInfo);
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
||||||
|
|
||||||
AddStep("select EZ mod", () =>
|
AddStep("select EZ mod", () =>
|
||||||
{
|
{
|
||||||
var ruleset = advancedStats.Beatmap.Ruleset.CreateInstance();
|
var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance();
|
||||||
SelectedMods.Value = new[] { ruleset.CreateMod<ModEasy>() };
|
SelectedMods.Value = new[] { ruleset.CreateMod<ModEasy>() };
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -101,11 +101,11 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestHardRockMod()
|
public void TestHardRockMod()
|
||||||
{
|
{
|
||||||
AddStep("set beatmap", () => advancedStats.Beatmap = exampleBeatmapInfo);
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
||||||
|
|
||||||
AddStep("select HR mod", () =>
|
AddStep("select HR mod", () =>
|
||||||
{
|
{
|
||||||
var ruleset = advancedStats.Beatmap.Ruleset.CreateInstance();
|
var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance();
|
||||||
SelectedMods.Value = new[] { ruleset.CreateMod<ModHardRock>() };
|
SelectedMods.Value = new[] { ruleset.CreateMod<ModHardRock>() };
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -118,13 +118,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestUnchangedDifficultyAdjustMod()
|
public void TestUnchangedDifficultyAdjustMod()
|
||||||
{
|
{
|
||||||
AddStep("set beatmap", () => advancedStats.Beatmap = exampleBeatmapInfo);
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
||||||
|
|
||||||
AddStep("select unchanged Difficulty Adjust mod", () =>
|
AddStep("select unchanged Difficulty Adjust mod", () =>
|
||||||
{
|
{
|
||||||
var ruleset = advancedStats.Beatmap.Ruleset.CreateInstance();
|
var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance();
|
||||||
var difficultyAdjustMod = ruleset.CreateMod<ModDifficultyAdjust>();
|
var difficultyAdjustMod = ruleset.CreateMod<ModDifficultyAdjust>();
|
||||||
difficultyAdjustMod.ReadFromDifficulty(advancedStats.Beatmap.BaseDifficulty);
|
difficultyAdjustMod.ReadFromDifficulty(advancedStats.BeatmapInfo.BaseDifficulty);
|
||||||
SelectedMods.Value = new[] { difficultyAdjustMod };
|
SelectedMods.Value = new[] { difficultyAdjustMod };
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -137,13 +137,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestChangedDifficultyAdjustMod()
|
public void TestChangedDifficultyAdjustMod()
|
||||||
{
|
{
|
||||||
AddStep("set beatmap", () => advancedStats.Beatmap = exampleBeatmapInfo);
|
AddStep("set beatmap", () => advancedStats.BeatmapInfo = exampleBeatmapInfo);
|
||||||
|
|
||||||
AddStep("select changed Difficulty Adjust mod", () =>
|
AddStep("select changed Difficulty Adjust mod", () =>
|
||||||
{
|
{
|
||||||
var ruleset = advancedStats.Beatmap.Ruleset.CreateInstance();
|
var ruleset = advancedStats.BeatmapInfo.Ruleset.CreateInstance();
|
||||||
var difficultyAdjustMod = ruleset.CreateMod<OsuModDifficultyAdjust>();
|
var difficultyAdjustMod = ruleset.CreateMod<OsuModDifficultyAdjust>();
|
||||||
var originalDifficulty = advancedStats.Beatmap.BaseDifficulty;
|
var originalDifficulty = advancedStats.BeatmapInfo.BaseDifficulty;
|
||||||
|
|
||||||
difficultyAdjustMod.ReadFromDifficulty(originalDifficulty);
|
difficultyAdjustMod.ReadFromDifficulty(originalDifficulty);
|
||||||
difficultyAdjustMod.DrainRate.Value = originalDifficulty.DrainRate - 0.5f;
|
difficultyAdjustMod.DrainRate.Value = originalDifficulty.DrainRate - 0.5f;
|
||||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
private readonly Stack<BeatmapSetInfo> selectedSets = new Stack<BeatmapSetInfo>();
|
private readonly Stack<BeatmapSetInfo> selectedSets = new Stack<BeatmapSetInfo>();
|
||||||
private readonly HashSet<int> eagerSelectedIDs = new HashSet<int>();
|
private readonly HashSet<int> eagerSelectedIDs = new HashSet<int>();
|
||||||
|
|
||||||
private BeatmapInfo currentSelection => carousel.SelectedBeatmap;
|
private BeatmapInfo currentSelection => carousel.SelectedBeatmapInfo;
|
||||||
|
|
||||||
private const int set_count = 5;
|
private const int set_count = 5;
|
||||||
|
|
||||||
@ -75,11 +75,11 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
AddStep("store selection", () => selection = carousel.SelectedBeatmap);
|
AddStep("store selection", () => selection = carousel.SelectedBeatmapInfo);
|
||||||
if (isIterating)
|
if (isIterating)
|
||||||
AddUntilStep("selection changed", () => carousel.SelectedBeatmap != selection);
|
AddUntilStep("selection changed", () => carousel.SelectedBeatmapInfo != selection);
|
||||||
else
|
else
|
||||||
AddUntilStep("selection not changed", () => carousel.SelectedBeatmap == selection);
|
AddUntilStep("selection not changed", () => carousel.SelectedBeatmapInfo == selection);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -387,7 +387,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep("Set non-empty mode filter", () =>
|
AddStep("Set non-empty mode filter", () =>
|
||||||
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(1) }, false));
|
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(1) }, false));
|
||||||
|
|
||||||
AddAssert("Something is selected", () => carousel.SelectedBeatmap != null);
|
AddAssert("Something is selected", () => carousel.SelectedBeatmapInfo != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -562,7 +562,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep("filter to ruleset 0", () =>
|
AddStep("filter to ruleset 0", () =>
|
||||||
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false));
|
carousel.Filter(new FilterCriteria { Ruleset = rulesets.AvailableRulesets.ElementAt(0) }, false));
|
||||||
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false));
|
AddStep("select filtered map skipping filtered", () => carousel.SelectBeatmap(testMixed.Beatmaps[1], false));
|
||||||
AddAssert("unfiltered beatmap not selected", () => carousel.SelectedBeatmap.RulesetID == 0);
|
AddAssert("unfiltered beatmap not selected", () => carousel.SelectedBeatmapInfo.RulesetID == 0);
|
||||||
|
|
||||||
AddStep("remove mixed set", () =>
|
AddStep("remove mixed set", () =>
|
||||||
{
|
{
|
||||||
@ -653,7 +653,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
carousel.Filter(new FilterCriteria { SearchText = Guid.NewGuid().ToString() }, false);
|
carousel.Filter(new FilterCriteria { SearchText = Guid.NewGuid().ToString() }, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("selection lost", () => carousel.SelectedBeatmap == null);
|
AddAssert("selection lost", () => carousel.SelectedBeatmapInfo == null);
|
||||||
|
|
||||||
AddStep("Restore different ruleset filter", () =>
|
AddStep("Restore different ruleset filter", () =>
|
||||||
{
|
{
|
||||||
@ -661,7 +661,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID);
|
eagerSelectedIDs.Add(carousel.SelectedBeatmapSet.ID);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("selection changed", () => carousel.SelectedBeatmap != manySets.First().Beatmaps.First());
|
AddAssert("selection changed", () => carousel.SelectedBeatmapInfo != manySets.First().Beatmaps.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 2);
|
AddAssert("Selection was random", () => eagerSelectedIDs.Count > 2);
|
||||||
@ -763,9 +763,9 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
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.SelectedBeatmap == carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Skip(diff.Value - 1).First();
|
return carousel.SelectedBeatmapInfo == carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Skip(diff.Value - 1).First();
|
||||||
|
|
||||||
return carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Contains(carousel.SelectedBeatmap);
|
return carousel.BeatmapSets.Skip(set - 1).First().Beatmaps.Contains(carousel.SelectedBeatmapInfo);
|
||||||
});
|
});
|
||||||
|
|
||||||
private void setSelected(int set, int diff) =>
|
private void setSelected(int set, int diff) =>
|
||||||
@ -800,7 +800,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
carousel.RandomAlgorithm.Value = RandomSelectAlgorithm.RandomPermutation;
|
carousel.RandomAlgorithm.Value = RandomSelectAlgorithm.RandomPermutation;
|
||||||
|
|
||||||
if (!selectedSets.Any() && carousel.SelectedBeatmap != null)
|
if (!selectedSets.Any() && carousel.SelectedBeatmapInfo != null)
|
||||||
selectedSets.Push(carousel.SelectedBeatmapSet);
|
selectedSets.Push(carousel.SelectedBeatmapSet);
|
||||||
|
|
||||||
carousel.SelectNextRandom();
|
carousel.SelectNextRandom();
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAllMetrics()
|
public void TestAllMetrics()
|
||||||
{
|
{
|
||||||
AddStep("all metrics", () => details.Beatmap = new BeatmapInfo
|
AddStep("all metrics", () => details.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BeatmapSet = new BeatmapSetInfo
|
BeatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
@ -61,7 +61,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestAllMetricsExceptSource()
|
public void TestAllMetricsExceptSource()
|
||||||
{
|
{
|
||||||
AddStep("all except source", () => details.Beatmap = new BeatmapInfo
|
AddStep("all except source", () => details.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BeatmapSet = new BeatmapSetInfo
|
BeatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestOnlyRatings()
|
public void TestOnlyRatings()
|
||||||
{
|
{
|
||||||
AddStep("ratings", () => details.Beatmap = new BeatmapInfo
|
AddStep("ratings", () => details.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
BeatmapSet = new BeatmapSetInfo
|
BeatmapSet = new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
@ -117,7 +117,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestOnlyFailsAndRetries()
|
public void TestOnlyFailsAndRetries()
|
||||||
{
|
{
|
||||||
AddStep("fails retries", () => details.Beatmap = new BeatmapInfo
|
AddStep("fails retries", () => details.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Version = "Only Retries and Fails",
|
Version = "Only Retries and Fails",
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
@ -144,7 +144,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestNoMetrics()
|
public void TestNoMetrics()
|
||||||
{
|
{
|
||||||
AddStep("no metrics", () => details.Beatmap = new BeatmapInfo
|
AddStep("no metrics", () => details.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
Version = "No Metrics",
|
Version = "No Metrics",
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
@ -166,13 +166,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestNullBeatmap()
|
public void TestNullBeatmap()
|
||||||
{
|
{
|
||||||
AddStep("null beatmap", () => details.Beatmap = null);
|
AddStep("null beatmap", () => details.BeatmapInfo = null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestOnlineMetrics()
|
public void TestOnlineMetrics()
|
||||||
{
|
{
|
||||||
AddStep("online ratings/retries/fails", () => details.Beatmap = new BeatmapInfo
|
AddStep("online ratings/retries/fails", () => details.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
OnlineBeatmapID = 162,
|
OnlineBeatmapID = 162,
|
||||||
});
|
});
|
||||||
|
@ -76,7 +76,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
|
beatmapManager.Import(TestResources.GetQuickTestBeatmapForImport()).Wait();
|
||||||
beatmapInfo = beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
|
beatmapInfo = beatmapManager.GetAllUsableBeatmapSets().First().Beatmaps.First();
|
||||||
|
|
||||||
leaderboard.Beatmap = beatmapInfo;
|
leaderboard.BeatmapInfo = beatmapInfo;
|
||||||
});
|
});
|
||||||
|
|
||||||
clearScores();
|
clearScores();
|
||||||
@ -186,7 +186,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
private void checkCount(int expected) =>
|
private void checkCount(int expected) =>
|
||||||
AddUntilStep("Correct count displayed", () => leaderboard.ChildrenOfType<LeaderboardScore>().Count() == expected);
|
AddUntilStep("Correct count displayed", () => leaderboard.ChildrenOfType<LeaderboardScore>().Count() == expected);
|
||||||
|
|
||||||
private static ScoreInfo[] generateSampleScores(BeatmapInfo beatmap)
|
private static ScoreInfo[] generateSampleScores(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
return new[]
|
return new[]
|
||||||
{
|
{
|
||||||
@ -197,7 +197,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 6602580,
|
Id = 6602580,
|
||||||
@ -216,7 +216,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 4608074,
|
Id = 4608074,
|
||||||
@ -235,7 +235,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 1014222,
|
Id = 1014222,
|
||||||
@ -254,7 +254,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 1541390,
|
Id = 1541390,
|
||||||
@ -273,7 +273,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 2243452,
|
Id = 2243452,
|
||||||
@ -292,7 +292,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 2705430,
|
Id = 2705430,
|
||||||
@ -311,7 +311,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 7151382,
|
Id = 7151382,
|
||||||
@ -330,7 +330,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 2051389,
|
Id = 2051389,
|
||||||
@ -349,7 +349,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 6169483,
|
Id = 6169483,
|
||||||
@ -368,7 +368,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
MaxCombo = 244,
|
MaxCombo = 244,
|
||||||
TotalScore = 1707827,
|
TotalScore = 1707827,
|
||||||
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
//Mods = new Mod[] { new OsuModHidden(), new OsuModHardRock(), },
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
User = new User
|
User = new User
|
||||||
{
|
{
|
||||||
Id = 6702666,
|
Id = 6702666,
|
||||||
@ -385,7 +385,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
private void showBeatmapWithStatus(BeatmapSetOnlineStatus status)
|
private void showBeatmapWithStatus(BeatmapSetOnlineStatus status)
|
||||||
{
|
{
|
||||||
leaderboard.Beatmap = new BeatmapInfo
|
leaderboard.BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
OnlineBeatmapID = 1113057,
|
OnlineBeatmapID = 1113057,
|
||||||
Status = status,
|
Status = status,
|
||||||
|
@ -192,7 +192,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
|
|
||||||
return Game.BeatmapManager.Import(beatmapSet).Result;
|
return Game.BeatmapManager.Import(beatmapSet).Result.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ensureAllBeatmapSetsImported(IEnumerable<BeatmapSetInfo> beatmapSets) => beatmapSets.All(set => set != null);
|
private bool ensureAllBeatmapSetsImported(IEnumerable<BeatmapSetInfo> beatmapSets) => beatmapSets.All(set => set != null);
|
||||||
|
@ -145,7 +145,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).Beatmap != songSelect.Carousel.SelectedBeatmap));
|
.First(b => ((CarouselBeatmap)b.Item).BeatmapInfo != songSelect.Carousel.SelectedBeatmapInfo));
|
||||||
|
|
||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
|
|
||||||
@ -172,7 +172,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).Beatmap != songSelect.Carousel.SelectedBeatmap));
|
.First(b => ((CarouselBeatmap)b.Item).BeatmapInfo != songSelect.Carousel.SelectedBeatmapInfo));
|
||||||
|
|
||||||
InputManager.PressButton(MouseButton.Left);
|
InputManager.PressButton(MouseButton.Left);
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
addRulesetImportStep(2);
|
addRulesetImportStep(2);
|
||||||
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -322,13 +322,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
changeRuleset(2);
|
changeRuleset(2);
|
||||||
addRulesetImportStep(2);
|
addRulesetImportStep(2);
|
||||||
addRulesetImportStep(1);
|
addRulesetImportStep(1);
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 2);
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.RulesetID == 2);
|
||||||
|
|
||||||
changeRuleset(1);
|
changeRuleset(1);
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 1);
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.RulesetID == 1);
|
||||||
|
|
||||||
changeRuleset(0);
|
changeRuleset(0);
|
||||||
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
AddUntilStep("no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -338,7 +338,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
changeRuleset(2);
|
changeRuleset(2);
|
||||||
|
|
||||||
addRulesetImportStep(2);
|
addRulesetImportStep(2);
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 2);
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.RulesetID == 2);
|
||||||
|
|
||||||
addRulesetImportStep(0);
|
addRulesetImportStep(0);
|
||||||
addRulesetImportStep(0);
|
addRulesetImportStep(0);
|
||||||
@ -355,7 +355,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
Beatmap.Value = manager.GetWorkingBeatmap(target);
|
Beatmap.Value = manager.GetWorkingBeatmap(target);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.Equals(target));
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(target));
|
||||||
|
|
||||||
// this is an important check, to make sure updateComponentFromBeatmap() was actually run
|
// this is an important check, to make sure updateComponentFromBeatmap() was actually run
|
||||||
AddUntilStep("selection shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap.BeatmapInfo.Equals(target));
|
AddUntilStep("selection shown on wedge", () => songSelect.CurrentBeatmapDetailsBeatmap.BeatmapInfo.Equals(target));
|
||||||
@ -368,7 +368,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
changeRuleset(2);
|
changeRuleset(2);
|
||||||
|
|
||||||
addRulesetImportStep(2);
|
addRulesetImportStep(2);
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.RulesetID == 2);
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.RulesetID == 2);
|
||||||
|
|
||||||
addRulesetImportStep(0);
|
addRulesetImportStep(0);
|
||||||
addRulesetImportStep(0);
|
addRulesetImportStep(0);
|
||||||
@ -385,7 +385,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == 0);
|
Ruleset.Value = rulesets.AvailableRulesets.First(r => r.ID == 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap.Equals(target));
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo.Equals(target));
|
||||||
|
|
||||||
AddUntilStep("has correct ruleset", () => Ruleset.Value.ID == 0);
|
AddUntilStep("has correct ruleset", () => Ruleset.Value.ID == 0);
|
||||||
|
|
||||||
@ -444,7 +444,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
{
|
{
|
||||||
createSongSelect();
|
createSongSelect();
|
||||||
addManyTestMaps();
|
addManyTestMaps();
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null);
|
||||||
|
|
||||||
bool startRequested = false;
|
bool startRequested = false;
|
||||||
|
|
||||||
@ -473,13 +473,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
// used for filter check below
|
// used for filter check below
|
||||||
AddStep("allow convert display", () => config.SetValue(OsuSetting.ShowConvertedBeatmaps, true));
|
AddStep("allow convert display", () => config.SetValue(OsuSetting.ShowConvertedBeatmaps, true));
|
||||||
|
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null);
|
||||||
|
|
||||||
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
|
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
|
||||||
|
|
||||||
AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);
|
AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);
|
||||||
|
|
||||||
AddUntilStep("has no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
AddUntilStep("has no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null);
|
||||||
|
|
||||||
BeatmapInfo target = null;
|
BeatmapInfo target = null;
|
||||||
|
|
||||||
@ -494,7 +494,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
Beatmap.Value = manager.GetWorkingBeatmap(target);
|
Beatmap.Value = manager.GetWorkingBeatmap(target);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null);
|
||||||
|
|
||||||
AddAssert("selected only shows expected ruleset (plus converts)", () =>
|
AddAssert("selected only shows expected ruleset (plus converts)", () =>
|
||||||
{
|
{
|
||||||
@ -502,16 +502,16 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
// special case for converts checked here.
|
// special case for converts checked here.
|
||||||
return selectedPanel.ChildrenOfType<FilterableDifficultyIcon>().All(i =>
|
return selectedPanel.ChildrenOfType<FilterableDifficultyIcon>().All(i =>
|
||||||
i.IsFiltered || i.Item.Beatmap.Ruleset.ID == targetRuleset || i.Item.Beatmap.Ruleset.ID == 0);
|
i.IsFiltered || i.Item.BeatmapInfo.Ruleset.ID == targetRuleset || i.Item.BeatmapInfo.Ruleset.ID == 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmap?.OnlineBeatmapID == target.OnlineBeatmapID);
|
AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmapInfo?.OnlineBeatmapID == target.OnlineBeatmapID);
|
||||||
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
||||||
|
|
||||||
AddStep("reset filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = string.Empty);
|
AddStep("reset filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = string.Empty);
|
||||||
|
|
||||||
AddAssert("game still correct", () => Beatmap.Value?.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
AddAssert("game still correct", () => Beatmap.Value?.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
||||||
AddAssert("carousel still correct", () => songSelect.Carousel.SelectedBeatmap.OnlineBeatmapID == target.OnlineBeatmapID);
|
AddAssert("carousel still correct", () => songSelect.Carousel.SelectedBeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -522,13 +522,13 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
changeRuleset(0);
|
changeRuleset(0);
|
||||||
|
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null);
|
||||||
|
|
||||||
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
|
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nonono");
|
||||||
|
|
||||||
AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);
|
AddUntilStep("dummy selected", () => Beatmap.Value is DummyWorkingBeatmap);
|
||||||
|
|
||||||
AddUntilStep("has no selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
AddUntilStep("has no selection", () => songSelect.Carousel.SelectedBeatmapInfo == null);
|
||||||
|
|
||||||
BeatmapInfo target = null;
|
BeatmapInfo target = null;
|
||||||
|
|
||||||
@ -540,15 +540,15 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
Beatmap.Value = manager.GetWorkingBeatmap(target);
|
Beatmap.Value = manager.GetWorkingBeatmap(target);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmap != null);
|
AddUntilStep("has selection", () => songSelect.Carousel.SelectedBeatmapInfo != null);
|
||||||
|
|
||||||
AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmap?.OnlineBeatmapID == target.OnlineBeatmapID);
|
AddUntilStep("carousel has correct", () => songSelect.Carousel.SelectedBeatmapInfo?.OnlineBeatmapID == target.OnlineBeatmapID);
|
||||||
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
AddUntilStep("game has correct", () => Beatmap.Value.BeatmapInfo.OnlineBeatmapID == target.OnlineBeatmapID);
|
||||||
|
|
||||||
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nononoo");
|
AddStep("set filter text", () => songSelect.FilterControl.ChildrenOfType<SearchTextBox>().First().Text = "nononoo");
|
||||||
|
|
||||||
AddUntilStep("game lost selection", () => Beatmap.Value is DummyWorkingBeatmap);
|
AddUntilStep("game lost selection", () => Beatmap.Value is DummyWorkingBeatmap);
|
||||||
AddAssert("carousel lost selection", () => songSelect.Carousel.SelectedBeatmap == null);
|
AddAssert("carousel lost selection", () => songSelect.Carousel.SelectedBeatmapInfo == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -581,9 +581,9 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
createSongSelect();
|
createSongSelect();
|
||||||
addRulesetImportStep(0);
|
addRulesetImportStep(0);
|
||||||
AddStep("Move to last difficulty", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.Last()));
|
AddStep("Move to last difficulty", () => songSelect.Carousel.SelectBeatmap(songSelect.Carousel.BeatmapSets.First().Beatmaps.Last()));
|
||||||
AddStep("Store current ID", () => previousID = songSelect.Carousel.SelectedBeatmap.ID);
|
AddStep("Store current ID", () => previousID = songSelect.Carousel.SelectedBeatmapInfo.ID);
|
||||||
AddStep("Hide first beatmap", () => manager.Hide(songSelect.Carousel.SelectedBeatmapSet.Beatmaps.First()));
|
AddStep("Hide first beatmap", () => manager.Hide(songSelect.Carousel.SelectedBeatmapSet.Beatmaps.First()));
|
||||||
AddAssert("Selected beatmap has not changed", () => songSelect.Carousel.SelectedBeatmap.ID == previousID);
|
AddAssert("Selected beatmap has not changed", () => songSelect.Carousel.SelectedBeatmapInfo.ID == previousID);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -641,7 +641,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
InputManager.Click(MouseButton.Left);
|
InputManager.Click(MouseButton.Left);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmap == filteredBeatmap);
|
AddAssert("Selected beatmap correct", () => songSelect.Carousel.SelectedBeatmapInfo == filteredBeatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -717,7 +717,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep("Find an icon for different ruleset", () =>
|
AddStep("Find an icon for different ruleset", () =>
|
||||||
{
|
{
|
||||||
difficultyIcon = set.ChildrenOfType<FilterableDifficultyIcon>()
|
difficultyIcon = set.ChildrenOfType<FilterableDifficultyIcon>()
|
||||||
.First(icon => icon.Item.Beatmap.Ruleset.ID == 3);
|
.First(icon => icon.Item.BeatmapInfo.Ruleset.ID == 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("Check ruleset is osu!", () => Ruleset.Value.ID == 0);
|
AddAssert("Check ruleset is osu!", () => Ruleset.Value.ID == 0);
|
||||||
@ -735,7 +735,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);
|
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);
|
||||||
|
|
||||||
AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmap.BeatmapSet.ID == previousSetID);
|
AddAssert("Selected beatmap still same set", () => songSelect.Carousel.SelectedBeatmapInfo.BeatmapSet.ID == previousSetID);
|
||||||
AddAssert("Selected beatmap is mania", () => Beatmap.Value.BeatmapInfo.Ruleset.ID == 3);
|
AddAssert("Selected beatmap is mania", () => Beatmap.Value.BeatmapInfo.Ruleset.ID == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -751,7 +751,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep("import huge difficulty count map", () =>
|
AddStep("import huge difficulty count map", () =>
|
||||||
{
|
{
|
||||||
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray();
|
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.ID != 2).ToArray();
|
||||||
imported = manager.Import(createTestBeatmapSet(usableRulesets, 50)).Result;
|
imported = manager.Import(createTestBeatmapSet(usableRulesets, 50)).Result.Value;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("select the first beatmap of import", () => Beatmap.Value = manager.GetWorkingBeatmap(imported.Beatmaps.First()));
|
AddStep("select the first beatmap of import", () => Beatmap.Value = manager.GetWorkingBeatmap(imported.Beatmaps.First()));
|
||||||
@ -767,7 +767,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep("Find group icon for different ruleset", () =>
|
AddStep("Find group icon for different ruleset", () =>
|
||||||
{
|
{
|
||||||
groupIcon = set.ChildrenOfType<FilterableGroupedDifficultyIcon>()
|
groupIcon = set.ChildrenOfType<FilterableGroupedDifficultyIcon>()
|
||||||
.First(icon => icon.Items.First().Beatmap.Ruleset.ID == 3);
|
.First(icon => icon.Items.First().BeatmapInfo.Ruleset.ID == 3);
|
||||||
});
|
});
|
||||||
|
|
||||||
AddAssert("Check ruleset is osu!", () => Ruleset.Value.ID == 0);
|
AddAssert("Check ruleset is osu!", () => Ruleset.Value.ID == 0);
|
||||||
@ -781,7 +781,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);
|
AddUntilStep("Check ruleset changed to mania", () => Ruleset.Value.ID == 3);
|
||||||
|
|
||||||
AddAssert("Check first item in group selected", () => Beatmap.Value.BeatmapInfo.Equals(groupIcon.Items.First().Beatmap));
|
AddAssert("Check first item in group selected", () => Beatmap.Value.BeatmapInfo.Equals(groupIcon.Items.First().BeatmapInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
@ -805,7 +805,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
songSelect.PresentScore(new ScoreInfo
|
songSelect.PresentScore(new ScoreInfo
|
||||||
{
|
{
|
||||||
User = new User { Username = "woo" },
|
User = new User { Username = "woo" },
|
||||||
Beatmap = getPresentBeatmap(),
|
BeatmapInfo = getPresentBeatmap(),
|
||||||
Ruleset = getPresentBeatmap().Ruleset
|
Ruleset = getPresentBeatmap().Ruleset
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -837,7 +837,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
songSelect.PresentScore(new ScoreInfo
|
songSelect.PresentScore(new ScoreInfo
|
||||||
{
|
{
|
||||||
User = new User { Username = "woo" },
|
User = new User { Username = "woo" },
|
||||||
Beatmap = getPresentBeatmap(),
|
BeatmapInfo = getPresentBeatmap(),
|
||||||
Ruleset = getPresentBeatmap().Ruleset
|
Ruleset = getPresentBeatmap().Ruleset
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -856,7 +856,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
private int getBeatmapIndex(BeatmapSetInfo set, BeatmapInfo info) => set.Beatmaps.FindIndex(b => b == info);
|
private int getBeatmapIndex(BeatmapSetInfo set, BeatmapInfo info) => set.Beatmaps.FindIndex(b => b == info);
|
||||||
|
|
||||||
private int getCurrentBeatmapIndex() => getBeatmapIndex(songSelect.Carousel.SelectedBeatmapSet, songSelect.Carousel.SelectedBeatmap);
|
private int getCurrentBeatmapIndex() => getBeatmapIndex(songSelect.Carousel.SelectedBeatmapSet, songSelect.Carousel.SelectedBeatmapInfo);
|
||||||
|
|
||||||
private int getDifficultyIconIndex(DrawableCarouselBeatmapSet set, FilterableDifficultyIcon icon)
|
private int getDifficultyIconIndex(DrawableCarouselBeatmapSet set, FilterableDifficultyIcon icon)
|
||||||
{
|
{
|
||||||
|
@ -37,7 +37,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
private ScoreManager scoreManager;
|
private ScoreManager scoreManager;
|
||||||
|
|
||||||
private readonly List<ScoreInfo> importedScores = new List<ScoreInfo>();
|
private readonly List<ScoreInfo> importedScores = new List<ScoreInfo>();
|
||||||
private BeatmapInfo beatmap;
|
|
||||||
|
private BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
[Cached]
|
[Cached]
|
||||||
private readonly DialogOverlay dialogOverlay;
|
private readonly DialogOverlay dialogOverlay;
|
||||||
@ -55,7 +56,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Size = new Vector2(550f, 450f),
|
Size = new Vector2(550f, 450f),
|
||||||
Scope = BeatmapLeaderboardScope.Local,
|
Scope = BeatmapLeaderboardScope.Local,
|
||||||
Beatmap = new BeatmapInfo
|
BeatmapInfo = new BeatmapInfo
|
||||||
{
|
{
|
||||||
ID = 1,
|
ID = 1,
|
||||||
Metadata = new BeatmapMetadata
|
Metadata = new BeatmapMetadata
|
||||||
@ -84,15 +85,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
||||||
dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, null, ContextFactory, Scheduler));
|
dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, null, ContextFactory, Scheduler));
|
||||||
|
|
||||||
beatmap = beatmapManager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).Result.Beatmaps[0];
|
beatmapInfo = beatmapManager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).Result.Value.Beatmaps[0];
|
||||||
|
|
||||||
for (int i = 0; i < 50; i++)
|
for (int i = 0; i < 50; i++)
|
||||||
{
|
{
|
||||||
var score = new ScoreInfo
|
var score = new ScoreInfo
|
||||||
{
|
{
|
||||||
OnlineScoreID = i,
|
OnlineScoreID = i,
|
||||||
Beatmap = beatmap,
|
BeatmapInfo = beatmapInfo,
|
||||||
BeatmapInfoID = beatmap.ID,
|
BeatmapInfoID = beatmapInfo.ID,
|
||||||
Accuracy = RNG.NextDouble(),
|
Accuracy = RNG.NextDouble(),
|
||||||
TotalScore = RNG.Next(1, 1000000),
|
TotalScore = RNG.Next(1, 1000000),
|
||||||
MaxCombo = RNG.Next(1, 1000),
|
MaxCombo = RNG.Next(1, 1000),
|
||||||
@ -100,7 +101,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
User = new User { Username = "TestUser" },
|
User = new User { Username = "TestUser" },
|
||||||
};
|
};
|
||||||
|
|
||||||
importedScores.Add(scoreManager.Import(score).Result);
|
importedScores.Add(scoreManager.Import(score).Result.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return dependencies;
|
return dependencies;
|
||||||
@ -115,7 +116,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
leaderboard.Scores = null;
|
leaderboard.Scores = null;
|
||||||
leaderboard.FinishTransforms(true); // After setting scores, we may be waiting for transforms to expire drawables
|
leaderboard.FinishTransforms(true); // After setting scores, we may be waiting for transforms to expire drawables
|
||||||
|
|
||||||
leaderboard.Beatmap = beatmap;
|
leaderboard.BeatmapInfo = beatmapInfo;
|
||||||
leaderboard.RefreshScores(); // Required in the case that the beatmap hasn't changed
|
leaderboard.RefreshScores(); // Required in the case that the beatmap hasn't changed
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Tournament.Tests.Components
|
|||||||
|
|
||||||
private void success(APIBeatmap apiBeatmap)
|
private void success(APIBeatmap apiBeatmap)
|
||||||
{
|
{
|
||||||
var beatmap = apiBeatmap.ToBeatmap(rulesets);
|
var beatmap = apiBeatmap.ToBeatmapInfo(rulesets);
|
||||||
Add(new TournamentBeatmapPanel(beatmap)
|
Add(new TournamentBeatmapPanel(beatmap)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Tournament.Tests.Components
|
|||||||
|
|
||||||
private FillFlowContainer<TournamentBeatmapPanel> fillFlow;
|
private FillFlowContainer<TournamentBeatmapPanel> fillFlow;
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
@ -44,12 +44,12 @@ namespace osu.Game.Tournament.Tests.Components
|
|||||||
|
|
||||||
private void success(APIBeatmap apiBeatmap)
|
private void success(APIBeatmap apiBeatmap)
|
||||||
{
|
{
|
||||||
beatmap = apiBeatmap.ToBeatmap(rulesets);
|
beatmapInfo = apiBeatmap.ToBeatmapInfo(rulesets);
|
||||||
var mods = rulesets.GetRuleset(Ladder.Ruleset.Value.ID ?? 0).CreateInstance().AllMods;
|
var mods = rulesets.GetRuleset(Ladder.Ruleset.Value.ID ?? 0).CreateInstance().AllMods;
|
||||||
|
|
||||||
foreach (var mod in mods)
|
foreach (var mod in mods)
|
||||||
{
|
{
|
||||||
fillFlow.Add(new TournamentBeatmapPanel(beatmap, mod.Acronym)
|
fillFlow.Add(new TournamentBeatmapPanel(beatmapInfo, mod.Acronym)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre
|
Origin = Anchor.Centre
|
||||||
|
@ -21,22 +21,22 @@ namespace osu.Game.Tournament.Components
|
|||||||
{
|
{
|
||||||
public class SongBar : CompositeDrawable
|
public class SongBar : CompositeDrawable
|
||||||
{
|
{
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
public const float HEIGHT = 145 / 2f;
|
public const float HEIGHT = 145 / 2f;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IBindable<RulesetInfo> ruleset { get; set; }
|
private IBindable<RulesetInfo> ruleset { get; set; }
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
public BeatmapInfo BeatmapInfo
|
||||||
{
|
{
|
||||||
get => beatmap;
|
get => beatmapInfo;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (beatmap == value)
|
if (beatmapInfo == value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
beatmap = value;
|
beatmapInfo = value;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,18 +95,18 @@ namespace osu.Game.Tournament.Components
|
|||||||
|
|
||||||
private void update()
|
private void update()
|
||||||
{
|
{
|
||||||
if (beatmap == null)
|
if (beatmapInfo == null)
|
||||||
{
|
{
|
||||||
flow.Clear();
|
flow.Clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bpm = beatmap.BeatmapSet.OnlineInfo.BPM;
|
var bpm = beatmapInfo.BeatmapSet.OnlineInfo.BPM;
|
||||||
var length = beatmap.Length;
|
var length = beatmapInfo.Length;
|
||||||
string hardRockExtra = "";
|
string hardRockExtra = "";
|
||||||
string srExtra = "";
|
string srExtra = "";
|
||||||
|
|
||||||
var ar = beatmap.BaseDifficulty.ApproachRate;
|
var ar = beatmapInfo.BaseDifficulty.ApproachRate;
|
||||||
|
|
||||||
if ((mods & LegacyMods.HardRock) > 0)
|
if ((mods & LegacyMods.HardRock) > 0)
|
||||||
{
|
{
|
||||||
@ -132,9 +132,9 @@ namespace osu.Game.Tournament.Components
|
|||||||
default:
|
default:
|
||||||
stats = new (string heading, string content)[]
|
stats = new (string heading, string content)[]
|
||||||
{
|
{
|
||||||
("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
|
("CS", $"{beatmapInfo.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
|
||||||
("AR", $"{ar:0.#}{hardRockExtra}"),
|
("AR", $"{ar:0.#}{hardRockExtra}"),
|
||||||
("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
("OD", $"{beatmapInfo.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -142,15 +142,15 @@ namespace osu.Game.Tournament.Components
|
|||||||
case 3:
|
case 3:
|
||||||
stats = new (string heading, string content)[]
|
stats = new (string heading, string content)[]
|
||||||
{
|
{
|
||||||
("OD", $"{beatmap.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
("OD", $"{beatmapInfo.BaseDifficulty.OverallDifficulty:0.#}{hardRockExtra}"),
|
||||||
("HP", $"{beatmap.BaseDifficulty.DrainRate:0.#}{hardRockExtra}")
|
("HP", $"{beatmapInfo.BaseDifficulty.DrainRate:0.#}{hardRockExtra}")
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
stats = new (string heading, string content)[]
|
stats = new (string heading, string content)[]
|
||||||
{
|
{
|
||||||
("CS", $"{beatmap.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
|
("CS", $"{beatmapInfo.BaseDifficulty.CircleSize:0.#}{hardRockExtra}"),
|
||||||
("AR", $"{ar:0.#}"),
|
("AR", $"{ar:0.#}"),
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
@ -186,7 +186,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new DiffPiece(stats),
|
new DiffPiece(stats),
|
||||||
new DiffPiece(("Star Rating", $"{beatmap.StarDifficulty:0.#}{srExtra}"))
|
new DiffPiece(("Star Rating", $"{beatmapInfo.StarDifficulty:0.#}{srExtra}"))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
@ -229,7 +229,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new TournamentBeatmapPanel(beatmap)
|
new TournamentBeatmapPanel(beatmapInfo)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Width = 0.5f,
|
Width = 0.5f,
|
||||||
|
@ -21,7 +21,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
{
|
{
|
||||||
public class TournamentBeatmapPanel : CompositeDrawable
|
public class TournamentBeatmapPanel : CompositeDrawable
|
||||||
{
|
{
|
||||||
public readonly BeatmapInfo Beatmap;
|
public readonly BeatmapInfo BeatmapInfo;
|
||||||
private readonly string mod;
|
private readonly string mod;
|
||||||
|
|
||||||
private const float horizontal_padding = 10;
|
private const float horizontal_padding = 10;
|
||||||
@ -32,11 +32,11 @@ namespace osu.Game.Tournament.Components
|
|||||||
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
private readonly Bindable<TournamentMatch> currentMatch = new Bindable<TournamentMatch>();
|
||||||
private Box flash;
|
private Box flash;
|
||||||
|
|
||||||
public TournamentBeatmapPanel(BeatmapInfo beatmap, string mod = null)
|
public TournamentBeatmapPanel(BeatmapInfo beatmapInfo, string mod = null)
|
||||||
{
|
{
|
||||||
if (beatmap == null) throw new ArgumentNullException(nameof(beatmap));
|
if (beatmapInfo == null) throw new ArgumentNullException(nameof(beatmapInfo));
|
||||||
|
|
||||||
Beatmap = beatmap;
|
BeatmapInfo = beatmapInfo;
|
||||||
this.mod = mod;
|
this.mod = mod;
|
||||||
Width = 400;
|
Width = 400;
|
||||||
Height = HEIGHT;
|
Height = HEIGHT;
|
||||||
@ -61,7 +61,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = OsuColour.Gray(0.5f),
|
Colour = OsuColour.Gray(0.5f),
|
||||||
BeatmapSet = Beatmap.BeatmapSet,
|
BeatmapSet = BeatmapInfo.BeatmapSet,
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
@ -75,8 +75,8 @@ namespace osu.Game.Tournament.Components
|
|||||||
new TournamentSpriteText
|
new TournamentSpriteText
|
||||||
{
|
{
|
||||||
Text = new RomanisableString(
|
Text = new RomanisableString(
|
||||||
$"{Beatmap.Metadata.ArtistUnicode ?? Beatmap.Metadata.Artist} - {Beatmap.Metadata.TitleUnicode ?? Beatmap.Metadata.Title}",
|
$"{BeatmapInfo.Metadata.ArtistUnicode ?? BeatmapInfo.Metadata.Artist} - {BeatmapInfo.Metadata.TitleUnicode ?? BeatmapInfo.Metadata.Title}",
|
||||||
$"{Beatmap.Metadata.Artist} - {Beatmap.Metadata.Title}"),
|
$"{BeatmapInfo.Metadata.Artist} - {BeatmapInfo.Metadata.Title}"),
|
||||||
Font = OsuFont.Torus.With(weight: FontWeight.Bold),
|
Font = OsuFont.Torus.With(weight: FontWeight.Bold),
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
@ -93,7 +93,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
},
|
},
|
||||||
new TournamentSpriteText
|
new TournamentSpriteText
|
||||||
{
|
{
|
||||||
Text = Beatmap.Metadata.AuthorString,
|
Text = BeatmapInfo.Metadata.AuthorString,
|
||||||
Padding = new MarginPadding { Right = 20 },
|
Padding = new MarginPadding { Right = 20 },
|
||||||
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
|
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
|
||||||
},
|
},
|
||||||
@ -105,7 +105,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
},
|
},
|
||||||
new TournamentSpriteText
|
new TournamentSpriteText
|
||||||
{
|
{
|
||||||
Text = Beatmap.Version,
|
Text = BeatmapInfo.Version,
|
||||||
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
|
Font = OsuFont.Torus.With(weight: FontWeight.Bold, size: 14)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -149,7 +149,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
var found = currentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == Beatmap.OnlineBeatmapID);
|
var found = currentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == BeatmapInfo.OnlineBeatmapID);
|
||||||
|
|
||||||
bool doFlash = found != choice;
|
bool doFlash = found != choice;
|
||||||
choice = found;
|
choice = found;
|
||||||
|
@ -94,7 +94,7 @@ namespace osu.Game.Tournament.IPC
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
beatmapLookupRequest = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = beatmapId });
|
beatmapLookupRequest = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = beatmapId });
|
||||||
beatmapLookupRequest.Success += b => Beatmap.Value = b.ToBeatmap(Rulesets);
|
beatmapLookupRequest.Success += b => Beatmap.Value = b.ToBeatmapInfo(Rulesets);
|
||||||
API.Queue(beatmapLookupRequest);
|
API.Queue(beatmapLookupRequest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ namespace osu.Game.Tournament.Screens
|
|||||||
private void beatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap)
|
private void beatmapChanged(ValueChangedEvent<BeatmapInfo> beatmap)
|
||||||
{
|
{
|
||||||
SongBar.FadeInFromZero(300, Easing.OutQuint);
|
SongBar.FadeInFromZero(300, Easing.OutQuint);
|
||||||
SongBar.Beatmap = beatmap.NewValue;
|
SongBar.BeatmapInfo = beatmap.NewValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
|
|
||||||
req.Success += res =>
|
req.Success += res =>
|
||||||
{
|
{
|
||||||
Model.BeatmapInfo = res.ToBeatmap(rulesets);
|
Model.BeatmapInfo = res.ToBeatmapInfo(rulesets);
|
||||||
updatePanel();
|
updatePanel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ namespace osu.Game.Tournament.Screens.Editors
|
|||||||
|
|
||||||
req.Success += res =>
|
req.Success += res =>
|
||||||
{
|
{
|
||||||
Model.BeatmapInfo = res.ToBeatmap(rulesets);
|
Model.BeatmapInfo = res.ToBeatmapInfo(rulesets);
|
||||||
updatePanel();
|
updatePanel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -147,11 +147,11 @@ namespace osu.Game.Tournament.Screens.MapPool
|
|||||||
|
|
||||||
if (map != null)
|
if (map != null)
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButton.Left && map.Beatmap.OnlineBeatmapID != null)
|
if (e.Button == MouseButton.Left && map.BeatmapInfo.OnlineBeatmapID != null)
|
||||||
addForBeatmap(map.Beatmap.OnlineBeatmapID.Value);
|
addForBeatmap(map.BeatmapInfo.OnlineBeatmapID.Value);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var existing = CurrentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.Beatmap.OnlineBeatmapID);
|
var existing = CurrentMatch.Value.PicksBans.FirstOrDefault(p => p.BeatmapID == map.BeatmapInfo.OnlineBeatmapID);
|
||||||
|
|
||||||
if (existing != null)
|
if (existing != null)
|
||||||
{
|
{
|
||||||
|
@ -182,7 +182,7 @@ namespace osu.Game.Tournament
|
|||||||
{
|
{
|
||||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
||||||
API.Perform(req);
|
API.Perform(req);
|
||||||
b.BeatmapInfo = req.Result?.ToBeatmap(RulesetStore);
|
b.BeatmapInfo = req.Result?.ToBeatmapInfo(RulesetStore);
|
||||||
|
|
||||||
addedInfo = true;
|
addedInfo = true;
|
||||||
}
|
}
|
||||||
@ -203,7 +203,7 @@ namespace osu.Game.Tournament
|
|||||||
{
|
{
|
||||||
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
var req = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = b.ID });
|
||||||
req.Perform(API);
|
req.Perform(API);
|
||||||
b.BeatmapInfo = req.Result?.ToBeatmap(RulesetStore);
|
b.BeatmapInfo = req.Result?.ToBeatmapInfo(RulesetStore);
|
||||||
|
|
||||||
addedInfo = true;
|
addedInfo = true;
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
// GetDifficultyAsync will fall back to existing data from BeatmapInfo if not locally available
|
// GetDifficultyAsync will fall back to existing data from BeatmapInfo if not locally available
|
||||||
// (contrary to GetAsync)
|
// (contrary to GetAsync)
|
||||||
GetDifficultyAsync(bindable.Beatmap, rulesetInfo, mods, cancellationToken)
|
GetDifficultyAsync(bindable.BeatmapInfo, rulesetInfo, mods, cancellationToken)
|
||||||
.ContinueWith(t =>
|
.ContinueWith(t =>
|
||||||
{
|
{
|
||||||
// We're on a threadpool thread, but we should exit back to the update thread so consumers can safely handle value-changed events.
|
// We're on a threadpool thread, but we should exit back to the update thread so consumers can safely handle value-changed events.
|
||||||
@ -262,7 +262,7 @@ namespace osu.Game.Beatmaps
|
|||||||
private StarDifficulty computeDifficulty(in DifficultyCacheLookup key)
|
private StarDifficulty computeDifficulty(in DifficultyCacheLookup key)
|
||||||
{
|
{
|
||||||
// In the case that the user hasn't given us a ruleset, use the beatmap's default ruleset.
|
// In the case that the user hasn't given us a ruleset, use the beatmap's default ruleset.
|
||||||
var beatmapInfo = key.Beatmap;
|
var beatmapInfo = key.BeatmapInfo;
|
||||||
var rulesetInfo = key.Ruleset;
|
var rulesetInfo = key.Ruleset;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -270,7 +270,7 @@ namespace osu.Game.Beatmaps
|
|||||||
var ruleset = rulesetInfo.CreateInstance();
|
var ruleset = rulesetInfo.CreateInstance();
|
||||||
Debug.Assert(ruleset != null);
|
Debug.Assert(ruleset != null);
|
||||||
|
|
||||||
var calculator = ruleset.CreateDifficultyCalculator(beatmapManager.GetWorkingBeatmap(key.Beatmap));
|
var calculator = ruleset.CreateDifficultyCalculator(beatmapManager.GetWorkingBeatmap(key.BeatmapInfo));
|
||||||
var attributes = calculator.Calculate(key.OrderedMods);
|
var attributes = calculator.Calculate(key.OrderedMods);
|
||||||
|
|
||||||
return new StarDifficulty(attributes);
|
return new StarDifficulty(attributes);
|
||||||
@ -300,21 +300,21 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public readonly struct DifficultyCacheLookup : IEquatable<DifficultyCacheLookup>
|
public readonly struct DifficultyCacheLookup : IEquatable<DifficultyCacheLookup>
|
||||||
{
|
{
|
||||||
public readonly BeatmapInfo Beatmap;
|
public readonly BeatmapInfo BeatmapInfo;
|
||||||
public readonly RulesetInfo Ruleset;
|
public readonly RulesetInfo Ruleset;
|
||||||
|
|
||||||
public readonly Mod[] OrderedMods;
|
public readonly Mod[] OrderedMods;
|
||||||
|
|
||||||
public DifficultyCacheLookup([NotNull] BeatmapInfo beatmap, [CanBeNull] RulesetInfo ruleset, IEnumerable<Mod> mods)
|
public DifficultyCacheLookup([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo ruleset, IEnumerable<Mod> mods)
|
||||||
{
|
{
|
||||||
Beatmap = beatmap;
|
BeatmapInfo = beatmapInfo;
|
||||||
// In the case that the user hasn't given us a ruleset, use the beatmap's default ruleset.
|
// In the case that the user hasn't given us a ruleset, use the beatmap's default ruleset.
|
||||||
Ruleset = ruleset ?? Beatmap.Ruleset;
|
Ruleset = ruleset ?? BeatmapInfo.Ruleset;
|
||||||
OrderedMods = mods?.OrderBy(m => m.Acronym).Select(mod => mod.DeepClone()).ToArray() ?? Array.Empty<Mod>();
|
OrderedMods = mods?.OrderBy(m => m.Acronym).Select(mod => mod.DeepClone()).ToArray() ?? Array.Empty<Mod>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(DifficultyCacheLookup other)
|
public bool Equals(DifficultyCacheLookup other)
|
||||||
=> Beatmap.ID == other.Beatmap.ID
|
=> BeatmapInfo.ID == other.BeatmapInfo.ID
|
||||||
&& Ruleset.ID == other.Ruleset.ID
|
&& Ruleset.ID == other.Ruleset.ID
|
||||||
&& OrderedMods.SequenceEqual(other.OrderedMods);
|
&& OrderedMods.SequenceEqual(other.OrderedMods);
|
||||||
|
|
||||||
@ -322,7 +322,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
var hashCode = new HashCode();
|
var hashCode = new HashCode();
|
||||||
|
|
||||||
hashCode.Add(Beatmap.ID);
|
hashCode.Add(BeatmapInfo.ID);
|
||||||
hashCode.Add(Ruleset.ID);
|
hashCode.Add(Ruleset.ID);
|
||||||
|
|
||||||
foreach (var mod in OrderedMods)
|
foreach (var mod in OrderedMods)
|
||||||
@ -334,12 +334,12 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
private class BindableStarDifficulty : Bindable<StarDifficulty?>
|
private class BindableStarDifficulty : Bindable<StarDifficulty?>
|
||||||
{
|
{
|
||||||
public readonly BeatmapInfo Beatmap;
|
public readonly BeatmapInfo BeatmapInfo;
|
||||||
public readonly CancellationToken CancellationToken;
|
public readonly CancellationToken CancellationToken;
|
||||||
|
|
||||||
public BindableStarDifficulty(BeatmapInfo beatmap, CancellationToken cancellationToken)
|
public BindableStarDifficulty(BeatmapInfo beatmapInfo, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
Beatmap = beatmap;
|
BeatmapInfo = beatmapInfo;
|
||||||
CancellationToken = cancellationToken;
|
CancellationToken = cancellationToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ namespace osu.Game.Beatmaps
|
|||||||
private readonly BeatmapModelDownloader beatmapModelDownloader;
|
private readonly BeatmapModelDownloader beatmapModelDownloader;
|
||||||
|
|
||||||
private readonly WorkingBeatmapCache workingBeatmapCache;
|
private readonly WorkingBeatmapCache workingBeatmapCache;
|
||||||
private readonly BeatmapOnlineLookupQueue onlineBetamapLookupQueue;
|
private readonly BeatmapOnlineLookupQueue onlineBeatmapLookupQueue;
|
||||||
|
|
||||||
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host = null,
|
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host = null,
|
||||||
WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false)
|
WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false)
|
||||||
@ -48,8 +48,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
if (performOnlineLookups)
|
if (performOnlineLookups)
|
||||||
{
|
{
|
||||||
onlineBetamapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
|
onlineBeatmapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
|
||||||
beatmapModelManager.OnlineLookupQueue = onlineBetamapLookupQueue;
|
beatmapModelManager.OnlineLookupQueue = onlineBeatmapLookupQueue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,8 +90,9 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var working = beatmapModelManager.Import(set).Result;
|
var imported = beatmapModelManager.Import(set).Result.Value;
|
||||||
return GetWorkingBeatmap(working.Beatmaps.First());
|
|
||||||
|
return GetWorkingBeatmap(imported.Beatmaps.First());
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Delegation to BeatmapModelManager (methods which previously existed locally).
|
#region Delegation to BeatmapModelManager (methods which previously existed locally).
|
||||||
@ -177,19 +178,19 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when the user requests to view the resulting import.
|
/// Fired when the user requests to view the resulting import.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<IEnumerable<BeatmapSetInfo>> PresentImport { set => beatmapModelManager.PresentImport = value; }
|
public Action<IEnumerable<ILive<BeatmapSetInfo>>> PresentImport { set => beatmapModelManager.PostImport = value; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete a beatmap difficulty.
|
/// Delete a beatmap difficulty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap difficulty to hide.</param>
|
/// <param name="beatmapInfo">The beatmap difficulty to hide.</param>
|
||||||
public void Hide(BeatmapInfo beatmap) => beatmapModelManager.Hide(beatmap);
|
public void Hide(BeatmapInfo beatmapInfo) => beatmapModelManager.Hide(beatmapInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restore a beatmap difficulty.
|
/// Restore a beatmap difficulty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap difficulty to restore.</param>
|
/// <param name="beatmapInfo">The beatmap difficulty to restore.</param>
|
||||||
public void Restore(BeatmapInfo beatmap) => beatmapModelManager.Restore(beatmap);
|
public void Restore(BeatmapInfo beatmapInfo) => beatmapModelManager.Restore(beatmapInfo);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -276,22 +277,22 @@ namespace osu.Game.Beatmaps
|
|||||||
return beatmapModelManager.Import(tasks);
|
return beatmapModelManager.Import(tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<IEnumerable<BeatmapSetInfo>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
public Task<IEnumerable<ILive<BeatmapSetInfo>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||||
{
|
{
|
||||||
return beatmapModelManager.Import(notification, tasks);
|
return beatmapModelManager.Import(notification, tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<BeatmapSetInfo> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
public Task<ILive<BeatmapSetInfo>> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return beatmapModelManager.Import(task, lowPriority, cancellationToken);
|
return beatmapModelManager.Import(task, lowPriority, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<BeatmapSetInfo> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
public Task<ILive<BeatmapSetInfo>> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return beatmapModelManager.Import(archive, lowPriority, cancellationToken);
|
return beatmapModelManager.Import(archive, lowPriority, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<BeatmapSetInfo> Import(BeatmapSetInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
public Task<ILive<BeatmapSetInfo>> Import(BeatmapSetInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return beatmapModelManager.Import(item, archive, lowPriority, cancellationToken);
|
return beatmapModelManager.Import(item, archive, lowPriority, cancellationToken);
|
||||||
}
|
}
|
||||||
@ -329,7 +330,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
onlineBetamapLookupQueue?.Dispose();
|
onlineBeatmapLookupQueue?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -173,24 +173,24 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delete a beatmap difficulty.
|
/// Delete a beatmap difficulty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap difficulty to hide.</param>
|
/// <param name="beatmapInfo">The beatmap difficulty to hide.</param>
|
||||||
public void Hide(BeatmapInfo beatmap) => beatmaps.Hide(beatmap);
|
public void Hide(BeatmapInfo beatmapInfo) => beatmaps.Hide(beatmapInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restore a beatmap difficulty.
|
/// Restore a beatmap difficulty.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap difficulty to restore.</param>
|
/// <param name="beatmapInfo">The beatmap difficulty to restore.</param>
|
||||||
public void Restore(BeatmapInfo beatmap) => beatmaps.Restore(beatmap);
|
public void Restore(BeatmapInfo beatmapInfo) => beatmaps.Restore(beatmapInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Saves an <see cref="IBeatmap"/> file against a given <see cref="BeatmapInfo"/>.
|
/// Saves an <see cref="IBeatmap"/> file against a given <see cref="BeatmapInfo"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info">The <see cref="BeatmapInfo"/> to save the content against. The file referenced by <see cref="BeatmapInfo.Path"/> will be replaced.</param>
|
/// <param name="beatmapInfo">The <see cref="BeatmapInfo"/> to save the content against. The file referenced by <see cref="BeatmapInfo.Path"/> will be replaced.</param>
|
||||||
/// <param name="beatmapContent">The <see cref="IBeatmap"/> content to write.</param>
|
/// <param name="beatmapContent">The <see cref="IBeatmap"/> content to write.</param>
|
||||||
/// <param name="beatmapSkin">The beatmap <see cref="ISkin"/> content to write, null if to be omitted.</param>
|
/// <param name="beatmapSkin">The beatmap <see cref="ISkin"/> content to write, null if to be omitted.</param>
|
||||||
public virtual void Save(BeatmapInfo info, IBeatmap beatmapContent, ISkin beatmapSkin = null)
|
public virtual void Save(BeatmapInfo beatmapInfo, IBeatmap beatmapContent, ISkin beatmapSkin = null)
|
||||||
{
|
{
|
||||||
var setInfo = info.BeatmapSet;
|
var setInfo = beatmapInfo.BeatmapSet;
|
||||||
|
|
||||||
using (var stream = new MemoryStream())
|
using (var stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
@ -201,7 +201,7 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
using (ContextFactory.GetForWrite())
|
using (ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
var beatmapInfo = setInfo.Beatmaps.Single(b => b.ID == info.ID);
|
beatmapInfo = setInfo.Beatmaps.Single(b => b.ID == beatmapInfo.ID);
|
||||||
var metadata = beatmapInfo.Metadata ?? setInfo.Metadata;
|
var metadata = beatmapInfo.Metadata ?? setInfo.Metadata;
|
||||||
|
|
||||||
// grab the original file (or create a new one if not found).
|
// grab the original file (or create a new one if not found).
|
||||||
@ -219,7 +219,7 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WorkingBeatmapCache?.Invalidate(info);
|
WorkingBeatmapCache?.Invalidate(beatmapInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -58,18 +58,18 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo: expose this when we need to do individual difficulty lookups.
|
// todo: expose this when we need to do individual difficulty lookups.
|
||||||
protected Task UpdateAsync(BeatmapSetInfo beatmapSet, BeatmapInfo beatmap, CancellationToken cancellationToken)
|
protected Task UpdateAsync(BeatmapSetInfo beatmapSet, BeatmapInfo beatmapInfo, CancellationToken cancellationToken)
|
||||||
=> Task.Factory.StartNew(() => lookup(beatmapSet, beatmap), cancellationToken, TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler);
|
=> Task.Factory.StartNew(() => lookup(beatmapSet, beatmapInfo), cancellationToken, TaskCreationOptions.HideScheduler | TaskCreationOptions.RunContinuationsAsynchronously, updateScheduler);
|
||||||
|
|
||||||
private void lookup(BeatmapSetInfo set, BeatmapInfo beatmap)
|
private void lookup(BeatmapSetInfo set, BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
if (checkLocalCache(set, beatmap))
|
if (checkLocalCache(set, beatmapInfo))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (api?.State.Value != APIState.Online)
|
if (api?.State.Value != APIState.Online)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var req = new GetBeatmapRequest(beatmap);
|
var req = new GetBeatmapRequest(beatmapInfo);
|
||||||
|
|
||||||
req.Failure += fail;
|
req.Failure += fail;
|
||||||
|
|
||||||
@ -82,18 +82,18 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
if (res != null)
|
if (res != null)
|
||||||
{
|
{
|
||||||
beatmap.Status = res.Status;
|
beatmapInfo.Status = res.Status;
|
||||||
beatmap.BeatmapSet.Status = res.BeatmapSet.Status;
|
beatmapInfo.BeatmapSet.Status = res.BeatmapSet.Status;
|
||||||
beatmap.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
beatmapInfo.BeatmapSet.OnlineBeatmapSetID = res.OnlineBeatmapSetID;
|
||||||
beatmap.OnlineBeatmapID = res.OnlineBeatmapID;
|
beatmapInfo.OnlineBeatmapID = res.OnlineBeatmapID;
|
||||||
|
|
||||||
if (beatmap.Metadata != null)
|
if (beatmapInfo.Metadata != null)
|
||||||
beatmap.Metadata.AuthorID = res.AuthorID;
|
beatmapInfo.Metadata.AuthorID = res.AuthorID;
|
||||||
|
|
||||||
if (beatmap.BeatmapSet.Metadata != null)
|
if (beatmapInfo.BeatmapSet.Metadata != null)
|
||||||
beatmap.BeatmapSet.Metadata.AuthorID = res.AuthorID;
|
beatmapInfo.BeatmapSet.Metadata.AuthorID = res.AuthorID;
|
||||||
|
|
||||||
logForModel(set, $"Online retrieval mapped {beatmap} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.");
|
logForModel(set, $"Online retrieval mapped {beatmapInfo} to {res.OnlineBeatmapSetID} / {res.OnlineBeatmapID}.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@ -103,8 +103,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
void fail(Exception e)
|
void fail(Exception e)
|
||||||
{
|
{
|
||||||
beatmap.OnlineBeatmapID = null;
|
beatmapInfo.OnlineBeatmapID = null;
|
||||||
logForModel(set, $"Online retrieval failed for {beatmap} ({e.Message})");
|
logForModel(set, $"Online retrieval failed for {beatmapInfo} ({e.Message})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ namespace osu.Game.Beatmaps
|
|||||||
cacheDownloadRequest.PerformAsync();
|
cacheDownloadRequest.PerformAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool checkLocalCache(BeatmapSetInfo set, BeatmapInfo beatmap)
|
private bool checkLocalCache(BeatmapSetInfo set, BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
// download is in progress (or was, and failed).
|
// download is in progress (or was, and failed).
|
||||||
if (cacheDownloadRequest != null)
|
if (cacheDownloadRequest != null)
|
||||||
@ -159,9 +159,9 @@ namespace osu.Game.Beatmaps
|
|||||||
if (!storage.Exists(cache_database_name))
|
if (!storage.Exists(cache_database_name))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(beatmap.MD5Hash)
|
if (string.IsNullOrEmpty(beatmapInfo.MD5Hash)
|
||||||
&& string.IsNullOrEmpty(beatmap.Path)
|
&& string.IsNullOrEmpty(beatmapInfo.Path)
|
||||||
&& beatmap.OnlineBeatmapID == null)
|
&& beatmapInfo.OnlineBeatmapID == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try
|
try
|
||||||
@ -174,9 +174,9 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
cmd.CommandText = "SELECT beatmapset_id, beatmap_id, approved, user_id FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineBeatmapID OR filename = @Path";
|
cmd.CommandText = "SELECT beatmapset_id, beatmap_id, approved, user_id FROM osu_beatmaps WHERE checksum = @MD5Hash OR beatmap_id = @OnlineBeatmapID OR filename = @Path";
|
||||||
|
|
||||||
cmd.Parameters.Add(new SqliteParameter("@MD5Hash", beatmap.MD5Hash));
|
cmd.Parameters.Add(new SqliteParameter("@MD5Hash", beatmapInfo.MD5Hash));
|
||||||
cmd.Parameters.Add(new SqliteParameter("@OnlineBeatmapID", beatmap.OnlineBeatmapID ?? (object)DBNull.Value));
|
cmd.Parameters.Add(new SqliteParameter("@OnlineBeatmapID", beatmapInfo.OnlineBeatmapID ?? (object)DBNull.Value));
|
||||||
cmd.Parameters.Add(new SqliteParameter("@Path", beatmap.Path));
|
cmd.Parameters.Add(new SqliteParameter("@Path", beatmapInfo.Path));
|
||||||
|
|
||||||
using (var reader = cmd.ExecuteReader())
|
using (var reader = cmd.ExecuteReader())
|
||||||
{
|
{
|
||||||
@ -184,18 +184,18 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
var status = (BeatmapSetOnlineStatus)reader.GetByte(2);
|
var status = (BeatmapSetOnlineStatus)reader.GetByte(2);
|
||||||
|
|
||||||
beatmap.Status = status;
|
beatmapInfo.Status = status;
|
||||||
beatmap.BeatmapSet.Status = status;
|
beatmapInfo.BeatmapSet.Status = status;
|
||||||
beatmap.BeatmapSet.OnlineBeatmapSetID = reader.GetInt32(0);
|
beatmapInfo.BeatmapSet.OnlineBeatmapSetID = reader.GetInt32(0);
|
||||||
beatmap.OnlineBeatmapID = reader.GetInt32(1);
|
beatmapInfo.OnlineBeatmapID = reader.GetInt32(1);
|
||||||
|
|
||||||
if (beatmap.Metadata != null)
|
if (beatmapInfo.Metadata != null)
|
||||||
beatmap.Metadata.AuthorID = reader.GetInt32(3);
|
beatmapInfo.Metadata.AuthorID = reader.GetInt32(3);
|
||||||
|
|
||||||
if (beatmap.BeatmapSet.Metadata != null)
|
if (beatmapInfo.BeatmapSet.Metadata != null)
|
||||||
beatmap.BeatmapSet.Metadata.AuthorID = reader.GetInt32(3);
|
beatmapInfo.BeatmapSet.Metadata.AuthorID = reader.GetInt32(3);
|
||||||
|
|
||||||
logForModel(set, $"Cached local retrieval for {beatmap}.");
|
logForModel(set, $"Cached local retrieval for {beatmapInfo}.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,7 +204,7 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logForModel(set, $"Cached local retrieval for {beatmap} failed with {ex}.");
|
logForModel(set, $"Cached local retrieval for {beatmapInfo} failed with {ex}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -25,40 +25,40 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Hide a <see cref="BeatmapInfo"/> in the database.
|
/// Hide a <see cref="BeatmapInfo"/> in the database.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap to hide.</param>
|
/// <param name="beatmapInfo">The beatmap to hide.</param>
|
||||||
/// <returns>Whether the beatmap's <see cref="BeatmapInfo.Hidden"/> was changed.</returns>
|
/// <returns>Whether the beatmap's <see cref="BeatmapInfo.Hidden"/> was changed.</returns>
|
||||||
public bool Hide(BeatmapInfo beatmap)
|
public bool Hide(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
using (ContextFactory.GetForWrite())
|
using (ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
Refresh(ref beatmap, Beatmaps);
|
Refresh(ref beatmapInfo, Beatmaps);
|
||||||
|
|
||||||
if (beatmap.Hidden) return false;
|
if (beatmapInfo.Hidden) return false;
|
||||||
|
|
||||||
beatmap.Hidden = true;
|
beatmapInfo.Hidden = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeatmapHidden?.Invoke(beatmap);
|
BeatmapHidden?.Invoke(beatmapInfo);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Restore a previously hidden <see cref="BeatmapInfo"/>.
|
/// Restore a previously hidden <see cref="BeatmapInfo"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap to restore.</param>
|
/// <param name="beatmapInfo">The beatmap to restore.</param>
|
||||||
/// <returns>Whether the beatmap's <see cref="BeatmapInfo.Hidden"/> was changed.</returns>
|
/// <returns>Whether the beatmap's <see cref="BeatmapInfo.Hidden"/> was changed.</returns>
|
||||||
public bool Restore(BeatmapInfo beatmap)
|
public bool Restore(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
using (ContextFactory.GetForWrite())
|
using (ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
Refresh(ref beatmap, Beatmaps);
|
Refresh(ref beatmapInfo, Beatmaps);
|
||||||
|
|
||||||
if (!beatmap.Hidden) return false;
|
if (!beatmapInfo.Hidden) return false;
|
||||||
|
|
||||||
beatmap.Hidden = false;
|
beatmapInfo.Hidden = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BeatmapRestored?.Invoke(beatmap);
|
BeatmapRestored?.Invoke(beatmapInfo);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,14 +62,14 @@ namespace osu.Game.Beatmaps
|
|||||||
if (!recommendedDifficultyMapping.TryGetValue(r, out var recommendation))
|
if (!recommendedDifficultyMapping.TryGetValue(r, out var recommendation))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
BeatmapInfo beatmap = beatmaps.Where(b => b.Ruleset.Equals(r)).OrderBy(b =>
|
BeatmapInfo beatmapInfo = beatmaps.Where(b => b.Ruleset.Equals(r)).OrderBy(b =>
|
||||||
{
|
{
|
||||||
var difference = b.StarDifficulty - recommendation;
|
var difference = b.StarDifficulty - recommendation;
|
||||||
return difference >= 0 ? difference * 2 : difference * -1; // prefer easier over harder
|
return difference >= 0 ? difference * 2 : difference * -1; // prefer easier over harder
|
||||||
}).FirstOrDefault();
|
}).FirstOrDefault();
|
||||||
|
|
||||||
if (beatmap != null)
|
if (beatmapInfo != null)
|
||||||
return beatmap;
|
return beatmapInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
}
|
}
|
||||||
|
|
||||||
[NotNull]
|
[NotNull]
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
@ -56,26 +56,26 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="DifficultyIcon"/> with a given <see cref="RulesetInfo"/> and <see cref="Mod"/> combination.
|
/// Creates a new <see cref="DifficultyIcon"/> with a given <see cref="RulesetInfo"/> and <see cref="Mod"/> combination.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap to show the difficulty of.</param>
|
/// <param name="beatmapInfo">The beatmap to show the difficulty of.</param>
|
||||||
/// <param name="ruleset">The ruleset to show the difficulty with.</param>
|
/// <param name="ruleset">The ruleset to show the difficulty with.</param>
|
||||||
/// <param name="mods">The mods to show the difficulty with.</param>
|
/// <param name="mods">The mods to show the difficulty with.</param>
|
||||||
/// <param name="shouldShowTooltip">Whether to display a tooltip when hovered.</param>
|
/// <param name="shouldShowTooltip">Whether to display a tooltip when hovered.</param>
|
||||||
public DifficultyIcon([NotNull] BeatmapInfo beatmap, [CanBeNull] RulesetInfo ruleset, [CanBeNull] IReadOnlyList<Mod> mods, bool shouldShowTooltip = true)
|
public DifficultyIcon([NotNull] BeatmapInfo beatmapInfo, [CanBeNull] RulesetInfo ruleset, [CanBeNull] IReadOnlyList<Mod> mods, bool shouldShowTooltip = true)
|
||||||
: this(beatmap, shouldShowTooltip)
|
: this(beatmapInfo, shouldShowTooltip)
|
||||||
{
|
{
|
||||||
this.ruleset = ruleset ?? beatmap.Ruleset;
|
this.ruleset = ruleset ?? beatmapInfo.Ruleset;
|
||||||
this.mods = mods ?? Array.Empty<Mod>();
|
this.mods = mods ?? Array.Empty<Mod>();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new <see cref="DifficultyIcon"/> that follows the currently-selected ruleset and mods.
|
/// Creates a new <see cref="DifficultyIcon"/> that follows the currently-selected ruleset and mods.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap to show the difficulty of.</param>
|
/// <param name="beatmapInfo">The beatmap to show the difficulty of.</param>
|
||||||
/// <param name="shouldShowTooltip">Whether to display a tooltip when hovered.</param>
|
/// <param name="shouldShowTooltip">Whether to display a tooltip when hovered.</param>
|
||||||
/// <param name="performBackgroundDifficultyLookup">Whether to perform difficulty lookup (including calculation if necessary).</param>
|
/// <param name="performBackgroundDifficultyLookup">Whether to perform difficulty lookup (including calculation if necessary).</param>
|
||||||
public DifficultyIcon([NotNull] BeatmapInfo beatmap, bool shouldShowTooltip = true, bool performBackgroundDifficultyLookup = true)
|
public DifficultyIcon([NotNull] BeatmapInfo beatmapInfo, bool shouldShowTooltip = true, bool performBackgroundDifficultyLookup = true)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap ?? throw new ArgumentNullException(nameof(beatmap));
|
this.beatmapInfo = beatmapInfo ?? throw new ArgumentNullException(nameof(beatmapInfo));
|
||||||
this.shouldShowTooltip = shouldShowTooltip;
|
this.shouldShowTooltip = shouldShowTooltip;
|
||||||
this.performBackgroundDifficultyLookup = performBackgroundDifficultyLookup;
|
this.performBackgroundDifficultyLookup = performBackgroundDifficultyLookup;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
Child = background = new Box
|
Child = background = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = colours.ForStarDifficulty(beatmap.StarDifficulty) // Default value that will be re-populated once difficulty calculation completes
|
Colour = colours.ForStarDifficulty(beatmapInfo.StarDifficulty) // Default value that will be re-populated once difficulty calculation completes
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
new ConstrainedIconContainer
|
new ConstrainedIconContainer
|
||||||
@ -114,27 +114,27 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
// the null coalesce here is only present to make unit tests work (ruleset dlls aren't copied correctly for testing at the moment)
|
// the null coalesce here is only present to make unit tests work (ruleset dlls aren't copied correctly for testing at the moment)
|
||||||
Icon = (ruleset ?? beatmap.Ruleset)?.CreateInstance()?.CreateIcon() ?? new SpriteIcon { Icon = FontAwesome.Regular.QuestionCircle }
|
Icon = (ruleset ?? beatmapInfo.Ruleset)?.CreateInstance()?.CreateIcon() ?? new SpriteIcon { Icon = FontAwesome.Regular.QuestionCircle }
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (performBackgroundDifficultyLookup)
|
if (performBackgroundDifficultyLookup)
|
||||||
iconContainer.Add(new DelayedLoadUnloadWrapper(() => new DifficultyRetriever(beatmap, ruleset, mods) { StarDifficulty = { BindTarget = difficultyBindable } }, 0));
|
iconContainer.Add(new DelayedLoadUnloadWrapper(() => new DifficultyRetriever(beatmapInfo, ruleset, mods) { StarDifficulty = { BindTarget = difficultyBindable } }, 0));
|
||||||
else
|
else
|
||||||
difficultyBindable.Value = new StarDifficulty(beatmap.StarDifficulty, 0);
|
difficultyBindable.Value = new StarDifficulty(beatmapInfo.StarDifficulty, 0);
|
||||||
|
|
||||||
difficultyBindable.BindValueChanged(difficulty => background.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars));
|
difficultyBindable.BindValueChanged(difficulty => background.Colour = colours.ForStarDifficulty(difficulty.NewValue.Stars));
|
||||||
}
|
}
|
||||||
|
|
||||||
ITooltip<DifficultyIconTooltipContent> IHasCustomTooltip<DifficultyIconTooltipContent>.GetCustomTooltip() => new DifficultyIconTooltip();
|
ITooltip<DifficultyIconTooltipContent> IHasCustomTooltip<DifficultyIconTooltipContent>.GetCustomTooltip() => new DifficultyIconTooltip();
|
||||||
|
|
||||||
DifficultyIconTooltipContent IHasCustomTooltip<DifficultyIconTooltipContent>.TooltipContent => shouldShowTooltip ? new DifficultyIconTooltipContent(beatmap, difficultyBindable) : null;
|
DifficultyIconTooltipContent IHasCustomTooltip<DifficultyIconTooltipContent>.TooltipContent => shouldShowTooltip ? new DifficultyIconTooltipContent(beatmapInfo, difficultyBindable) : null;
|
||||||
|
|
||||||
private class DifficultyRetriever : Component
|
private class DifficultyRetriever : Component
|
||||||
{
|
{
|
||||||
public readonly Bindable<StarDifficulty> StarDifficulty = new Bindable<StarDifficulty>();
|
public readonly Bindable<StarDifficulty> StarDifficulty = new Bindable<StarDifficulty>();
|
||||||
|
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly BeatmapInfo beatmapInfo;
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
private readonly IReadOnlyList<Mod> mods;
|
private readonly IReadOnlyList<Mod> mods;
|
||||||
|
|
||||||
@ -143,9 +143,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private BeatmapDifficultyCache difficultyCache { get; set; }
|
private BeatmapDifficultyCache difficultyCache { get; set; }
|
||||||
|
|
||||||
public DifficultyRetriever(BeatmapInfo beatmap, RulesetInfo ruleset, IReadOnlyList<Mod> mods)
|
public DifficultyRetriever(BeatmapInfo beatmapInfo, RulesetInfo ruleset, IReadOnlyList<Mod> mods)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmapInfo = beatmapInfo;
|
||||||
this.ruleset = ruleset;
|
this.ruleset = ruleset;
|
||||||
this.mods = mods;
|
this.mods = mods;
|
||||||
}
|
}
|
||||||
@ -157,8 +157,8 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
{
|
{
|
||||||
difficultyCancellation = new CancellationTokenSource();
|
difficultyCancellation = new CancellationTokenSource();
|
||||||
localStarDifficulty = ruleset != null
|
localStarDifficulty = ruleset != null
|
||||||
? difficultyCache.GetBindableDifficulty(beatmap, ruleset, mods, difficultyCancellation.Token)
|
? difficultyCache.GetBindableDifficulty(beatmapInfo, ruleset, mods, difficultyCancellation.Token)
|
||||||
: difficultyCache.GetBindableDifficulty(beatmap, difficultyCancellation.Token);
|
: difficultyCache.GetBindableDifficulty(beatmapInfo, difficultyCancellation.Token);
|
||||||
localStarDifficulty.BindValueChanged(d =>
|
localStarDifficulty.BindValueChanged(d =>
|
||||||
{
|
{
|
||||||
if (d.NewValue is StarDifficulty diff)
|
if (d.NewValue is StarDifficulty diff)
|
||||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
public void SetContent(DifficultyIconTooltipContent content)
|
public void SetContent(DifficultyIconTooltipContent content)
|
||||||
{
|
{
|
||||||
difficultyName.Text = content.Beatmap.Version;
|
difficultyName.Text = content.BeatmapInfo.Version;
|
||||||
|
|
||||||
starDifficulty.UnbindAll();
|
starDifficulty.UnbindAll();
|
||||||
starDifficulty.BindTo(content.Difficulty);
|
starDifficulty.BindTo(content.Difficulty);
|
||||||
@ -109,12 +109,12 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
|
|
||||||
internal class DifficultyIconTooltipContent
|
internal class DifficultyIconTooltipContent
|
||||||
{
|
{
|
||||||
public readonly BeatmapInfo Beatmap;
|
public readonly BeatmapInfo BeatmapInfo;
|
||||||
public readonly IBindable<StarDifficulty> Difficulty;
|
public readonly IBindable<StarDifficulty> Difficulty;
|
||||||
|
|
||||||
public DifficultyIconTooltipContent(BeatmapInfo beatmap, IBindable<StarDifficulty> difficulty)
|
public DifficultyIconTooltipContent(BeatmapInfo beatmapInfo, IBindable<StarDifficulty> difficulty)
|
||||||
{
|
{
|
||||||
Beatmap = beatmap;
|
BeatmapInfo = beatmapInfo;
|
||||||
Difficulty = difficulty;
|
Difficulty = difficulty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ namespace osu.Game.Database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TModel">The model type.</typeparam>
|
/// <typeparam name="TModel">The model type.</typeparam>
|
||||||
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
/// <typeparam name="TFileModel">The associated file join type.</typeparam>
|
||||||
public abstract class ArchiveModelManager<TModel, TFileModel> : ICanAcceptFiles, IModelManager<TModel>, IModelFileManager<TModel, TFileModel>, IPresentImports<TModel>
|
public abstract class ArchiveModelManager<TModel, TFileModel> : ICanAcceptFiles, IModelManager<TModel>, IModelFileManager<TModel, TFileModel>, IPostImports<TModel>
|
||||||
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
where TModel : class, IHasFiles<TFileModel>, IHasPrimaryKey, ISoftDelete
|
||||||
where TFileModel : class, INamedFileInfo, new()
|
where TFileModel : class, INamedFileInfo, new()
|
||||||
{
|
{
|
||||||
@ -132,13 +132,13 @@ namespace osu.Game.Database
|
|||||||
return Import(notification, tasks);
|
return Import(notification, tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IEnumerable<TModel>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
public async Task<IEnumerable<ILive<TModel>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||||
{
|
{
|
||||||
if (tasks.Length == 0)
|
if (tasks.Length == 0)
|
||||||
{
|
{
|
||||||
notification.CompletionText = $"No {HumanisedModelName}s were found to import!";
|
notification.CompletionText = $"No {HumanisedModelName}s were found to import!";
|
||||||
notification.State = ProgressNotificationState.Completed;
|
notification.State = ProgressNotificationState.Completed;
|
||||||
return Enumerable.Empty<TModel>();
|
return Enumerable.Empty<ILive<TModel>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
notification.Progress = 0;
|
notification.Progress = 0;
|
||||||
@ -146,7 +146,7 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
int current = 0;
|
int current = 0;
|
||||||
|
|
||||||
var imported = new List<TModel>();
|
var imported = new List<ILive<TModel>>();
|
||||||
|
|
||||||
bool isLowPriorityImport = tasks.Length > low_priority_import_batch_size;
|
bool isLowPriorityImport = tasks.Length > low_priority_import_batch_size;
|
||||||
|
|
||||||
@ -200,12 +200,12 @@ namespace osu.Game.Database
|
|||||||
? $"Imported {imported.First()}!"
|
? $"Imported {imported.First()}!"
|
||||||
: $"Imported {imported.Count} {HumanisedModelName}s!";
|
: $"Imported {imported.Count} {HumanisedModelName}s!";
|
||||||
|
|
||||||
if (imported.Count > 0 && PresentImport != null)
|
if (imported.Count > 0 && PostImport != null)
|
||||||
{
|
{
|
||||||
notification.CompletionText += " Click to view.";
|
notification.CompletionText += " Click to view.";
|
||||||
notification.CompletionClickAction = () =>
|
notification.CompletionClickAction = () =>
|
||||||
{
|
{
|
||||||
PresentImport?.Invoke(imported);
|
PostImport?.Invoke(imported);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -224,11 +224,11 @@ namespace osu.Game.Database
|
|||||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||||
/// <returns>The imported model, if successful.</returns>
|
/// <returns>The imported model, if successful.</returns>
|
||||||
public async Task<TModel> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
public async Task<ILive<TModel>> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
TModel import;
|
ILive<TModel> import;
|
||||||
using (ArchiveReader reader = task.GetReader())
|
using (ArchiveReader reader = task.GetReader())
|
||||||
import = await Import(reader, lowPriority, cancellationToken).ConfigureAwait(false);
|
import = await Import(reader, lowPriority, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
@ -243,13 +243,13 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
LogForModel(import, $@"Could not delete original file after import ({task})", e);
|
LogForModel(import?.Value, $@"Could not delete original file after import ({task})", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return import;
|
return import;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action<IEnumerable<TModel>> PresentImport { protected get; set; }
|
public Action<IEnumerable<ILive<TModel>>> PostImport { protected get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Silently import an item from an <see cref="ArchiveReader"/>.
|
/// Silently import an item from an <see cref="ArchiveReader"/>.
|
||||||
@ -257,7 +257,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="archive">The archive to be imported.</param>
|
/// <param name="archive">The archive to be imported.</param>
|
||||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||||
public Task<TModel> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
public Task<ILive<TModel>> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ namespace osu.Game.Database
|
|||||||
model = CreateModel(archive);
|
model = CreateModel(archive);
|
||||||
|
|
||||||
if (model == null)
|
if (model == null)
|
||||||
return Task.FromResult<TModel>(null);
|
return Task.FromResult<ILive<TModel>>(new EntityFrameworkLive<TModel>(null));
|
||||||
}
|
}
|
||||||
catch (TaskCanceledException)
|
catch (TaskCanceledException)
|
||||||
{
|
{
|
||||||
@ -343,7 +343,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="archive">An optional archive to use for model population.</param>
|
/// <param name="archive">An optional archive to use for model population.</param>
|
||||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||||
public virtual async Task<TModel> Import(TModel item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default) => await Task.Factory.StartNew(async () =>
|
public virtual async Task<ILive<TModel>> Import(TModel item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default) => await Task.Factory.StartNew(async () =>
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
LogForModel(item, @$"Found existing (optimised) {HumanisedModelName} for {item} (ID {existing.ID}) – skipping import.");
|
LogForModel(item, @$"Found existing (optimised) {HumanisedModelName} for {item} (ID {existing.ID}) – skipping import.");
|
||||||
Undelete(existing);
|
Undelete(existing);
|
||||||
return existing;
|
return existing.ToEntityFrameworkLive();
|
||||||
}
|
}
|
||||||
|
|
||||||
LogForModel(item, @"Found existing (optimised) but failed pre-check.");
|
LogForModel(item, @"Found existing (optimised) but failed pre-check.");
|
||||||
@ -415,7 +415,7 @@ namespace osu.Game.Database
|
|||||||
// existing item will be used; rollback new import and exit early.
|
// existing item will be used; rollback new import and exit early.
|
||||||
rollback();
|
rollback();
|
||||||
flushEvents(true);
|
flushEvents(true);
|
||||||
return existing;
|
return existing.ToEntityFrameworkLive();
|
||||||
}
|
}
|
||||||
|
|
||||||
LogForModel(item, @"Found existing but failed re-use check.");
|
LogForModel(item, @"Found existing but failed re-use check.");
|
||||||
@ -448,7 +448,7 @@ namespace osu.Game.Database
|
|||||||
}
|
}
|
||||||
|
|
||||||
flushEvents(true);
|
flushEvents(true);
|
||||||
return item;
|
return item.ToEntityFrameworkLive();
|
||||||
}, cancellationToken, TaskCreationOptions.HideScheduler, lowPriority ? import_scheduler_low_priority : import_scheduler).Unwrap().ConfigureAwait(false);
|
}, cancellationToken, TaskCreationOptions.HideScheduler, lowPriority ? import_scheduler_low_priority : import_scheduler).Unwrap().ConfigureAwait(false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
34
osu.Game/Database/EntityFrameworkLive.cs
Normal file
34
osu.Game/Database/EntityFrameworkLive.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// 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 System;
|
||||||
|
|
||||||
|
namespace osu.Game.Database
|
||||||
|
{
|
||||||
|
public class EntityFrameworkLive<T> : ILive<T> where T : class
|
||||||
|
{
|
||||||
|
public EntityFrameworkLive(T item)
|
||||||
|
{
|
||||||
|
Value = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Guid ID => throw new InvalidOperationException();
|
||||||
|
|
||||||
|
public void PerformRead(Action<T> perform)
|
||||||
|
{
|
||||||
|
perform(Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TReturn PerformRead<TReturn>(Func<T, TReturn> perform)
|
||||||
|
{
|
||||||
|
return perform(Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void PerformWrite(Action<T> perform)
|
||||||
|
{
|
||||||
|
perform(Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Value { get; }
|
||||||
|
}
|
||||||
|
}
|
14
osu.Game/Database/EntityFrameworkLiveExtensions.cs
Normal file
14
osu.Game/Database/EntityFrameworkLiveExtensions.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
namespace osu.Game.Database
|
||||||
|
{
|
||||||
|
public static class EntityFrameworkLiveExtensions
|
||||||
|
{
|
||||||
|
public static ILive<T> ToEntityFrameworkLive<T>(this T item)
|
||||||
|
where T : class
|
||||||
|
{
|
||||||
|
return new EntityFrameworkLive<T>(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,6 +11,6 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
Guid ID { get; set; }
|
Guid ID { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
42
osu.Game/Database/ILive.cs
Normal file
42
osu.Game/Database/ILive.cs
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// 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 System;
|
||||||
|
|
||||||
|
namespace osu.Game.Database
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A wrapper to provide access to database backed classes in a thread-safe manner.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The databased type.</typeparam>
|
||||||
|
public interface ILive<out T> where T : class // TODO: Add IHasGuidPrimaryKey once we don't need EF support any more.
|
||||||
|
{
|
||||||
|
Guid ID { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Perform a read operation on this live object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="perform">The action to perform.</param>
|
||||||
|
void PerformRead(Action<T> perform);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Perform a read operation on this live object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="perform">The action to perform.</param>
|
||||||
|
TReturn PerformRead<TReturn>(Func<T, TReturn> perform);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Perform a write operation on this live object.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="perform">The action to perform.</param>
|
||||||
|
void PerformWrite(Action<T> perform);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolve the value of this instance on the current thread's context.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// After resolving the data should not be passed between threads.
|
||||||
|
/// </remarks>
|
||||||
|
T Value { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -28,7 +28,7 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
Task Import(params ImportTask[] tasks);
|
Task Import(params ImportTask[] tasks);
|
||||||
|
|
||||||
Task<IEnumerable<TModel>> Import(ProgressNotification notification, params ImportTask[] tasks);
|
Task<IEnumerable<ILive<TModel>>> Import(ProgressNotification notification, params ImportTask[] tasks);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Import one <typeparamref name="TModel"/> from the filesystem and delete the file on success.
|
/// Import one <typeparamref name="TModel"/> from the filesystem and delete the file on success.
|
||||||
@ -38,7 +38,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||||
/// <returns>The imported model, if successful.</returns>
|
/// <returns>The imported model, if successful.</returns>
|
||||||
Task<TModel> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default);
|
Task<ILive<TModel>> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Silently import an item from an <see cref="ArchiveReader"/>.
|
/// Silently import an item from an <see cref="ArchiveReader"/>.
|
||||||
@ -46,7 +46,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="archive">The archive to be imported.</param>
|
/// <param name="archive">The archive to be imported.</param>
|
||||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||||
Task<TModel> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default);
|
Task<ILive<TModel>> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Silently import an item from a <typeparamref name="TModel"/>.
|
/// Silently import an item from a <typeparamref name="TModel"/>.
|
||||||
@ -55,7 +55,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="archive">An optional archive to use for model population.</param>
|
/// <param name="archive">An optional archive to use for model population.</param>
|
||||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||||
Task<TModel> Import(TModel item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default);
|
Task<ILive<TModel>> Import(TModel item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A user displayable name for the model type associated with this manager.
|
/// A user displayable name for the model type associated with this manager.
|
||||||
|
@ -6,12 +6,12 @@ using System.Collections.Generic;
|
|||||||
|
|
||||||
namespace osu.Game.Database
|
namespace osu.Game.Database
|
||||||
{
|
{
|
||||||
public interface IPresentImports<TModel>
|
public interface IPostImports<out TModel>
|
||||||
where TModel : class
|
where TModel : class
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fired when the user requests to view the resulting import.
|
/// Fired when the user requests to view the resulting import.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<IEnumerable<TModel>> PresentImport { set; }
|
public Action<IEnumerable<ILive<TModel>>> PostImport { set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,7 +6,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Game.Graphics.Containers;
|
using osu.Game.Graphics.Containers;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.AccountCreation
|
namespace osu.Game.Graphics
|
||||||
{
|
{
|
||||||
public class ErrorTextFlowContainer : OsuTextFlowContainer
|
public class ErrorTextFlowContainer : OsuTextFlowContainer
|
||||||
{
|
{
|
@ -35,9 +35,8 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public string WebsiteRootUrl { get; }
|
public string WebsiteRootUrl { get; }
|
||||||
|
|
||||||
/// <summary>
|
public Exception LastLoginError { get; private set; }
|
||||||
/// The username/email provided by the user when initiating a login.
|
|
||||||
/// </summary>
|
|
||||||
public string ProvidedUsername { get; private set; }
|
public string ProvidedUsername { get; private set; }
|
||||||
|
|
||||||
private string password;
|
private string password;
|
||||||
@ -136,15 +135,24 @@ namespace osu.Game.Online.API
|
|||||||
// save the username at this point, if the user requested for it to be.
|
// save the username at this point, if the user requested for it to be.
|
||||||
config.SetValue(OsuSetting.Username, config.Get<bool>(OsuSetting.SaveUsername) ? ProvidedUsername : string.Empty);
|
config.SetValue(OsuSetting.Username, config.Get<bool>(OsuSetting.SaveUsername) ? ProvidedUsername : string.Empty);
|
||||||
|
|
||||||
if (!authentication.HasValidAccessToken && !authentication.AuthenticateWithLogin(ProvidedUsername, password))
|
if (!authentication.HasValidAccessToken)
|
||||||
|
{
|
||||||
|
LastLoginError = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
authentication.AuthenticateWithLogin(ProvidedUsername, password);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
//todo: this fails even on network-related issues. we should probably handle those differently.
|
//todo: this fails even on network-related issues. we should probably handle those differently.
|
||||||
//NotificationOverlay.ShowMessage("Login failed!");
|
LastLoginError = e;
|
||||||
log.Add(@"Login failed!");
|
log.Add(@"Login failed!");
|
||||||
password = null;
|
password = null;
|
||||||
authentication.Clear();
|
authentication.Clear();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var userReq = new GetUserRequest();
|
var userReq = new GetUserRequest();
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public string WebsiteRootUrl => "http://localhost";
|
public string WebsiteRootUrl => "http://localhost";
|
||||||
|
|
||||||
|
public Exception LastLoginError { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provide handling logic for an arbitrary API request.
|
/// Provide handling logic for an arbitrary API request.
|
||||||
/// Should return true is a request was handled. If null or false return, the request will be failed with a <see cref="NotSupportedException"/>.
|
/// Should return true is a request was handled. If null or false return, the request will be failed with a <see cref="NotSupportedException"/>.
|
||||||
@ -40,6 +42,8 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
private readonly Bindable<APIState> state = new Bindable<APIState>(APIState.Online);
|
private readonly Bindable<APIState> state = new Bindable<APIState>(APIState.Online);
|
||||||
|
|
||||||
|
private bool shouldFailNextLogin;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current connectivity state of the API.
|
/// The current connectivity state of the API.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -74,6 +78,18 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public void Login(string username, string password)
|
public void Login(string username, string password)
|
||||||
{
|
{
|
||||||
|
state.Value = APIState.Connecting;
|
||||||
|
|
||||||
|
if (shouldFailNextLogin)
|
||||||
|
{
|
||||||
|
LastLoginError = new APIException("Not powerful enough to login.", new ArgumentException(nameof(shouldFailNextLogin)));
|
||||||
|
|
||||||
|
state.Value = APIState.Offline;
|
||||||
|
shouldFailNextLogin = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LastLoginError = null;
|
||||||
LocalUser.Value = new User
|
LocalUser.Value = new User
|
||||||
{
|
{
|
||||||
Username = username,
|
Username = username,
|
||||||
@ -102,5 +118,7 @@ namespace osu.Game.Online.API
|
|||||||
IBindable<User> IAPIProvider.LocalUser => LocalUser;
|
IBindable<User> IAPIProvider.LocalUser => LocalUser;
|
||||||
IBindableList<User> IAPIProvider.Friends => Friends;
|
IBindableList<User> IAPIProvider.Friends => Friends;
|
||||||
IBindable<UserActivity> IAPIProvider.Activity => Activity;
|
IBindable<UserActivity> IAPIProvider.Activity => Activity;
|
||||||
|
|
||||||
|
public void FailNextLogin() => shouldFailNextLogin = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#nullable enable
|
#nullable enable
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
@ -55,6 +56,11 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
string WebsiteRootUrl { get; }
|
string WebsiteRootUrl { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The last login error that occurred, if any.
|
||||||
|
/// </summary>
|
||||||
|
Exception? LastLoginError { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current connection state of the API.
|
/// The current connection state of the API.
|
||||||
/// This is not thread-safe and should be scheduled locally if consumed from a drawable component.
|
/// This is not thread-safe and should be scheduled locally if consumed from a drawable component.
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
// 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.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
|
||||||
namespace osu.Game.Online.API
|
namespace osu.Game.Online.API
|
||||||
@ -32,10 +34,10 @@ namespace osu.Game.Online.API
|
|||||||
this.endpoint = endpoint;
|
this.endpoint = endpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool AuthenticateWithLogin(string username, string password)
|
internal void AuthenticateWithLogin(string username, string password)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(username)) return false;
|
if (string.IsNullOrEmpty(username)) throw new ArgumentException("Missing username.");
|
||||||
if (string.IsNullOrEmpty(password)) return false;
|
if (string.IsNullOrEmpty(password)) throw new ArgumentException("Missing password.");
|
||||||
|
|
||||||
using (var req = new AccessTokenRequestPassword(username, password)
|
using (var req = new AccessTokenRequestPassword(username, password)
|
||||||
{
|
{
|
||||||
@ -49,13 +51,27 @@ namespace osu.Game.Online.API
|
|||||||
{
|
{
|
||||||
req.Perform();
|
req.Perform();
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Token.Value = null;
|
||||||
|
|
||||||
|
var throwableException = ex;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// attempt to decode a displayable error string.
|
||||||
|
var error = JsonConvert.DeserializeObject<OAuthError>(req.GetResponseString() ?? string.Empty);
|
||||||
|
if (error != null)
|
||||||
|
throwableException = new APIException(error.UserDisplayableError, ex);
|
||||||
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
throw throwableException;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token.Value = req.ResponseObject;
|
Token.Value = req.ResponseObject;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,5 +198,19 @@ namespace osu.Game.Online.API
|
|||||||
base.PrePerform();
|
base.PrePerform();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class OAuthError
|
||||||
|
{
|
||||||
|
public string UserDisplayableError => !string.IsNullOrEmpty(Hint) ? Hint : ErrorIdentifier;
|
||||||
|
|
||||||
|
[JsonProperty("error")]
|
||||||
|
public string ErrorIdentifier { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("hint")]
|
||||||
|
public string Hint { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("message")]
|
||||||
|
public string Message { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,13 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
public class GetBeatmapRequest : APIRequest<APIBeatmap>
|
||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
public GetBeatmapRequest(BeatmapInfo beatmap)
|
public GetBeatmapRequest(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmapInfo = beatmapInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Target => $@"beatmaps/lookup?id={beatmap.OnlineBeatmapID}&checksum={beatmap.MD5Hash}&filename={System.Uri.EscapeUriString(beatmap.Path ?? string.Empty)}";
|
protected override string Target => $@"beatmaps/lookup?id={beatmapInfo.OnlineBeatmapID}&checksum={beatmapInfo.MD5Hash}&filename={System.Uri.EscapeUriString(beatmapInfo.Path ?? string.Empty)}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,20 +15,20 @@ namespace osu.Game.Online.API.Requests
|
|||||||
{
|
{
|
||||||
public class GetScoresRequest : APIRequest<APILegacyScores>
|
public class GetScoresRequest : APIRequest<APILegacyScores>
|
||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly BeatmapInfo beatmapInfo;
|
||||||
private readonly BeatmapLeaderboardScope scope;
|
private readonly BeatmapLeaderboardScope scope;
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
private readonly IEnumerable<IMod> mods;
|
private readonly IEnumerable<IMod> mods;
|
||||||
|
|
||||||
public GetScoresRequest(BeatmapInfo beatmap, RulesetInfo ruleset, BeatmapLeaderboardScope scope = BeatmapLeaderboardScope.Global, IEnumerable<IMod> mods = null)
|
public GetScoresRequest(BeatmapInfo beatmapInfo, RulesetInfo ruleset, BeatmapLeaderboardScope scope = BeatmapLeaderboardScope.Global, IEnumerable<IMod> mods = null)
|
||||||
{
|
{
|
||||||
if (!beatmap.OnlineBeatmapID.HasValue)
|
if (!beatmapInfo.OnlineBeatmapID.HasValue)
|
||||||
throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(BeatmapInfo.OnlineBeatmapID)}.");
|
throw new InvalidOperationException($"Cannot lookup a beatmap's scores without having a populated {nameof(BeatmapInfo.OnlineBeatmapID)}.");
|
||||||
|
|
||||||
if (scope == BeatmapLeaderboardScope.Local)
|
if (scope == BeatmapLeaderboardScope.Local)
|
||||||
throw new InvalidOperationException("Should not attempt to request online scores for a local scoped leaderboard");
|
throw new InvalidOperationException("Should not attempt to request online scores for a local scoped leaderboard");
|
||||||
|
|
||||||
this.beatmap = beatmap;
|
this.beatmapInfo = beatmapInfo;
|
||||||
this.scope = scope;
|
this.scope = scope;
|
||||||
this.ruleset = ruleset ?? throw new ArgumentNullException(nameof(ruleset));
|
this.ruleset = ruleset ?? throw new ArgumentNullException(nameof(ruleset));
|
||||||
this.mods = mods ?? Array.Empty<IMod>();
|
this.mods = mods ?? Array.Empty<IMod>();
|
||||||
@ -42,7 +42,7 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
foreach (APILegacyScoreInfo score in r.Scores)
|
foreach (APILegacyScoreInfo score in r.Scores)
|
||||||
{
|
{
|
||||||
score.Beatmap = beatmap;
|
score.BeatmapInfo = beatmapInfo;
|
||||||
score.OnlineRulesetID = ruleset.ID.Value;
|
score.OnlineRulesetID = ruleset.ID.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,12 +50,12 @@ namespace osu.Game.Online.API.Requests
|
|||||||
|
|
||||||
if (userScore != null)
|
if (userScore != null)
|
||||||
{
|
{
|
||||||
userScore.Score.Beatmap = beatmap;
|
userScore.Score.BeatmapInfo = beatmapInfo;
|
||||||
userScore.Score.OnlineRulesetID = ruleset.ID.Value;
|
userScore.Score.OnlineRulesetID = ruleset.ID.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string Target => $@"beatmaps/{beatmap.OnlineBeatmapID}/scores{createQueryParameters()}";
|
protected override string Target => $@"beatmaps/{beatmapInfo.OnlineBeatmapID}/scores{createQueryParameters()}";
|
||||||
|
|
||||||
private string createQueryParameters()
|
private string createQueryParameters()
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
[JsonProperty(@"max_combo")]
|
[JsonProperty(@"max_combo")]
|
||||||
private int? maxCombo { get; set; }
|
private int? maxCombo { get; set; }
|
||||||
|
|
||||||
public virtual BeatmapInfo ToBeatmap(RulesetStore rulesets)
|
public virtual BeatmapInfo ToBeatmapInfo(RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
var set = BeatmapSet?.ToBeatmapSet(rulesets);
|
var set = BeatmapSet?.ToBeatmapSet(rulesets);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
|
|
||||||
beatmapSet.Beatmaps = beatmaps?.Select(b =>
|
beatmapSet.Beatmaps = beatmaps?.Select(b =>
|
||||||
{
|
{
|
||||||
var beatmap = b.ToBeatmap(rulesets);
|
var beatmap = b.ToBeatmapInfo(rulesets);
|
||||||
beatmap.BeatmapSet = beatmapSet;
|
beatmap.BeatmapSet = beatmapSet;
|
||||||
beatmap.Metadata = beatmapSet.Metadata;
|
beatmap.Metadata = beatmapSet.Metadata;
|
||||||
return beatmap;
|
return beatmap;
|
||||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
OnlineScoreID = OnlineScoreID,
|
OnlineScoreID = OnlineScoreID,
|
||||||
Date = Date,
|
Date = Date,
|
||||||
PP = PP,
|
PP = PP,
|
||||||
Beatmap = Beatmap,
|
BeatmapInfo = BeatmapInfo,
|
||||||
RulesetID = OnlineRulesetID,
|
RulesetID = OnlineRulesetID,
|
||||||
Hash = Replay ? "online" : string.Empty, // todo: temporary?
|
Hash = Replay ? "online" : string.Empty, // todo: temporary?
|
||||||
Rank = Rank,
|
Rank = Rank,
|
||||||
@ -100,7 +100,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
public DateTimeOffset Date { get; set; }
|
public DateTimeOffset Date { get; set; }
|
||||||
|
|
||||||
[JsonProperty(@"beatmap")]
|
[JsonProperty(@"beatmap")]
|
||||||
public BeatmapInfo Beatmap { get; set; }
|
public BeatmapInfo BeatmapInfo { get; set; }
|
||||||
|
|
||||||
[JsonProperty("accuracy")]
|
[JsonProperty("accuracy")]
|
||||||
public double Accuracy { get; set; }
|
public double Accuracy { get; set; }
|
||||||
@ -114,10 +114,10 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
// extract the set ID to its correct place.
|
// extract the set ID to its correct place.
|
||||||
Beatmap.BeatmapSet = new BeatmapSetInfo { OnlineBeatmapSetID = value.ID };
|
BeatmapInfo.BeatmapSet = new BeatmapSetInfo { OnlineBeatmapSetID = value.ID };
|
||||||
value.ID = 0;
|
value.ID = 0;
|
||||||
|
|
||||||
Beatmap.Metadata = value;
|
BeatmapInfo.Metadata = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
public int PlayCount { get; set; }
|
public int PlayCount { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
private BeatmapInfo beatmap { get; set; }
|
private BeatmapInfo beatmapInfo { get; set; }
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
private APIBeatmapSet beatmapSet { get; set; }
|
private APIBeatmapSet beatmapSet { get; set; }
|
||||||
@ -24,9 +24,9 @@ namespace osu.Game.Online.API.Requests.Responses
|
|||||||
public BeatmapInfo GetBeatmapInfo(RulesetStore rulesets)
|
public BeatmapInfo GetBeatmapInfo(RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
BeatmapSetInfo setInfo = beatmapSet.ToBeatmapSet(rulesets);
|
BeatmapSetInfo setInfo = beatmapSet.ToBeatmapSet(rulesets);
|
||||||
beatmap.BeatmapSet = setInfo;
|
beatmapInfo.BeatmapSet = setInfo;
|
||||||
beatmap.Metadata = setInfo.Metadata;
|
beatmapInfo.Metadata = setInfo.Metadata;
|
||||||
return beatmap;
|
return beatmapInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,27 +37,27 @@ namespace osu.Game.Online.Chat
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
string verb;
|
string verb;
|
||||||
BeatmapInfo beatmap;
|
BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
switch (api.Activity.Value)
|
switch (api.Activity.Value)
|
||||||
{
|
{
|
||||||
case UserActivity.InGame game:
|
case UserActivity.InGame game:
|
||||||
verb = "playing";
|
verb = "playing";
|
||||||
beatmap = game.Beatmap;
|
beatmapInfo = game.BeatmapInfo;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case UserActivity.Editing edit:
|
case UserActivity.Editing edit:
|
||||||
verb = "editing";
|
verb = "editing";
|
||||||
beatmap = edit.Beatmap;
|
beatmapInfo = edit.BeatmapInfo;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
verb = "listening to";
|
verb = "listening to";
|
||||||
beatmap = currentBeatmap.Value.BeatmapInfo;
|
beatmapInfo = currentBeatmap.Value.BeatmapInfo;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
var beatmapString = beatmap.OnlineBeatmapID.HasValue ? $"[{api.WebsiteRootUrl}/b/{beatmap.OnlineBeatmapID} {beatmap}]" : beatmap.ToString();
|
var beatmapString = beatmapInfo.OnlineBeatmapID.HasValue ? $"[{api.WebsiteRootUrl}/b/{beatmapInfo.OnlineBeatmapID} {beatmapInfo}]" : beatmapInfo.ToString();
|
||||||
|
|
||||||
channelManager.PostMessage($"is {verb} {beatmapString}", true, target);
|
channelManager.PostMessage($"is {verb} {beatmapString}", true, target);
|
||||||
Expire();
|
Expire();
|
||||||
|
@ -13,9 +13,9 @@ namespace osu.Game.Online.Rooms
|
|||||||
[JsonProperty("checksum")]
|
[JsonProperty("checksum")]
|
||||||
public string Checksum { get; set; }
|
public string Checksum { get; set; }
|
||||||
|
|
||||||
public override BeatmapInfo ToBeatmap(RulesetStore rulesets)
|
public override BeatmapInfo ToBeatmapInfo(RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
var b = base.ToBeatmap(rulesets);
|
var b = base.ToBeatmapInfo(rulesets);
|
||||||
b.MD5Hash = Checksum;
|
b.MD5Hash = Checksum;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ namespace osu.Game.Online.Rooms
|
|||||||
OnlineScoreID = ID,
|
OnlineScoreID = ID,
|
||||||
TotalScore = TotalScore,
|
TotalScore = TotalScore,
|
||||||
MaxCombo = MaxCombo,
|
MaxCombo = MaxCombo,
|
||||||
Beatmap = playlistItem.Beatmap.Value,
|
BeatmapInfo = playlistItem.Beatmap.Value,
|
||||||
BeatmapInfoID = playlistItem.BeatmapID,
|
BeatmapInfoID = playlistItem.BeatmapID,
|
||||||
Ruleset = playlistItem.Ruleset.Value,
|
Ruleset = playlistItem.Ruleset.Value,
|
||||||
RulesetID = playlistItem.RulesetID,
|
RulesetID = playlistItem.RulesetID,
|
||||||
|
@ -70,7 +70,7 @@ namespace osu.Game.Online.Rooms
|
|||||||
|
|
||||||
public void MapObjects(BeatmapManager beatmaps, RulesetStore rulesets)
|
public void MapObjects(BeatmapManager beatmaps, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
Beatmap.Value ??= apiBeatmap.ToBeatmap(rulesets);
|
Beatmap.Value ??= apiBeatmap.ToBeatmapInfo(rulesets);
|
||||||
Ruleset.Value ??= rulesets.GetRuleset(RulesetID);
|
Ruleset.Value ??= rulesets.GetRuleset(RulesetID);
|
||||||
|
|
||||||
Ruleset rulesetInstance = Ruleset.Value.CreateInstance();
|
Ruleset rulesetInstance = Ruleset.Value.CreateInstance();
|
||||||
|
@ -144,7 +144,7 @@ namespace osu.Game.Online.Spectator
|
|||||||
IsPlaying = true;
|
IsPlaying = true;
|
||||||
|
|
||||||
// transfer state at point of beginning play
|
// transfer state at point of beginning play
|
||||||
currentState.BeatmapID = score.ScoreInfo.Beatmap.OnlineBeatmapID;
|
currentState.BeatmapID = score.ScoreInfo.BeatmapInfo.OnlineBeatmapID;
|
||||||
currentState.RulesetID = score.ScoreInfo.RulesetID;
|
currentState.RulesetID = score.ScoreInfo.RulesetID;
|
||||||
currentState.Mods = score.ScoreInfo.Mods.Select(m => new APIMod(m)).ToArray();
|
currentState.Mods = score.ScoreInfo.Mods.Select(m => new APIMod(m)).ToArray();
|
||||||
|
|
||||||
|
@ -482,7 +482,7 @@ namespace osu.Game
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var databasedBeatmap = BeatmapManager.QueryBeatmap(b => b.ID == databasedScoreInfo.Beatmap.ID);
|
var databasedBeatmap = BeatmapManager.QueryBeatmap(b => b.ID == databasedScoreInfo.BeatmapInfo.ID);
|
||||||
|
|
||||||
if (databasedBeatmap == null)
|
if (databasedBeatmap == null)
|
||||||
{
|
{
|
||||||
@ -624,10 +624,10 @@ namespace osu.Game
|
|||||||
SkinManager.PostNotification = n => Notifications.Post(n);
|
SkinManager.PostNotification = n => Notifications.Post(n);
|
||||||
|
|
||||||
BeatmapManager.PostNotification = n => Notifications.Post(n);
|
BeatmapManager.PostNotification = n => Notifications.Post(n);
|
||||||
BeatmapManager.PresentImport = items => PresentBeatmap(items.First());
|
BeatmapManager.PresentImport = items => PresentBeatmap(items.First().Value);
|
||||||
|
|
||||||
ScoreManager.PostNotification = n => Notifications.Post(n);
|
ScoreManager.PostNotification = n => Notifications.Post(n);
|
||||||
ScoreManager.PresentImport = items => PresentScore(items.First());
|
ScoreManager.PostImport = items => PresentScore(items.First().Value);
|
||||||
|
|
||||||
// make config aware of how to lookup skins for on-screen display purposes.
|
// make config aware of how to lookup skins for on-screen display purposes.
|
||||||
// if this becomes a more common thing, tracked settings should be reconsidered to allow local DI.
|
// if this becomes a more common thing, tracked settings should be reconsidered to allow local DI.
|
||||||
|
@ -244,7 +244,7 @@ namespace osu.Game
|
|||||||
List<ScoreInfo> getBeatmapScores(BeatmapSetInfo set)
|
List<ScoreInfo> getBeatmapScores(BeatmapSetInfo set)
|
||||||
{
|
{
|
||||||
var beatmapIds = BeatmapManager.QueryBeatmaps(b => b.BeatmapSetInfoID == set.ID).Select(b => b.ID).ToList();
|
var beatmapIds = BeatmapManager.QueryBeatmaps(b => b.BeatmapSetInfoID == set.ID).Select(b => b.ID).ToList();
|
||||||
return ScoreManager.QueryScores(s => beatmapIds.Contains(s.Beatmap.ID)).ToList();
|
return ScoreManager.QueryScores(s => beatmapIds.Contains(s.BeatmapInfo.ID)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
BeatmapManager.ItemRemoved.BindValueChanged(i =>
|
BeatmapManager.ItemRemoved.BindValueChanged(i =>
|
||||||
|
@ -38,16 +38,16 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
public BeatmapInfo BeatmapInfo
|
||||||
{
|
{
|
||||||
get => beatmap;
|
get => beatmapInfo;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == beatmap) return;
|
if (value == beatmapInfo) return;
|
||||||
|
|
||||||
beatmap = value;
|
beatmapInfo = value;
|
||||||
|
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
{
|
{
|
||||||
bpm.Value = BeatmapSet?.OnlineInfo?.BPM.ToLocalisableString(@"0.##") ?? (LocalisableString)"-";
|
bpm.Value = BeatmapSet?.OnlineInfo?.BPM.ToLocalisableString(@"0.##") ?? (LocalisableString)"-";
|
||||||
|
|
||||||
if (beatmap == null)
|
if (beatmapInfo == null)
|
||||||
{
|
{
|
||||||
length.Value = string.Empty;
|
length.Value = string.Empty;
|
||||||
circleCount.Value = string.Empty;
|
circleCount.Value = string.Empty;
|
||||||
@ -65,11 +65,11 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
length.TooltipText = BeatmapsetsStrings.ShowStatsTotalLength(TimeSpan.FromMilliseconds(beatmap.Length).ToFormattedDuration());
|
length.TooltipText = BeatmapsetsStrings.ShowStatsTotalLength(TimeSpan.FromMilliseconds(beatmapInfo.Length).ToFormattedDuration());
|
||||||
length.Value = TimeSpan.FromMilliseconds(beatmap.Length).ToFormattedDuration();
|
length.Value = TimeSpan.FromMilliseconds(beatmapInfo.Length).ToFormattedDuration();
|
||||||
|
|
||||||
circleCount.Value = beatmap.OnlineInfo.CircleCount.ToLocalisableString(@"N0");
|
circleCount.Value = beatmapInfo.OnlineInfo.CircleCount.ToLocalisableString(@"N0");
|
||||||
sliderCount.Value = beatmap.OnlineInfo.SliderCount.ToLocalisableString(@"N0");
|
sliderCount.Value = beatmapInfo.OnlineInfo.SliderCount.ToLocalisableString(@"N0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,21 +178,21 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
}
|
}
|
||||||
|
|
||||||
starRatingContainer.FadeOut(100);
|
starRatingContainer.FadeOut(100);
|
||||||
Beatmap.Value = Difficulties.FirstOrDefault()?.Beatmap;
|
Beatmap.Value = Difficulties.FirstOrDefault()?.BeatmapInfo;
|
||||||
plays.Value = BeatmapSet?.OnlineInfo.PlayCount ?? 0;
|
plays.Value = BeatmapSet?.OnlineInfo.PlayCount ?? 0;
|
||||||
favourites.Value = BeatmapSet?.OnlineInfo.FavouriteCount ?? 0;
|
favourites.Value = BeatmapSet?.OnlineInfo.FavouriteCount ?? 0;
|
||||||
|
|
||||||
updateDifficultyButtons();
|
updateDifficultyButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showBeatmap(BeatmapInfo beatmap)
|
private void showBeatmap(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
version.Text = beatmap?.Version;
|
version.Text = beatmapInfo?.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDifficultyButtons()
|
private void updateDifficultyButtons()
|
||||||
{
|
{
|
||||||
Difficulties.Children.ToList().ForEach(diff => diff.State = diff.Beatmap == Beatmap.Value ? DifficultySelectorState.Selected : DifficultySelectorState.NotSelected);
|
Difficulties.Children.ToList().ForEach(diff => diff.State = diff.BeatmapInfo == Beatmap.Value ? DifficultySelectorState.Selected : DifficultySelectorState.NotSelected);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DifficultiesContainer : FillFlowContainer<DifficultySelectorButton>
|
public class DifficultiesContainer : FillFlowContainer<DifficultySelectorButton>
|
||||||
@ -216,7 +216,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
private readonly Box backgroundBox;
|
private readonly Box backgroundBox;
|
||||||
private readonly DifficultyIcon icon;
|
private readonly DifficultyIcon icon;
|
||||||
|
|
||||||
public readonly BeatmapInfo Beatmap;
|
public readonly BeatmapInfo BeatmapInfo;
|
||||||
|
|
||||||
public Action<BeatmapInfo> OnHovered;
|
public Action<BeatmapInfo> OnHovered;
|
||||||
public Action<BeatmapInfo> OnClicked;
|
public Action<BeatmapInfo> OnClicked;
|
||||||
@ -241,9 +241,9 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public DifficultySelectorButton(BeatmapInfo beatmap)
|
public DifficultySelectorButton(BeatmapInfo beatmapInfo)
|
||||||
{
|
{
|
||||||
Beatmap = beatmap;
|
BeatmapInfo = beatmapInfo;
|
||||||
Size = new Vector2(size);
|
Size = new Vector2(size);
|
||||||
Margin = new MarginPadding { Horizontal = tile_spacing / 2 };
|
Margin = new MarginPadding { Horizontal = tile_spacing / 2 };
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
Alpha = 0.5f
|
Alpha = 0.5f
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon = new DifficultyIcon(beatmap, shouldShowTooltip: false)
|
icon = new DifficultyIcon(beatmapInfo, shouldShowTooltip: false)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
@ -273,7 +273,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
protected override bool OnHover(HoverEvent e)
|
protected override bool OnHover(HoverEvent e)
|
||||||
{
|
{
|
||||||
fadeIn();
|
fadeIn();
|
||||||
OnHovered?.Invoke(Beatmap);
|
OnHovered?.Invoke(BeatmapInfo);
|
||||||
return base.OnHover(e);
|
return base.OnHover(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
protected override bool OnClick(ClickEvent e)
|
||||||
{
|
{
|
||||||
OnClicked?.Invoke(Beatmap);
|
OnClicked?.Invoke(BeatmapInfo);
|
||||||
return base.OnClick(e);
|
return base.OnClick(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
Picker.Beatmap.ValueChanged += b =>
|
Picker.Beatmap.ValueChanged += b =>
|
||||||
{
|
{
|
||||||
Details.Beatmap = b.NewValue;
|
Details.BeatmapInfo = b.NewValue;
|
||||||
externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineBeatmapSetID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineBeatmapID}";
|
externalLink.Link = $@"{api.WebsiteRootUrl}/beatmapsets/{BeatmapSet.Value?.OnlineBeatmapSetID}#{b.NewValue?.Ruleset.ShortName}/{b.NewValue?.OnlineBeatmapID}";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -37,16 +37,16 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
public BeatmapInfo BeatmapInfo
|
||||||
{
|
{
|
||||||
get => beatmap;
|
get => beatmapInfo;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == beatmap) return;
|
if (value == beatmapInfo) return;
|
||||||
|
|
||||||
basic.Beatmap = advanced.Beatmap = beatmap = value;
|
basic.BeatmapInfo = advanced.BeatmapInfo = beatmapInfo = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
public readonly Bindable<BeatmapSetInfo> BeatmapSet = new Bindable<BeatmapSetInfo>();
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
public BeatmapInfo BeatmapInfo
|
||||||
{
|
{
|
||||||
get => successRate.Beatmap;
|
get => successRate.BeatmapInfo;
|
||||||
set => successRate.Beatmap = value;
|
set => successRate.BeatmapInfo = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Info()
|
public Info()
|
||||||
|
@ -172,7 +172,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
{
|
{
|
||||||
Text = score.MaxCombo.ToLocalisableString(@"0\x"),
|
Text = score.MaxCombo.ToLocalisableString(@"0\x"),
|
||||||
Font = OsuFont.GetFont(size: text_size),
|
Font = OsuFont.GetFont(size: text_size),
|
||||||
Colour = score.MaxCombo == score.Beatmap?.MaxCombo ? highAccuracyColour : Color4.White
|
Colour = score.MaxCombo == score.BeatmapInfo?.MaxCombo ? highAccuracyColour : Color4.White
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
|
|
||||||
var topScore = ordered.Result.First();
|
var topScore = ordered.Result.First();
|
||||||
|
|
||||||
scoreTable.DisplayScores(ordered.Result, topScore.Beatmap?.Status.GrantsPerformancePoints() == true);
|
scoreTable.DisplayScores(ordered.Result, topScore.BeatmapInfo?.Status.GrantsPerformancePoints() == true);
|
||||||
scoreTable.Show();
|
scoreTable.Show();
|
||||||
|
|
||||||
var userScore = value.UserScore;
|
var userScore = value.UserScore;
|
||||||
|
@ -115,7 +115,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
|||||||
accuracyColumn.Text = value.DisplayAccuracy;
|
accuracyColumn.Text = value.DisplayAccuracy;
|
||||||
maxComboColumn.Text = value.MaxCombo.ToLocalisableString(@"0\x");
|
maxComboColumn.Text = value.MaxCombo.ToLocalisableString(@"0\x");
|
||||||
|
|
||||||
ppColumn.Alpha = value.Beatmap?.Status.GrantsPerformancePoints() == true ? 1 : 0;
|
ppColumn.Alpha = value.BeatmapInfo?.Status.GrantsPerformancePoints() == true ? 1 : 0;
|
||||||
ppColumn.Text = value.PP?.ToLocalisableString(@"N0");
|
ppColumn.Text = value.PP?.ToLocalisableString(@"N0");
|
||||||
|
|
||||||
statisticsColumns.ChildrenEnumerable = value.GetStatisticsForDisplay().Select(createStatisticsColumn);
|
statisticsColumns.ChildrenEnumerable = value.GetStatisticsForDisplay().Select(createStatisticsColumn);
|
||||||
|
@ -23,16 +23,16 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
private readonly Bar successRate;
|
private readonly Bar successRate;
|
||||||
private readonly Container percentContainer;
|
private readonly Container percentContainer;
|
||||||
|
|
||||||
private BeatmapInfo beatmap;
|
private BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
public BeatmapInfo Beatmap
|
public BeatmapInfo BeatmapInfo
|
||||||
{
|
{
|
||||||
get => beatmap;
|
get => beatmapInfo;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value == beatmap) return;
|
if (value == beatmapInfo) return;
|
||||||
|
|
||||||
beatmap = value;
|
beatmapInfo = value;
|
||||||
|
|
||||||
updateDisplay();
|
updateDisplay();
|
||||||
}
|
}
|
||||||
@ -40,15 +40,15 @@ namespace osu.Game.Overlays.BeatmapSet
|
|||||||
|
|
||||||
private void updateDisplay()
|
private void updateDisplay()
|
||||||
{
|
{
|
||||||
int passCount = beatmap?.OnlineInfo?.PassCount ?? 0;
|
int passCount = beatmapInfo?.OnlineInfo?.PassCount ?? 0;
|
||||||
int playCount = beatmap?.OnlineInfo?.PlayCount ?? 0;
|
int playCount = beatmapInfo?.OnlineInfo?.PlayCount ?? 0;
|
||||||
|
|
||||||
var rate = playCount != 0 ? (float)passCount / playCount : 0;
|
var rate = playCount != 0 ? (float)passCount / playCount : 0;
|
||||||
successPercent.Text = rate.ToLocalisableString(@"0.#%");
|
successPercent.Text = rate.ToLocalisableString(@"0.#%");
|
||||||
successRate.Length = rate;
|
successRate.Length = rate;
|
||||||
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
|
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
|
||||||
|
|
||||||
Graph.Metrics = beatmap?.Metrics;
|
Graph.Metrics = beatmapInfo?.Metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuccessRate()
|
public SuccessRate()
|
||||||
|
@ -61,7 +61,7 @@ namespace osu.Game.Overlays
|
|||||||
|
|
||||||
Header.HeaderContent.Picker.Beatmap.ValueChanged += b =>
|
Header.HeaderContent.Picker.Beatmap.ValueChanged += b =>
|
||||||
{
|
{
|
||||||
info.Beatmap = b.NewValue;
|
info.BeatmapInfo = b.NewValue;
|
||||||
ScrollFlow.ScrollToStart();
|
ScrollFlow.ScrollToStart();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
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.Online.API;
|
using osu.Game.Online.API;
|
||||||
@ -42,6 +43,9 @@ namespace osu.Game.Overlays.Login
|
|||||||
Spacing = new Vector2(0, 5);
|
Spacing = new Vector2(0, 5);
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
|
|
||||||
|
ErrorTextFlowContainer errorText;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
username = new OsuTextBox
|
username = new OsuTextBox
|
||||||
@ -57,6 +61,11 @@ namespace osu.Game.Overlays.Login
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
TabbableContentContainer = this,
|
TabbableContentContainer = this,
|
||||||
},
|
},
|
||||||
|
errorText = new ErrorTextFlowContainer
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.X,
|
||||||
|
AutoSizeAxes = Axes.Y,
|
||||||
|
},
|
||||||
new SettingsCheckbox
|
new SettingsCheckbox
|
||||||
{
|
{
|
||||||
LabelText = "Remember username",
|
LabelText = "Remember username",
|
||||||
@ -97,6 +106,9 @@ namespace osu.Game.Overlays.Login
|
|||||||
};
|
};
|
||||||
|
|
||||||
password.OnCommit += (sender, newText) => performLogin();
|
password.OnCommit += (sender, newText) => performLogin();
|
||||||
|
|
||||||
|
if (api?.LastLoginError?.Message is string error)
|
||||||
|
errorText.AddErrors(new[] { error });
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool AcceptsFocus => true;
|
public override bool AcceptsFocus => true;
|
||||||
|
@ -15,12 +15,12 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class BeatmapMetadataContainer : OsuHoverContainer
|
public abstract class BeatmapMetadataContainer : OsuHoverContainer
|
||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly BeatmapInfo beatmapInfo;
|
||||||
|
|
||||||
protected BeatmapMetadataContainer(BeatmapInfo beatmap)
|
protected BeatmapMetadataContainer(BeatmapInfo beatmapInfo)
|
||||||
: base(HoverSampleSet.Submit)
|
: base(HoverSampleSet.Submit)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmapInfo = beatmapInfo;
|
||||||
|
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
@ -30,19 +30,19 @@ namespace osu.Game.Overlays.Profile.Sections
|
|||||||
{
|
{
|
||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
if (beatmap.OnlineBeatmapID != null)
|
if (beatmapInfo.OnlineBeatmapID != null)
|
||||||
beatmapSetOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value);
|
beatmapSetOverlay?.FetchAndShowBeatmap(beatmapInfo.OnlineBeatmapID.Value);
|
||||||
else if (beatmap.BeatmapSet?.OnlineBeatmapSetID != null)
|
else if (beatmapInfo.BeatmapSet?.OnlineBeatmapSetID != null)
|
||||||
beatmapSetOverlay?.FetchAndShowBeatmapSet(beatmap.BeatmapSet.OnlineBeatmapSetID.Value);
|
beatmapSetOverlay?.FetchAndShowBeatmapSet(beatmapInfo.BeatmapSet.OnlineBeatmapSetID.Value);
|
||||||
};
|
};
|
||||||
|
|
||||||
Child = new FillFlowContainer
|
Child = new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Children = CreateText(beatmap),
|
Children = CreateText(beatmapInfo),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Drawable[] CreateText(BeatmapInfo beatmap);
|
protected abstract Drawable[] CreateText(BeatmapInfo beatmapInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,12 +22,12 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
private const int cover_width = 100;
|
private const int cover_width = 100;
|
||||||
private const int corner_radius = 6;
|
private const int corner_radius = 6;
|
||||||
|
|
||||||
private readonly BeatmapInfo beatmap;
|
private readonly BeatmapInfo beatmapInfo;
|
||||||
private readonly int playCount;
|
private readonly int playCount;
|
||||||
|
|
||||||
public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount)
|
public DrawableMostPlayedBeatmap(BeatmapInfo beatmapInfo, int playCount)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.beatmapInfo = beatmapInfo;
|
||||||
this.playCount = playCount;
|
this.playCount = playCount;
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -46,7 +46,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
Width = cover_width,
|
Width = cover_width,
|
||||||
BeatmapSet = beatmap.BeatmapSet,
|
BeatmapSet = beatmapInfo.BeatmapSet,
|
||||||
},
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
Direction = FillDirection.Vertical,
|
Direction = FillDirection.Vertical,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new MostPlayedBeatmapMetadataContainer(beatmap),
|
new MostPlayedBeatmapMetadataContainer(beatmapInfo),
|
||||||
new LinkFlowContainer(t =>
|
new LinkFlowContainer(t =>
|
||||||
{
|
{
|
||||||
t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular);
|
t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular);
|
||||||
@ -89,7 +89,7 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
}.With(d =>
|
}.With(d =>
|
||||||
{
|
{
|
||||||
d.AddText("mapped by ");
|
d.AddText("mapped by ");
|
||||||
d.AddUserLink(beatmap.Metadata.Author);
|
d.AddUserLink(beatmapInfo.Metadata.Author);
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -120,23 +120,23 @@ namespace osu.Game.Overlays.Profile.Sections.Historical
|
|||||||
|
|
||||||
private class MostPlayedBeatmapMetadataContainer : BeatmapMetadataContainer
|
private class MostPlayedBeatmapMetadataContainer : BeatmapMetadataContainer
|
||||||
{
|
{
|
||||||
public MostPlayedBeatmapMetadataContainer(BeatmapInfo beatmap)
|
public MostPlayedBeatmapMetadataContainer(BeatmapInfo beatmapInfo)
|
||||||
: base(beatmap)
|
: base(beatmapInfo)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable[] CreateText(BeatmapInfo beatmap) => new Drawable[]
|
protected override Drawable[] CreateText(BeatmapInfo beatmapInfo) => new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = new RomanisableString(
|
Text = new RomanisableString(
|
||||||
$"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ",
|
$"{beatmapInfo.Metadata.TitleUnicode ?? beatmapInfo.Metadata.Title} [{beatmapInfo.Version}] ",
|
||||||
$"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] "),
|
$"{beatmapInfo.Metadata.Title ?? beatmapInfo.Metadata.TitleUnicode} [{beatmapInfo.Version}] "),
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = "by " + new RomanisableString(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist),
|
Text = "by " + new RomanisableString(beatmapInfo.Metadata.ArtistUnicode, beatmapInfo.Metadata.Artist),
|
||||||
Font = OsuFont.GetFont(weight: FontWeight.Regular)
|
Font = OsuFont.GetFont(weight: FontWeight.Regular)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -78,7 +78,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
Spacing = new Vector2(0, 2),
|
Spacing = new Vector2(0, 2),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new ScoreBeatmapMetadataContainer(Score.Beatmap),
|
new ScoreBeatmapMetadataContainer(Score.BeatmapInfo),
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
@ -88,7 +88,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
{
|
{
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = $"{Score.Beatmap.Version}",
|
Text = $"{Score.BeatmapInfo.Version}",
|
||||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
|
||||||
Colour = colours.Yellow
|
Colour = colours.Yellow
|
||||||
},
|
},
|
||||||
@ -245,27 +245,27 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
|
|
||||||
private class ScoreBeatmapMetadataContainer : BeatmapMetadataContainer
|
private class ScoreBeatmapMetadataContainer : BeatmapMetadataContainer
|
||||||
{
|
{
|
||||||
public ScoreBeatmapMetadataContainer(BeatmapInfo beatmap)
|
public ScoreBeatmapMetadataContainer(BeatmapInfo beatmapInfo)
|
||||||
: base(beatmap)
|
: base(beatmapInfo)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Drawable[] CreateText(BeatmapInfo beatmap) => new Drawable[]
|
protected override Drawable[] CreateText(BeatmapInfo beatmapInfo) => new Drawable[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Text = new RomanisableString(
|
Text = new RomanisableString(
|
||||||
$"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} ",
|
$"{beatmapInfo.Metadata.TitleUnicode ?? beatmapInfo.Metadata.Title} ",
|
||||||
$"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} "),
|
$"{beatmapInfo.Metadata.Title ?? beatmapInfo.Metadata.TitleUnicode} "),
|
||||||
Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold, italics: true)
|
Font = OsuFont.GetFont(size: 14, weight: FontWeight.SemiBold, italics: true)
|
||||||
},
|
},
|
||||||
new OsuSpriteText
|
new OsuSpriteText
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Text = "by " + new RomanisableString(beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist),
|
Text = "by " + new RomanisableString(beatmapInfo.Metadata.ArtistUnicode, beatmapInfo.Metadata.Artist),
|
||||||
Font = OsuFont.GetFont(size: 12, italics: true)
|
Font = OsuFont.GetFont(size: 12, italics: true)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -14,15 +14,15 @@ namespace osu.Game.Rulesets.Filter
|
|||||||
public interface IRulesetFilterCriteria
|
public interface IRulesetFilterCriteria
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks whether the supplied <paramref name="beatmap"/> satisfies ruleset-specific custom criteria,
|
/// Checks whether the supplied <paramref name="beatmapInfo"/> satisfies ruleset-specific custom criteria,
|
||||||
/// in addition to the ones mandated by song select.
|
/// in addition to the ones mandated by song select.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="beatmap">The beatmap to test the criteria against.</param>
|
/// <param name="beatmapInfo">The beatmap to test the criteria against.</param>
|
||||||
/// <returns>
|
/// <returns>
|
||||||
/// <c>true</c> if the beatmap matches the ruleset-specific custom filtering criteria,
|
/// <c>true</c> if the beatmap matches the ruleset-specific custom filtering criteria,
|
||||||
/// <c>false</c> otherwise.
|
/// <c>false</c> otherwise.
|
||||||
/// </returns>
|
/// </returns>
|
||||||
bool Matches(BeatmapInfo beatmap);
|
bool Matches(BeatmapInfo beatmapInfo);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempts to parse a single custom keyword criterion, given by the user via the song select search box.
|
/// Attempts to parse a single custom keyword criterion, given by the user via the song select search box.
|
||||||
|
@ -70,7 +70,7 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
scoreInfo.Mods = scoreInfo.Mods.Append(currentRuleset.CreateMod<ModClassic>()).ToArray();
|
scoreInfo.Mods = scoreInfo.Mods.Append(currentRuleset.CreateMod<ModClassic>()).ToArray();
|
||||||
|
|
||||||
currentBeatmap = workingBeatmap.GetPlayableBeatmap(currentRuleset.RulesetInfo, scoreInfo.Mods);
|
currentBeatmap = workingBeatmap.GetPlayableBeatmap(currentRuleset.RulesetInfo, scoreInfo.Mods);
|
||||||
scoreInfo.Beatmap = currentBeatmap.BeatmapInfo;
|
scoreInfo.BeatmapInfo = currentBeatmap.BeatmapInfo;
|
||||||
|
|
||||||
/* score.HpGraphString = */
|
/* score.HpGraphString = */
|
||||||
sr.ReadString();
|
sr.ReadString();
|
||||||
@ -119,7 +119,7 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
|
|
||||||
// before returning for database import, we must restore the database-sourced BeatmapInfo.
|
// before returning for database import, we must restore the database-sourced BeatmapInfo.
|
||||||
// if not, the clone operation in GetPlayableBeatmap will cause a dereference and subsequent database exception.
|
// if not, the clone operation in GetPlayableBeatmap will cause a dereference and subsequent database exception.
|
||||||
score.ScoreInfo.Beatmap = workingBeatmap.BeatmapInfo;
|
score.ScoreInfo.BeatmapInfo = workingBeatmap.BeatmapInfo;
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
this.score = score;
|
this.score = score;
|
||||||
this.beatmap = beatmap;
|
this.beatmap = beatmap;
|
||||||
|
|
||||||
if (score.ScoreInfo.Beatmap.RulesetID < 0 || score.ScoreInfo.Beatmap.RulesetID > 3)
|
if (score.ScoreInfo.BeatmapInfo.RulesetID < 0 || score.ScoreInfo.BeatmapInfo.RulesetID > 3)
|
||||||
throw new ArgumentException("Only scores in the osu, taiko, catch, or mania rulesets can be encoded to the legacy score format.", nameof(score));
|
throw new ArgumentException("Only scores in the osu, taiko, catch, or mania rulesets can be encoded to the legacy score format.", nameof(score));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
{
|
{
|
||||||
sw.Write((byte)(score.ScoreInfo.Ruleset.ID ?? 0));
|
sw.Write((byte)(score.ScoreInfo.Ruleset.ID ?? 0));
|
||||||
sw.Write(LATEST_VERSION);
|
sw.Write(LATEST_VERSION);
|
||||||
sw.Write(score.ScoreInfo.Beatmap.MD5Hash);
|
sw.Write(score.ScoreInfo.BeatmapInfo.MD5Hash);
|
||||||
sw.Write(score.ScoreInfo.UserString);
|
sw.Write(score.ScoreInfo.UserString);
|
||||||
sw.Write($"lazer-{score.ScoreInfo.UserString}-{score.ScoreInfo.Date}".ComputeMD5Hash());
|
sw.Write($"lazer-{score.ScoreInfo.UserString}-{score.ScoreInfo.Date}".ComputeMD5Hash());
|
||||||
sw.Write((ushort)(score.ScoreInfo.GetCount300() ?? 0));
|
sw.Write((ushort)(score.ScoreInfo.GetCount300() ?? 0));
|
||||||
|
@ -150,7 +150,8 @@ namespace osu.Game.Scoring
|
|||||||
public int BeatmapInfoID { get; set; }
|
public int BeatmapInfoID { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public virtual BeatmapInfo Beatmap { get; set; }
|
[Column("Beatmap")]
|
||||||
|
public virtual BeatmapInfo BeatmapInfo { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public long? OnlineScoreID { get; set; }
|
public long? OnlineScoreID { get; set; }
|
||||||
@ -252,7 +253,7 @@ namespace osu.Game.Scoring
|
|||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => $"{User} playing {Beatmap}";
|
public override string ToString() => $"{User} playing {BeatmapInfo}";
|
||||||
|
|
||||||
public bool Equals(ScoreInfo other)
|
public bool Equals(ScoreInfo other)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ using osu.Game.Rulesets.Scoring;
|
|||||||
|
|
||||||
namespace osu.Game.Scoring
|
namespace osu.Game.Scoring
|
||||||
{
|
{
|
||||||
public class ScoreManager : IModelManager<ScoreInfo>, IModelFileManager<ScoreInfo, ScoreFileInfo>, IModelDownloader<ScoreInfo>, ICanAcceptFiles, IPresentImports<ScoreInfo>
|
public class ScoreManager : IModelManager<ScoreInfo>, IModelFileManager<ScoreInfo, ScoreFileInfo>, IModelDownloader<ScoreInfo>, ICanAcceptFiles, IPostImports<ScoreInfo>
|
||||||
{
|
{
|
||||||
private readonly Scheduler scheduler;
|
private readonly Scheduler scheduler;
|
||||||
private readonly Func<BeatmapDifficultyCache> difficulties;
|
private readonly Func<BeatmapDifficultyCache> difficulties;
|
||||||
@ -67,7 +67,7 @@ namespace osu.Game.Scoring
|
|||||||
// Compute difficulties asynchronously first to prevent blocking via the GetTotalScore() call below.
|
// Compute difficulties asynchronously first to prevent blocking via the GetTotalScore() call below.
|
||||||
foreach (var s in scores)
|
foreach (var s in scores)
|
||||||
{
|
{
|
||||||
await difficultyCache.GetDifficultyAsync(s.Beatmap, s.Ruleset, s.Mods, cancellationToken).ConfigureAwait(false);
|
await difficultyCache.GetDifficultyAsync(s.BeatmapInfo, s.Ruleset, s.Mods, cancellationToken).ConfigureAwait(false);
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,7 +126,7 @@ namespace osu.Game.Scoring
|
|||||||
/// <returns>The total score.</returns>
|
/// <returns>The total score.</returns>
|
||||||
public async Task<long> GetTotalScoreAsync([NotNull] ScoreInfo score, ScoringMode mode = ScoringMode.Standardised, CancellationToken cancellationToken = default)
|
public async Task<long> GetTotalScoreAsync([NotNull] ScoreInfo score, ScoringMode mode = ScoringMode.Standardised, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
if (score.Beatmap == null)
|
if (score.BeatmapInfo == null)
|
||||||
return score.TotalScore;
|
return score.TotalScore;
|
||||||
|
|
||||||
int beatmapMaxCombo;
|
int beatmapMaxCombo;
|
||||||
@ -147,18 +147,18 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
// This score is guaranteed to be an osu!stable score.
|
// This score is guaranteed to be an osu!stable score.
|
||||||
// The combo must be determined through either the beatmap's max combo value or the difficulty calculator, as lazer's scoring has changed and the score statistics cannot be used.
|
// The combo must be determined through either the beatmap's max combo value or the difficulty calculator, as lazer's scoring has changed and the score statistics cannot be used.
|
||||||
if (score.Beatmap.MaxCombo != null)
|
if (score.BeatmapInfo.MaxCombo != null)
|
||||||
beatmapMaxCombo = score.Beatmap.MaxCombo.Value;
|
beatmapMaxCombo = score.BeatmapInfo.MaxCombo.Value;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (score.Beatmap.ID == 0 || difficulties == null)
|
if (score.BeatmapInfo.ID == 0 || difficulties == null)
|
||||||
{
|
{
|
||||||
// We don't have enough information (max combo) to compute the score, so use the provided score.
|
// We don't have enough information (max combo) to compute the score, so use the provided score.
|
||||||
return score.TotalScore;
|
return score.TotalScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can compute the max combo locally after the async beatmap difficulty computation.
|
// We can compute the max combo locally after the async beatmap difficulty computation.
|
||||||
var difficulty = await difficulties().GetDifficultyAsync(score.Beatmap, score.Ruleset, score.Mods, cancellationToken).ConfigureAwait(false);
|
var difficulty = await difficulties().GetDifficultyAsync(score.BeatmapInfo, score.Ruleset, score.Mods, cancellationToken).ConfigureAwait(false);
|
||||||
beatmapMaxCombo = difficulty.MaxCombo;
|
beatmapMaxCombo = difficulty.MaxCombo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -299,22 +299,22 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
public IEnumerable<string> HandledExtensions => scoreModelManager.HandledExtensions;
|
public IEnumerable<string> HandledExtensions => scoreModelManager.HandledExtensions;
|
||||||
|
|
||||||
public Task<IEnumerable<ScoreInfo>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
public Task<IEnumerable<ILive<ScoreInfo>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||||
{
|
{
|
||||||
return scoreModelManager.Import(notification, tasks);
|
return scoreModelManager.Import(notification, tasks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<ScoreInfo> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
public Task<ILive<ScoreInfo>> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return scoreModelManager.Import(task, lowPriority, cancellationToken);
|
return scoreModelManager.Import(task, lowPriority, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<ScoreInfo> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
public Task<ILive<ScoreInfo>> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return scoreModelManager.Import(archive, lowPriority, cancellationToken);
|
return scoreModelManager.Import(archive, lowPriority, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<ScoreInfo> Import(ScoreInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
public Task<ILive<ScoreInfo>> Import(ScoreInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
return scoreModelManager.Import(item, archive, lowPriority, cancellationToken);
|
return scoreModelManager.Import(item, archive, lowPriority, cancellationToken);
|
||||||
}
|
}
|
||||||
@ -365,9 +365,9 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
#region Implementation of IPresentImports<ScoreInfo>
|
#region Implementation of IPresentImports<ScoreInfo>
|
||||||
|
|
||||||
public Action<IEnumerable<ScoreInfo>> PresentImport
|
public Action<IEnumerable<ILive<ScoreInfo>>> PostImport
|
||||||
{
|
{
|
||||||
set => scoreModelManager.PresentImport = value;
|
set => scoreModelManager.PostImport = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Scoring
|
|||||||
{
|
{
|
||||||
var score = lookup.ScoreInfo;
|
var score = lookup.ScoreInfo;
|
||||||
|
|
||||||
var attributes = await difficultyCache.GetDifficultyAsync(score.Beatmap, score.Ruleset, score.Mods, token).ConfigureAwait(false);
|
var attributes = await difficultyCache.GetDifficultyAsync(score.BeatmapInfo, score.Ruleset, score.Mods, token).ConfigureAwait(false);
|
||||||
|
|
||||||
// Performance calculation requires the beatmap and ruleset to be locally available. If not, return a default value.
|
// Performance calculation requires the beatmap and ruleset to be locally available. If not, return a default value.
|
||||||
if (attributes.Attributes == null)
|
if (attributes.Attributes == null)
|
||||||
|
@ -17,9 +17,9 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
protected override IQueryable<ScoreInfo> AddIncludesForConsumption(IQueryable<ScoreInfo> query)
|
protected override IQueryable<ScoreInfo> AddIncludesForConsumption(IQueryable<ScoreInfo> query)
|
||||||
=> base.AddIncludesForConsumption(query)
|
=> base.AddIncludesForConsumption(query)
|
||||||
.Include(s => s.Beatmap)
|
.Include(s => s.BeatmapInfo)
|
||||||
.Include(s => s.Beatmap).ThenInclude(b => b.Metadata)
|
.Include(s => s.BeatmapInfo).ThenInclude(b => b.Metadata)
|
||||||
.Include(s => s.Beatmap).ThenInclude(b => b.BeatmapSet).ThenInclude(s => s.Metadata)
|
.Include(s => s.BeatmapInfo).ThenInclude(b => b.BeatmapSet).ThenInclude(s => s.Metadata)
|
||||||
.Include(s => s.Ruleset);
|
.Include(s => s.Ruleset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user