From 2e28f378deb2afbb1fa621bc506dedda2947b59f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 20 Dec 2018 15:17:33 +0900 Subject: [PATCH] Move beatmap + mod info to header --- osu.Game.Tests/Visual/TestCaseMatchHeader.cs | 58 +++++++++++++++++ osu.Game.Tests/Visual/TestCaseMatchInfo.cs | 3 - .../UpdateableBeatmapBackgroundSprite.cs | 2 +- .../Screens/Multi/Components/BeatmapTitle.cs | 2 +- .../Multi/Components/BeatmapTypeInfo.cs | 6 +- .../Screens/Multi/Components/ModeTypeInfo.cs | 4 +- .../Multi/Lounge/Components/DrawableRoom.cs | 13 ++-- .../Multi/Lounge/Components/RoomInspector.cs | 11 ++-- .../Screens/Multi/Match/Components/Header.cs | 64 +++++++++++++------ .../Screens/Multi/Match/Components/Info.cs | 25 -------- .../Multi/Match/Components/MatchTabControl.cs | 8 +-- .../Match/Components/RoomSettingsOverlay.cs | 31 +++++++-- osu.Game/Screens/Multi/Match/MatchScreen.cs | 7 +- 13 files changed, 153 insertions(+), 81 deletions(-) create mode 100644 osu.Game.Tests/Visual/TestCaseMatchHeader.cs diff --git a/osu.Game.Tests/Visual/TestCaseMatchHeader.cs b/osu.Game.Tests/Visual/TestCaseMatchHeader.cs new file mode 100644 index 0000000000..8ff16a20b9 --- /dev/null +++ b/osu.Game.Tests/Visual/TestCaseMatchHeader.cs @@ -0,0 +1,58 @@ +// 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; +using osu.Framework.Configuration; +using osu.Game.Beatmaps; +using osu.Game.Online.Multiplayer; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Osu; +using osu.Game.Rulesets.Osu.Mods; +using osu.Game.Screens.Multi.Match.Components; + +namespace osu.Game.Tests.Visual +{ + public class TestCaseMatchHeader : OsuTestCase + { + public override IReadOnlyList RequiredTypes => new[] + { + typeof(Header) + }; + + private readonly Bindable beatmap = new Bindable(); + private readonly Bindable type = new Bindable(); + private readonly Bindable> mods = new Bindable>(); + + public TestCaseMatchHeader() + { + var header = new Header(new Room()); + + header.Beatmap.BindTo(beatmap); + header.Type.BindTo(type); + header.Mods.BindTo(mods); + + beatmap.Value = new BeatmapInfo + { + Metadata = new BeatmapMetadata + { + Title = "Title", + Artist = "Artist", + AuthorString = "Author", + }, + Version = "Version", + Ruleset = new OsuRuleset().RulesetInfo + }; + + type.Value = new GameTypeTimeshift(); + mods.Value = new Mod[] + { + new OsuModDoubleTime(), + new OsuModNoFail(), + new OsuModRelax(), + }; + + Child = header; + } + } +} diff --git a/osu.Game.Tests/Visual/TestCaseMatchInfo.cs b/osu.Game.Tests/Visual/TestCaseMatchInfo.cs index 799b5f2526..0d3c769dc5 100644 --- a/osu.Game.Tests/Visual/TestCaseMatchInfo.cs +++ b/osu.Game.Tests/Visual/TestCaseMatchInfo.cs @@ -44,13 +44,10 @@ namespace osu.Game.Tests.Visual }, }); - AddStep(@"set type", () => info.Type.Value = new GameTypeTagTeam()); - AddStep(@"change name", () => info.Name.Value = @"Room Name!"); AddStep(@"change availability", () => info.Availability.Value = RoomAvailability.InviteOnly); AddStep(@"change status", () => info.Status.Value = new RoomStatusOpen()); AddStep(@"null beatmap", () => info.Beatmap.Value = null); - AddStep(@"change type", () => info.Type.Value = new GameTypeTeamVersus()); AddStep(@"change beatmap", () => info.Beatmap.Value = new BeatmapInfo { StarDifficulty = 4.2, diff --git a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs index 15b89d27bd..0a9726b121 100644 --- a/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs +++ b/osu.Game/Beatmaps/Drawables/UpdateableBeatmapBackgroundSprite.cs @@ -11,7 +11,7 @@ namespace osu.Game.Beatmaps.Drawables { public class UpdateableBeatmapBackgroundSprite : ModelBackedDrawable { - public readonly Bindable Beatmap = new Bindable(); + public readonly IBindable Beatmap = new Bindable(); [Resolved] private BeatmapManager beatmaps { get; set; } diff --git a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs index e3ef5eb401..02ec598f82 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTitle.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTitle.cs @@ -19,7 +19,7 @@ namespace osu.Game.Screens.Multi.Components set { beatmapTitle.TextSize = beatmapDash.TextSize = beatmapArtist.TextSize = value; } } - public readonly Bindable Beatmap = new Bindable(); + public readonly IBindable Beatmap = new Bindable(); public BeatmapTitle() { diff --git a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs index 2bd7b19a0a..90319de40f 100644 --- a/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/BeatmapTypeInfo.cs @@ -17,9 +17,9 @@ namespace osu.Game.Screens.Multi.Components { private readonly OsuSpriteText beatmapAuthor; - public readonly Bindable Beatmap = new Bindable(); + public readonly IBindable Beatmap = new Bindable(); - public readonly Bindable Type = new Bindable(); + public readonly IBindable Type = new Bindable(); public BeatmapTypeInfo() { @@ -67,7 +67,7 @@ namespace osu.Game.Screens.Multi.Components [BackgroundDependencyLoader] private void load(OsuColour colours) { - beatmapAuthor.Colour = colours.Gray9; + beatmapAuthor.Colour = colours.GrayC; } } } diff --git a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs index 87d150c5a4..8104244084 100644 --- a/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs +++ b/osu.Game/Screens/Multi/Components/ModeTypeInfo.cs @@ -18,8 +18,8 @@ namespace osu.Game.Screens.Multi.Components private readonly Container rulesetContainer; - public readonly Bindable Beatmap = new Bindable(); - public readonly Bindable Type = new Bindable(); + public readonly IBindable Beatmap = new Bindable(); + public readonly IBindable Type = new Bindable(); public ModeTypeInfo() { diff --git a/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs b/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs index adcb088f4e..c1a9dd3b1d 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/DrawableRoom.cs @@ -47,7 +47,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components private readonly IBindableCollection playlistBind = new BindableCollection(); private readonly IBindable endDateBind = new Bindable(); - private readonly Bindable beatmap = new Bindable(); + private readonly Bindable beatmap = new Bindable(); private UpdateableBeatmapBackgroundSprite background; private BeatmapTitle beatmapTitle; @@ -243,6 +243,10 @@ namespace osu.Game.Screens.Multi.Lounge.Components endDateBind.BindValueChanged(d => endDate.Date = d, true); + background.Beatmap.BindTo(beatmap); + modeTypeInfo.Beatmap.BindTo(beatmap); + beatmapTitle.Beatmap.BindTo(beatmap); + modeTypeInfo.Type.BindTo(typeBind); participantInfo.Host.BindTo(hostBind); @@ -266,12 +270,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components return; // For now, only the first playlist item is supported - var item = playlistBind.First(); - - beatmap.Value = beatmaps.GetWorkingBeatmap(item.Beatmap); - background.Beatmap.Value = item.Beatmap; - modeTypeInfo.Beatmap.Value = item.Beatmap; - beatmapTitle.Beatmap.Value = item.Beatmap; + beatmap.Value = playlistBind.First().Beatmap; } } } diff --git a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs index 818fd78f32..80adc8787f 100644 --- a/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs +++ b/osu.Game/Screens/Multi/Lounge/Components/RoomInspector.cs @@ -39,7 +39,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components private readonly Bindable> participantsBind = new Bindable>(); private readonly IBindableCollection playlistBind = new BindableCollection(); - private readonly Bindable beatmap = new Bindable(); + private readonly Bindable beatmap = new Bindable(); private OsuColour colours; private Box statusStrip; @@ -190,6 +190,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components beatmapTypeInfo.Type.BindTo(typeBind); + background.Beatmap.BindTo(beatmap); + beatmapTypeInfo.Beatmap.BindTo(beatmap); + Room.BindValueChanged(updateRoom, true); } @@ -244,11 +247,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components return; // For now, only the first playlist item is supported - var item = playlistBind.First(); - - beatmap.Value = beatmaps.GetWorkingBeatmap(item.Beatmap); - background.Beatmap.Value = item.Beatmap; - beatmapTypeInfo.Beatmap.Value = item.Beatmap; + beatmap.Value = playlistBind.First().Beatmap; } protected override void UpdateAfterChildren() diff --git a/osu.Game/Screens/Multi/Match/Components/Header.cs b/osu.Game/Screens/Multi/Match/Components/Header.cs index 4b831ed3c6..de93e8587f 100644 --- a/osu.Game/Screens/Multi/Match/Components/Header.cs +++ b/osu.Game/Screens/Multi/Match/Components/Header.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.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions.Color4Extensions; @@ -14,6 +15,10 @@ using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; using osu.Game.Online.Multiplayer; using osu.Game.Overlays.SearchableList; +using osu.Game.Rulesets.Mods; +using osu.Game.Screens.Multi.Components; +using osu.Game.Screens.Play.HUD; +using osuTK; using osuTK.Graphics; namespace osu.Game.Screens.Multi.Match.Components @@ -23,6 +28,8 @@ namespace osu.Game.Screens.Multi.Match.Components public const float HEIGHT = 200; public readonly Bindable Beatmap = new Bindable(); + public readonly IBindable Type = new Bindable(); + public readonly Bindable> Mods = new Bindable>(); private readonly Box tabStrip; @@ -30,25 +37,31 @@ namespace osu.Game.Screens.Multi.Match.Components public Action OnRequestSelectBeatmap; - public Header() + public Header(Room room) { RelativeSizeAxes = Axes.X; Height = HEIGHT; + BeatmapTypeInfo beatmapTypeInfo; BeatmapSelectButton beatmapButton; UpdateableBeatmapBackgroundSprite background; + ModDisplay modDisplay; + Children = new Drawable[] { new Container { RelativeSizeAxes = Axes.Both, Masking = true, - Child = background = new HeaderBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both } - }, - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0), Color4.Black.Opacity(0.5f)), + Children = new Drawable[] + { + background = new HeaderBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both }, + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourInfo.GradientVertical(Color4.Black.Opacity(0.4f), Color4.Black.Opacity(0.6f)), + }, + } }, tabStrip = new Box { @@ -60,9 +73,27 @@ namespace osu.Game.Screens.Multi.Match.Components new Container { RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding { Horizontal = SearchableListOverlay.WIDTH_PADDING }, + Padding = new MarginPadding + { + Left = SearchableListOverlay.WIDTH_PADDING, + Top = 20 + }, Children = new Drawable[] { + new FillFlowContainer + { + AutoSizeAxes = Axes.Both, + Direction = FillDirection.Vertical, + Children = new Drawable[] + { + beatmapTypeInfo = new BeatmapTypeInfo(), + modDisplay = new ModDisplay + { + Scale = new Vector2(0.75f), + DisplayUnrankedText = false + }, + } + }, new Container { Anchor = Anchor.TopRight, @@ -70,13 +101,13 @@ namespace osu.Game.Screens.Multi.Match.Components RelativeSizeAxes = Axes.Y, Width = 200, Padding = new MarginPadding { Vertical = 5 }, - Child = beatmapButton = new BeatmapSelectButton + Child = beatmapButton = new BeatmapSelectButton(room) { RelativeSizeAxes = Axes.Both, Height = 1 }, }, - Tabs = new MatchTabControl + Tabs = new MatchTabControl(room) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -86,6 +117,10 @@ namespace osu.Game.Screens.Multi.Match.Components }, }; + beatmapTypeInfo.Beatmap.BindTo(Beatmap); + beatmapTypeInfo.Type.BindTo(Type); + modDisplay.Current.BindTo(Mods); + beatmapButton.Action = () => OnRequestSelectBeatmap?.Invoke(); background.Beatmap.BindTo(Beatmap); @@ -101,17 +136,10 @@ namespace osu.Game.Screens.Multi.Match.Components { private readonly IBindable roomIDBind = new Bindable(); - [Resolved] - private Room room { get; set; } - - public BeatmapSelectButton() + public BeatmapSelectButton(Room room) { Text = "Select beatmap"; - } - [BackgroundDependencyLoader] - private void load() - { roomIDBind.BindTo(room.RoomID); roomIDBind.BindValueChanged(v => this.FadeTo(v.HasValue ? 0 : 1), true); } diff --git a/osu.Game/Screens/Multi/Match/Components/Info.cs b/osu.Game/Screens/Multi/Match/Components/Info.cs index f63135fc2d..e972a9b6a4 100644 --- a/osu.Game/Screens/Multi/Match/Components/Info.cs +++ b/osu.Game/Screens/Multi/Match/Components/Info.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions; @@ -14,9 +13,7 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Online.Multiplayer; using osu.Game.Overlays.SearchableList; -using osu.Game.Rulesets.Mods; using osu.Game.Screens.Multi.Components; -using osu.Game.Screens.Play.HUD; using osuTK; namespace osu.Game.Screens.Multi.Match.Components @@ -33,8 +30,6 @@ namespace osu.Game.Screens.Multi.Match.Components public readonly Bindable Availability = new Bindable(); public readonly Bindable Status = new Bindable(); public readonly Bindable Beatmap = new Bindable(); - public readonly Bindable Type = new Bindable(); - public readonly Bindable> Mods = new Bindable>(); public readonly Bindable EndDate = new Bindable(); public Info(Room room) @@ -44,9 +39,7 @@ namespace osu.Game.Screens.Multi.Match.Components ReadyButton readyButton; ViewBeatmapButton viewBeatmapButton; - BeatmapTypeInfo beatmapTypeInfo; OsuSpriteText name; - ModDisplay modDisplay; EndDateInfo endDate; Children = new Drawable[] @@ -82,20 +75,6 @@ namespace osu.Game.Screens.Multi.Match.Components endDate = new EndDateInfo { TextSize = 14 } } }, - new FillFlowContainer - { - AutoSizeAxes = Axes.Both, - Direction = FillDirection.Vertical, - Children = new Drawable[] - { - beatmapTypeInfo = new BeatmapTypeInfo(), - modDisplay = new ModDisplay - { - Scale = new Vector2(0.75f), - DisplayUnrankedText = false - }, - } - } }, }, new FillFlowContainer @@ -119,10 +98,6 @@ namespace osu.Game.Screens.Multi.Match.Components }, }; - beatmapTypeInfo.Beatmap.BindTo(Beatmap); - beatmapTypeInfo.Type.BindTo(Type); - modDisplay.Current.BindTo(Mods); - viewBeatmapButton.Beatmap.BindTo(Beatmap); readyButton.Beatmap.BindTo(Beatmap); diff --git a/osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs b/osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs index 538dcc341e..a9932ee3c6 100644 --- a/osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs +++ b/osu.Game/Screens/Multi/Match/Components/MatchTabControl.cs @@ -16,11 +16,10 @@ namespace osu.Game.Screens.Multi.Match.Components { private readonly IBindable roomIdBind = new Bindable(); - [Resolved] - private Room room { get; set; } - - public MatchTabControl() + public MatchTabControl(Room room) { + roomIdBind.BindTo(room.RoomID); + AddItem(new RoomMatchPage()); AddItem(new SettingsMatchPage()); } @@ -28,7 +27,6 @@ namespace osu.Game.Screens.Multi.Match.Components [BackgroundDependencyLoader] private void load() { - roomIdBind.BindTo(room.RoomID); roomIdBind.BindValueChanged(v => { if (v.HasValue) diff --git a/osu.Game/Screens/Multi/Match/Components/RoomSettingsOverlay.cs b/osu.Game/Screens/Multi/Match/Components/RoomSettingsOverlay.cs index d3098efb82..bab44d62b2 100644 --- a/osu.Game/Screens/Multi/Match/Components/RoomSettingsOverlay.cs +++ b/osu.Game/Screens/Multi/Match/Components/RoomSettingsOverlay.cs @@ -5,6 +5,7 @@ using System; using Humanizer; using osu.Framework.Allocation; using osu.Framework.Configuration; +using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -133,6 +134,7 @@ namespace osu.Game.Screens.Multi.Match.Components RelativeSizeAxes = Axes.X, Items = new[] { + TimeSpan.FromMinutes(1), TimeSpan.FromMinutes(30), TimeSpan.FromHours(1), TimeSpan.FromHours(2), @@ -159,14 +161,29 @@ namespace osu.Game.Screens.Multi.Match.Components }, }, }, - ApplyButton = new CreateRoomButton + new Container { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - Size = new Vector2(230, 35), - Margin = new MarginPadding { Bottom = 20 }, - Action = apply, - }, + Anchor = Anchor.BottomLeft, + Origin = Anchor.BottomLeft, + Y = 2, + RelativeSizeAxes = Axes.X, + Height = 60, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = OsuColour.FromHex(@"28242d").Darken(0.5f).Opacity(1f), + }, + ApplyButton = new CreateRoomButton + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Size = new Vector2(230, 35), + Action = apply, + }, + } + } }, }; diff --git a/osu.Game/Screens/Multi/Match/MatchScreen.cs b/osu.Game/Screens/Multi/Match/MatchScreen.cs index c169a5fb5d..656402d0f3 100644 --- a/osu.Game/Screens/Multi/Match/MatchScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchScreen.cs @@ -80,7 +80,7 @@ namespace osu.Game.Screens.Multi.Match RelativeSizeAxes = Axes.Both, Content = new[] { - new Drawable[] { header = new Components.Header { Depth = -1 } }, + new Drawable[] { header = new Components.Header(room) { Depth = -1 } }, new Drawable[] { info = new Info(room) { OnStart = onStart } }, new Drawable[] { @@ -135,9 +135,10 @@ namespace osu.Game.Screens.Multi.Match info.Name.BindTo(nameBind); info.Status.BindTo(statusBind); info.Availability.BindTo(availabilityBind); - info.Type.BindTo(typeBind); info.EndDate.BindTo(endDateBind); + header.Type.BindTo(typeBind); + participants.Users.BindTo(participantsBind); participants.MaxParticipants.BindTo(maxParticipantsBind); @@ -167,8 +168,8 @@ namespace osu.Game.Screens.Multi.Match var item = playlistBind.First(); header.Beatmap.Value = item.Beatmap; + header.Mods.Value = item.RequiredMods; info.Beatmap.Value = item.Beatmap; - info.Mods.Value = item.RequiredMods; // Todo: item.Beatmap can be null here... var localBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineBeatmapID == item.BeatmapID) ?? item.Beatmap;