mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 09:27:18 +09:00
Fix match beatmap not updating after re-download
This commit is contained in:
parent
3c85561cdc
commit
fac96f6ddd
@ -5,7 +5,9 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Audio;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Platform;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
@ -29,14 +31,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
[Cached(typeof(IRoomManager))]
|
[Cached(typeof(IRoomManager))]
|
||||||
private readonly TestRoomManager roomManager = new TestRoomManager();
|
private readonly TestRoomManager roomManager = new TestRoomManager();
|
||||||
|
|
||||||
[Resolved]
|
private BeatmapManager manager;
|
||||||
private BeatmapManager beatmaps { get; set; }
|
private RulesetStore rulesets;
|
||||||
|
|
||||||
[Resolved]
|
|
||||||
private RulesetStore rulesets { get; set; }
|
|
||||||
|
|
||||||
private TestMatchSubScreen match;
|
private TestMatchSubScreen match;
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(GameHost host, AudioManager audio)
|
||||||
|
{
|
||||||
|
Dependencies.Cache(rulesets = new RulesetStore(ContextFactory));
|
||||||
|
Dependencies.Cache(manager = new BeatmapManager(LocalStorage, ContextFactory, rulesets, null, audio, host, Beatmap.Default));
|
||||||
|
|
||||||
|
manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait();
|
||||||
|
}
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup() => Schedule(() =>
|
public void Setup() => Schedule(() =>
|
||||||
{
|
{
|
||||||
@ -75,10 +83,49 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddAssert("first playlist item selected", () => match.SelectedItem.Value == Room.Playlist[0]);
|
AddAssert("first playlist item selected", () => match.SelectedItem.Value == Room.Playlist[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestBeatmapUpdatedOnReImport()
|
||||||
|
{
|
||||||
|
BeatmapSetInfo importedSet = null;
|
||||||
|
|
||||||
|
AddStep("import altered beatmap", () =>
|
||||||
|
{
|
||||||
|
var beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
|
beatmap.BeatmapInfo.BaseDifficulty.CircleSize = 1;
|
||||||
|
|
||||||
|
importedSet = manager.Import(beatmap.BeatmapInfo.BeatmapSet).Result;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("load room", () =>
|
||||||
|
{
|
||||||
|
Room.Name.Value = "my awesome room";
|
||||||
|
Room.Host.Value = new User { Id = 2, Username = "peppy" };
|
||||||
|
Room.Playlist.Add(new PlaylistItem
|
||||||
|
{
|
||||||
|
Beatmap = { Value = importedSet.Beatmaps[0] },
|
||||||
|
Ruleset = { Value = new OsuRuleset().RulesetInfo }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("create room", () =>
|
||||||
|
{
|
||||||
|
InputManager.MoveMouseTo(match.ChildrenOfType<MatchSettingsOverlay.CreateRoomButton>().Single());
|
||||||
|
InputManager.Click(MouseButton.Left);
|
||||||
|
});
|
||||||
|
|
||||||
|
AddAssert("match has altered beatmap", () => match.Beatmap.Value.Beatmap.BeatmapInfo.BaseDifficulty.CircleSize == 1);
|
||||||
|
|
||||||
|
AddStep("re-import original beatmap", () => manager.Import(new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo.BeatmapSet).Wait());
|
||||||
|
|
||||||
|
AddAssert("match has original beatmap", () => match.Beatmap.Value.Beatmap.BeatmapInfo.BaseDifficulty.CircleSize != 1);
|
||||||
|
}
|
||||||
|
|
||||||
private class TestMatchSubScreen : MatchSubScreen
|
private class TestMatchSubScreen : MatchSubScreen
|
||||||
{
|
{
|
||||||
public new Bindable<PlaylistItem> SelectedItem => base.SelectedItem;
|
public new Bindable<PlaylistItem> SelectedItem => base.SelectedItem;
|
||||||
|
|
||||||
|
public new Bindable<WorkingBeatmap> Beatmap => base.Beatmap;
|
||||||
|
|
||||||
public TestMatchSubScreen(Room room)
|
public TestMatchSubScreen(Room room)
|
||||||
: base(room)
|
: base(room)
|
||||||
{
|
{
|
||||||
|
@ -433,7 +433,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CreateRoomButton : TriangleButton
|
public class CreateRoomButton : TriangleButton
|
||||||
{
|
{
|
||||||
public CreateRoomButton()
|
public CreateRoomButton()
|
||||||
{
|
{
|
||||||
|
@ -207,6 +207,8 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
Ruleset.Value = item.Ruleset.Value;
|
Ruleset.Value = item.Ruleset.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> weakSet) => Schedule(updateWorkingBeatmap);
|
||||||
|
|
||||||
private void updateWorkingBeatmap()
|
private void updateWorkingBeatmap()
|
||||||
{
|
{
|
||||||
var beatmap = SelectedItem.Value?.Beatmap.Value;
|
var beatmap = SelectedItem.Value?.Beatmap.Value;
|
||||||
@ -217,17 +219,6 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
Beatmap.Value = beatmapManager.GetWorkingBeatmap(localBeatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void beatmapUpdated(ValueChangedEvent<WeakReference<BeatmapSetInfo>> weakSet)
|
|
||||||
{
|
|
||||||
Schedule(() =>
|
|
||||||
{
|
|
||||||
if (Beatmap.Value != beatmapManager.DefaultBeatmap)
|
|
||||||
return;
|
|
||||||
|
|
||||||
updateWorkingBeatmap();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onStart()
|
private void onStart()
|
||||||
{
|
{
|
||||||
switch (type.Value)
|
switch (type.Value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user