Merge https://github.com/ppy/osu into multiplayer-room-settings

This commit is contained in:
DrabWeb
2018-06-08 01:16:22 -03:00
112 changed files with 893 additions and 1448 deletions

View File

@ -3,7 +3,6 @@
using System.ComponentModel;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play;
@ -13,12 +12,11 @@ namespace osu.Game.Tests.Visual
[Description("Player instantiated with an autoplay mod.")]
public class TestCaseAutoplay : TestCasePlayer
{
protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset)
protected override Player CreatePlayer(Ruleset ruleset)
{
beatmap.Mods.Value = beatmap.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
return new ScoreAccessiblePlayer
{
InitialBeatmap = beatmap,
AllowPause = false,
AllowLeadIn = false,
AllowResults = false,

View File

@ -6,7 +6,6 @@ using System.Linq;
using NUnit.Framework;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps;
@ -29,14 +28,11 @@ namespace osu.Game.Tests.Visual
private RulesetStore rulesets;
private TestBeatmapInfoWedge infoWedge;
private readonly List<IBeatmap> beatmaps = new List<IBeatmap>();
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
[BackgroundDependencyLoader]
private void load(OsuGameBase game, RulesetStore rulesets)
private void load(RulesetStore rulesets)
{
this.rulesets = rulesets;
beatmap.BindTo(game.Beatmap);
}
protected override void LoadComplete()
@ -53,11 +49,11 @@ namespace osu.Game.Tests.Visual
AddStep("show", () =>
{
infoWedge.State = Visibility.Visible;
infoWedge.Beatmap = beatmap;
infoWedge.Beatmap = Beatmap;
});
// select part is redundant, but wait for load isn't
selectBeatmap(beatmap.Value.Beatmap);
selectBeatmap(Beatmap.Value.Beatmap);
AddWaitStep(3);
@ -120,8 +116,8 @@ namespace osu.Game.Tests.Visual
{
selectNullBeatmap();
AddAssert("check empty version", () => string.IsNullOrEmpty(infoWedge.Info.VersionLabel.Text));
AddAssert("check default title", () => infoWedge.Info.TitleLabel.Text == beatmap.Default.BeatmapInfo.Metadata.Title);
AddAssert("check default artist", () => infoWedge.Info.ArtistLabel.Text == beatmap.Default.BeatmapInfo.Metadata.Artist);
AddAssert("check default title", () => infoWedge.Info.TitleLabel.Text == Beatmap.Default.BeatmapInfo.Metadata.Title);
AddAssert("check default artist", () => infoWedge.Info.ArtistLabel.Text == Beatmap.Default.BeatmapInfo.Metadata.Artist);
AddAssert("check empty author", () => !infoWedge.Info.MapperContainer.Children.Any());
AddAssert("check no infolabels", () => !infoWedge.Info.InfoLabelContainer.Children.Any());
}
@ -133,7 +129,7 @@ namespace osu.Game.Tests.Visual
AddStep($"select {b.Metadata.Title} beatmap", () =>
{
infoBefore = infoWedge.Info;
infoWedge.Beatmap = beatmap.Value = new TestWorkingBeatmap(b);
infoWedge.Beatmap = Beatmap.Value = new TestWorkingBeatmap(b);
});
AddUntilStep(() => infoWedge.Info != infoBefore, "wait for async load");
@ -143,8 +139,8 @@ namespace osu.Game.Tests.Visual
{
AddStep("select null beatmap", () =>
{
beatmap.Value = beatmap.Default;
infoWedge.Beatmap = beatmap;
Beatmap.Value = Beatmap.Default;
infoWedge.Beatmap = Beatmap;
});
}

View File

@ -35,9 +35,6 @@ namespace osu.Game.Tests.Visual
typeof(MessageFormatter)
};
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
public TestCaseChatLink()
{
Add(textContainer = new TestChatLineContainer
@ -53,7 +50,7 @@ namespace osu.Game.Tests.Visual
private void load(OsuColour colours)
{
linkColour = colours.Blue;
dependencies.Cache(new ChatOverlay
Dependencies.Cache(new ChatOverlay
{
AvailableChannels =
{

View File

@ -17,14 +17,10 @@ namespace osu.Game.Tests.Visual
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Compose) };
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame)
private void load()
{
osuGame.Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo);
var compose = new Compose();
compose.Beatmap.BindTo(osuGame.Beatmap);
Child = compose;
Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo);
Child = new Compose();
}
}
}

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using NUnit.Framework;
using OpenTK;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Overlays;
@ -18,8 +17,6 @@ namespace osu.Game.Tests.Visual
{
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(ScrollableTimeline), typeof(ScrollingTimelineContainer), typeof(BeatmapWaveformGraph), typeof(TimelineButton) };
private readonly ScrollableTimeline timeline;
public TestCaseEditorComposeTimeline()
{
Children = new Drawable[]
@ -30,7 +27,7 @@ namespace osu.Game.Tests.Visual
Origin = Anchor.TopCentre,
State = Visibility.Visible
},
timeline = new ScrollableTimeline
new ScrollableTimeline
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
@ -38,11 +35,5 @@ namespace osu.Game.Tests.Visual
}
};
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame)
{
timeline.Beatmap.BindTo(osuGame.Beatmap);
}
}
}

View File

@ -30,7 +30,7 @@ namespace osu.Game.Tests.Visual
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame)
private void load()
{
var testBeatmap = new Beatmap
{
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual
}
};
osuGame.Beatmap.Value = new TestWorkingBeatmap(testBeatmap);
Beatmap.Value = new TestWorkingBeatmap(testBeatmap);
Child = new TimingPointVisualiser(testBeatmap, 5000) { Clock = Clock };

View File

@ -19,19 +19,16 @@ namespace osu.Game.Tests.Visual
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(SummaryTimeline) };
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame)
private void load()
{
osuGame.Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo);
Beatmap.Value = new TestWorkingBeatmap(new OsuRuleset().RulesetInfo);
SummaryTimeline summaryTimeline;
Add(summaryTimeline = new SummaryTimeline
Add(new SummaryTimeline
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Size = new Vector2(500, 50)
});
summaryTimeline.Beatmap.BindTo(osuGame.Beatmap);
}
}
}

View File

@ -32,15 +32,10 @@ namespace osu.Game.Tests.Visual
typeof(NotNullAttribute)
};
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(parent);
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame)
private void load()
{
osuGame.Beatmap.Value = new TestWorkingBeatmap(new Beatmap
Beatmap.Value = new TestWorkingBeatmap(new Beatmap
{
HitObjects = new List<HitObject>
{
@ -63,8 +58,8 @@ namespace osu.Game.Tests.Visual
});
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
dependencies.CacheAs<IAdjustableClock>(clock);
dependencies.CacheAs<IFrameBasedClock>(clock);
Dependencies.CacheAs<IAdjustableClock>(clock);
Dependencies.CacheAs<IFrameBasedClock>(clock);
Child = new OsuHitObjectComposer(new OsuRuleset());
}

View File

@ -2,12 +2,9 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual
@ -15,8 +12,6 @@ namespace osu.Game.Tests.Visual
[TestFixture]
public class TestCaseMusicController : OsuTestCase
{
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
public TestCaseMusicController()
{
Clock = new FramedClock();
@ -30,13 +25,7 @@ namespace osu.Game.Tests.Visual
AddToggleStep(@"toggle visibility", state => mc.State = state ? Visibility.Visible : Visibility.Hidden);
AddStep(@"show", () => mc.State = Visibility.Visible);
AddToggleStep(@"toggle beatmap lock", state => beatmapBacking.Disabled = state);
}
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
{
beatmapBacking.BindTo(game.Beatmap);
AddToggleStep(@"toggle beatmap lock", state => Beatmap.Disabled = state);
}
}
}

View File

@ -27,7 +27,6 @@ namespace osu.Game.Tests.Visual
private RulesetStore rulesets;
private DependencyContainer dependencies;
private WorkingBeatmap defaultBeatmap;
public override IReadOnlyList<Type> RequiredTypes => new[]
@ -48,8 +47,6 @@ namespace osu.Game.Tests.Visual
typeof(DrawableCarouselBeatmapSet),
};
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
private class TestSongSelect : PlaySongSelect
{
public WorkingBeatmap CurrentBeatmap => Beatmap.Value;
@ -58,7 +55,7 @@ namespace osu.Game.Tests.Visual
}
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
private void load()
{
TestSongSelect songSelect = null;
@ -67,10 +64,10 @@ namespace osu.Game.Tests.Visual
// this is by no means clean. should be replacing inside of OsuGameBase somehow.
IDatabaseContextFactory factory = new SingletonContextFactory(new OsuDbContext());
dependencies.Cache(rulesets = new RulesetStore(factory));
dependencies.Cache(manager = new BeatmapManager(storage, factory, rulesets, null, null)
Dependencies.Cache(rulesets = new RulesetStore(factory));
Dependencies.Cache(manager = new BeatmapManager(storage, factory, rulesets, null, null)
{
DefaultBeatmap = defaultBeatmap = game.Beatmap.Default
DefaultBeatmap = defaultBeatmap = Beatmap.Default
});
void loadNewSongSelect(bool deleteMaps = false) => AddStep("reload song select", () =>
@ -78,7 +75,7 @@ namespace osu.Game.Tests.Visual
if (deleteMaps)
{
manager.Delete(manager.GetAllUsableBeatmapSets());
game.Beatmap.SetDefault();
Beatmap.SetDefault();
}
if (songSelect != null)

View File

@ -15,17 +15,12 @@ namespace osu.Game.Tests.Visual
[TestFixture]
public class TestCasePlaybackControl : OsuTestCase
{
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
=> dependencies = new DependencyContainer(parent);
[BackgroundDependencyLoader]
private void load()
{
var clock = new DecoupleableInterpolatingFramedClock { IsCoupled = false };
dependencies.CacheAs<IAdjustableClock>(clock);
dependencies.CacheAs<IFrameBasedClock>(clock);
Dependencies.CacheAs<IAdjustableClock>(clock);
Dependencies.CacheAs<IFrameBasedClock>(clock);
var playback = new PlaybackControl
{
@ -34,7 +29,7 @@ namespace osu.Game.Tests.Visual
Size = new Vector2(200,100)
};
playback.Beatmap.Value = new TestWorkingBeatmap(new Beatmap());
Beatmap.Value = new TestWorkingBeatmap(new Beatmap());
Child = playback;
}

View File

@ -12,9 +12,10 @@ namespace osu.Game.Tests.Visual
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
{
Beatmap.Value = new DummyWorkingBeatmap(game);
AddStep("load dummy beatmap", () => Add(new PlayerLoader(new Player
{
InitialBeatmap = new DummyWorkingBeatmap(game),
AllowPause = false,
AllowLeadIn = false,
AllowResults = false,

View File

@ -3,7 +3,6 @@
using System.ComponentModel;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Screens.Play;
@ -13,23 +12,20 @@ namespace osu.Game.Tests.Visual
[Description("Player instantiated with a replay.")]
public class TestCaseReplay : TestCasePlayer
{
protected override Player CreatePlayer(WorkingBeatmap beatmap, Ruleset ruleset)
protected override Player CreatePlayer(Ruleset ruleset)
{
// We create a dummy RulesetContainer just to get the replay - we don't want to use mods here
// to simulate setting a replay rather than having the replay already set for us
beatmap.Mods.Value = beatmap.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
var dummyRulesetContainer = ruleset.CreateRulesetContainerWith(beatmap);
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Concat(new[] { ruleset.GetAutoplayMod() });
var dummyRulesetContainer = ruleset.CreateRulesetContainerWith(Beatmap.Value);
// We have the replay
var replay = dummyRulesetContainer.Replay;
// Reset the mods
beatmap.Mods.Value = beatmap.Mods.Value.Where(m => !(m is ModAutoplay));
Beatmap.Value.Mods.Value = Beatmap.Value.Mods.Value.Where(m => !(m is ModAutoplay));
return new ReplayPlayer(replay)
{
InitialBeatmap = beatmap
};
return new ReplayPlayer(replay);
}
}
}

View File

@ -32,18 +32,13 @@ namespace osu.Game.Tests.Visual
this.beatmaps = beatmaps;
}
private WorkingBeatmap beatmap;
protected override void LoadComplete()
{
base.LoadComplete();
if (beatmap == null)
{
var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0);
if (beatmapInfo != null)
beatmap = beatmaps.GetWorkingBeatmap(beatmapInfo);
}
var beatmapInfo = beatmaps.QueryBeatmap(b => b.RulesetID == 0);
if (beatmapInfo != null)
Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmapInfo);
Add(new Results(new Score
{
@ -63,10 +58,7 @@ namespace osu.Game.Tests.Visual
{
Username = "peppy",
}
})
{
InitialBeatmap = beatmap
});
}));
}
}
}

View File

@ -14,10 +14,6 @@ namespace osu.Game.Tests.Visual
private readonly SettingsOverlay settings;
private readonly DialogOverlay dialogOverlay;
private DependencyContainer dependencies;
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent) => dependencies = new DependencyContainer(parent);
public TestCaseSettings()
{
settings = new MainSettings
@ -33,7 +29,7 @@ namespace osu.Game.Tests.Visual
[BackgroundDependencyLoader]
private void load()
{
dependencies.Cache(dialogOverlay);
Dependencies.Cache(dialogOverlay);
Add(settings);
}

View File

@ -3,7 +3,6 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -18,8 +17,6 @@ namespace osu.Game.Tests.Visual
[TestFixture]
public class TestCaseStoryboard : OsuTestCase
{
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
private readonly Container<DrawableStoryboard> storyboardContainer;
private DrawableStoryboard storyboard;
@ -43,6 +40,7 @@ namespace osu.Game.Tests.Visual
},
},
});
Add(new MusicController
{
Origin = Anchor.TopRight,
@ -55,10 +53,9 @@ namespace osu.Game.Tests.Visual
}
[BackgroundDependencyLoader]
private void load(OsuGameBase game)
private void load()
{
beatmapBacking.BindTo(game.Beatmap);
beatmapBacking.ValueChanged += beatmapChanged;
Beatmap.ValueChanged += beatmapChanged;
}
private void beatmapChanged(WorkingBeatmap working)
@ -66,10 +63,10 @@ namespace osu.Game.Tests.Visual
private void restart()
{
var track = beatmapBacking.Value.Track;
var track = Beatmap.Value.Track;
track.Reset();
loadStoryboard(beatmapBacking.Value);
loadStoryboard(Beatmap);
track.Start();
}
@ -81,7 +78,7 @@ namespace osu.Game.Tests.Visual
var decoupledClock = new DecoupleableInterpolatingFramedClock { IsCoupled = true };
storyboardContainer.Clock = decoupledClock;
storyboard = working.Storyboard.CreateDrawable(beatmapBacking);
storyboard = working.Storyboard.CreateDrawable(Beatmap);
storyboard.Passing = false;
storyboardContainer.Add(storyboard);

View File

@ -5,11 +5,9 @@ using NUnit.Framework;
using OpenTK;
using OpenTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Configuration;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osu.Game.Screens.Edit.Screens.Compose.Timeline;
@ -19,9 +17,8 @@ namespace osu.Game.Tests.Visual
[TestFixture]
public class TestCaseWaveform : OsuTestCase
{
private readonly Bindable<WorkingBeatmap> beatmapBacking = new Bindable<WorkingBeatmap>();
public TestCaseWaveform()
[BackgroundDependencyLoader]
private void load()
{
FillFlowContainer flow;
Child = flow = new FillFlowContainer
@ -46,10 +43,11 @@ namespace osu.Game.Tests.Visual
var newDisplay = new BeatmapWaveformGraph
{
RelativeSizeAxes = Axes.Both,
Resolution = 1f / i
Resolution = 1f / i,
Beatmap = Beatmap
};
newDisplay.Beatmap.BindTo(beatmapBacking);
Beatmap.ValueChanged += b => newDisplay.Beatmap = b;
flow.Add(new Container
{
@ -83,8 +81,5 @@ namespace osu.Game.Tests.Visual
});
}
}
[BackgroundDependencyLoader]
private void load(OsuGameBase osuGame) => beatmapBacking.BindTo(osuGame.Beatmap);
}
}