mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 13:22:55 +08:00
Merge branch 'master' into fix-out-of-order-events-on-block-fail
This commit is contained in:
commit
91e0d1021f
@ -43,7 +43,7 @@ namespace osu.Game.Tests.Database
|
||||
using (var importer = new BeatmapModelManager(realm, storage))
|
||||
using (new RulesetStore(realm, storage))
|
||||
{
|
||||
ILive<BeatmapSetInfo>? beatmapSet;
|
||||
Live<BeatmapSetInfo>? beatmapSet;
|
||||
|
||||
using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
|
||||
beatmapSet = await importer.Import(reader);
|
||||
@ -87,7 +87,7 @@ namespace osu.Game.Tests.Database
|
||||
using (var importer = new BeatmapModelManager(realm, storage))
|
||||
using (new RulesetStore(realm, storage))
|
||||
{
|
||||
ILive<BeatmapSetInfo>? beatmapSet;
|
||||
Live<BeatmapSetInfo>? beatmapSet;
|
||||
|
||||
using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
|
||||
beatmapSet = await importer.Import(reader);
|
||||
@ -144,7 +144,7 @@ namespace osu.Game.Tests.Database
|
||||
using (var importer = new BeatmapModelManager(realm, storage))
|
||||
using (new RulesetStore(realm, storage))
|
||||
{
|
||||
ILive<BeatmapSetInfo>? imported;
|
||||
Live<BeatmapSetInfo>? imported;
|
||||
|
||||
using (var reader = new ZipArchiveReader(TestResources.GetTestBeatmapStream()))
|
||||
imported = await importer.Import(reader);
|
||||
@ -219,7 +219,7 @@ namespace osu.Game.Tests.Database
|
||||
|
||||
string? tempPath = TestResources.GetTestBeatmapForImport();
|
||||
|
||||
ILive<BeatmapSetInfo>? importedSet;
|
||||
Live<BeatmapSetInfo>? importedSet;
|
||||
|
||||
using (var stream = File.OpenRead(tempPath))
|
||||
{
|
||||
@ -685,7 +685,7 @@ namespace osu.Game.Tests.Database
|
||||
[Test]
|
||||
public void TestImportWithDuplicateBeatmapIDs()
|
||||
{
|
||||
RunTestWithRealmAsync(async (realm, storage) =>
|
||||
RunTestWithRealm((realm, storage) =>
|
||||
{
|
||||
using var importer = new BeatmapModelManager(realm, storage);
|
||||
using var store = new RulesetStore(realm, storage);
|
||||
@ -718,7 +718,7 @@ namespace osu.Game.Tests.Database
|
||||
}
|
||||
};
|
||||
|
||||
var imported = await importer.Import(toImport);
|
||||
var imported = importer.Import(toImport);
|
||||
|
||||
Assert.NotNull(imported);
|
||||
Debug.Assert(imported != null);
|
||||
|
@ -23,9 +23,9 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
RunTestWithRealm((realm, _) =>
|
||||
{
|
||||
ILive<BeatmapInfo> beatmap = realm.Run(r => r.Write(_ => r.Add(new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata()))).ToLive(realm));
|
||||
Live<BeatmapInfo> beatmap = realm.Run(r => r.Write(_ => r.Add(new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata()))).ToLive(realm));
|
||||
|
||||
ILive<BeatmapInfo> beatmap2 = realm.Run(r => r.All<BeatmapInfo>().First().ToLive(realm));
|
||||
Live<BeatmapInfo> beatmap2 = realm.Run(r => r.All<BeatmapInfo>().First().ToLive(realm));
|
||||
|
||||
Assert.AreEqual(beatmap, beatmap2);
|
||||
});
|
||||
@ -38,7 +38,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
var beatmap = new BeatmapInfo(CreateRuleset(), new BeatmapDifficulty(), new BeatmapMetadata());
|
||||
|
||||
ILive<BeatmapInfo>? liveBeatmap = null;
|
||||
Live<BeatmapInfo>? liveBeatmap = null;
|
||||
|
||||
realm.Run(r =>
|
||||
{
|
||||
@ -100,7 +100,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
RunTestWithRealm((realm, _) =>
|
||||
{
|
||||
ILive<BeatmapInfo>? liveBeatmap = null;
|
||||
Live<BeatmapInfo>? liveBeatmap = null;
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
realm.Run(threadContext =>
|
||||
@ -129,7 +129,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
RunTestWithRealm((realm, _) =>
|
||||
{
|
||||
ILive<BeatmapInfo>? liveBeatmap = null;
|
||||
Live<BeatmapInfo>? liveBeatmap = null;
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
realm.Run(threadContext =>
|
||||
@ -170,7 +170,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
RunTestWithRealm((realm, _) =>
|
||||
{
|
||||
ILive<BeatmapInfo>? liveBeatmap = null;
|
||||
Live<BeatmapInfo>? liveBeatmap = null;
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
@ -209,7 +209,7 @@ namespace osu.Game.Tests.Database
|
||||
{
|
||||
RunTestWithRealm((realm, _) =>
|
||||
{
|
||||
ILive<BeatmapInfo>? liveBeatmap = null;
|
||||
Live<BeatmapInfo>? liveBeatmap = null;
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
realm.Run(threadContext =>
|
||||
@ -242,7 +242,7 @@ namespace osu.Game.Tests.Database
|
||||
realm.RegisterCustomSubscription(outerRealm =>
|
||||
{
|
||||
outerRealm.All<BeatmapInfo>().QueryAsyncWithNotifications(gotChange);
|
||||
ILive<BeatmapInfo>? liveBeatmap = null;
|
||||
Live<BeatmapInfo>? liveBeatmap = null;
|
||||
|
||||
Task.Factory.StartNew(() =>
|
||||
{
|
||||
|
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Online
|
||||
addAvailabilityCheckStep("state importing", BeatmapAvailability.Importing);
|
||||
|
||||
AddStep("allow importing", () => beatmaps.AllowImport.SetResult(true));
|
||||
AddUntilStep("wait for import", () => beatmaps.CurrentImportTask?.IsCompleted == true);
|
||||
AddUntilStep("wait for import", () => beatmaps.CurrentImport != null);
|
||||
addAvailabilityCheckStep("state locally available", BeatmapAvailability.LocallyAvailable);
|
||||
}
|
||||
|
||||
@ -164,7 +164,7 @@ namespace osu.Game.Tests.Online
|
||||
{
|
||||
public TaskCompletionSource<bool> AllowImport = new TaskCompletionSource<bool>();
|
||||
|
||||
public Task<ILive<BeatmapSetInfo>> CurrentImportTask { get; private set; }
|
||||
public Live<BeatmapSetInfo> CurrentImport { get; private set; }
|
||||
|
||||
public TestBeatmapManager(Storage storage, RealmAccess realm, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host = null, WorkingBeatmap defaultBeatmap = null)
|
||||
: base(storage, realm, rulesets, api, audioManager, resources, host, defaultBeatmap)
|
||||
@ -186,10 +186,10 @@ namespace osu.Game.Tests.Online
|
||||
this.testBeatmapManager = testBeatmapManager;
|
||||
}
|
||||
|
||||
public override async Task<ILive<BeatmapSetInfo>> Import(BeatmapSetInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public override Live<BeatmapSetInfo> Import(BeatmapSetInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await testBeatmapManager.AllowImport.Task.ConfigureAwait(false);
|
||||
return await (testBeatmapManager.CurrentImportTask = base.Import(item, archive, lowPriority, cancellationToken)).ConfigureAwait(false);
|
||||
testBeatmapManager.AllowImport.Task.WaitSafely();
|
||||
return (testBeatmapManager.CurrentImport = base.Import(item, archive, lowPriority, cancellationToken));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
@ -25,7 +24,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
public class ImportScoreTest : ImportTest
|
||||
{
|
||||
[Test]
|
||||
public async Task TestBasicImport()
|
||||
public void TestBasicImport()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
|
||||
{
|
||||
@ -49,7 +48,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
BeatmapInfo = beatmap.Beatmaps.First()
|
||||
};
|
||||
|
||||
var imported = await LoadScoreIntoOsu(osu, toImport);
|
||||
var imported = LoadScoreIntoOsu(osu, toImport);
|
||||
|
||||
Assert.AreEqual(toImport.Rank, imported.Rank);
|
||||
Assert.AreEqual(toImport.TotalScore, imported.TotalScore);
|
||||
@ -67,7 +66,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestImportMods()
|
||||
public void TestImportMods()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
|
||||
{
|
||||
@ -85,7 +84,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() },
|
||||
};
|
||||
|
||||
var imported = await LoadScoreIntoOsu(osu, toImport);
|
||||
var imported = LoadScoreIntoOsu(osu, toImport);
|
||||
|
||||
Assert.IsTrue(imported.Mods.Any(m => m is OsuModHardRock));
|
||||
Assert.IsTrue(imported.Mods.Any(m => m is OsuModDoubleTime));
|
||||
@ -98,7 +97,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestImportStatistics()
|
||||
public void TestImportStatistics()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
|
||||
{
|
||||
@ -120,7 +119,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
}
|
||||
};
|
||||
|
||||
var imported = await LoadScoreIntoOsu(osu, toImport);
|
||||
var imported = LoadScoreIntoOsu(osu, toImport);
|
||||
|
||||
Assert.AreEqual(toImport.Statistics[HitResult.Perfect], imported.Statistics[HitResult.Perfect]);
|
||||
Assert.AreEqual(toImport.Statistics[HitResult.Miss], imported.Statistics[HitResult.Miss]);
|
||||
@ -133,7 +132,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task TestOnlineScoreIsAvailableLocally()
|
||||
public void TestOnlineScoreIsAvailableLocally()
|
||||
{
|
||||
using (HeadlessGameHost host = new CleanRunHeadlessGameHost())
|
||||
{
|
||||
@ -143,7 +142,7 @@ namespace osu.Game.Tests.Scores.IO
|
||||
|
||||
var beatmap = BeatmapImportHelper.LoadOszIntoOsu(osu, TestResources.GetQuickTestBeatmapForImport()).GetResultSafely();
|
||||
|
||||
await LoadScoreIntoOsu(osu, new ScoreInfo
|
||||
LoadScoreIntoOsu(osu, new ScoreInfo
|
||||
{
|
||||
User = new APIUser { Username = "Test user" },
|
||||
BeatmapInfo = beatmap.Beatmaps.First(),
|
||||
@ -168,13 +167,14 @@ namespace osu.Game.Tests.Scores.IO
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<ScoreInfo> LoadScoreIntoOsu(OsuGameBase osu, ScoreInfo score, ArchiveReader archive = null)
|
||||
public static ScoreInfo LoadScoreIntoOsu(OsuGameBase osu, ScoreInfo score, ArchiveReader archive = null)
|
||||
{
|
||||
// clone to avoid attaching the input score to realm.
|
||||
score = score.DeepClone();
|
||||
|
||||
var scoreManager = osu.Dependencies.Get<ScoreManager>();
|
||||
await scoreManager.Import(score, archive);
|
||||
|
||||
scoreManager.Import(score, archive);
|
||||
|
||||
return scoreManager.Query(_ => true);
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
|
||||
#endregion
|
||||
|
||||
private void assertCorrectMetadata(ILive<SkinInfo> import1, string name, string creator, OsuGameBase osu)
|
||||
private void assertCorrectMetadata(Live<SkinInfo> import1, string name, string creator, OsuGameBase osu)
|
||||
{
|
||||
import1.PerformRead(i =>
|
||||
{
|
||||
@ -250,7 +250,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
});
|
||||
}
|
||||
|
||||
private void assertImportedBoth(ILive<SkinInfo> import1, ILive<SkinInfo> import2)
|
||||
private void assertImportedBoth(Live<SkinInfo> import1, Live<SkinInfo> import2)
|
||||
{
|
||||
import1.PerformRead(i1 => import2.PerformRead(i2 =>
|
||||
{
|
||||
@ -260,7 +260,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
}));
|
||||
}
|
||||
|
||||
private void assertImportedOnce(ILive<SkinInfo> import1, ILive<SkinInfo> import2)
|
||||
private void assertImportedOnce(Live<SkinInfo> import1, Live<SkinInfo> import2)
|
||||
{
|
||||
import1.PerformRead(i1 => import2.PerformRead(i2 =>
|
||||
{
|
||||
@ -334,7 +334,7 @@ namespace osu.Game.Tests.Skins.IO
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<ILive<SkinInfo>> loadSkinIntoOsu(OsuGameBase osu, ArchiveReader archive = null)
|
||||
private async Task<Live<SkinInfo>> loadSkinIntoOsu(OsuGameBase osu, ArchiveReader archive = null)
|
||||
{
|
||||
var skinManager = osu.Dependencies.Get<SkinManager>();
|
||||
return await skinManager.Import(archive);
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
|
||||
namespace osu.Game.Tests.Visual.Editing
|
||||
@ -37,11 +38,8 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
base.SetUpSteps();
|
||||
}
|
||||
|
||||
protected override void LoadEditor()
|
||||
{
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First());
|
||||
base.LoadEditor();
|
||||
}
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||
=> beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First());
|
||||
|
||||
[Test]
|
||||
public void TestBasicSwitch()
|
||||
|
@ -13,6 +13,7 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Setup;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Resources;
|
||||
using SharpCompress.Archives;
|
||||
using SharpCompress.Archives.Zip;
|
||||
@ -39,11 +40,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("make new beatmap unique", () => EditorBeatmap.Metadata.Title = Guid.NewGuid().ToString());
|
||||
}
|
||||
|
||||
protected override void LoadEditor()
|
||||
{
|
||||
Beatmap.Value = new DummyWorkingBeatmap(Audio, null);
|
||||
base.LoadEditor();
|
||||
}
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => new DummyWorkingBeatmap(Audio, null);
|
||||
|
||||
[Test]
|
||||
public void TestCreateNewBeatmap()
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -40,6 +41,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep("Enter compose mode", () => InputManager.Key(Key.F1));
|
||||
AddUntilStep("Wait for compose mode load", () => editor.ChildrenOfType<HitObjectComposer>().FirstOrDefault()?.IsLoaded == true);
|
||||
|
||||
AddStep("Set beat divisor", () => editor.Dependencies.Get<BindableBeatDivisor>().Value = 16);
|
||||
AddStep("Set overall difficulty", () => editorBeatmap.Difficulty.OverallDifficulty = 7);
|
||||
AddStep("Set artist and title", () =>
|
||||
{
|
||||
@ -88,6 +90,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
private void checkMutations()
|
||||
{
|
||||
AddAssert("Beatmap contains single hitcircle", () => editorBeatmap.HitObjects.Count == 1);
|
||||
AddAssert("Beatmap has correct beat divisor", () => editorBeatmap.BeatmapInfo.BeatDivisor == 16);
|
||||
AddAssert("Beatmap has correct overall difficulty", () => editorBeatmap.Difficulty.OverallDifficulty == 7);
|
||||
AddAssert("Beatmap has correct metadata", () => editorBeatmap.BeatmapInfo.Metadata.Artist == "artist" && editorBeatmap.BeatmapInfo.Metadata.Title == "title");
|
||||
AddAssert("Beatmap has correct author", () => editorBeatmap.BeatmapInfo.Metadata.Author.Username == "author");
|
||||
|
@ -17,6 +17,7 @@ using osu.Game.Screens.Edit;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
||||
using osu.Game.Screens.Edit.GameplayTest;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Beatmaps.IO;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
@ -43,9 +44,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
base.SetUpSteps();
|
||||
}
|
||||
|
||||
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||
=> beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First(b => b.RulesetID == 0));
|
||||
|
||||
protected override void LoadEditor()
|
||||
{
|
||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First(b => b.RulesetID == 0));
|
||||
SelectedMods.Value = new[] { new ModCinema() };
|
||||
base.LoadEditor();
|
||||
}
|
||||
|
@ -47,25 +47,25 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects = new[]
|
||||
{
|
||||
new HitCircle { StartTime = 100 },
|
||||
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 500 },
|
||||
new HitCircle { StartTime = 1000, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 1500, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 2000, Position = new Vector2(300) },
|
||||
}));
|
||||
|
||||
AddStep("select objects", () => EditorBeatmap.SelectedHitObjects.AddRange(addedObjects));
|
||||
|
||||
AddStep("nudge forwards", () => InputManager.Key(Key.K));
|
||||
AddAssert("objects moved forwards in time", () => addedObjects[0].StartTime > 100);
|
||||
AddAssert("objects moved forwards in time", () => addedObjects[0].StartTime > 500);
|
||||
|
||||
AddStep("nudge backwards", () => InputManager.Key(Key.J));
|
||||
AddAssert("objects reverted to original position", () => addedObjects[0].StartTime == 100);
|
||||
AddAssert("objects reverted to original position", () => addedObjects[0].StartTime == 500);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestBasicSelect()
|
||||
{
|
||||
var addedObject = new HitCircle { StartTime = 100 };
|
||||
var addedObject = new HitCircle { StartTime = 500 };
|
||||
AddStep("add hitobject", () => EditorBeatmap.Add(addedObject));
|
||||
|
||||
moveMouseToObject(() => addedObject);
|
||||
@ -75,7 +75,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
var addedObject2 = new HitCircle
|
||||
{
|
||||
StartTime = 200,
|
||||
StartTime = 1000,
|
||||
Position = new Vector2(100),
|
||||
};
|
||||
|
||||
@ -92,10 +92,10 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
var addedObjects = new[]
|
||||
{
|
||||
new HitCircle { StartTime = 100 },
|
||||
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 500 },
|
||||
new HitCircle { StartTime = 1000, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 1500, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 2000, Position = new Vector2(300) },
|
||||
};
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||
@ -125,7 +125,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
[Test]
|
||||
public void TestBasicDeselect()
|
||||
{
|
||||
var addedObject = new HitCircle { StartTime = 100 };
|
||||
var addedObject = new HitCircle { StartTime = 500 };
|
||||
AddStep("add hitobject", () => EditorBeatmap.Add(addedObject));
|
||||
|
||||
moveMouseToObject(() => addedObject);
|
||||
@ -166,11 +166,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
var addedObjects = new[]
|
||||
{
|
||||
new HitCircle { StartTime = 100 },
|
||||
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 500, Position = new Vector2(400) },
|
||||
new HitCircle { StartTime = 500 },
|
||||
new HitCircle { StartTime = 1000, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 1500, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 2000, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 2500, Position = new Vector2(400) },
|
||||
};
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||
@ -236,10 +236,10 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
{
|
||||
var addedObjects = new[]
|
||||
{
|
||||
new HitCircle { StartTime = 100 },
|
||||
new HitCircle { StartTime = 200, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 300, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 400, Position = new Vector2(300) },
|
||||
new HitCircle { StartTime = 500 },
|
||||
new HitCircle { StartTime = 1000, Position = new Vector2(100) },
|
||||
new HitCircle { StartTime = 1500, Position = new Vector2(200) },
|
||||
new HitCircle { StartTime = 2000, Position = new Vector2(300) },
|
||||
};
|
||||
|
||||
AddStep("add hitobjects", () => EditorBeatmap.AddRange(addedObjects));
|
||||
|
@ -132,7 +132,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestScoreImportThenDelete()
|
||||
{
|
||||
ILive<ScoreInfo> imported = null;
|
||||
Live<ScoreInfo> imported = null;
|
||||
|
||||
AddStep("create button without replay", () =>
|
||||
{
|
||||
@ -147,7 +147,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
AddUntilStep("state is not downloaded", () => downloadButton.State.Value == DownloadState.NotDownloaded);
|
||||
|
||||
AddStep("import score", () => imported = scoreManager.Import(getScoreInfo(true)).GetResultSafely());
|
||||
AddStep("import score", () => imported = scoreManager.Import(getScoreInfo(true)));
|
||||
|
||||
AddUntilStep("state is available", () => downloadButton.State.Value == DownloadState.LocallyAvailable);
|
||||
|
||||
|
@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
Queue<(IWorkingBeatmap working, TrackChangeDirection changeDirection)> trackChangeQueue = null;
|
||||
|
||||
// ensure we have at least two beatmaps available to identify the direction the music controller navigated to.
|
||||
AddRepeatStep("import beatmap", () => Game.BeatmapManager.Import(TestResources.CreateTestBeatmapSetInfo()).WaitSafely(), 5);
|
||||
AddRepeatStep("import beatmap", () => Game.BeatmapManager.Import(TestResources.CreateTestBeatmapSetInfo()), 5);
|
||||
|
||||
AddStep("import beatmap with track", () =>
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Platform;
|
||||
@ -154,11 +153,11 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
public void TestDownloadButtonHiddenWhenBeatmapExists()
|
||||
{
|
||||
var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo;
|
||||
ILive<BeatmapSetInfo> imported = null;
|
||||
Live<BeatmapSetInfo> imported = null;
|
||||
|
||||
Debug.Assert(beatmap.BeatmapSet != null);
|
||||
|
||||
AddStep("import beatmap", () => imported = manager.Import(beatmap.BeatmapSet).GetResultSafely());
|
||||
AddStep("import beatmap", () => imported = manager.Import(beatmap.BeatmapSet));
|
||||
|
||||
createPlaylistWithBeatmaps(() => imported.PerformRead(s => s.Beatmaps.Detach()));
|
||||
|
||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
beatmapSetInfo.Beatmaps.Add(beatmap);
|
||||
}
|
||||
|
||||
manager.Import(beatmapSetInfo).WaitSafely();
|
||||
manager.Import(beatmapSetInfo);
|
||||
}
|
||||
|
||||
public override void SetUpSteps()
|
||||
|
@ -6,7 +6,6 @@ using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Utils;
|
||||
@ -40,7 +39,7 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
|
||||
var beatmapSet = TestResources.CreateTestBeatmapSetInfo();
|
||||
|
||||
manager.Import(beatmapSet).WaitSafely();
|
||||
manager.Import(beatmapSet);
|
||||
}
|
||||
|
||||
public override void SetUpSteps()
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
@ -125,7 +124,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo
|
||||
},
|
||||
}
|
||||
}).GetResultSafely()?.Value;
|
||||
})?.Value;
|
||||
});
|
||||
|
||||
AddAssert($"import {i} succeeded", () => imported != null);
|
||||
|
@ -4,7 +4,6 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -60,7 +59,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
Ruleset = new OsuRuleset().RulesetInfo
|
||||
},
|
||||
}
|
||||
}).GetResultSafely()?.Value;
|
||||
})?.Value;
|
||||
});
|
||||
}
|
||||
|
||||
@ -135,7 +134,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
BeatmapInfo = beatmap.Beatmaps.First(),
|
||||
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo,
|
||||
User = new GuestUser(),
|
||||
}).GetResultSafely().Value;
|
||||
}).Value;
|
||||
});
|
||||
|
||||
AddAssert($"import {i} succeeded", () => imported != null);
|
||||
|
@ -8,7 +8,6 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
@ -151,7 +150,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
|
||||
Debug.Assert(modifiedBeatmap.BeatmapInfo.BeatmapSet != null);
|
||||
|
||||
manager.Import(modifiedBeatmap.BeatmapInfo.BeatmapSet).WaitSafely();
|
||||
manager.Import(modifiedBeatmap.BeatmapInfo.BeatmapSet);
|
||||
});
|
||||
|
||||
// Create the room using the real beatmap values.
|
||||
@ -196,7 +195,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
|
||||
Debug.Assert(originalBeatmap.BeatmapInfo.BeatmapSet != null);
|
||||
|
||||
manager.Import(originalBeatmap.BeatmapInfo.BeatmapSet).WaitSafely();
|
||||
manager.Import(originalBeatmap.BeatmapInfo.BeatmapSet);
|
||||
});
|
||||
|
||||
AddUntilStep("match has correct beatmap", () => realHash == match.Beatmap.Value.BeatmapInfo.MD5Hash);
|
||||
@ -219,7 +218,7 @@ namespace osu.Game.Tests.Visual.Playlists
|
||||
|
||||
Debug.Assert(beatmap.BeatmapInfo.BeatmapSet != null);
|
||||
|
||||
importedBeatmap = manager.Import(beatmap.BeatmapInfo.BeatmapSet).GetResultSafely()?.Value.Detach();
|
||||
importedBeatmap = manager.Import(beatmap.BeatmapInfo.BeatmapSet)?.Value.Detach();
|
||||
});
|
||||
|
||||
private class TestPlaylistsRoomSubScreen : PlaylistsRoomSubScreen
|
||||
|
@ -180,7 +180,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddStep(@"Load new scores via manager", () =>
|
||||
{
|
||||
foreach (var score in generateSampleScores(beatmapInfo()))
|
||||
scoreManager.Import(score).WaitSafely();
|
||||
scoreManager.Import(score);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Extensions;
|
||||
@ -184,7 +183,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
beatmap.DifficultyName = $"SR{i + 1}";
|
||||
}
|
||||
|
||||
return Game.BeatmapManager.Import(beatmapSet).GetResultSafely()?.Value;
|
||||
return Game.BeatmapManager.Import(beatmapSet)?.Value;
|
||||
}
|
||||
|
||||
private bool ensureAllBeatmapSetsImported(IEnumerable<BeatmapSetInfo> beatmapSets) => beatmapSets.All(set => set != null);
|
||||
|
@ -8,7 +8,6 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
@ -260,7 +259,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddStep("import multi-ruleset map", () =>
|
||||
{
|
||||
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
|
||||
manager.Import(TestResources.CreateTestBeatmapSetInfo(rulesets: usableRulesets)).WaitSafely();
|
||||
manager.Import(TestResources.CreateTestBeatmapSetInfo(rulesets: usableRulesets));
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -675,7 +674,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddStep("import multi-ruleset map", () =>
|
||||
{
|
||||
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
|
||||
manager.Import(TestResources.CreateTestBeatmapSetInfo(3, usableRulesets)).WaitSafely();
|
||||
manager.Import(TestResources.CreateTestBeatmapSetInfo(3, usableRulesets));
|
||||
});
|
||||
|
||||
int previousSetID = 0;
|
||||
@ -715,7 +714,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddStep("import multi-ruleset map", () =>
|
||||
{
|
||||
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
|
||||
manager.Import(TestResources.CreateTestBeatmapSetInfo(3, usableRulesets)).WaitSafely();
|
||||
manager.Import(TestResources.CreateTestBeatmapSetInfo(3, usableRulesets));
|
||||
});
|
||||
|
||||
DrawableCarouselBeatmapSet set = null;
|
||||
@ -764,7 +763,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
AddStep("import huge difficulty count map", () =>
|
||||
{
|
||||
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
|
||||
imported = manager.Import(TestResources.CreateTestBeatmapSetInfo(50, usableRulesets)).GetResultSafely()?.Value;
|
||||
imported = manager.Import(TestResources.CreateTestBeatmapSetInfo(50, usableRulesets))?.Value;
|
||||
});
|
||||
|
||||
AddStep("select the first beatmap of import", () => Beatmap.Value = manager.GetWorkingBeatmap(imported.Beatmaps.First()));
|
||||
@ -873,7 +872,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
|
||||
private void addRulesetImportStep(int id) => AddStep($"import test map for ruleset {id}", () => importForRuleset(id));
|
||||
|
||||
private void importForRuleset(int id) => manager.Import(TestResources.CreateTestBeatmapSetInfo(3, rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray())).WaitSafely();
|
||||
private void importForRuleset(int id) => manager.Import(TestResources.CreateTestBeatmapSetInfo(3, rulesets.AvailableRulesets.Where(r => r.OnlineID == id).ToArray()));
|
||||
|
||||
private void checkMusicPlaying(bool playing) =>
|
||||
AddUntilStep($"music {(playing ? "" : "not ")}playing", () => music.IsPlaying == playing);
|
||||
@ -903,7 +902,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
var usableRulesets = rulesets.AvailableRulesets.Where(r => r.OnlineID != 2).ToArray();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
manager.Import(TestResources.CreateTestBeatmapSetInfo(difficultyCountPerSet, usableRulesets)).WaitSafely();
|
||||
manager.Import(TestResources.CreateTestBeatmapSetInfo(difficultyCountPerSet, usableRulesets));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -112,7 +112,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
Ruleset = new OsuRuleset().RulesetInfo,
|
||||
};
|
||||
|
||||
importedScores.Add(scoreManager.Import(score).GetResultSafely().Value);
|
||||
importedScores.Add(scoreManager.Import(score).Value);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -10,7 +10,6 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Track;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.IO.Stores;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Testing;
|
||||
@ -105,7 +104,7 @@ namespace osu.Game.Beatmaps
|
||||
foreach (BeatmapInfo b in beatmapSet.Beatmaps)
|
||||
b.BeatmapSet = beatmapSet;
|
||||
|
||||
var imported = beatmapModelManager.Import(beatmapSet).GetResultSafely();
|
||||
var imported = beatmapModelManager.Import(beatmapSet);
|
||||
|
||||
if (imported == null)
|
||||
throw new InvalidOperationException("Failed to import new beatmap");
|
||||
@ -183,7 +182,7 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
/// <param name="query">The query.</param>
|
||||
/// <returns>The first result for the provided query, or null if no results were found.</returns>
|
||||
public ILive<BeatmapSetInfo>? QueryBeatmapSet(Expression<Func<BeatmapSetInfo, bool>> query)
|
||||
public Live<BeatmapSetInfo>? QueryBeatmapSet(Expression<Func<BeatmapSetInfo, bool>> query)
|
||||
{
|
||||
return realm.Run(r => r.All<BeatmapSetInfo>().FirstOrDefault(query)?.ToLive(realm));
|
||||
}
|
||||
@ -280,22 +279,22 @@ namespace osu.Game.Beatmaps
|
||||
return beatmapModelManager.Import(tasks);
|
||||
}
|
||||
|
||||
public Task<IEnumerable<ILive<BeatmapSetInfo>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||
public Task<IEnumerable<Live<BeatmapSetInfo>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||
{
|
||||
return beatmapModelManager.Import(notification, tasks);
|
||||
}
|
||||
|
||||
public Task<ILive<BeatmapSetInfo>?> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public Task<Live<BeatmapSetInfo>?> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return beatmapModelManager.Import(task, lowPriority, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<ILive<BeatmapSetInfo>?> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public Task<Live<BeatmapSetInfo>?> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return beatmapModelManager.Import(archive, lowPriority, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<ILive<BeatmapSetInfo>?> Import(BeatmapSetInfo item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public Live<BeatmapSetInfo>? Import(BeatmapSetInfo item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return beatmapModelManager.Import(item, archive, lowPriority, cancellationToken);
|
||||
}
|
||||
@ -324,7 +323,7 @@ namespace osu.Game.Beatmaps
|
||||
return workingBeatmapCache.GetWorkingBeatmap(importedBeatmap);
|
||||
}
|
||||
|
||||
public WorkingBeatmap GetWorkingBeatmap(ILive<BeatmapInfo>? importedBeatmap)
|
||||
public WorkingBeatmap GetWorkingBeatmap(Live<BeatmapInfo>? importedBeatmap)
|
||||
{
|
||||
WorkingBeatmap working = workingBeatmapCache.GetWorkingBeatmap(null);
|
||||
|
||||
@ -368,7 +367,7 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
#region Implementation of IPostImports<out BeatmapSetInfo>
|
||||
|
||||
public Action<IEnumerable<ILive<BeatmapSetInfo>>>? PostImport
|
||||
public Action<IEnumerable<Live<BeatmapSetInfo>>>? PostImport
|
||||
{
|
||||
set => beatmapModelManager.PostImport = value;
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ namespace osu.Game.Database
|
||||
/// </summary>
|
||||
/// <typeparam name="TModel">The model type.</typeparam>
|
||||
public interface IModelImporter<TModel> : IPostNotifications, IPostImports<TModel>, ICanAcceptFiles
|
||||
where TModel : class
|
||||
where TModel : class, IHasGuidPrimaryKey
|
||||
{
|
||||
Task<IEnumerable<ILive<TModel>>> Import(ProgressNotification notification, params ImportTask[] tasks);
|
||||
Task<IEnumerable<Live<TModel>>> Import(ProgressNotification notification, params ImportTask[] tasks);
|
||||
|
||||
/// <summary>
|
||||
/// Import one <typeparamref name="TModel"/> from the filesystem and delete the file on success.
|
||||
@ -28,7 +28,7 @@ namespace osu.Game.Database
|
||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||
/// <returns>The imported model, if successful.</returns>
|
||||
Task<ILive<TModel>?> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default);
|
||||
Task<Live<TModel>?> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Silently import an item from an <see cref="ArchiveReader"/>.
|
||||
@ -36,7 +36,7 @@ namespace osu.Game.Database
|
||||
/// <param name="archive">The archive to be imported.</param>
|
||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||
Task<ILive<TModel>?> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default);
|
||||
Task<Live<TModel>?> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Silently import an item from a <typeparamref name="TModel"/>.
|
||||
@ -45,7 +45,7 @@ namespace osu.Game.Database
|
||||
/// <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="cancellationToken">An optional cancellation token.</param>
|
||||
Task<ILive<TModel>?> Import(TModel item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default);
|
||||
Live<TModel>? Import(TModel item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// A user displayable name for the model type associated with this manager.
|
||||
|
@ -9,11 +9,11 @@ using System.Collections.Generic;
|
||||
namespace osu.Game.Database
|
||||
{
|
||||
public interface IPostImports<TModel>
|
||||
where TModel : class
|
||||
where TModel : class, IHasGuidPrimaryKey
|
||||
{
|
||||
/// <summary>
|
||||
/// Fired when the user requests to view the resulting import.
|
||||
/// </summary>
|
||||
public Action<IEnumerable<ILive<TModel>>>? PostImport { set; }
|
||||
public Action<IEnumerable<Live<TModel>>>? PostImport { set; }
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ namespace osu.Game.Database
|
||||
/// A class which handles importing legacy user data of a single type from osu-stable.
|
||||
/// </summary>
|
||||
public abstract class LegacyModelImporter<TModel>
|
||||
where TModel : class
|
||||
where TModel : class, IHasGuidPrimaryKey
|
||||
{
|
||||
/// <summary>
|
||||
/// The relative path from osu-stable's data directory to import items from.
|
||||
|
@ -3,39 +3,41 @@
|
||||
|
||||
using System;
|
||||
|
||||
#nullable enable
|
||||
|
||||
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<T> : IEquatable<ILive<T>>
|
||||
where T : class // TODO: Add IHasGuidPrimaryKey once we don't need EF support any more.
|
||||
public abstract class Live<T> : IEquatable<Live<T>>
|
||||
where T : class, IHasGuidPrimaryKey
|
||||
{
|
||||
Guid ID { get; }
|
||||
public 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);
|
||||
public abstract 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);
|
||||
public abstract 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);
|
||||
public abstract void PerformWrite(Action<T> perform);
|
||||
|
||||
/// <summary>
|
||||
/// Whether this instance is tracking data which is managed by the database backing.
|
||||
/// </summary>
|
||||
bool IsManaged { get; }
|
||||
public abstract bool IsManaged { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Resolve the value of this instance on the update thread.
|
||||
@ -43,6 +45,15 @@ namespace osu.Game.Database
|
||||
/// <remarks>
|
||||
/// After resolving, the data should not be passed between threads.
|
||||
/// </remarks>
|
||||
T Value { get; }
|
||||
public abstract T Value { get; }
|
||||
|
||||
protected Live(Guid id)
|
||||
{
|
||||
ID = id;
|
||||
}
|
||||
|
||||
public bool Equals(Live<T>? other) => ID == other?.ID;
|
||||
|
||||
public override string ToString() => PerformRead(i => i.ToString());
|
||||
}
|
||||
}
|
@ -83,6 +83,8 @@ namespace osu.Game.Database
|
||||
|
||||
private static readonly GlobalStatistic<int> realm_instances_created = GlobalStatistics.Get<int>(@"Realm", @"Instances (Created)");
|
||||
|
||||
private static readonly GlobalStatistic<int> total_subscriptions = GlobalStatistics.Get<int>(@"Realm", @"Subscriptions");
|
||||
|
||||
private readonly object realmLock = new object();
|
||||
|
||||
private Realm? updateRealm;
|
||||
@ -289,6 +291,8 @@ namespace osu.Game.Database
|
||||
|
||||
var syncContext = SynchronizationContext.Current;
|
||||
|
||||
total_subscriptions.Value++;
|
||||
|
||||
registerSubscription(action);
|
||||
|
||||
// This token is returned to the consumer.
|
||||
@ -309,6 +313,7 @@ namespace osu.Game.Database
|
||||
unsubscriptionAction?.Dispose();
|
||||
customSubscriptionsResetMap.Remove(action);
|
||||
notificationsResetMap.Remove(action);
|
||||
total_subscriptions.Value--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,9 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using osu.Framework.Development;
|
||||
using osu.Framework.Statistics;
|
||||
using Realms;
|
||||
|
||||
#nullable enable
|
||||
@ -13,16 +15,16 @@ namespace osu.Game.Database
|
||||
/// Provides a method of working with realm objects over longer application lifetimes.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The underlying object type.</typeparam>
|
||||
public class RealmLive<T> : ILive<T> where T : RealmObject, IHasGuidPrimaryKey
|
||||
public class RealmLive<T> : Live<T> where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
public Guid ID { get; }
|
||||
|
||||
public bool IsManaged => data.IsManaged;
|
||||
public override bool IsManaged => data.IsManaged;
|
||||
|
||||
/// <summary>
|
||||
/// The original live data used to create this instance.
|
||||
/// </summary>
|
||||
private readonly T data;
|
||||
private T data;
|
||||
|
||||
private bool dataIsFromUpdateThread;
|
||||
|
||||
private readonly RealmAccess realm;
|
||||
|
||||
@ -32,18 +34,19 @@ namespace osu.Game.Database
|
||||
/// <param name="data">The realm data.</param>
|
||||
/// <param name="realm">The realm factory the data was sourced from. May be null for an unmanaged object.</param>
|
||||
public RealmLive(T data, RealmAccess realm)
|
||||
: base(data.ID)
|
||||
{
|
||||
this.data = data;
|
||||
this.realm = realm;
|
||||
|
||||
ID = data.ID;
|
||||
dataIsFromUpdateThread = ThreadSafety.IsUpdateThread;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform a read operation on this live object.
|
||||
/// </summary>
|
||||
/// <param name="perform">The action to perform.</param>
|
||||
public void PerformRead(Action<T> perform)
|
||||
public override void PerformRead(Action<T> perform)
|
||||
{
|
||||
if (!IsManaged)
|
||||
{
|
||||
@ -51,21 +54,39 @@ namespace osu.Game.Database
|
||||
return;
|
||||
}
|
||||
|
||||
realm.Run(r => perform(retrieveFromID(r, ID)));
|
||||
realm.Run(r =>
|
||||
{
|
||||
if (ThreadSafety.IsUpdateThread)
|
||||
{
|
||||
ensureDataIsFromUpdateThread();
|
||||
perform(data);
|
||||
return;
|
||||
}
|
||||
|
||||
perform(retrieveFromID(r, ID));
|
||||
RealmLiveStatistics.USAGE_ASYNC.Value++;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Perform a read operation on this live object.
|
||||
/// </summary>
|
||||
/// <param name="perform">The action to perform.</param>
|
||||
public TReturn PerformRead<TReturn>(Func<T, TReturn> perform)
|
||||
public override TReturn PerformRead<TReturn>(Func<T, TReturn> perform)
|
||||
{
|
||||
if (!IsManaged)
|
||||
return perform(data);
|
||||
|
||||
if (ThreadSafety.IsUpdateThread)
|
||||
{
|
||||
ensureDataIsFromUpdateThread();
|
||||
return perform(data);
|
||||
}
|
||||
|
||||
return realm.Run(r =>
|
||||
{
|
||||
var returnData = perform(retrieveFromID(r, ID));
|
||||
RealmLiveStatistics.USAGE_ASYNC.Value++;
|
||||
|
||||
if (returnData is RealmObjectBase realmObject && realmObject.IsManaged)
|
||||
throw new InvalidOperationException(@$"Managed realm objects should not exit the scope of {nameof(PerformRead)}.");
|
||||
@ -78,7 +99,7 @@ namespace osu.Game.Database
|
||||
/// Perform a write operation on this live object.
|
||||
/// </summary>
|
||||
/// <param name="perform">The action to perform.</param>
|
||||
public void PerformWrite(Action<T> perform)
|
||||
public override void PerformWrite(Action<T> perform)
|
||||
{
|
||||
if (!IsManaged)
|
||||
throw new InvalidOperationException(@"Can't perform writes on a non-managed underlying value");
|
||||
@ -88,10 +109,11 @@ namespace osu.Game.Database
|
||||
var transaction = t.Realm.BeginWrite();
|
||||
perform(t);
|
||||
transaction.Commit();
|
||||
RealmLiveStatistics.WRITES.Value++;
|
||||
});
|
||||
}
|
||||
|
||||
public T Value
|
||||
public override T Value
|
||||
{
|
||||
get
|
||||
{
|
||||
@ -101,10 +123,26 @@ namespace osu.Game.Database
|
||||
if (!ThreadSafety.IsUpdateThread)
|
||||
throw new InvalidOperationException($"Can't use {nameof(Value)} on managed objects from non-update threads");
|
||||
|
||||
return realm.Realm.Find<T>(ID);
|
||||
ensureDataIsFromUpdateThread();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureDataIsFromUpdateThread()
|
||||
{
|
||||
Debug.Assert(ThreadSafety.IsUpdateThread);
|
||||
|
||||
if (dataIsFromUpdateThread && !data.Realm.IsClosed)
|
||||
{
|
||||
RealmLiveStatistics.USAGE_UPDATE_IMMEDIATE.Value++;
|
||||
return;
|
||||
}
|
||||
|
||||
dataIsFromUpdateThread = true;
|
||||
data = retrieveFromID(realm.Realm, ID);
|
||||
RealmLiveStatistics.USAGE_UPDATE_REFETCH.Value++;
|
||||
}
|
||||
|
||||
private T retrieveFromID(Realm realm, Guid id)
|
||||
{
|
||||
var found = realm.Find<T>(ID);
|
||||
@ -120,9 +158,13 @@ namespace osu.Game.Database
|
||||
|
||||
return found;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Equals(ILive<T>? other) => ID == other?.ID;
|
||||
|
||||
public override string ToString() => PerformRead(i => i.ToString());
|
||||
internal static class RealmLiveStatistics
|
||||
{
|
||||
public static readonly GlobalStatistic<int> WRITES = GlobalStatistics.Get<int>(@"Realm", @"Live writes");
|
||||
public static readonly GlobalStatistic<int> USAGE_UPDATE_IMMEDIATE = GlobalStatistics.Get<int>(@"Realm", @"Live update read (fast)");
|
||||
public static readonly GlobalStatistic<int> USAGE_UPDATE_REFETCH = GlobalStatistics.Get<int>(@"Realm", @"Live update read (slow)");
|
||||
public static readonly GlobalStatistic<int> USAGE_ASYNC = GlobalStatistics.Get<int>(@"Realm", @"Live async read");
|
||||
}
|
||||
}
|
||||
|
@ -13,13 +13,19 @@ namespace osu.Game.Database
|
||||
/// Usually used for testing purposes where the instance is never required to be managed.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The underlying object type.</typeparam>
|
||||
public class RealmLiveUnmanaged<T> : ILive<T> where T : RealmObjectBase, IHasGuidPrimaryKey
|
||||
public class RealmLiveUnmanaged<T> : Live<T> where T : RealmObjectBase, IHasGuidPrimaryKey
|
||||
{
|
||||
/// <summary>
|
||||
/// The original live data used to create this instance.
|
||||
/// </summary>
|
||||
public override T Value { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Construct a new instance of live realm data.
|
||||
/// </summary>
|
||||
/// <param name="data">The realm data.</param>
|
||||
public RealmLiveUnmanaged(T data)
|
||||
: base(data.ID)
|
||||
{
|
||||
if (data.IsManaged)
|
||||
throw new InvalidOperationException($"Cannot use {nameof(RealmLiveUnmanaged<T>)} with managed instances");
|
||||
@ -27,23 +33,12 @@ namespace osu.Game.Database
|
||||
Value = data;
|
||||
}
|
||||
|
||||
public bool Equals(ILive<T>? other) => ID == other?.ID;
|
||||
public override void PerformRead(Action<T> perform) => perform(Value);
|
||||
|
||||
public override string ToString() => Value.ToString();
|
||||
public override TReturn PerformRead<TReturn>(Func<T, TReturn> perform) => perform(Value);
|
||||
|
||||
public Guid ID => Value.ID;
|
||||
public override void PerformWrite(Action<T> perform) => throw new InvalidOperationException(@"Can't perform writes on a non-managed underlying value");
|
||||
|
||||
public void PerformRead(Action<T> perform) => perform(Value);
|
||||
|
||||
public TReturn PerformRead<TReturn>(Func<T, TReturn> perform) => perform(Value);
|
||||
|
||||
public void PerformWrite(Action<T> perform) => throw new InvalidOperationException(@"Can't perform writes on a non-managed underlying value");
|
||||
|
||||
public bool IsManaged => false;
|
||||
|
||||
/// <summary>
|
||||
/// The original live data used to create this instance.
|
||||
/// </summary>
|
||||
public T Value { get; }
|
||||
public override bool IsManaged => false;
|
||||
}
|
||||
}
|
||||
|
@ -204,25 +204,25 @@ namespace osu.Game.Database
|
||||
private static void copyChangesToRealm<T>(T source, T destination) where T : RealmObjectBase
|
||||
=> write_mapper.Map(source, destination);
|
||||
|
||||
public static List<ILive<T>> ToLiveUnmanaged<T>(this IEnumerable<T> realmList)
|
||||
public static List<Live<T>> ToLiveUnmanaged<T>(this IEnumerable<T> realmList)
|
||||
where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
return realmList.Select(l => new RealmLiveUnmanaged<T>(l)).Cast<ILive<T>>().ToList();
|
||||
return realmList.Select(l => new RealmLiveUnmanaged<T>(l)).Cast<Live<T>>().ToList();
|
||||
}
|
||||
|
||||
public static ILive<T> ToLiveUnmanaged<T>(this T realmObject)
|
||||
public static Live<T> ToLiveUnmanaged<T>(this T realmObject)
|
||||
where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
return new RealmLiveUnmanaged<T>(realmObject);
|
||||
}
|
||||
|
||||
public static List<ILive<T>> ToLive<T>(this IEnumerable<T> realmList, RealmAccess realm)
|
||||
public static List<Live<T>> ToLive<T>(this IEnumerable<T> realmList, RealmAccess realm)
|
||||
where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
return realmList.Select(l => new RealmLive<T>(l, realm)).Cast<ILive<T>>().ToList();
|
||||
return realmList.Select(l => new RealmLive<T>(l, realm)).Cast<Live<T>>().ToList();
|
||||
}
|
||||
|
||||
public static ILive<T> ToLive<T>(this T realmObject, RealmAccess realm)
|
||||
public static Live<T> ToLive<T>(this T realmObject, RealmAccess realm)
|
||||
where T : RealmObject, IHasGuidPrimaryKey
|
||||
{
|
||||
return new RealmLive<T>(realmObject, realm);
|
||||
|
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets;
|
||||
using Realms;
|
||||
|
||||
namespace osu.Game.Input.Bindings
|
||||
{
|
||||
@ -46,41 +47,36 @@ namespace osu.Game.Input.Bindings
|
||||
throw new InvalidOperationException($"{nameof(variant)} can not be null when a non-null {nameof(ruleset)} is provided.");
|
||||
}
|
||||
|
||||
private IQueryable<RealmKeyBinding> queryRealmKeyBindings()
|
||||
{
|
||||
string rulesetName = ruleset?.ShortName;
|
||||
return realm.Realm.All<RealmKeyBinding>()
|
||||
.Where(b => b.RulesetName == rulesetName && b.Variant == variant);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
realmSubscription = realm.RegisterForNotifications(r => queryRealmKeyBindings(), (sender, changes, error) =>
|
||||
realmSubscription = realm.RegisterForNotifications(queryRealmKeyBindings, (sender, changes, error) =>
|
||||
{
|
||||
// The first fire of this is a bit redundant as this is being called in base.LoadComplete,
|
||||
// but this is safest in case the subscription is restored after a context recycle.
|
||||
ReloadMappings();
|
||||
reloadMappings(sender.AsQueryable());
|
||||
});
|
||||
|
||||
base.LoadComplete();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
protected override void ReloadMappings() => reloadMappings(queryRealmKeyBindings(realm.Realm));
|
||||
|
||||
realmSubscription?.Dispose();
|
||||
private IQueryable<RealmKeyBinding> queryRealmKeyBindings(Realm realm)
|
||||
{
|
||||
string rulesetName = ruleset?.ShortName;
|
||||
return realm.All<RealmKeyBinding>()
|
||||
.Where(b => b.RulesetName == rulesetName && b.Variant == variant);
|
||||
}
|
||||
|
||||
protected override void ReloadMappings()
|
||||
private void reloadMappings(IQueryable<RealmKeyBinding> realmKeyBindings)
|
||||
{
|
||||
var defaults = DefaultKeyBindings.ToList();
|
||||
|
||||
List<RealmKeyBinding> newBindings = queryRealmKeyBindings().Detach()
|
||||
// this ordering is important to ensure that we read entries from the database in the order
|
||||
// enforced by DefaultKeyBindings. allow for song select to handle actions that may otherwise
|
||||
// have been eaten by the music controller due to query order.
|
||||
.OrderBy(b => defaults.FindIndex(d => (int)d.Action == b.ActionInt)).ToList();
|
||||
List<RealmKeyBinding> newBindings = realmKeyBindings.Detach()
|
||||
// this ordering is important to ensure that we read entries from the database in the order
|
||||
// enforced by DefaultKeyBindings. allow for song select to handle actions that may otherwise
|
||||
// have been eaten by the music controller due to query order.
|
||||
.OrderBy(b => defaults.FindIndex(d => (int)d.Action == b.ActionInt)).ToList();
|
||||
|
||||
// In the case no bindings were found in the database, presume this usage is for a non-databased ruleset.
|
||||
// This actually should never be required and can be removed if it is ever deemed to cause a problem.
|
||||
@ -91,5 +87,12 @@ namespace osu.Game.Input.Bindings
|
||||
else
|
||||
KeyBindings = newBindings;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
realmSubscription?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ namespace osu.Game
|
||||
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID.ToString();
|
||||
configSkin.ValueChanged += skinId =>
|
||||
{
|
||||
ILive<SkinInfo> skinInfo = null;
|
||||
Live<SkinInfo> skinInfo = null;
|
||||
|
||||
if (Guid.TryParse(skinId.NewValue, out var guid))
|
||||
skinInfo = SkinManager.Query(s => s.ID == guid);
|
||||
@ -439,7 +439,7 @@ namespace osu.Game
|
||||
/// </remarks>
|
||||
public void PresentBeatmap(IBeatmapSetInfo beatmap, Predicate<BeatmapInfo> difficultyCriteria = null)
|
||||
{
|
||||
ILive<BeatmapSetInfo> databasedSet = null;
|
||||
Live<BeatmapSetInfo> databasedSet = null;
|
||||
|
||||
if (beatmap.OnlineID > 0)
|
||||
databasedSet = BeatmapManager.QueryBeatmapSet(s => s.OnlineID == beatmap.OnlineID);
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Logging;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Localisation;
|
||||
@ -118,6 +119,8 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
++runningDepth;
|
||||
|
||||
Logger.Log($"⚠️ {notification.Text}");
|
||||
|
||||
notification.Closed += notificationClosed;
|
||||
|
||||
if (notification is IHasCompletionTarget hasCompletionTarget)
|
||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics.Effects;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osuTK;
|
||||
@ -25,6 +26,8 @@ namespace osu.Game.Overlays.Notifications
|
||||
/// </summary>
|
||||
public event Action Closed;
|
||||
|
||||
public abstract LocalisableString Text { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this notification should forcefully display itself.
|
||||
/// </summary>
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
|
||||
private LocalisableString text;
|
||||
|
||||
public LocalisableString Text
|
||||
public override LocalisableString Text
|
||||
{
|
||||
get => text;
|
||||
set
|
||||
|
@ -18,7 +18,7 @@ namespace osu.Game.Overlays.Notifications
|
||||
{
|
||||
private LocalisableString text;
|
||||
|
||||
public LocalisableString Text
|
||||
public override LocalisableString Text
|
||||
{
|
||||
get => text;
|
||||
set
|
||||
|
@ -73,6 +73,9 @@ namespace osu.Game.Overlays.Settings.Sections.DebugSettings
|
||||
|
||||
void unblock()
|
||||
{
|
||||
if (token == null)
|
||||
return;
|
||||
|
||||
token?.Dispose();
|
||||
token = null;
|
||||
|
||||
|
@ -32,16 +32,16 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
Icon = FontAwesome.Solid.PaintBrush
|
||||
};
|
||||
|
||||
private readonly Bindable<ILive<SkinInfo>> dropdownBindable = new Bindable<ILive<SkinInfo>> { Default = DefaultSkin.CreateInfo().ToLiveUnmanaged() };
|
||||
private readonly Bindable<Live<SkinInfo>> dropdownBindable = new Bindable<Live<SkinInfo>> { Default = DefaultSkin.CreateInfo().ToLiveUnmanaged() };
|
||||
private readonly Bindable<string> configBindable = new Bindable<string>();
|
||||
|
||||
private static readonly ILive<SkinInfo> random_skin_info = new SkinInfo
|
||||
private static readonly Live<SkinInfo> random_skin_info = new SkinInfo
|
||||
{
|
||||
ID = SkinInfo.RANDOM_SKIN,
|
||||
Name = "<Random Skin>",
|
||||
}.ToLiveUnmanaged();
|
||||
|
||||
private List<ILive<SkinInfo>> skinItems;
|
||||
private List<Live<SkinInfo>> skinItems;
|
||||
|
||||
[Resolved]
|
||||
private SkinManager skins { get; set; }
|
||||
@ -118,7 +118,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
|
||||
private void updateSelectedSkinFromConfig()
|
||||
{
|
||||
ILive<SkinInfo> skin = null;
|
||||
Live<SkinInfo> skin = null;
|
||||
|
||||
if (Guid.TryParse(configBindable.Value, out var configId))
|
||||
skin = skinDropdown.Items.FirstOrDefault(s => s.ID == configId);
|
||||
@ -144,13 +144,13 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
realmSubscription?.Dispose();
|
||||
}
|
||||
|
||||
private class SkinSettingsDropdown : SettingsDropdown<ILive<SkinInfo>>
|
||||
private class SkinSettingsDropdown : SettingsDropdown<Live<SkinInfo>>
|
||||
{
|
||||
protected override OsuDropdown<ILive<SkinInfo>> CreateDropdown() => new SkinDropdownControl();
|
||||
protected override OsuDropdown<Live<SkinInfo>> CreateDropdown() => new SkinDropdownControl();
|
||||
|
||||
private class SkinDropdownControl : DropdownControl
|
||||
{
|
||||
protected override LocalisableString GenerateItemText(ILive<SkinInfo> item) => item.ToString();
|
||||
protected override LocalisableString GenerateItemText(Live<SkinInfo> item) => item.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,22 +293,22 @@ namespace osu.Game.Scoring
|
||||
|
||||
public IEnumerable<string> HandledExtensions => scoreModelManager.HandledExtensions;
|
||||
|
||||
public Task<IEnumerable<ILive<ScoreInfo>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||
public Task<IEnumerable<Live<ScoreInfo>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||
{
|
||||
return scoreModelManager.Import(notification, tasks);
|
||||
}
|
||||
|
||||
public Task<ILive<ScoreInfo>> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public Task<Live<ScoreInfo>> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return scoreModelManager.Import(task, lowPriority, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<ILive<ScoreInfo>> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public Task<Live<ScoreInfo>> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return scoreModelManager.Import(archive, lowPriority, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<ILive<ScoreInfo>> Import(ScoreInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public Live<ScoreInfo> Import(ScoreInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return scoreModelManager.Import(item, archive, lowPriority, cancellationToken);
|
||||
}
|
||||
@ -322,7 +322,7 @@ namespace osu.Game.Scoring
|
||||
|
||||
#region Implementation of IPresentImports<ScoreInfo>
|
||||
|
||||
public Action<IEnumerable<ILive<ScoreInfo>>> PostImport
|
||||
public Action<IEnumerable<Live<ScoreInfo>>> PostImport
|
||||
{
|
||||
set => scoreModelManager.PostImport = value;
|
||||
}
|
||||
|
@ -24,7 +24,11 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
[Cached]
|
||||
public class Timeline : ZoomableScrollContainer, IPositionSnapProvider
|
||||
{
|
||||
private const float timeline_height = 72;
|
||||
private const float timeline_expanded_height = 94;
|
||||
|
||||
private readonly Drawable userContent;
|
||||
|
||||
public readonly Bindable<bool> WaveformVisible = new Bindable<bool>();
|
||||
|
||||
public readonly Bindable<bool> ControlPointsVisible = new Bindable<bool>();
|
||||
@ -58,8 +62,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
private Track track;
|
||||
|
||||
private const float timeline_height = 72;
|
||||
private const float timeline_expanded_height = 94;
|
||||
/// <summary>
|
||||
/// The timeline zoom level at a 1x zoom scale.
|
||||
/// </summary>
|
||||
private float defaultTimelineZoom;
|
||||
|
||||
private readonly Bindable<double> timelineZoomScale = new BindableDouble(1.0);
|
||||
|
||||
public Timeline(Drawable userContent)
|
||||
{
|
||||
@ -84,7 +92,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private Bindable<float> waveformOpacity;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, OsuColour colours, OsuConfigManager config)
|
||||
private void load(IBindable<WorkingBeatmap> beatmap, EditorBeatmap editorBeatmap, OsuColour colours, OsuConfigManager config)
|
||||
{
|
||||
CentreMarker centreMarker;
|
||||
|
||||
@ -141,9 +149,16 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
MaxZoom = getZoomLevelForVisibleMilliseconds(500);
|
||||
MinZoom = getZoomLevelForVisibleMilliseconds(10000);
|
||||
Zoom = getZoomLevelForVisibleMilliseconds(2000);
|
||||
defaultTimelineZoom = getZoomLevelForVisibleMilliseconds(6000);
|
||||
}
|
||||
}, true);
|
||||
|
||||
timelineZoomScale.Value = editorBeatmap.BeatmapInfo.TimelineZoom;
|
||||
timelineZoomScale.BindValueChanged(scale =>
|
||||
{
|
||||
Zoom = (float)(defaultTimelineZoom * scale.NewValue);
|
||||
editorBeatmap.BeatmapInfo.TimelineZoom = scale.NewValue;
|
||||
}, true);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -201,6 +216,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
return base.OnScroll(e);
|
||||
}
|
||||
|
||||
protected override void OnZoomChanged()
|
||||
{
|
||||
base.OnZoomChanged();
|
||||
timelineZoomScale.Value = Zoom / defaultTimelineZoom;
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
|
@ -136,11 +136,20 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
zoomTarget = Math.Clamp(newZoom, MinZoom, MaxZoom);
|
||||
transformZoomTo(zoomTarget, focusPoint, ZoomDuration, ZoomEasing);
|
||||
|
||||
OnZoomChanged();
|
||||
}
|
||||
|
||||
private void transformZoomTo(float newZoom, float focusPoint, double duration = 0, Easing easing = Easing.None)
|
||||
=> this.TransformTo(this.PopulateTransform(new TransformZoom(focusPoint, zoomedContent.DrawWidth, Current), newZoom, duration, easing));
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when <see cref="Zoom"/> has changed.
|
||||
/// </summary>
|
||||
protected virtual void OnZoomChanged()
|
||||
{
|
||||
}
|
||||
|
||||
private class TransformZoom : Transform<float, ZoomableScrollContainer>
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -158,9 +158,6 @@ namespace osu.Game.Screens.Edit
|
||||
return;
|
||||
}
|
||||
|
||||
beatDivisor.Value = playableBeatmap.BeatmapInfo.BeatDivisor;
|
||||
beatDivisor.BindValueChanged(divisor => playableBeatmap.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
||||
|
||||
// Todo: should probably be done at a DrawableRuleset level to share logic with Player.
|
||||
clock = new EditorClock(playableBeatmap, beatDivisor) { IsCoupled = false };
|
||||
clock.ChangeSource(loadableBeatmap.Track);
|
||||
@ -178,6 +175,9 @@ namespace osu.Game.Screens.Edit
|
||||
changeHandler = new EditorChangeHandler(editorBeatmap);
|
||||
dependencies.CacheAs<IEditorChangeHandler>(changeHandler);
|
||||
|
||||
beatDivisor.Value = editorBeatmap.BeatmapInfo.BeatDivisor;
|
||||
beatDivisor.BindValueChanged(divisor => editorBeatmap.BeatmapInfo.BeatDivisor = divisor.NewValue);
|
||||
|
||||
updateLastSavedHash();
|
||||
|
||||
Schedule(() =>
|
||||
|
@ -1024,11 +1024,11 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
/// <param name="score">The <see cref="Scoring.Score"/> to import.</param>
|
||||
/// <returns>The imported score.</returns>
|
||||
protected virtual async Task ImportScore(Score score)
|
||||
protected virtual Task ImportScore(Score score)
|
||||
{
|
||||
// Replays are already populated and present in the game's database, so should not be re-imported.
|
||||
if (DrawableRuleset.ReplayScore != null)
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
|
||||
LegacyByteArrayReader replayReader;
|
||||
|
||||
@ -1048,7 +1048,7 @@ namespace osu.Game.Screens.Play
|
||||
// conflicts across various systems (ie. solo and multiplayer).
|
||||
importableScore.OnlineID = -1;
|
||||
|
||||
var imported = await scoreManager.Import(importableScore, replayReader).ConfigureAwait(false);
|
||||
var imported = scoreManager.Import(importableScore, replayReader);
|
||||
|
||||
imported.PerformRead(s =>
|
||||
{
|
||||
@ -1056,6 +1056,8 @@ namespace osu.Game.Screens.Play
|
||||
score.ScoreInfo.Hash = s.Hash;
|
||||
score.ScoreInfo.ID = s.ID;
|
||||
});
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Skinning
|
||||
{
|
||||
public abstract class Skin : IDisposable, ISkin
|
||||
{
|
||||
public readonly ILive<SkinInfo> SkinInfo;
|
||||
public readonly Live<SkinInfo> SkinInfo;
|
||||
private readonly IStorageResourceProvider resources;
|
||||
|
||||
public SkinConfiguration Configuration { get; set; }
|
||||
|
@ -11,7 +11,6 @@ using JetBrains.Annotations;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Audio.Sample;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.OpenGL.Textures;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
@ -48,7 +47,7 @@ namespace osu.Game.Skinning
|
||||
|
||||
public readonly Bindable<Skin> CurrentSkin = new Bindable<Skin>();
|
||||
|
||||
public readonly Bindable<ILive<SkinInfo>> CurrentSkinInfo = new Bindable<ILive<SkinInfo>>(Skinning.DefaultSkin.CreateInfo().ToLiveUnmanaged())
|
||||
public readonly Bindable<Live<SkinInfo>> CurrentSkinInfo = new Bindable<Live<SkinInfo>>(Skinning.DefaultSkin.CreateInfo().ToLiveUnmanaged())
|
||||
{
|
||||
Default = Skinning.DefaultSkin.CreateInfo().ToLiveUnmanaged()
|
||||
};
|
||||
@ -151,7 +150,7 @@ namespace osu.Game.Skinning
|
||||
Name = s.Name + @" (modified)",
|
||||
Creator = s.Creator,
|
||||
InstantiationInfo = s.InstantiationInfo,
|
||||
}).GetResultSafely();
|
||||
});
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
@ -177,7 +176,7 @@ namespace osu.Game.Skinning
|
||||
/// </summary>
|
||||
/// <param name="query">The query.</param>
|
||||
/// <returns>The first result for the provided query, or null if no results were found.</returns>
|
||||
public ILive<SkinInfo> Query(Expression<Func<SkinInfo, bool>> query)
|
||||
public Live<SkinInfo> Query(Expression<Func<SkinInfo, bool>> query)
|
||||
{
|
||||
return realm.Run(r => r.All<SkinInfo>().FirstOrDefault(query)?.ToLive(realm));
|
||||
}
|
||||
@ -246,7 +245,7 @@ namespace osu.Game.Skinning
|
||||
set => skinModelManager.PostNotification = value;
|
||||
}
|
||||
|
||||
public Action<IEnumerable<ILive<SkinInfo>>> PostImport
|
||||
public Action<IEnumerable<Live<SkinInfo>>> PostImport
|
||||
{
|
||||
set => skinModelManager.PostImport = value;
|
||||
}
|
||||
@ -263,22 +262,22 @@ namespace osu.Game.Skinning
|
||||
|
||||
public IEnumerable<string> HandledExtensions => skinModelManager.HandledExtensions;
|
||||
|
||||
public Task<IEnumerable<ILive<SkinInfo>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||
public Task<IEnumerable<Live<SkinInfo>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||
{
|
||||
return skinModelManager.Import(notification, tasks);
|
||||
}
|
||||
|
||||
public Task<ILive<SkinInfo>> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public Task<Live<SkinInfo>> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return skinModelManager.Import(task, lowPriority, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<ILive<SkinInfo>> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public Task<Live<SkinInfo>> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return skinModelManager.Import(archive, lowPriority, cancellationToken);
|
||||
}
|
||||
|
||||
public Task<ILive<SkinInfo>> Import(SkinInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public Live<SkinInfo> Import(SkinInfo item, ArchiveReader archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return skinModelManager.Import(item, archive, lowPriority, cancellationToken);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ namespace osu.Game.Stores
|
||||
/// <summary>
|
||||
/// Fired when the user requests to view the resulting import.
|
||||
/// </summary>
|
||||
public Action<IEnumerable<ILive<TModel>>>? PostImport { get; set; }
|
||||
public Action<IEnumerable<Live<TModel>>>? PostImport { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set an endpoint for notifications to be posted to.
|
||||
@ -104,7 +104,7 @@ namespace osu.Game.Stores
|
||||
return Import(notification, tasks);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ILive<TModel>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||
public async Task<IEnumerable<Live<TModel>>> Import(ProgressNotification notification, params ImportTask[] tasks)
|
||||
{
|
||||
if (tasks.Length == 0)
|
||||
{
|
||||
@ -118,7 +118,7 @@ namespace osu.Game.Stores
|
||||
|
||||
int current = 0;
|
||||
|
||||
var imported = new List<ILive<TModel>>();
|
||||
var imported = new List<Live<TModel>>();
|
||||
|
||||
bool isLowPriorityImport = tasks.Length > low_priority_import_batch_size;
|
||||
|
||||
@ -196,11 +196,11 @@ namespace osu.Game.Stores
|
||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||
/// <returns>The imported model, if successful.</returns>
|
||||
public async Task<ILive<TModel>?> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public async Task<Live<TModel>?> Import(ImportTask task, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
ILive<TModel>? import;
|
||||
Live<TModel>? import;
|
||||
using (ArchiveReader reader = task.GetReader())
|
||||
import = await Import(reader, lowPriority, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@ -227,7 +227,7 @@ namespace osu.Game.Stores
|
||||
/// <param name="archive">The archive to be imported.</param>
|
||||
/// <param name="lowPriority">Whether this is a low priority import.</param>
|
||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||
public async Task<ILive<TModel>?> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public async Task<Live<TModel>?> Import(ArchiveReader archive, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
|
||||
@ -250,8 +250,10 @@ namespace osu.Game.Stores
|
||||
return null;
|
||||
}
|
||||
|
||||
var scheduledImport = Task.Factory.StartNew(async () => await Import(model, archive, lowPriority, cancellationToken).ConfigureAwait(false),
|
||||
cancellationToken, TaskCreationOptions.HideScheduler, lowPriority ? import_scheduler_low_priority : import_scheduler).Unwrap();
|
||||
var scheduledImport = Task.Factory.StartNew(() => Import(model, archive, lowPriority, cancellationToken),
|
||||
cancellationToken,
|
||||
TaskCreationOptions.HideScheduler,
|
||||
lowPriority ? import_scheduler_low_priority : import_scheduler);
|
||||
|
||||
return await scheduledImport.ConfigureAwait(false);
|
||||
}
|
||||
@ -318,7 +320,7 @@ namespace osu.Game.Stores
|
||||
/// <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="cancellationToken">An optional cancellation token.</param>
|
||||
public virtual Task<ILive<TModel>?> Import(TModel item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
public virtual Live<TModel>? Import(TModel item, ArchiveReader? archive = null, bool lowPriority = false, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Realm.Run(realm =>
|
||||
{
|
||||
@ -353,7 +355,7 @@ namespace osu.Game.Stores
|
||||
transaction.Commit();
|
||||
}
|
||||
|
||||
return Task.FromResult((ILive<TModel>?)existing.ToLive(Realm));
|
||||
return existing.ToLive(Realm);
|
||||
}
|
||||
|
||||
LogForModel(item, @"Found existing (optimised) but failed pre-check.");
|
||||
@ -388,7 +390,7 @@ namespace osu.Game.Stores
|
||||
existing.DeletePending = false;
|
||||
transaction.Commit();
|
||||
|
||||
return Task.FromResult((ILive<TModel>?)existing.ToLive(Realm));
|
||||
return existing.ToLive(Realm);
|
||||
}
|
||||
|
||||
LogForModel(item, @"Found existing but failed re-use check.");
|
||||
@ -414,7 +416,7 @@ namespace osu.Game.Stores
|
||||
throw;
|
||||
}
|
||||
|
||||
return Task.FromResult((ILive<TModel>?)item.ToLive(Realm));
|
||||
return (Live<TModel>?)item.ToLive(Realm);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -43,28 +43,16 @@ namespace osu.Game.Tests.Visual
|
||||
};
|
||||
|
||||
private TestBeatmapManager testBeatmapManager;
|
||||
private WorkingBeatmap working;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(GameHost host, AudioManager audio, RulesetStore rulesets)
|
||||
{
|
||||
Add(logo);
|
||||
|
||||
working = CreateWorkingBeatmap(Ruleset.Value);
|
||||
|
||||
if (IsolateSavingFromDatabase)
|
||||
Dependencies.CacheAs<BeatmapManager>(testBeatmapManager = new TestBeatmapManager(LocalStorage, Realm, rulesets, null, audio, Resources, host, Beatmap.Default));
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
Beatmap.Value = working;
|
||||
if (testBeatmapManager != null)
|
||||
testBeatmapManager.TestBeatmap = working;
|
||||
}
|
||||
|
||||
protected virtual bool EditorComponentsReady => Editor.ChildrenOfType<HitObjectComposer>().FirstOrDefault()?.IsLoaded == true
|
||||
&& Editor.ChildrenOfType<TimelineArea>().FirstOrDefault()?.IsLoaded == true;
|
||||
|
||||
@ -78,6 +66,11 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected virtual void LoadEditor()
|
||||
{
|
||||
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
|
||||
|
||||
if (testBeatmapManager != null)
|
||||
testBeatmapManager.TestBeatmap = Beatmap.Value;
|
||||
|
||||
LoadScreen(editorLoader = new TestEditorLoader());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user