diff --git a/.vscode/tasks.json b/.vscode/tasks.json index f285ebde67..b0fd5fbb0d 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -9,15 +9,9 @@ "showOutput": "silent", "args": [ "/property:GenerateFullPaths=true", - "/property:DebugType=portable" + "/property:DebugType=portable", + "/m" //parallel compiling support. ], - "windows": { - "args": [ - "/property:GenerateFullPaths=true", - "/property:DebugType=portable", - "/m" //parallel compiling support. doesn't work well with mono atm - ] - }, "tasks": [ { "taskName": "Build (Debug)", diff --git a/osu-framework b/osu-framework index 3dd751659b..991177da4f 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 3dd751659b5f8e3267146db1557ec43d77456b8e +Subproject commit 991177da4fbed2dd8260c215f2d341ebc858b03e diff --git a/osu-resources b/osu-resources index 10fda22522..76656c51f2 160000 --- a/osu-resources +++ b/osu-resources @@ -1 +1 @@ -Subproject commit 10fda22522ffadbdbc43fa0f3683a065e536f7d1 +Subproject commit 76656c51f281e7934159e9ed4414378fef24d130 diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatSyncedContainer.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatSyncedContainer.cs new file mode 100644 index 0000000000..909ee9b134 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatSyncedContainer.cs @@ -0,0 +1,206 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Framework.Graphics; +using osu.Framework.Timing; +using osu.Game.Overlays; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.Containers; +using osu.Framework.Audio.Track; +using osu.Game.Beatmaps.ControlPoints; +using osu.Framework.Graphics.Shapes; +using OpenTK.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Framework.Lists; +using System; +using osu.Framework.Extensions.Color4Extensions; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseBeatSyncedContainer : TestCase + { + public override string Description => @"Tests beat synced containers."; + + private readonly MusicController mc; + + public TestCaseBeatSyncedContainer() + { + Clock = new FramedClock(); + Clock.ProcessFrame(); + + Add(new BeatContainer + { + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + }); + + Add(mc = new MusicController + { + Origin = Anchor.TopRight, + Anchor = Anchor.TopRight, + }); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + mc.ToggleVisibility(); + } + + private class BeatContainer : BeatSyncedContainer + { + private const int flash_layer_heigth = 150; + + private readonly InfoString timingPointCount; + private readonly InfoString currentTimingPoint; + private readonly InfoString beatCount; + private readonly InfoString currentBeat; + private readonly InfoString beatsPerMinute; + private readonly InfoString adjustedBeatLength; + private readonly InfoString timeUntilNextBeat; + private readonly InfoString timeSinceLastBeat; + + private readonly Box flashLayer; + + public BeatContainer() + { + RelativeSizeAxes = Axes.X; + AutoSizeAxes = Axes.Y; + Children = new Drawable[] + { + new Container + { + Name = @"Info Layer", + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.Both, + Margin = new MarginPadding { Bottom = flash_layer_heigth }, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black.Opacity(150), + }, + new FillFlowContainer + { + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + timingPointCount = new InfoString(@"Timing points amount"), + currentTimingPoint = new InfoString(@"Current timing point"), + beatCount = new InfoString(@"Beats amount (in the current timing point)"), + currentBeat = new InfoString(@"Current beat"), + beatsPerMinute = new InfoString(@"BPM"), + adjustedBeatLength = new InfoString(@"Adjusted beat length"), + timeUntilNextBeat = new InfoString(@"Time until next beat"), + timeSinceLastBeat = new InfoString(@"Time since last beat"), + } + } + } + }, + new Container + { + Name = @"Color indicator", + Anchor = Anchor.BottomCentre, + Origin = Anchor.BottomCentre, + RelativeSizeAxes = Axes.X, + Height = flash_layer_heigth, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + }, + flashLayer = new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.White, + Alpha = 0, + } + } + } + }; + + Beatmap.ValueChanged += delegate + { + timingPointCount.Value = 0; + currentTimingPoint.Value = 0; + beatCount.Value = 0; + currentBeat.Value = 0; + beatsPerMinute.Value = 0; + adjustedBeatLength.Value = 0; + timeUntilNextBeat.Value = 0; + timeSinceLastBeat.Value = 0; + }; + } + + private SortedList timingPoints => Beatmap.Value.Beatmap.ControlPointInfo.TimingPoints; + private TimingControlPoint getNextTimingPoint(TimingControlPoint current) + { + if (timingPoints[timingPoints.Count - 1] == current) + return current; + + return timingPoints[timingPoints.IndexOf(current) + 1]; + } + + private int calculateBeatCount(TimingControlPoint current) + { + if (timingPoints[timingPoints.Count - 1] == current) + return (int)Math.Ceiling((Beatmap.Value.Track.Length - current.Time) / current.BeatLength); + + return (int)Math.Ceiling((getNextTimingPoint(current).Time - current.Time) / current.BeatLength); + } + + protected override void Update() + { + base.Update(); + timeUntilNextBeat.Value = TimeUntilNextBeat; + timeSinceLastBeat.Value = TimeSinceLastBeat; + } + + protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, TrackAmplitudes amplitudes) + { + base.OnNewBeat(beatIndex, timingPoint, effectPoint, amplitudes); + + timingPointCount.Value = timingPoints.Count; + currentTimingPoint.Value = timingPoints.IndexOf(timingPoint); + beatCount.Value = calculateBeatCount(timingPoint); + currentBeat.Value = beatIndex; + beatsPerMinute.Value = 60000 / timingPoint.BeatLength; + adjustedBeatLength.Value = timingPoint.BeatLength; + + flashLayer.ClearTransforms(); + flashLayer.FadeTo(1); + flashLayer.FadeTo(0, timingPoint.BeatLength); + } + } + + private class InfoString : FillFlowContainer + { + private const int text_size = 20; + private const int margin = 7; + + private readonly OsuSpriteText valueText; + + public double Value + { + set { valueText.Text = $"{value:G}"; } + } + + public InfoString(string header) + { + AutoSizeAxes = Axes.Both; + Direction = FillDirection.Horizontal; + Add(new OsuSpriteText { Text = header + @": ", TextSize = text_size }); + Add(valueText = new OsuSpriteText { TextSize = text_size }); + Margin = new MarginPadding(margin); + } + } + } +} diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs index e755924a15..e0a503bc76 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetailArea.cs @@ -12,10 +12,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Beatmap details in song select"; - public override void Reset() + public TestCaseBeatmapDetailArea() { - base.Reset(); - Add(new BeatmapDetailArea { Anchor = Anchor.Centre, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index df80ffdf53..9335938265 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -13,12 +13,10 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => "BeatmapDetails tab of BeatmapDetailArea"; - private BeatmapDetails details; + private readonly BeatmapDetails details; - public override void Reset() + public TestCaseBeatmapDetails() { - base.Reset(); - Add(details = new BeatmapDetails { RelativeSizeAxes = Axes.Both, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapOptionsOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapOptionsOverlay.cs index 7c211227c6..c9c1740856 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapOptionsOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapOptionsOverlay.cs @@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Beatmap options in song select"; - public override void Reset() + public TestCaseBeatmapOptionsOverlay() { - base.Reset(); - var overlay = new BeatmapOptionsOverlay(); overlay.AddButton(@"Remove", @"from unplayed", FontAwesome.fa_times_circle_o, Color4.Purple, null, Key.Number1); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs index 658d2f92b1..f2dd454d65 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBreadcrumbs.cs @@ -11,10 +11,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"breadcrumb > control"; - public override void Reset() + public TestCaseBreadcrumbs() { - base.Reset(); - BreadcrumbControl c; Add(c = new BreadcrumbControl { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs index 2663c952cf..751b979bad 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseChatDisplay.cs @@ -11,10 +11,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Testing chat api and overlay"; - public override void Reset() + public TestCaseChatDisplay() { - base.Reset(); - Add(new ChatOverlay { State = Visibility.Visible diff --git a/osu.Desktop.VisualTests/Tests/TestCaseContextMenu.cs b/osu.Desktop.VisualTests/Tests/TestCaseContextMenu.cs index 00d4d33c86..f9dc424153 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseContextMenu.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseContextMenu.cs @@ -6,8 +6,7 @@ using OpenTK.Graphics; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Cursor; -using osu.Framework.Graphics.Sprites; -using osu.Framework.Graphics.Transforms; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing; using osu.Game.Graphics.UserInterface; @@ -21,12 +20,10 @@ namespace osu.Desktop.VisualTests.Tests private const int start_time = 0; private const int duration = 1000; - private MyContextMenuContainer container; + private readonly Container container; - public override void Reset() + public TestCaseContextMenu() { - base.Reset(); - Add(container = new MyContextMenuContainer { Size = new Vector2(200), @@ -56,43 +53,26 @@ namespace osu.Desktop.VisualTests.Tests } } }); + } - container.Transforms.Add(new TransformPosition + protected override void LoadComplete() + { + base.LoadComplete(); + + using (container.BeginLoopedSequence()) { - StartValue = Vector2.Zero, - EndValue = new Vector2(0, 100), - StartTime = start_time, - EndTime = start_time + duration, - LoopCount = -1, - LoopDelay = duration * 3 - }); - container.Transforms.Add(new TransformPosition - { - StartValue = new Vector2(0, 100), - EndValue = new Vector2(100, 100), - StartTime = start_time + duration, - EndTime = start_time + duration * 2, - LoopCount = -1, - LoopDelay = duration * 3 - }); - container.Transforms.Add(new TransformPosition - { - StartValue = new Vector2(100, 100), - EndValue = new Vector2(100, 0), - StartTime = start_time + duration * 2, - EndTime = start_time + duration * 3, - LoopCount = -1, - LoopDelay = duration * 3 - }); - container.Transforms.Add(new TransformPosition - { - StartValue = new Vector2(100, 0), - EndValue = Vector2.Zero, - StartTime = start_time + duration * 3, - EndTime = start_time + duration * 4, - LoopCount = -1, - LoopDelay = duration * 3 - }); + container.MoveTo(new Vector2(0, 100), duration); + using (container.BeginDelayedSequence(duration)) + { + container.MoveTo(new Vector2(100, 100), duration); + using (container.BeginDelayedSequence(duration)) + { + container.MoveTo(new Vector2(100, 0), duration); + using (container.BeginDelayedSequence(duration)) + container.MoveTo(Vector2.Zero, duration); + } + } + } } private class MyContextMenuContainer : Container, IHasContextMenu diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDialogOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseDialogOverlay.cs index 90e214c3c9..6924817827 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDialogOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDialogOverlay.cs @@ -12,11 +12,9 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Display dialogs"; - private DialogOverlay overlay; - - public override void Reset() + public TestCaseDialogOverlay() { - base.Reset(); + DialogOverlay overlay; Add(overlay = new DialogOverlay()); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs index 4cda14559f..2a20bca836 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDirect.cs @@ -16,9 +16,9 @@ namespace osu.Desktop.VisualTests.Tests private DirectOverlay direct; private RulesetDatabase rulesets; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); Add(direct = new DirectOverlay()); newBeatmaps(); @@ -48,6 +48,17 @@ namespace osu.Desktop.VisualTests.Tests Author = @"RLC", Source = @"", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Card = @"https://assets.ppy.sh/beatmaps/578332/covers/card.jpg?1494591390", + Cover = @"https://assets.ppy.sh/beatmaps/578332/covers/cover.jpg?1494591390", + }, + Preview = @"https://b.ppy.sh/preview/578332.mp3", + PlayCount = 97, + FavouriteCount = 72, + }, Beatmaps = new List { new BeatmapInfo @@ -55,13 +66,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 5.35f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/578332/covers/cover.jpg?1494591390" }, - Preview = @"https://b.ppy.sh/preview/578332.mp3", - PlayCount = 97, - FavouriteCount = 72, - }, }, }, }, @@ -74,6 +78,17 @@ namespace osu.Desktop.VisualTests.Tests Author = @"Sotarks", Source = @"ぎんぎつね", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Card = @"https://assets.ppy.sh/beatmaps/599627/covers/card.jpg?1494539318", + Cover = @"https://assets.ppy.sh/beatmaps/599627/covers/cover.jpg?1494539318", + }, + Preview = @"https//b.ppy.sh/preview/599627.mp3", + PlayCount = 3082, + FavouriteCount = 14, + }, Beatmaps = new List { new BeatmapInfo @@ -81,13 +96,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 5.81f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/599627/covers/cover.jpg?1494539318" }, - Preview = @"https//b.ppy.sh/preview/599627.mp3", - PlayCount = 3082, - FavouriteCount = 14, - }, }, }, }, @@ -100,6 +108,17 @@ namespace osu.Desktop.VisualTests.Tests Author = @"Cerulean Veyron", Source = @"", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Card = @"https://assets.ppy.sh/beatmaps/513268/covers/card.jpg?1494502863", + Cover = @"https://assets.ppy.sh/beatmaps/513268/covers/cover.jpg?1494502863", + }, + Preview = @"https//b.ppy.sh/preview/513268.mp3", + PlayCount = 2762, + FavouriteCount = 15, + }, Beatmaps = new List { new BeatmapInfo @@ -107,13 +126,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 0.9f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/513268/covers/cover.jpg?1494502863" }, - Preview = @"https//b.ppy.sh/preview/513268.mp3", - PlayCount = 2762, - FavouriteCount = 15, - }, }, new BeatmapInfo { @@ -141,6 +153,17 @@ namespace osu.Desktop.VisualTests.Tests Author = @"[Kamiya]", Source = @"小林さんちのメイドラゴン", }, + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Card = @"https://assets.ppy.sh/beatmaps/586841/covers/card.jpg?1494052741", + Cover = @"https://assets.ppy.sh/beatmaps/586841/covers/cover.jpg?1494052741", + }, + Preview = @"https//b.ppy.sh/preview/586841.mp3", + PlayCount = 62317, + FavouriteCount = 161, + }, Beatmaps = new List { new BeatmapInfo @@ -148,13 +171,6 @@ namespace osu.Desktop.VisualTests.Tests Ruleset = ruleset, StarDifficulty = 1.26f, Metadata = new BeatmapMetadata(), - OnlineInfo = new BeatmapOnlineInfo - { - Covers = new[] { @"https://assets.ppy.sh//beatmaps/586841/covers/cover.jpg?1494052741" }, - Preview = @"https//b.ppy.sh/preview/586841.mp3", - PlayCount = 62317, - FavouriteCount = 161, - }, }, new BeatmapInfo { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs index 0a401700cf..4f4ef9bbb5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawableRoom.cs @@ -8,6 +8,7 @@ using osu.Game.Screens.Multiplayer; using osu.Game.Online.Multiplayer; using osu.Game.Users; using osu.Game.Database; +using osu.Framework.Allocation; namespace osu.Desktop.VisualTests.Tests { @@ -15,60 +16,117 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Select your favourite room"; - public override void Reset() + private RulesetDatabase rulesets; + + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); DrawableRoom first; - DrawableRoom second; Add(new FillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Y, - Width = 500f, + Width = 580f, Direction = FillDirection.Vertical, Children = new Drawable[] { - first = new DrawableRoom(new Room()), - second = new DrawableRoom(new Room()), + first = new DrawableRoom(new Room + { + Name = { Value = @"Great Room Right Here" }, + Host = { Value = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" } } }, + Status = { Value = new RoomStatusOpen() }, + Type = { Value = new GameTypeTeamVersus() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 4.65, + Ruleset = rulesets.GetRuleset(3), + Metadata = new BeatmapMetadata + { + Title = @"Critical Crystal", + Artist = @"Seiryu", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh//beatmaps/376340/covers/cover.jpg?1456478455", + }, + }, + }, + }, + }, + Participants = + { + Value = new[] + { + new User { GlobalRank = 1355 }, + new User { GlobalRank = 8756 }, + }, + }, + }), + new DrawableRoom(new Room + { + Name = { Value = @"Relax It's The Weekend" }, + Host = { Value = new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" } } }, + Status = { Value = new RoomStatusPlaying() }, + Type = { Value = new GameTypeTagTeam() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 1.96, + Ruleset = rulesets.GetRuleset(0), + Metadata = new BeatmapMetadata + { + Title = @"Serendipity", + Artist = @"ZAQ", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh//beatmaps/526839/covers/cover.jpg?1493815706", + }, + }, + }, + }, + }, + Participants = + { + Value = new[] + { + new User { GlobalRank = 578975 }, + new User { GlobalRank = 24554 }, + }, + }, + }), } }); - first.Room.Name.Value = @"Great Room Right Here"; - first.Room.Host.Value = new User { Username = @"Naeferith", Id = 9492835, Country = new Country { FlagName = @"FR" } }; - first.Room.Status.Value = new RoomStatusOpen(); - first.Room.Beatmap.Value = new BeatmapMetadata { Title = @"Seiryu", Artist = @"Critical Crystal" }; - - second.Room.Name.Value = @"Relax It's The Weekend"; - second.Room.Host.Value = new User { Username = @"peppy", Id = 2, Country = new Country { FlagName = @"AU" } }; - second.Room.Status.Value = new RoomStatusPlaying(); - second.Room.Beatmap.Value = new BeatmapMetadata { Title = @"ZAQ", Artist = @"Serendipity" }; - - AddStep(@"change state", () => + AddStep(@"change title", () => first.Room.Name.Value = @"I Changed Name"); + AddStep(@"change host", () => first.Room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } }); + AddStep(@"change status", () => first.Room.Status.Value = new RoomStatusPlaying()); + AddStep(@"change type", () => first.Room.Type.Value = new GameTypeVersus()); + AddStep(@"change beatmap", () => first.Room.Beatmap.Value = null); + AddStep(@"change participants", () => first.Room.Participants.Value = new[] { - first.Room.Status.Value = new RoomStatusPlaying(); + new User { GlobalRank = 1254 }, + new User { GlobalRank = 123189 }, }); + } - AddStep(@"change name", () => - { - first.Room.Name.Value = @"I Changed Name"; - }); - - AddStep(@"change host", () => - { - first.Room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } }; - }); - - AddStep(@"change beatmap", () => - { - first.Room.Beatmap.Value = null; - }); - - AddStep(@"change state", () => - { - first.Room.Status.Value = new RoomStatusOpen(); - }); + [BackgroundDependencyLoader] + private void load(RulesetDatabase rulesets) + { + this.rulesets = rulesets; } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs index ebc9930f93..63ec06963c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseDrawings.cs @@ -12,10 +12,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => "Tournament drawings"; - public override void Reset() + public TestCaseDrawings() { - base.Reset(); - Add(new Drawings { TeamList = new TestTeamList(), diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs index e2cd2bf67b..0c5f21a185 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGamefield.cs @@ -34,9 +34,9 @@ namespace osu.Desktop.VisualTests.Tests this.rulesets = rulesets; } - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); List objects = new List(); @@ -76,7 +76,7 @@ namespace osu.Desktop.VisualTests.Tests ControlPointInfo = controlPointInfo }); - Add(new Drawable[] + AddRange(new Drawable[] { new Container { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs b/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs index f653e2b9b4..d969decaa5 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs @@ -13,11 +13,9 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => "graph"; - private BarGraph graph; - - public override void Reset() + public TestCaseGraph() { - base.Reset(); + BarGraph graph; Children = new[] { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs index 8c913ae95e..33841cae90 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs @@ -29,15 +29,58 @@ namespace osu.Desktop.VisualTests.Tests var rateAdjustClock = new StopwatchClock(true); framedClock = new FramedClock(rateAdjustClock); playbackSpeed.ValueChanged += delegate { rateAdjustClock.Rate = playbackSpeed.Value; }; + + playbackSpeed.TriggerChange(); + + AddStep(@"circles", () => loadHitobjects(HitObjectType.Circle)); + AddStep(@"slider", () => loadHitobjects(HitObjectType.Slider)); + AddStep(@"spinner", () => loadHitobjects(HitObjectType.Spinner)); + + AddToggleStep(@"auto", state => { auto = state; loadHitobjects(mode); }); + + BasicSliderBar sliderBar; + Add(new Container + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new SpriteText { Text = "Playback Speed" }, + sliderBar = new BasicSliderBar + { + Width = 150, + Height = 10, + SelectionColor = Color4.Orange, + } + } + }); + + sliderBar.Current.BindTo(playbackSpeed); + + framedClock.ProcessFrame(); + + var clockAdjustContainer = new Container + { + RelativeSizeAxes = Axes.Both, + Clock = framedClock, + Children = new[] + { + playfieldContainer = new Container { RelativeSizeAxes = Axes.Both }, + approachContainer = new Container { RelativeSizeAxes = Axes.Both } + } + }; + + Add(clockAdjustContainer); } private HitObjectType mode = HitObjectType.Slider; private readonly BindableNumber playbackSpeed = new BindableDouble(0.5) { MinValue = 0, MaxValue = 1 }; - private Container playfieldContainer; - private Container approachContainer; + private readonly Container playfieldContainer; + private readonly Container approachContainer; - private void load(HitObjectType mode) + private void loadHitobjects(HitObjectType mode) { this.mode = mode; @@ -83,54 +126,6 @@ namespace osu.Desktop.VisualTests.Tests } } - public override void Reset() - { - base.Reset(); - - playbackSpeed.TriggerChange(); - - AddStep(@"circles", () => load(HitObjectType.Circle)); - AddStep(@"slider", () => load(HitObjectType.Slider)); - AddStep(@"spinner", () => load(HitObjectType.Spinner)); - - AddToggleStep(@"auto", state => { auto = state; load(mode); }); - - BasicSliderBar sliderBar; - Add(new Container - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new SpriteText { Text = "Playback Speed" }, - sliderBar = new BasicSliderBar - { - Width = 150, - Height = 10, - SelectionColor = Color4.Orange, - } - } - }); - - sliderBar.Current.BindTo(playbackSpeed); - - framedClock.ProcessFrame(); - - var clockAdjustContainer = new Container - { - RelativeSizeAxes = Axes.Both, - Clock = framedClock, - Children = new[] - { - playfieldContainer = new Container { RelativeSizeAxes = Axes.Both }, - approachContainer = new Container { RelativeSizeAxes = Axes.Both } - } - }; - - Add(clockAdjustContainer); - } - private int depth; private void add(DrawableOsuHitObject h) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs index 000d59a365..87a40a76ca 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseKeyCounter.cs @@ -10,6 +10,7 @@ using osu.Framework.Graphics.Containers; using OpenTK; using OpenTK.Graphics; using osu.Framework.MathUtils; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Game.Screens.Play; @@ -19,10 +20,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests key counter"; - public override void Reset() + public TestCaseKeyCounter() { - base.Reset(); - KeyCounterCollection kc = new KeyCounterCollection { Origin = Anchor.Centre, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs b/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs index 39010baf91..12d01ecc79 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseLeaderboard.cs @@ -16,7 +16,7 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"From song select"; - private Leaderboard leaderboard; + private readonly Leaderboard leaderboard; private void newScores() { @@ -207,10 +207,8 @@ namespace osu.Desktop.VisualTests.Tests leaderboard.Scores = scores; } - public override void Reset() + public TestCaseLeaderboard() { - base.Reset(); - Add(leaderboard = new Leaderboard { Origin = Anchor.Centre, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs index c66b0b4db4..30346e90c9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaHitObjects.cs @@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests { internal class TestCaseManiaHitObjects : TestCase { - public override void Reset() + public TestCaseManiaHitObjects() { - base.Reset(); - Add(new FillFlowContainer { Anchor = Anchor.Centre, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index 352b6cdc81..adaae91815 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -25,10 +25,8 @@ namespace osu.Desktop.VisualTests.Tests protected override double TimePerAction => 200; - public override void Reset() + public TestCaseManiaPlayfield() { - base.Reset(); - Action createPlayfield = (cols, pos) => { Clear(); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs new file mode 100644 index 0000000000..1533f2141e --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseMedalOverlay.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Game.Overlays; +using osu.Game.Users; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseMedalOverlay : TestCase + { + public override string Description => @"medal get!"; + + public TestCaseMedalOverlay() + { + AddStep(@"display", () => + { + LoadComponentAsync(new MedalOverlay(new Medal + { + Name = @"Animations", + InternalName = @"all-intro-doubletime", + Description = @"More complex than you think.", + }), Add); + }); + } + } +} diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs b/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs index ddb62598cf..bab471ed6a 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMenuButtonSystem.cs @@ -3,9 +3,9 @@ using osu.Framework.Testing; using osu.Framework.Graphics.Colour; -using osu.Framework.Graphics.Sprites; using osu.Game.Screens.Menu; using OpenTK.Graphics; +using osu.Framework.Graphics.Shapes; namespace osu.Desktop.VisualTests.Tests { @@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Main menu button system"; - public override void Reset() + public TestCaseMenuButtonSystem() { - base.Reset(); - Add(new Box { ColourInfo = ColourInfo.GradientVertical(Color4.Gray, Color4.WhiteSmoke), diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs b/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs index 4de8b297eb..0187c0e629 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMenuOverlays.cs @@ -12,15 +12,12 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests pause and fail overlays"; - private PauseContainer.PauseOverlay pauseOverlay; - private FailOverlay failOverlay; - private int retryCount; - - public override void Reset() + public TestCaseMenuOverlays() { - base.Reset(); + FailOverlay failOverlay; + PauseContainer.PauseOverlay pauseOverlay; - retryCount = 0; + var retryCount = 0; Add(pauseOverlay = new PauseContainer.PauseOverlay { @@ -34,14 +31,16 @@ namespace osu.Desktop.VisualTests.Tests OnQuit = () => Logger.Log(@"Quit"), }); - AddStep(@"Pause", delegate { + AddStep(@"Pause", delegate + { if (failOverlay.State == Visibility.Visible) { failOverlay.Hide(); } pauseOverlay.Show(); }); - AddStep("Fail", delegate { + AddStep("Fail", delegate + { if (pauseOverlay.State == Visibility.Visible) { pauseOverlay.Hide(); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMods.cs b/osu.Desktop.VisualTests/Tests/TestCaseMods.cs index 3f3a9d82f5..e626a70e5f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMods.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMods.cs @@ -27,9 +27,9 @@ namespace osu.Desktop.VisualTests.Tests this.rulesets = rulesets; } - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); Add(modSelect = new ModSelectOverlay { diff --git a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs index 5665bf859a..cbb2775234 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseMusicController.cs @@ -13,18 +13,11 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests music controller ui."; - private MusicController mc; - public TestCaseMusicController() { Clock = new FramedClock(); - } - public override void Reset() - { - base.Reset(); - Clock.ProcessFrame(); - mc = new MusicController + var mc = new MusicController { Origin = Anchor.Centre, Anchor = Anchor.Centre diff --git a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs index 8972040b06..4ba50c8220 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseNotificationManager.cs @@ -16,12 +16,10 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"I handle notifications"; - private NotificationManager manager; + private readonly NotificationManager manager; - public override void Reset() + public TestCaseNotificationManager() { - base.Reset(); - progressingNotifications.Clear(); Content.Add(manager = new NotificationManager diff --git a/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs b/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs index 3cefb8a3d2..f2b4ed7918 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseOnScreenDisplay.cs @@ -15,9 +15,9 @@ namespace osu.Desktop.VisualTests.Tests public override string Description => @"Make it easier to see setting changes"; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); Add(new OnScreenDisplay()); diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs index 35eb6d0ff9..83a1436357 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlaySongSelect.cs @@ -13,20 +13,19 @@ namespace osu.Desktop.VisualTests.Tests { internal class TestCasePlaySongSelect : TestCase { - private BeatmapDatabase db; - private TestStorage storage; - private PlaySongSelect songSelect; + private readonly BeatmapDatabase db; public override string Description => @"with fake data"; - private RulesetDatabase rulesets; + private readonly RulesetDatabase rulesets; - public override void Reset() + public TestCasePlaySongSelect() { - base.Reset(); + PlaySongSelect songSelect; + if (db == null) { - storage = new TestStorage(@"TestCasePlaySongSelect"); + var storage = new TestStorage(@"TestCasePlaySongSelect"); var backingDatabase = storage.GetDatabase(@"client"); diff --git a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs index f28cdd6a7e..954d24fcc1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs +++ b/osu.Desktop.VisualTests/Tests/TestCasePlayer.cs @@ -2,12 +2,10 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; -using System.Linq; using osu.Framework.Allocation; using osu.Framework.Testing; using osu.Game.Beatmaps; using OpenTK; -using osu.Framework.Graphics.Sprites; using osu.Game.Database; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Osu.Objects; @@ -15,71 +13,61 @@ using osu.Game.Screens.Play; using OpenTK.Graphics; using osu.Desktop.VisualTests.Beatmaps; using osu.Game.Rulesets.Osu.UI; +using osu.Framework.Graphics.Shapes; namespace osu.Desktop.VisualTests.Tests { internal class TestCasePlayer : TestCase { protected Player Player; - private BeatmapDatabase db; private RulesetDatabase rulesets; public override string Description => @"Showing everything to play the game."; [BackgroundDependencyLoader] - private void load(BeatmapDatabase db, RulesetDatabase rulesets) + private void load(RulesetDatabase rulesets) { this.rulesets = rulesets; - this.db = db; } - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); - WorkingBeatmap beatmap = null; + var objects = new List(); - var beatmapInfo = db.Query().FirstOrDefault(b => b.RulesetID == 0); - if (beatmapInfo != null) - beatmap = db.GetWorkingBeatmap(beatmapInfo); - - if (beatmap?.Track == null) + int time = 1500; + for (int i = 0; i < 50; i++) { - var objects = new List(); - - int time = 1500; - for (int i = 0; i < 50; i++) + objects.Add(new HitCircle { - objects.Add(new HitCircle - { - StartTime = time, - Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : OsuPlayfield.BASE_SIZE.X, - i % 4 < 2 ? 0 : OsuPlayfield.BASE_SIZE.Y), - NewCombo = i % 4 == 0 - }); + StartTime = time, + Position = new Vector2(i % 4 == 0 || i % 4 == 2 ? 0 : OsuPlayfield.BASE_SIZE.X, + i % 4 < 2 ? 0 : OsuPlayfield.BASE_SIZE.Y), + NewCombo = i % 4 == 0 + }); - time += 500; - } - - Beatmap b = new Beatmap - { - HitObjects = objects, - BeatmapInfo = new BeatmapInfo - { - Difficulty = new BeatmapDifficulty(), - Ruleset = rulesets.Query().First(), - Metadata = new BeatmapMetadata - { - Artist = @"Unknown", - Title = @"Sample Beatmap", - Author = @"peppy", - } - } - }; - - beatmap = new TestWorkingBeatmap(b); + time += 500; } + Beatmap b = new Beatmap + { + HitObjects = objects, + BeatmapInfo = new BeatmapInfo + { + Difficulty = new BeatmapDifficulty(), + Ruleset = rulesets.Query().First(), + Metadata = new BeatmapMetadata + { + Artist = @"Unknown", + Title = @"Sample Beatmap", + Author = @"peppy", + } + } + }; + + WorkingBeatmap beatmap = new TestWorkingBeatmap(b); + Add(new Box { RelativeSizeAxes = Framework.Graphics.Axes.Both, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs b/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs index b2c211b7f0..00a9774067 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseReplaySettingsOverlay.cs @@ -13,13 +13,11 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Settings visible in replay/auto"; - private ExampleContainer container; - - public override void Reset() + public TestCaseReplaySettingsOverlay() { - base.Reset(); + ExampleContainer container; - Add(new ReplaySettingsOverlay() + Add(new ReplaySettingsOverlay { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseResults.cs b/osu.Desktop.VisualTests/Tests/TestCaseResults.cs index f8c93e9a73..775bfe0f03 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseResults.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseResults.cs @@ -28,9 +28,9 @@ namespace osu.Desktop.VisualTests.Tests private WorkingBeatmap beatmap; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); if (beatmap == null) { @@ -39,8 +39,6 @@ namespace osu.Desktop.VisualTests.Tests beatmap = db.GetWorkingBeatmap(beatmapInfo); } - base.Reset(); - Add(new Results(new Score { TotalScore = 2845370, @@ -48,7 +46,7 @@ namespace osu.Desktop.VisualTests.Tests MaxCombo = 123, Rank = ScoreRank.A, Date = DateTimeOffset.Now, - Statistics = new Dictionary() + Statistics = new Dictionary { { "300", 50 }, { "100", 20 }, diff --git a/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs new file mode 100644 index 0000000000..4d650afed5 --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseRoomInspector.cs @@ -0,0 +1,143 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Testing; +using osu.Framework.Graphics; +using osu.Game.Screens.Multiplayer; +using osu.Game.Database; +using osu.Game.Online.Multiplayer; +using osu.Game.Users; +using osu.Framework.Allocation; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseRoomInspector : TestCase + { + public override string Description => @"from the multiplayer lobby"; + + private RulesetDatabase rulesets; + + protected override void LoadComplete() + { + base.LoadComplete(); + + var room = new Room + { + Name = { Value = @"My Awesome Room" }, + Host = { Value = new User { Username = @"flyte", Id = 3103765, Country = new Country { FlagName = @"JP" } } }, + Status = { Value = new RoomStatusOpen() }, + Type = { Value = new GameTypeTeamVersus() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 3.7, + Ruleset = rulesets.GetRuleset(3), + Metadata = new BeatmapMetadata + { + Title = @"Platina", + Artist = @"Maaya Sakamoto", + Author = @"uwutm8", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/560573/covers/cover.jpg?1492722343", + }, + }, + }, + } + }, + MaxParticipants = { Value = 200 }, + Participants = + { + Value = new[] + { + new User { Username = @"flyte", Id = 3103765, GlobalRank = 1425 }, + new User { Username = @"Cookiezi", Id = 124493, GlobalRank = 5466 }, + new User { Username = @"Angelsim", Id = 1777162, GlobalRank = 2873 }, + new User { Username = @"Rafis", Id = 2558286, GlobalRank = 4687 }, + new User { Username = @"hvick225", Id = 50265, GlobalRank = 3258 }, + new User { Username = @"peppy", Id = 2, GlobalRank = 6251 } + } + } + }; + + RoomInspector inspector; + Add(inspector = new RoomInspector + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Room = room, + }); + + AddStep(@"change title", () => room.Name.Value = @"A Better Room Than The Above"); + AddStep(@"change host", () => room.Host.Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } }); + AddStep(@"change status", () => room.Status.Value = new RoomStatusPlaying()); + AddStep(@"change type", () => room.Type.Value = new GameTypeTag()); + AddStep(@"change beatmap", () => room.Beatmap.Value = null); + AddStep(@"change max participants", () => room.MaxParticipants.Value = null); + AddStep(@"change participants", () => room.Participants.Value = new[] + { + new User { Username = @"filsdelama", Id = 2831793, GlobalRank = 8542 }, + new User { Username = @"_index", Id = 652457, GlobalRank = 15024 } + }); + + AddStep(@"change room", () => + { + var newRoom = new Room + { + Name = { Value = @"My New, Better Than Ever Room" }, + Host = { Value = new User { Username = @"Angelsim", Id = 1777162, Country = new Country { FlagName = @"KR" } } }, + Status = { Value = new RoomStatusOpen() }, + Type = { Value = new GameTypeTagTeam() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 7.07, + Ruleset = rulesets.GetRuleset(0), + Metadata = new BeatmapMetadata + { + Title = @"FREEDOM DIVE", + Artist = @"xi", + Author = @"Nakagawa-Kanon", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/39804/covers/cover.jpg?1456506845", + }, + }, + }, + }, + }, + MaxParticipants = { Value = 10 }, + Participants = + { + Value = new[] + { + new User { Username = @"Angelsim", Id = 1777162, GlobalRank = 4 }, + new User { Username = @"HappyStick", Id = 256802, GlobalRank = 752 }, + new User { Username = @"-Konpaku-", Id = 2258797, GlobalRank = 571 } + } + } + }; + + inspector.Room = newRoom; + }); + } + + [BackgroundDependencyLoader] + private void load(RulesetDatabase rulesets) + { + this.rulesets = rulesets; + } + } +} diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs index 45ae82109f..fc29e8481e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScoreCounter.cs @@ -15,10 +15,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests multiple counters"; - public override void Reset() + public TestCaseScoreCounter() { - base.Reset(); - int numerator = 0, denominator = 0; ScoreCounter score = new ScoreCounter(7) @@ -52,7 +50,7 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Position = new Vector2(20, -160), - Count = 5, + CountStars = 5, }; Add(stars); @@ -61,7 +59,7 @@ namespace osu.Desktop.VisualTests.Tests Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, Position = new Vector2(20, -190), - Text = stars.Count.ToString("0.00"), + Text = stars.CountStars.ToString("0.00"), }; Add(starsLabel); @@ -71,8 +69,8 @@ namespace osu.Desktop.VisualTests.Tests comboCounter.Current.Value = 0; numerator = denominator = 0; accuracyCounter.SetFraction(0, 0); - stars.Count = 0; - starsLabel.Text = stars.Count.ToString("0.00"); + stars.CountStars = 0; + starsLabel.Text = stars.CountStars.ToString("0.00"); }); AddStep(@"Hit! :D", delegate @@ -93,8 +91,8 @@ namespace osu.Desktop.VisualTests.Tests AddStep(@"Alter stars", delegate { - stars.Count = RNG.NextSingle() * (stars.StarCount + 1); - starsLabel.Text = stars.Count.ToString("0.00"); + stars.CountStars = RNG.NextSingle() * (stars.StarCount + 1); + starsLabel.Text = stars.CountStars.ToString("0.00"); }); AddStep(@"Stop counters", delegate diff --git a/osu.Desktop.VisualTests/Tests/TestCaseScrollingHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseScrollingHitObjects.cs index 5a4b3deb05..8e5cf8687c 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseScrollingHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseScrollingHitObjects.cs @@ -6,6 +6,7 @@ using OpenTK.Graphics; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Testing; @@ -20,16 +21,15 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => "SpeedAdjustmentContainer/DrawableTimingSection"; - private SpeedAdjustmentCollection adjustmentCollection; + private readonly BindableDouble timeRangeBindable; + private readonly OsuSpriteText bottomLabel; + private readonly SpriteText topTime; + private readonly SpriteText bottomTime; - private BindableDouble timeRangeBindable; - private OsuSpriteText timeRangeText; - private OsuSpriteText bottomLabel; - private SpriteText topTime, bottomTime; - - public override void Reset() + public TestCaseScrollingHitObjects() { - base.Reset(); + OsuSpriteText timeRangeText; + SpeedAdjustmentCollection adjustmentCollection; timeRangeBindable = new BindableDouble(2000) { @@ -55,7 +55,7 @@ namespace osu.Desktop.VisualTests.Tests timeRangeBindable.ValueChanged += v => timeRangeText.Text = $"Visible Range: {v:#,#.#}"; timeRangeBindable.ValueChanged += v => bottomLabel.Text = $"t minus {v:#,#}"; - Add(new Drawable[] + AddRange(new Drawable[] { new Container { @@ -125,6 +125,8 @@ namespace osu.Desktop.VisualTests.Tests private class TestSpeedAdjustmentContainer : SpeedAdjustmentContainer { + public override bool RemoveWhenNotAlive => false; + public TestSpeedAdjustmentContainer(MultiplierControlPoint controlPoint) : base(controlPoint) { @@ -150,11 +152,13 @@ namespace osu.Desktop.VisualTests.Tests } } - private class TestDrawableHitObject : DrawableHitObject + private class TestDrawableHitObject : DrawableHitObject, IScrollingHitObject { private readonly Box background; private const float height = 14; + public BindableDouble LifetimeOffset { get; } = new BindableDouble(); + public TestDrawableHitObject(HitObject hitObject) : base(hitObject) { @@ -195,25 +199,11 @@ namespace osu.Desktop.VisualTests.Tests FadeInFromZero(250, EasingTypes.OutQuint); } - private bool hasExpired; protected override void Update() { base.Update(); if (Time.Current >= HitObject.StartTime) - { background.Colour = Color4.Red; - - if (!hasExpired) - { - using (BeginDelayedSequence(200)) - { - FadeOut(200); - Expire(); - } - - hasExpired = true; - } - } } } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs b/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs index 660085e558..3d21f0e3b1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSettings.cs @@ -10,13 +10,16 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests the settings overlay"; - private SettingsOverlay settings; + private readonly SettingsOverlay settings; - public override void Reset() + public TestCaseSettings() { - base.Reset(); - Children = new[] { settings = new SettingsOverlay() }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); settings.ToggleVisibility(); } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSkipButton.cs b/osu.Desktop.VisualTests/Tests/TestCaseSkipButton.cs index fb5be719c1..1f81226a8e 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSkipButton.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSkipButton.cs @@ -10,9 +10,10 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Skip skip skippediskip"; - public override void Reset() + protected override void LoadComplete() { - base.Reset(); + base.LoadComplete(); + Add(new SkipButton(Clock.CurrentTime + 5000)); } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSocial.cs b/osu.Desktop.VisualTests/Tests/TestCaseSocial.cs index eb7df96355..34209119bd 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSocial.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSocial.cs @@ -11,10 +11,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"social browser overlay"; - public override void Reset() + public TestCaseSocial() { - base.Reset(); - SocialOverlay s = new SocialOverlay { Users = new[] diff --git a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs index e3c343f5f8..3368224be1 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseSongProgress.cs @@ -15,15 +15,13 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"With fake data"; - private SongProgress progress; - private SongProgressGraph graph; + private readonly SongProgress progress; + private readonly SongProgressGraph graph; - private StopwatchClock clock; + private readonly StopwatchClock clock; - public override void Reset() + public TestCaseSongProgress() { - base.Reset(); - clock = new StopwatchClock(true); Add(progress = new SongProgress diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index 96933a15e7..c0c01a6daa 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -14,10 +14,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Filter for song select"; - public override void Reset() + public TestCaseTabControl() { - base.Reset(); - OsuSpriteText text; OsuTabControl filter; Add(filter = new OsuTabControl diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs index d769071bd9..d98e39ae7b 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoHitObjects.cs @@ -16,10 +16,8 @@ namespace osu.Desktop.VisualTests.Tests private bool kiai; - public override void Reset() + public TestCaseTaikoHitObjects() { - base.Reset(); - AddToggleStep("Kiai", b => { kiai = !kiai; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs index 259d0267db..00929c06c2 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTaikoPlayfield.cs @@ -26,13 +26,11 @@ namespace osu.Desktop.VisualTests.Tests protected override double TimePerAction => default_duration * 2; private readonly Random rng = new Random(1337); - private TaikoPlayfield playfield; - private Container playfieldContainer; + private readonly TaikoPlayfield playfield; + private readonly Container playfieldContainer; - public override void Reset() + public TestCaseTaikoPlayfield() { - base.Reset(); - AddStep("Hit!", addHitJudgement); AddStep("Miss :(", addMissJudgement); AddStep("DrumRoll", () => addDrumRoll(false)); diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs b/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs index 7182ee7c06..2824c0416f 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTextAwesome.cs @@ -16,10 +16,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Tests display of icons"; - public override void Reset() + public TestCaseTextAwesome() { - base.Reset(); - FillFlowContainer flow; Add(flow = new FillFlowContainer diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs b/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs index 2decb4c469..0c35a4b8aa 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTwoLayerButton.cs @@ -10,10 +10,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Mostly back button"; - public override void Reset() + public TestCaseTwoLayerButton() { - base.Reset(); - Add(new BackButton()); } } diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs index 92d58c10c9..22cdf42f7d 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserPanel.cs @@ -13,10 +13,8 @@ namespace osu.Desktop.VisualTests.Tests { public override string Description => @"Panels for displaying a user's status"; - public override void Reset() + public TestCaseUserPanel() { - base.Reset(); - UserPanel flyte; UserPanel peppy; Add(new FillFlowContainer diff --git a/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs new file mode 100644 index 0000000000..d7a2c8e47d --- /dev/null +++ b/osu.Desktop.VisualTests/Tests/TestCaseUserProfile.cs @@ -0,0 +1,64 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System; +using System.Linq; +using osu.Framework.Testing; +using osu.Game.Overlays; +using osu.Game.Users; + +namespace osu.Desktop.VisualTests.Tests +{ + internal class TestCaseUserProfile : TestCase + { + public override string Description => "Tests user's profile page."; + + public TestCaseUserProfile() + { + var profile = new UserProfileOverlay(); + Add(profile); + + AddStep("Show offline dummy", () => profile.ShowUser(new User + { + Username = @"Somebody", + Id = 1, + Country = new Country { FullName = @"Alien" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c1.jpg", + JoinDate = DateTimeOffset.Now.AddDays(-1), + LastVisit = DateTimeOffset.Now, + Age = 1, + ProfileOrder = new[] { "me" }, + CountryRank = 1, + Statistics = new UserStatistics + { + Rank = 2148, + PP = 4567.89m + }, + AllRankHistories = new User.RankHistories + { + Osu = new User.RankHistory + { + Mode = @"osu", + Data = Enumerable.Range(2345,45).Concat(Enumerable.Range(2109,40)).ToArray() + } + } + }, false)); + AddStep("Show ppy", () => profile.ShowUser(new User + { + Username = @"peppy", + Id = 2, + Country = new Country { FullName = @"Australia", FlagName = @"AU" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" + })); + AddStep("Show flyte", () => profile.ShowUser(new User + { + Username = @"flyte", + Id = 3103765, + Country = new Country { FullName = @"Japan", FlagName = @"JP" }, + CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" + })); + AddStep("Hide", profile.Hide); + AddStep("Show without reload", profile.Show); + } + } +} diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index de84e567d2..4974f0c0d1 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -187,6 +187,7 @@ + @@ -215,6 +216,7 @@ + @@ -230,6 +232,8 @@ + + diff --git a/osu.Desktop/OsuGameDesktop.cs b/osu.Desktop/OsuGameDesktop.cs index 299f64d998..a2bfe6bf2e 100644 --- a/osu.Desktop/OsuGameDesktop.cs +++ b/osu.Desktop/OsuGameDesktop.cs @@ -11,6 +11,7 @@ using System.Reflection; using System.Drawing; using System.IO; using System.Threading.Tasks; +using osu.Framework.Graphics.Containers; using osu.Game.Screens.Menu; namespace osu.Desktop @@ -22,18 +23,22 @@ namespace osu.Desktop public OsuGameDesktop(string[] args = null) : base(args) { - versionManager = new VersionManager { Depth = int.MinValue }; + versionManager = new VersionManager + { + Depth = int.MinValue, + State = Visibility.Hidden + }; } protected override void LoadComplete() { base.LoadComplete(); - LoadComponentAsync(versionManager); + LoadComponentAsync(versionManager, Add); ScreenChanged += s => { - if (!versionManager.IsAlive && s is Intro) - Add(versionManager); + if (!versionManager.IsPresent && s is Intro) + versionManager.State = Visibility.Visible; }; } @@ -45,7 +50,7 @@ namespace osu.Desktop { desktopWindow.CursorState |= CursorState.Hidden; - desktopWindow.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location); + desktopWindow.Icon = new Icon(Assembly.GetExecutingAssembly().GetManifestResourceStream(GetType(), "lazer.ico")); desktopWindow.Title = Name; desktopWindow.DragEnter += dragEnter; diff --git a/osu.Desktop/Overlays/VersionManager.cs b/osu.Desktop/Overlays/VersionManager.cs index 9532652bfe..a8ab97ce37 100644 --- a/osu.Desktop/Overlays/VersionManager.cs +++ b/osu.Desktop/Overlays/VersionManager.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; using Squirrel; +using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Textures; using osu.Game.Graphics; @@ -92,12 +93,6 @@ namespace osu.Desktop.Overlays checkForUpdateAsync(); } - protected override void LoadComplete() - { - base.LoadComplete(); - State = Visibility.Visible; - } - protected override void Dispose(bool isDisposing) { base.Dispose(isDisposing); @@ -191,7 +186,7 @@ namespace osu.Desktop.Overlays { private OsuGame game; - protected override Notification CreateCompletionNotification() => new ProgressCompletionNotification() + protected override Notification CreateCompletionNotification() => new ProgressCompletionNotification { Text = @"Update ready to install. Click to restart!", Activated = () => @@ -207,7 +202,7 @@ namespace osu.Desktop.Overlays { this.game = game; - IconContent.Add(new Drawable[] + IconContent.AddRange(new Drawable[] { new Box { diff --git a/osu.Desktop/osu.Desktop.csproj b/osu.Desktop/osu.Desktop.csproj index 5ac888b515..e69603602c 100644 --- a/osu.Desktop/osu.Desktop.csproj +++ b/osu.Desktop/osu.Desktop.csproj @@ -232,7 +232,7 @@ - +