From 1210368e29bdf8ebfb159894067cb9679add1fae Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Mon, 21 May 2018 23:00:02 -0300 Subject: [PATCH 01/13] Add MultiplayerScreen base class. --- osu.Game/Screens/Multi/Header.cs | 3 +- .../Multi/Screens/MultiplayerScreen.cs | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index db8898495f..f6b7bbfcef 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -10,6 +10,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.SearchableList; +using osu.Game.Screens.Multi.Screens; using OpenTK; using OpenTK.Graphics; @@ -85,7 +86,7 @@ namespace osu.Game.Screens.Multi }, }; - breadcrumbs.Current.ValueChanged += s => screenTitle.Text = s.ToString(); + breadcrumbs.Current.ValueChanged += s => screenTitle.Text = s is MultiplayerScreen m ? m.Title : s.ToString(); breadcrumbs.Current.TriggerChange(); } diff --git a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs new file mode 100644 index 0000000000..5a17a32d8c --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs @@ -0,0 +1,57 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Screens; +using osu.Game.Graphics.Containers; + +namespace osu.Game.Screens.Multi.Screens +{ + public abstract class MultiplayerScreen : OsuScreen + { + private const Easing in_easing = Easing.OutQuint; + private const Easing out_easing = Easing.InSine; + + protected virtual Container TransitionContent => Content; + + public abstract string Title { get; } + public abstract string Name { get; } + + public override string ToString() => Name; + + protected override void OnEntering(Screen last) + { + base.OnEntering(last); + + TransitionContent.MoveToX(200); + + TransitionContent.FadeInFromZero(WaveContainer.APPEAR_DURATION, in_easing); + TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, in_easing); + } + + protected override bool OnExiting(Screen next) + { + Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, out_easing); + TransitionContent.MoveToX(200, WaveContainer.DISAPPEAR_DURATION, out_easing); + + return base.OnExiting(next); + } + + protected override void OnResuming(Screen last) + { + base.OnResuming(last); + + Content.FadeIn(WaveContainer.APPEAR_DURATION, in_easing); + TransitionContent.MoveToX(0, WaveContainer.APPEAR_DURATION, in_easing); + } + + protected override void OnSuspending(Screen next) + { + base.OnSuspending(next); + + Content.FadeOut(WaveContainer.DISAPPEAR_DURATION, out_easing); + TransitionContent.MoveToX(-200, WaveContainer.DISAPPEAR_DURATION, out_easing); + } + } +} From cae09492c30749096e2b6c54351234527f47be27 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 00:07:04 -0300 Subject: [PATCH 02/13] Basic Lounge functionality. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 158 ++++++++++++++++++ osu.Game.Tests/Visual/TestCaseMultiHeader.cs | 6 +- .../Screens/Multi/Components/DrawableRoom.cs | 33 +++- osu.Game/Screens/Multi/Multiplayer.cs | 8 +- osu.Game/Screens/Multi/Screens/Lobby.cs | 16 -- osu.Game/Screens/Multi/Screens/Lounge.cs | 115 +++++++++++++ osu.Game/Screens/Multi/Screens/Match.cs | 5 + 7 files changed, 312 insertions(+), 29 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseLounge.cs delete mode 100644 osu.Game/Screens/Multi/Screens/Lobby.cs create mode 100644 osu.Game/Screens/Multi/Screens/Lounge.cs diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs new file mode 100644 index 0000000000..b621899949 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -0,0 +1,158 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Game.Beatmaps; +using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets; +using osu.Game.Screens.Multi.Screens; +using osu.Game.Users; + +namespace osu.Game.Tests.Visual +{ + [TestFixture] + public class TestCaseLounge : OsuTestCase + { + [BackgroundDependencyLoader] + private void load(RulesetStore rulesets) + { + Lounge lounge = new Lounge(); + + Room[] rooms = + { + new Room + { + Name = { Value = @"Just Another Room" }, + Host = { Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } } }, + Status = { Value = new RoomStatusPlaying() }, + Type = { Value = new GameTypeTagTeam() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 5.65, + Ruleset = rulesets.GetRuleset(0), + Metadata = new BeatmapMetadata + { + Title = @"Sidetracked Day (Short Ver.)", + Artist = @"VINXIS", + AuthorString = @"Hobbes2", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/767600/covers/cover.jpg?1526243446", + }, + }, + }, + } + }, + MaxParticipants = { Value = 10 }, + Participants = + { + Value = new[] + { + new User { Username = @"flyte", Id = 3103765, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 142 } } }, + new User { Username = @"Cookiezi", Id = 124493, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 546 } } }, + new User { Username = @"Angelsim", Id = 1777162, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 287 } } }, + new User { Username = @"Rafis", Id = 2558286, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 468 } } }, + new User { Username = @"hvick225", Id = 50265, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 325 } } }, + new User { Username = @"peppy", Id = 2, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 625 } } }, + } + } + }, + new Room + { + Name = { Value = @"Not Just Any Room" }, + Host = { Value = new User { Username = @"Monstrata", Id = 2706438, Country = new Country { FlagName = @"CA" } } }, + Status = { Value = new RoomStatusOpen() }, + Type = { Value = new GameTypeTeamVersus() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 2.73, + Ruleset = rulesets.GetRuleset(0), + Metadata = new BeatmapMetadata + { + Title = @"lit(var)", + Artist = @"kensuke ushio", + AuthorString = @"Monstrata", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/623972/covers/cover.jpg?1521167183", + }, + }, + }, + } + }, + Participants = + { + Value = new[] + { + new User { Username = @"Jeby", Id = 3136279, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 3497 } } }, + new User { Username = @"DualAkira", Id = 5220933, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 643 } } }, + new User { Username = @"Datenshi Yohane", Id = 7171857, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 10555 } } }, + } + } + }, + new Room + { + Name = { Value = @"room THE FINAL" }, + Host = { Value = new User { Username = @"Delis", Id = 1603923, Country = new Country { FlagName = @"JP" } } }, + Status = { Value = new RoomStatusPlaying() }, + Type = { Value = new GameTypeTagTeam() }, + Beatmap = + { + Value = new BeatmapInfo + { + StarDifficulty = 4.48, + Ruleset = rulesets.GetRuleset(3), + Metadata = new BeatmapMetadata + { + Title = @"663098", + Artist = @"OISHII", + AuthorString = @"Mentholzzz", + }, + BeatmapSet = new BeatmapSetInfo + { + OnlineInfo = new BeatmapSetOnlineInfo + { + Covers = new BeatmapSetOnlineCovers + { + Cover = @"https://assets.ppy.sh/beatmaps/663098/covers/cover.jpg?1521898837", + }, + }, + }, + } + }, + MaxParticipants = { Value = 30 }, + Participants = + { + Value = new[] + { + new User { Username = @"KizuA", Id = 6510442, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 5372 } } }, + new User { Username = @"Colored", Id = 827563, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 810 } } }, + new User { Username = @"Beryl", Id = 3817591, Statistics = new UserStatistics { Ranks = new UserStatistics.UserRanks { Global = 10096 } } }, + } + } + }, + }; + + AddStep(@"show", () => Add(lounge)); + AddStep(@"set rooms", () => lounge.Rooms = rooms); + AddStep(@"clear rooms", () => lounge.Rooms = new Room[] {}); + AddStep(@"set rooms", () => lounge.Rooms = rooms); + AddStep(@"exit", lounge.Exit); + } + } +} diff --git a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs index af51a6221f..4406676aca 100644 --- a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs +++ b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs @@ -13,14 +13,14 @@ namespace osu.Game.Tests.Visual { public TestCaseMultiHeader() { - Lobby lobby; + Lounge lounge; Children = new Drawable[] { - lobby = new Lobby + lounge = new Lounge { Padding = new MarginPadding { Top = Header.HEIGHT }, }, - new Header(lobby), + new Header(lounge), }; } } diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 88a253d719..e5ba1a87cf 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -9,6 +9,7 @@ using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input; using osu.Framework.Localisation; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; @@ -25,8 +26,8 @@ namespace osu.Game.Screens.Multi.Components { public class DrawableRoom : OsuClickableContainer, IStateful { + public const float SELECTION_BORDER_WIDTH = 4; private const float corner_radius = 5; - private const float selection_border_width = 4; private const float transition_duration = 100; private const float content_padding = 10; private const float height = 100; @@ -62,6 +63,17 @@ namespace osu.Game.Screens.Multi.Components } } + private Action action; + public new Action Action + { + get { return action; } + set + { + action = value; + Enabled.Value = action != null; + } + } + public event Action StateChanged; public DrawableRoom(Room room) @@ -69,8 +81,8 @@ namespace osu.Game.Screens.Multi.Components Room = room; RelativeSizeAxes = Axes.X; - Height = height + selection_border_width * 2; - CornerRadius = corner_radius + selection_border_width / 2; + Height = height + SELECTION_BORDER_WIDTH * 2; + CornerRadius = corner_radius + SELECTION_BORDER_WIDTH / 2; Masking = true; // create selectionBox here so State can be set before being loaded @@ -79,8 +91,6 @@ namespace osu.Game.Screens.Multi.Components RelativeSizeAxes = Axes.Both, Alpha = 0f, }; - - Action += () => State = SelectionState.Selected; } [BackgroundDependencyLoader] @@ -98,7 +108,7 @@ namespace osu.Game.Screens.Multi.Components new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding(selection_border_width), + Padding = new MarginPadding(SELECTION_BORDER_WIDTH), Child = new Container { RelativeSizeAxes = Axes.Both, @@ -272,5 +282,16 @@ namespace osu.Game.Screens.Multi.Components beatmapBind.BindTo(Room.Beatmap); participantsBind.BindTo(Room.Participants); } + + protected override bool OnClick(InputState state) + { + if (Enabled.Value) + { + Action?.Invoke(this); + State = SelectionState.Selected; + } + + return true; + } } } diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index b3d393209c..347a12dd56 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -25,7 +25,7 @@ namespace osu.Game.Screens.Multi RelativeSizeAxes = Axes.Both, }; - Lobby lobby; + Lounge lounge; Children = new Drawable[] { new Container @@ -52,12 +52,12 @@ namespace osu.Game.Screens.Multi { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Top = Header.HEIGHT }, - Child = lobby = new Lobby(), + Child = lounge = new Lounge(), }, - new Header(lobby), + new Header(lounge), }; - lobby.Exited += s => Exit(); + lounge.Exited += s => Exit(); } protected override void OnEntering(Screen last) diff --git a/osu.Game/Screens/Multi/Screens/Lobby.cs b/osu.Game/Screens/Multi/Screens/Lobby.cs deleted file mode 100644 index dcda40e0d7..0000000000 --- a/osu.Game/Screens/Multi/Screens/Lobby.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE - -using System; -using System.Collections.Generic; - -namespace osu.Game.Screens.Multi.Screens -{ - public class Lobby : ScreenWhiteBox - { - protected override IEnumerable PossibleChildren => new[] { - typeof(MatchCreate), - typeof(Match) - }; - } -} diff --git a/osu.Game/Screens/Multi/Screens/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge.cs new file mode 100644 index 0000000000..b2ce94dd64 --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Lounge.cs @@ -0,0 +1,115 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Linq; +using System.Collections.Generic; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Graphics.UserInterface; +using osu.Game.Online.Multiplayer; +using osu.Game.Overlays.SearchableList; +using osu.Game.Screens.Multi.Components; +using OpenTK; + +namespace osu.Game.Screens.Multi.Screens +{ + public class Lounge : MultiplayerScreen + { + private readonly Container content; + private readonly FillFlowContainer roomsFlow; + private readonly RoomInspector roomInspector; + + protected override Container TransitionContent => content; + + public override string Title => "lounge"; + public override string Name => "Lounge"; + + private IEnumerable rooms; + public IEnumerable Rooms + { + get { return rooms; } + set + { + if (Equals(value, rooms)) return; + rooms = value; + + var enumerable = rooms.ToList(); + + roomsFlow.Children = enumerable.Select(r => new DrawableRoom(r) + { + Action = didSelect, + }).ToList(); + + if (!enumerable.Contains(roomInspector.Room)) + roomInspector.Room = null; + } + } + + public Lounge() + { + Children = new Drawable[] + { + content = new Container + { + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] + { + new ScrollContainer + { + RelativeSizeAxes = Axes.Both, + Width = 0.55f, + Padding = new MarginPadding + { + Vertical = 35 - DrawableRoom.SELECTION_BORDER_WIDTH, + Right = 20 - DrawableRoom.SELECTION_BORDER_WIDTH + }, + Child = roomsFlow = new FillFlowContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + LayoutEasing = Easing.OutQuint, + LayoutDuration = 200, + Spacing = new Vector2(10 - DrawableRoom.SELECTION_BORDER_WIDTH * 2), + }, + }, + roomInspector = new RoomInspector + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.Both, + Width = 0.45f, + }, + }, + }, + }; + } + + protected override void UpdateAfterChildren() + { + base.UpdateAfterChildren(); + + content.Padding = new MarginPadding + { + Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH, + Right = SearchableListOverlay.WIDTH_PADDING, + }; + } + + private void didSelect(DrawableRoom room) + { + roomsFlow.Children.ForEach(c => + { + if (c != room) + c.State = SelectionState.NotSelected; + }); + + roomInspector.Room = room.Room; + + // open the room if its selected and is clicked again + if (room.State == SelectionState.Selected) + Push(new Match(room.Room)); + } + } +} diff --git a/osu.Game/Screens/Multi/Screens/Match.cs b/osu.Game/Screens/Multi/Screens/Match.cs index 4ba7fe9f6a..f6178d5691 100644 --- a/osu.Game/Screens/Multi/Screens/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match.cs @@ -5,6 +5,7 @@ using System; using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Screens; +using osu.Game.Online.Multiplayer; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Play; using osu.Game.Screens.Select; @@ -21,6 +22,10 @@ namespace osu.Game.Screens.Multi.Screens protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); + public Match(Room room) + { + } + protected override void OnEntering(Screen last) { base.OnEntering(last); From f7a4a4eeef45c7afc392729949b70ecd12231b40 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 00:24:39 -0300 Subject: [PATCH 03/13] Add Lounge FilterControl. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 2 +- osu.Game.Tests/Visual/TestCaseMultiHeader.cs | 2 +- osu.Game/Online/Multiplayer/Room.cs | 1 + .../Online/Multiplayer/RoomAvailability.cs | 18 +++++++++ osu.Game/Screens/Multi/Multiplayer.cs | 2 +- .../Multi/Screens/Lounge/FilterControl.cs | 27 +++++++++++++ .../Multi/Screens/{ => Lounge}/Lounge.cs | 40 ++++++++++++++++++- 7 files changed, 87 insertions(+), 5 deletions(-) create mode 100644 osu.Game/Online/Multiplayer/RoomAvailability.cs create mode 100644 osu.Game/Screens/Multi/Screens/Lounge/FilterControl.cs rename osu.Game/Screens/Multi/Screens/{ => Lounge}/Lounge.cs (78%) diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs index b621899949..9dbc4012d5 100644 --- a/osu.Game.Tests/Visual/TestCaseLounge.cs +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -6,7 +6,7 @@ using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; -using osu.Game.Screens.Multi.Screens; +using osu.Game.Screens.Multi.Screens.Lounge; using osu.Game.Users; namespace osu.Game.Tests.Visual diff --git a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs index 4406676aca..d27a447077 100644 --- a/osu.Game.Tests/Visual/TestCaseMultiHeader.cs +++ b/osu.Game.Tests/Visual/TestCaseMultiHeader.cs @@ -4,7 +4,7 @@ using NUnit.Framework; using osu.Framework.Graphics; using osu.Game.Screens.Multi; -using osu.Game.Screens.Multi.Screens; +using osu.Game.Screens.Multi.Screens.Lounge; namespace osu.Game.Tests.Visual { diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index f1c23e9e84..ae3fb5ec6e 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -12,6 +12,7 @@ namespace osu.Game.Online.Multiplayer public Bindable Name = new Bindable(); public Bindable Host = new Bindable(); public Bindable Status = new Bindable(); + public Bindable Availability = new Bindable(); public Bindable Type = new Bindable(); public Bindable Beatmap = new Bindable(); public Bindable MaxParticipants = new Bindable(); diff --git a/osu.Game/Online/Multiplayer/RoomAvailability.cs b/osu.Game/Online/Multiplayer/RoomAvailability.cs new file mode 100644 index 0000000000..6c154207ff --- /dev/null +++ b/osu.Game/Online/Multiplayer/RoomAvailability.cs @@ -0,0 +1,18 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.ComponentModel; + +namespace osu.Game.Online.Multiplayer +{ + public enum RoomAvailability + { + Public, + + [Description(@"Friends Only")] + FriendsOnly, + + [Description(@"Invite Only")] + InviteOnly, + } +} diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index 347a12dd56..ddaeb26806 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -8,7 +8,7 @@ using osu.Framework.Screens; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; -using osu.Game.Screens.Multi.Screens; +using osu.Game.Screens.Multi.Screens.Lounge; namespace osu.Game.Screens.Multi { diff --git a/osu.Game/Screens/Multi/Screens/Lounge/FilterControl.cs b/osu.Game/Screens/Multi/Screens/Lounge/FilterControl.cs new file mode 100644 index 0000000000..421c89479a --- /dev/null +++ b/osu.Game/Screens/Multi/Screens/Lounge/FilterControl.cs @@ -0,0 +1,27 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Graphics; +using osu.Game.Online.Multiplayer; +using osu.Game.Overlays.SearchableList; +using OpenTK.Graphics; + +namespace osu.Game.Screens.Multi.Screens.Lounge +{ + public class FilterControl : SearchableListFilterControl + { + protected override Color4 BackgroundColour => OsuColour.FromHex(@"362e42"); + protected override LoungeTab DefaultTab => LoungeTab.Public; + + public FilterControl() + { + DisplayStyleControl.Hide(); + } + } + + public enum LoungeTab + { + Public = RoomAvailability.Public, + Private = RoomAvailability.FriendsOnly, + } +} diff --git a/osu.Game/Screens/Multi/Screens/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs similarity index 78% rename from osu.Game/Screens/Multi/Screens/Lounge.cs rename to osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index b2ce94dd64..39aa1d73e7 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -1,21 +1,24 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using System.Collections.Generic; +using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Framework.Input; +using osu.Framework.Screens; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Overlays.SearchableList; using osu.Game.Screens.Multi.Components; using OpenTK; -namespace osu.Game.Screens.Multi.Screens +namespace osu.Game.Screens.Multi.Screens.Lounge { public class Lounge : MultiplayerScreen { + private readonly FilterControl filter; private readonly Container content; private readonly FillFlowContainer roomsFlow; private readonly RoomInspector roomInspector; @@ -50,6 +53,7 @@ namespace osu.Game.Screens.Multi.Screens { Children = new Drawable[] { + filter = new FilterControl(), content = new Container { RelativeSizeAxes = Axes.Both, @@ -84,6 +88,8 @@ namespace osu.Game.Screens.Multi.Screens }, }, }; + + filter.Search.Exit += Exit; } protected override void UpdateAfterChildren() @@ -92,11 +98,41 @@ namespace osu.Game.Screens.Multi.Screens content.Padding = new MarginPadding { + Top = filter.DrawHeight, Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH, Right = SearchableListOverlay.WIDTH_PADDING, }; } + protected override void OnFocus(InputState state) + { + GetContainingInputManager().ChangeFocus(filter.Search); + } + + protected override void OnEntering(Screen last) + { + base.OnEntering(last); + filter.Search.HoldFocus = true; + } + + protected override bool OnExiting(Screen next) + { + filter.Search.HoldFocus = false; + return base.OnExiting(next); + } + + protected override void OnResuming(Screen last) + { + base.OnResuming(last); + filter.Search.HoldFocus = true; + } + + protected override void OnSuspending(Screen next) + { + base.OnSuspending(next); + filter.Search.HoldFocus = false; + } + private void didSelect(DrawableRoom room) { roomsFlow.Children.ForEach(c => From 6aac4269e6c4e458a41ee5ebf64d0adca01d07ac Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 00:33:41 -0300 Subject: [PATCH 04/13] Add filtering. --- .../Screens/Multi/Components/DrawableRoom.cs | 18 ++++++- .../Screens/Multi/Screens/Lounge/Lounge.cs | 52 ++++++++++++++++--- 2 files changed, 63 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index e5ba1a87cf..94f5f95062 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Configuration; @@ -24,7 +25,7 @@ using OpenTK.Graphics; namespace osu.Game.Screens.Multi.Components { - public class DrawableRoom : OsuClickableContainer, IStateful + public class DrawableRoom : OsuClickableContainer, IStateful, IFilterable { public const float SELECTION_BORDER_WIDTH = 4; private const float corner_radius = 5; @@ -63,6 +64,21 @@ namespace osu.Game.Screens.Multi.Components } } + public IEnumerable FilterTerms => new[] { Room.Name.Value }; + + private bool matchingFilter; + public bool MatchingFilter + { + get { return matchingFilter; } + set + { + if (value == matchingFilter) return; + matchingFilter = value; + + this.FadeTo(MatchingFilter ? 1 : 0, 200); + } + } + private Action action; public new Action Action { diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 39aa1d73e7..26c4acdcfd 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -20,7 +20,8 @@ namespace osu.Game.Screens.Multi.Screens.Lounge { private readonly FilterControl filter; private readonly Container content; - private readonly FillFlowContainer roomsFlow; + private readonly SearchContainer search; + private readonly RoomsFilterContainer roomsFlow; private readonly RoomInspector roomInspector; protected override Container TransitionContent => content; @@ -46,6 +47,8 @@ namespace osu.Game.Screens.Multi.Screens.Lounge if (!enumerable.Contains(roomInspector.Room)) roomInspector.Room = null; + + filterRooms(); } } @@ -68,14 +71,17 @@ namespace osu.Game.Screens.Multi.Screens.Lounge Vertical = 35 - DrawableRoom.SELECTION_BORDER_WIDTH, Right = 20 - DrawableRoom.SELECTION_BORDER_WIDTH }, - Child = roomsFlow = new FillFlowContainer + Child = search = new SearchContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - LayoutEasing = Easing.OutQuint, - LayoutDuration = 200, - Spacing = new Vector2(10 - DrawableRoom.SELECTION_BORDER_WIDTH * 2), + Child = roomsFlow = new RoomsFilterContainer + { + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(10 - DrawableRoom.SELECTION_BORDER_WIDTH * 2), + }, }, }, roomInspector = new RoomInspector @@ -89,6 +95,8 @@ namespace osu.Game.Screens.Multi.Screens.Lounge }, }; + filter.Search.Current.ValueChanged += s => filterRooms(); + filter.Tabs.Current.ValueChanged += t => filterRooms(); filter.Search.Exit += Exit; } @@ -133,6 +141,17 @@ namespace osu.Game.Screens.Multi.Screens.Lounge filter.Search.HoldFocus = false; } + private void filterRooms() + { + search.SearchTerm = filter.Search.Current.Value ?? string.Empty; + + foreach (DrawableRoom r in roomsFlow.Children) + { + r.MatchingFilter = r.MatchingFilter && + r.Room.Availability.Value == (RoomAvailability)filter.Tabs.Current.Value; + } + } + private void didSelect(DrawableRoom room) { roomsFlow.Children.ForEach(c => @@ -147,5 +166,26 @@ namespace osu.Game.Screens.Multi.Screens.Lounge if (room.State == SelectionState.Selected) Push(new Match(room.Room)); } + + private class RoomsFilterContainer : FillFlowContainer, IHasFilterableChildren + { + public IEnumerable FilterTerms => new string[] { }; + public IEnumerable FilterableChildren => Children; + + public bool MatchingFilter + { + set + { + if (value) + InvalidateLayout(); + } + } + + public RoomsFilterContainer() + { + LayoutDuration = 200; + LayoutEasing = Easing.OutQuint; + } + } } } From 662559d3c993859a9fd24c3aaab74c690edbdf82 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 01:22:23 -0300 Subject: [PATCH 05/13] More test steps. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 58 ++++++++++++++++++- .../Screens/Multi/Components/DrawableRoom.cs | 2 - .../Screens/Multi/Screens/Lounge/Lounge.cs | 48 +++++++-------- 3 files changed, 80 insertions(+), 28 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs index 9dbc4012d5..a89c12a1be 100644 --- a/osu.Game.Tests/Visual/TestCaseLounge.cs +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -1,23 +1,29 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; using osu.Framework.Allocation; using osu.Game.Beatmaps; using osu.Game.Online.Multiplayer; using osu.Game.Rulesets; +using osu.Game.Screens.Multi.Components; using osu.Game.Screens.Multi.Screens.Lounge; using osu.Game.Users; +using OpenTK.Input; namespace osu.Game.Tests.Visual { [TestFixture] - public class TestCaseLounge : OsuTestCase + public class TestCaseLounge : ManualInputManagerTestCase { + private TestLounge lounge; + [BackgroundDependencyLoader] private void load(RulesetStore rulesets) { - Lounge lounge = new Lounge(); + lounge = new TestLounge(); Room[] rooms = { @@ -26,6 +32,7 @@ namespace osu.Game.Tests.Visual Name = { Value = @"Just Another Room" }, Host = { Value = new User { Username = @"DrabWeb", Id = 6946022, Country = new Country { FlagName = @"CA" } } }, Status = { Value = new RoomStatusPlaying() }, + Availability = { Value = RoomAvailability.Public }, Type = { Value = new GameTypeTagTeam() }, Beatmap = { @@ -70,6 +77,7 @@ namespace osu.Game.Tests.Visual Name = { Value = @"Not Just Any Room" }, Host = { Value = new User { Username = @"Monstrata", Id = 2706438, Country = new Country { FlagName = @"CA" } } }, Status = { Value = new RoomStatusOpen() }, + Availability = { Value = RoomAvailability.FriendsOnly }, Type = { Value = new GameTypeTeamVersus() }, Beatmap = { @@ -110,6 +118,7 @@ namespace osu.Game.Tests.Visual Name = { Value = @"room THE FINAL" }, Host = { Value = new User { Username = @"Delis", Id = 1603923, Country = new Country { FlagName = @"JP" } } }, Status = { Value = new RoomStatusPlaying() }, + Availability = { Value = RoomAvailability.Public }, Type = { Value = new GameTypeTagTeam() }, Beatmap = { @@ -150,9 +159,54 @@ namespace osu.Game.Tests.Visual AddStep(@"show", () => Add(lounge)); AddStep(@"set rooms", () => lounge.Rooms = rooms); + selectAssert(0); + AddStep(@"clear rooms", () => lounge.Rooms = new Room[] {}); + AddAssert(@"no room selected", () => lounge.SelectedRoom == null); + AddStep(@"set rooms", () => lounge.Rooms = rooms); + selectAssert(1); + AddStep(@"open room 1", () => clickRoom(1)); + AddStep(@"make lounge current", lounge.MakeCurrent); + filterAssert(@"THE FINAL", LoungeTab.Public, 1); + filterAssert(string.Empty, LoungeTab.Public, 2); + filterAssert(string.Empty, LoungeTab.Private, 1); + filterAssert(string.Empty, LoungeTab.Public, 2); + filterAssert(@"no matches", LoungeTab.Public, 0); AddStep(@"clear rooms", () => lounge.Rooms = new Room[] {}); AddStep(@"set rooms", () => lounge.Rooms = rooms); + AddAssert(@"no matches after clear", () => lounge.MatchedCount == 0); + filterAssert(string.Empty, LoungeTab.Public, 2); AddStep(@"exit", lounge.Exit); } + + private void clickRoom(int n) + { + InputManager.MoveMouseTo(lounge.ChildRooms[n]); + InputManager.Click(MouseButton.Left); + } + + private void selectAssert(int n) + { + AddStep($@"select room {n}", () => clickRoom(n)); + AddAssert($@"room {n} selected", () => lounge.SelectedRoom == lounge.ChildRooms[n].Room); + } + + private void filterAssert(string filter, LoungeTab tab, int endCount) + { + AddStep($@"filter '{filter}', {tab}", () => lounge.SetFilter(filter, tab)); + AddAssert(@"filtered correctly", () => lounge.MatchedCount == endCount); + } + + private class TestLounge : Lounge + { + public IReadOnlyList ChildRooms => RoomsContainer.Children; + public Room SelectedRoom => Inspector.Room; + public int MatchedCount => ChildRooms.Count(r => r.MatchingFilter); + + public void SetFilter(string filter, LoungeTab tab) + { + Filter.Search.Current.Value = filter; + Filter.Tabs.Current.Value = tab; + } + } } } diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 94f5f95062..d11d4a4795 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -72,9 +72,7 @@ namespace osu.Game.Screens.Multi.Components get { return matchingFilter; } set { - if (value == matchingFilter) return; matchingFilter = value; - this.FadeTo(MatchingFilter ? 1 : 0, 200); } } diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 26c4acdcfd..30ca897c1a 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -18,16 +18,16 @@ namespace osu.Game.Screens.Multi.Screens.Lounge { public class Lounge : MultiplayerScreen { - private readonly FilterControl filter; private readonly Container content; private readonly SearchContainer search; - private readonly RoomsFilterContainer roomsFlow; - private readonly RoomInspector roomInspector; - protected override Container TransitionContent => content; + protected readonly FilterControl Filter; + protected readonly FillFlowContainer RoomsContainer; + protected readonly RoomInspector Inspector; public override string Title => "lounge"; public override string Name => "Lounge"; + protected override Container TransitionContent => content; private IEnumerable rooms; public IEnumerable Rooms @@ -40,13 +40,13 @@ namespace osu.Game.Screens.Multi.Screens.Lounge var enumerable = rooms.ToList(); - roomsFlow.Children = enumerable.Select(r => new DrawableRoom(r) + RoomsContainer.Children = enumerable.Select(r => new DrawableRoom(r) { Action = didSelect, }).ToList(); - if (!enumerable.Contains(roomInspector.Room)) - roomInspector.Room = null; + if (!enumerable.Contains(Inspector.Room)) + Inspector.Room = null; filterRooms(); } @@ -56,7 +56,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge { Children = new Drawable[] { - filter = new FilterControl(), + Filter = new FilterControl(), content = new Container { RelativeSizeAxes = Axes.Both, @@ -75,7 +75,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, - Child = roomsFlow = new RoomsFilterContainer + Child = RoomsContainer = new RoomsFilterContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y, @@ -84,7 +84,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge }, }, }, - roomInspector = new RoomInspector + Inspector = new RoomInspector { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, @@ -95,9 +95,9 @@ namespace osu.Game.Screens.Multi.Screens.Lounge }, }; - filter.Search.Current.ValueChanged += s => filterRooms(); - filter.Tabs.Current.ValueChanged += t => filterRooms(); - filter.Search.Exit += Exit; + Filter.Search.Current.ValueChanged += s => filterRooms(); + Filter.Tabs.Current.ValueChanged += t => filterRooms(); + Filter.Search.Exit += Exit; } protected override void UpdateAfterChildren() @@ -106,7 +106,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge content.Padding = new MarginPadding { - Top = filter.DrawHeight, + Top = Filter.DrawHeight, Left = SearchableListOverlay.WIDTH_PADDING - DrawableRoom.SELECTION_BORDER_WIDTH, Right = SearchableListOverlay.WIDTH_PADDING, }; @@ -114,53 +114,53 @@ namespace osu.Game.Screens.Multi.Screens.Lounge protected override void OnFocus(InputState state) { - GetContainingInputManager().ChangeFocus(filter.Search); + GetContainingInputManager().ChangeFocus(Filter.Search); } protected override void OnEntering(Screen last) { base.OnEntering(last); - filter.Search.HoldFocus = true; + Filter.Search.HoldFocus = true; } protected override bool OnExiting(Screen next) { - filter.Search.HoldFocus = false; + Filter.Search.HoldFocus = false; return base.OnExiting(next); } protected override void OnResuming(Screen last) { base.OnResuming(last); - filter.Search.HoldFocus = true; + Filter.Search.HoldFocus = true; } protected override void OnSuspending(Screen next) { base.OnSuspending(next); - filter.Search.HoldFocus = false; + Filter.Search.HoldFocus = false; } private void filterRooms() { - search.SearchTerm = filter.Search.Current.Value ?? string.Empty; + search.SearchTerm = Filter.Search.Current.Value ?? string.Empty; - foreach (DrawableRoom r in roomsFlow.Children) + foreach (DrawableRoom r in RoomsContainer.Children) { r.MatchingFilter = r.MatchingFilter && - r.Room.Availability.Value == (RoomAvailability)filter.Tabs.Current.Value; + r.Room.Availability.Value == (RoomAvailability)Filter.Tabs.Current.Value; } } private void didSelect(DrawableRoom room) { - roomsFlow.Children.ForEach(c => + RoomsContainer.Children.ForEach(c => { if (c != room) c.State = SelectionState.NotSelected; }); - roomInspector.Room = room.Room; + Inspector.Room = room.Room; // open the room if its selected and is clicked again if (room.State == SelectionState.Selected) From fba79a4de651a3cab48ceb58b8acd2cd120df4fc Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 01:31:01 -0300 Subject: [PATCH 06/13] Test typo. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs index a89c12a1be..8a3bc79e8d 100644 --- a/osu.Game.Tests/Visual/TestCaseLounge.cs +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -128,7 +128,7 @@ namespace osu.Game.Tests.Visual Ruleset = rulesets.GetRuleset(3), Metadata = new BeatmapMetadata { - Title = @"663098", + Title = @"ONIGIRI FREEWAY", Artist = @"OISHII", AuthorString = @"Mentholzzz", }, From 3cc5bb516e6c875f415ca7d519ed78468eed2665 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 01:39:25 -0300 Subject: [PATCH 07/13] Remove unused Match ctor param. --- osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs | 2 +- osu.Game/Screens/Multi/Screens/Match.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 30ca897c1a..01a7510f76 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -164,7 +164,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge // open the room if its selected and is clicked again if (room.State == SelectionState.Selected) - Push(new Match(room.Room)); + Push(new Match()); } private class RoomsFilterContainer : FillFlowContainer, IHasFilterableChildren diff --git a/osu.Game/Screens/Multi/Screens/Match.cs b/osu.Game/Screens/Multi/Screens/Match.cs index f6178d5691..d57f43fcd1 100644 --- a/osu.Game/Screens/Multi/Screens/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using osu.Framework.Graphics; using osu.Framework.Screens; -using osu.Game.Online.Multiplayer; using osu.Game.Screens.Backgrounds; using osu.Game.Screens.Play; using osu.Game.Screens.Select; @@ -22,7 +21,7 @@ namespace osu.Game.Screens.Multi.Screens protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - public Match(Room room) + public Match() { } From 349b0a33221acf335cb9bae3a99178fc2522036b Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 01:46:08 -0300 Subject: [PATCH 08/13] Remove empty ctor. --- osu.Game/Screens/Multi/Screens/Match.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/osu.Game/Screens/Multi/Screens/Match.cs b/osu.Game/Screens/Multi/Screens/Match.cs index d57f43fcd1..4ba7fe9f6a 100644 --- a/osu.Game/Screens/Multi/Screens/Match.cs +++ b/osu.Game/Screens/Multi/Screens/Match.cs @@ -21,10 +21,6 @@ namespace osu.Game.Screens.Multi.Screens protected override BackgroundScreen CreateBackground() => new BackgroundScreenCustom(@"Backgrounds/bg4"); - public Match() - { - } - protected override void OnEntering(Screen last) { base.OnEntering(last); From 0b19b7d9e56f64032207c9c36ea0a4382919e781 Mon Sep 17 00:00:00 2001 From: DrabWeb Date: Tue, 22 May 2018 02:08:50 -0300 Subject: [PATCH 09/13] Fix test case. --- osu.Game.Tests/Visual/TestCaseLounge.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseLounge.cs b/osu.Game.Tests/Visual/TestCaseLounge.cs index 8a3bc79e8d..b96d705d5c 100644 --- a/osu.Game.Tests/Visual/TestCaseLounge.cs +++ b/osu.Game.Tests/Visual/TestCaseLounge.cs @@ -173,34 +173,33 @@ namespace osu.Game.Tests.Visual filterAssert(@"no matches", LoungeTab.Public, 0); AddStep(@"clear rooms", () => lounge.Rooms = new Room[] {}); AddStep(@"set rooms", () => lounge.Rooms = rooms); - AddAssert(@"no matches after clear", () => lounge.MatchedCount == 0); + AddAssert(@"no matches after clear", () => !lounge.ChildRooms.Any()); filterAssert(string.Empty, LoungeTab.Public, 2); AddStep(@"exit", lounge.Exit); } private void clickRoom(int n) { - InputManager.MoveMouseTo(lounge.ChildRooms[n]); + InputManager.MoveMouseTo(lounge.ChildRooms.ElementAt(n)); InputManager.Click(MouseButton.Left); } private void selectAssert(int n) { AddStep($@"select room {n}", () => clickRoom(n)); - AddAssert($@"room {n} selected", () => lounge.SelectedRoom == lounge.ChildRooms[n].Room); + AddAssert($@"room {n} selected", () => lounge.SelectedRoom == lounge.ChildRooms.ElementAt(n).Room); } private void filterAssert(string filter, LoungeTab tab, int endCount) { AddStep($@"filter '{filter}', {tab}", () => lounge.SetFilter(filter, tab)); - AddAssert(@"filtered correctly", () => lounge.MatchedCount == endCount); + AddAssert(@"filtered correctly", () => lounge.ChildRooms.Count() == endCount); } private class TestLounge : Lounge { - public IReadOnlyList ChildRooms => RoomsContainer.Children; + public IEnumerable ChildRooms => RoomsContainer.Children.Where(r => r.MatchingFilter); public Room SelectedRoom => Inspector.Room; - public int MatchedCount => ChildRooms.Count(r => r.MatchingFilter); public void SetFilter(string filter, LoungeTab tab) { From 95315e46f06dfc70acebf3cce07f03b166128150 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Sun, 27 May 2018 14:12:20 +0900 Subject: [PATCH 10/13] Make drawable rooms fade in when first displayed Stops filtered rooms from briefly displaying. --- osu.Game/Screens/Multi/Components/DrawableRoom.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index d11d4a4795..8e93fda68f 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -297,6 +297,12 @@ namespace osu.Game.Screens.Multi.Components participantsBind.BindTo(Room.Participants); } + protected override void LoadComplete() + { + base.LoadComplete(); + this.FadeInFromZero(transition_duration); + } + protected override bool OnClick(InputState state) { if (Enabled.Value) From 0ca6d73f0ec7d43773b404d66666cd89c77657e0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 12:28:11 +0900 Subject: [PATCH 11/13] Add a delay before the osu! logo appears when exiting multiplayer --- osu.Game/Screens/Multi/Multiplayer.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index ddaeb26806..7822fa68dc 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -8,6 +8,7 @@ using osu.Framework.Screens; using osu.Game.Graphics; using osu.Game.Graphics.Backgrounds; using osu.Game.Graphics.Containers; +using osu.Game.Screens.Menu; using osu.Game.Screens.Multi.Screens.Lounge; namespace osu.Game.Screens.Multi @@ -84,6 +85,13 @@ namespace osu.Game.Screens.Multi waves.Hide(); } + protected override void LogoExiting(OsuLogo logo) + { + // the wave overlay transition takes longer than expected to run. + logo.Delay(WaveContainer.DISAPPEAR_DURATION / 2).FadeOut(); + base.LogoExiting(logo); + } + private class MultiplayerWaveContainer : WaveContainer { protected override bool StartHidden => true; From 02c37ebc1f928d96fbeaa79df5337e3cd1a1703e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 13:02:06 +0900 Subject: [PATCH 12/13] Move screen titles to OsuScreen --- .../Visual/TestCaseScreenBreadcrumbControl.cs | 7 ++----- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 3 ++- osu.Game/Screens/Multi/Header.cs | 2 +- osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs | 2 +- osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs | 5 ----- osu.Game/Screens/OsuScreen.cs | 10 +++++++++- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs index 7a743655f4..83bbbfddd1 100644 --- a/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs +++ b/osu.Game.Tests/Visual/TestCaseScreenBreadcrumbControl.cs @@ -84,12 +84,9 @@ namespace osu.Game.Tests.Visual private abstract class TestScreen : OsuScreen { - protected abstract string Title { get; } protected abstract string NextTitle { get; } protected abstract TestScreen CreateNextScreen(); - public override string ToString() => Title; - public TestScreen PushNext() { TestScreen screen = CreateNextScreen(); @@ -130,14 +127,14 @@ namespace osu.Game.Tests.Visual private class TestScreenOne : TestScreen { - protected override string Title => @"Screen One"; + public override string Title => @"Screen One"; protected override string NextTitle => @"Two"; protected override TestScreen CreateNextScreen() => new TestScreenTwo(); } private class TestScreenTwo : TestScreen { - protected override string Title => @"Screen Two"; + public override string Title => @"Screen Two"; protected override string NextTitle => @"One"; protected override TestScreen CreateNextScreen() => new TestScreenOne(); } diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index fc14a9c6ba..d015a563f6 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -6,6 +6,7 @@ using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Allocation; +using osu.Framework.Configuration; using osu.Framework.Extensions; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; @@ -157,7 +158,7 @@ namespace osu.Game.Graphics.UserInterface Margin = new MarginPadding { Top = 5, Bottom = 5 }, Origin = Anchor.BottomLeft, Anchor = Anchor.BottomLeft, - Text = (value as Enum)?.GetDescription() ?? value.ToString(), + Text = (value as IHasDescription)?.Description ?? (value as Enum)?.GetDescription() ?? value.ToString(), TextSize = 14, Font = @"Exo2.0-Bold", // Font should only turn bold when active? }, diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index f6b7bbfcef..de71b20007 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -86,7 +86,7 @@ namespace osu.Game.Screens.Multi }, }; - breadcrumbs.Current.ValueChanged += s => screenTitle.Text = s is MultiplayerScreen m ? m.Title : s.ToString(); + breadcrumbs.Current.ValueChanged += s => screenTitle.Text = ((MultiplayerScreen)s).Title; breadcrumbs.Current.TriggerChange(); } diff --git a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs index 01a7510f76..60ffe2c0b9 100644 --- a/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs +++ b/osu.Game/Screens/Multi/Screens/Lounge/Lounge.cs @@ -26,7 +26,7 @@ namespace osu.Game.Screens.Multi.Screens.Lounge protected readonly RoomInspector Inspector; public override string Title => "lounge"; - public override string Name => "Lounge"; + protected override Container TransitionContent => content; private IEnumerable rooms; diff --git a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs index 5a17a32d8c..191fe66037 100644 --- a/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs +++ b/osu.Game/Screens/Multi/Screens/MultiplayerScreen.cs @@ -15,11 +15,6 @@ namespace osu.Game.Screens.Multi.Screens protected virtual Container TransitionContent => Content; - public abstract string Title { get; } - public abstract string Name { get; } - - public override string ToString() => Name; - protected override void OnEntering(Screen last) { base.OnEntering(last); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index a188b7aa64..cd9cbe119f 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using Microsoft.EntityFrameworkCore.Internal; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; @@ -20,10 +21,17 @@ using OpenTK.Input; namespace osu.Game.Screens { - public abstract class OsuScreen : Screen, IKeyBindingHandler + public abstract class OsuScreen : Screen, IKeyBindingHandler, IHasDescription { public BackgroundScreen Background { get; private set; } + /// + /// A user-facing title for this screen. + /// + public virtual string Title => GetType().ShortDisplayName(); + + public string Description => Title; + protected virtual bool AllowBackButton => true; /// From ed7c8608028149b4549026f09efe7de500cffc49 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 28 May 2018 13:02:15 +0900 Subject: [PATCH 13/13] Adjust transitions of DrawableRoom --- osu.Game/Screens/Multi/Components/DrawableRoom.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/Multi/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Components/DrawableRoom.cs index 8e93fda68f..1851f4618e 100644 --- a/osu.Game/Screens/Multi/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Components/DrawableRoom.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Multi.Components { public const float SELECTION_BORDER_WIDTH = 4; private const float corner_radius = 5; - private const float transition_duration = 100; + private const float transition_duration = 60; private const float content_padding = 10; private const float height = 100; private const float side_strip_width = 5; @@ -254,7 +254,7 @@ namespace osu.Game.Screens.Multi.Components status.Text = s.Message; foreach (Drawable d in new Drawable[] { selectionBox, sideStrip, status }) - d.FadeColour(s.GetAppropriateColour(colours), 100); + d.FadeColour(s.GetAppropriateColour(colours), transition_duration); }; beatmapBind.ValueChanged += b =>