mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:13:21 +08:00
Merge branch 'master' into fix-beat-divisor-not-saving
This commit is contained in:
commit
5b82eaf112
@ -13,6 +13,7 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Tests.Beatmaps.IO;
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editing
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
@ -37,11 +38,8 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadEditor()
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||||
{
|
=> beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First());
|
||||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First());
|
|
||||||
base.LoadEditor();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestBasicSwitch()
|
public void TestBasicSwitch()
|
||||||
|
@ -13,6 +13,7 @@ using osu.Game.Rulesets;
|
|||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Setup;
|
using osu.Game.Screens.Edit.Setup;
|
||||||
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Tests.Resources;
|
using osu.Game.Tests.Resources;
|
||||||
using SharpCompress.Archives;
|
using SharpCompress.Archives;
|
||||||
using SharpCompress.Archives.Zip;
|
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());
|
AddStep("make new beatmap unique", () => EditorBeatmap.Metadata.Title = Guid.NewGuid().ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadEditor()
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null) => new DummyWorkingBeatmap(Audio, null);
|
||||||
{
|
|
||||||
Beatmap.Value = new DummyWorkingBeatmap(Audio, null);
|
|
||||||
base.LoadEditor();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCreateNewBeatmap()
|
public void TestCreateNewBeatmap()
|
||||||
|
@ -17,6 +17,7 @@ using osu.Game.Screens.Edit;
|
|||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
||||||
using osu.Game.Screens.Edit.GameplayTest;
|
using osu.Game.Screens.Edit.GameplayTest;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
|
using osu.Game.Storyboards;
|
||||||
using osu.Game.Tests.Beatmaps.IO;
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
@ -43,9 +44,11 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
base.SetUpSteps();
|
base.SetUpSteps();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storyboard storyboard = null)
|
||||||
|
=> beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First(b => b.RulesetID == 0));
|
||||||
|
|
||||||
protected override void LoadEditor()
|
protected override void LoadEditor()
|
||||||
{
|
{
|
||||||
Beatmap.Value = beatmaps.GetWorkingBeatmap(importedBeatmapSet.Beatmaps.First(b => b.RulesetID == 0));
|
|
||||||
SelectedMods.Value = new[] { new ModCinema() };
|
SelectedMods.Value = new[] { new ModCinema() };
|
||||||
base.LoadEditor();
|
base.LoadEditor();
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
|
using Realms;
|
||||||
|
|
||||||
namespace osu.Game.Input.Bindings
|
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.");
|
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()
|
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,
|
// 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.
|
// but this is safest in case the subscription is restored after a context recycle.
|
||||||
ReloadMappings();
|
reloadMappings(sender.AsQueryable());
|
||||||
});
|
});
|
||||||
|
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void ReloadMappings() => reloadMappings(queryRealmKeyBindings(realm.Realm));
|
||||||
{
|
|
||||||
base.Dispose(isDisposing);
|
|
||||||
|
|
||||||
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();
|
var defaults = DefaultKeyBindings.ToList();
|
||||||
|
|
||||||
List<RealmKeyBinding> newBindings = queryRealmKeyBindings().Detach()
|
List<RealmKeyBinding> newBindings = realmKeyBindings.Detach()
|
||||||
// this ordering is important to ensure that we read entries from the database in the order
|
// 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
|
// enforced by DefaultKeyBindings. allow for song select to handle actions that may otherwise
|
||||||
// have been eaten by the music controller due to query order.
|
// have been eaten by the music controller due to query order.
|
||||||
.OrderBy(b => defaults.FindIndex(d => (int)d.Action == b.ActionInt)).ToList();
|
.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.
|
// 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.
|
// 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
|
else
|
||||||
KeyBindings = newBindings;
|
KeyBindings = newBindings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
realmSubscription?.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,28 +43,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
};
|
};
|
||||||
|
|
||||||
private TestBeatmapManager testBeatmapManager;
|
private TestBeatmapManager testBeatmapManager;
|
||||||
private WorkingBeatmap working;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(GameHost host, AudioManager audio, RulesetStore rulesets)
|
private void load(GameHost host, AudioManager audio, RulesetStore rulesets)
|
||||||
{
|
{
|
||||||
Add(logo);
|
Add(logo);
|
||||||
|
|
||||||
working = CreateWorkingBeatmap(Ruleset.Value);
|
|
||||||
|
|
||||||
if (IsolateSavingFromDatabase)
|
if (IsolateSavingFromDatabase)
|
||||||
Dependencies.CacheAs<BeatmapManager>(testBeatmapManager = new TestBeatmapManager(LocalStorage, Realm, rulesets, null, audio, Resources, host, Beatmap.Default));
|
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
|
protected virtual bool EditorComponentsReady => Editor.ChildrenOfType<HitObjectComposer>().FirstOrDefault()?.IsLoaded == true
|
||||||
&& Editor.ChildrenOfType<TimelineArea>().FirstOrDefault()?.IsLoaded == true;
|
&& Editor.ChildrenOfType<TimelineArea>().FirstOrDefault()?.IsLoaded == true;
|
||||||
|
|
||||||
@ -78,6 +66,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected virtual void LoadEditor()
|
protected virtual void LoadEditor()
|
||||||
{
|
{
|
||||||
|
Beatmap.Value = CreateWorkingBeatmap(Ruleset.Value);
|
||||||
|
|
||||||
|
if (testBeatmapManager != null)
|
||||||
|
testBeatmapManager.TestBeatmap = Beatmap.Value;
|
||||||
|
|
||||||
LoadScreen(editorLoader = new TestEditorLoader());
|
LoadScreen(editorLoader = new TestEditorLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user