From bf3f5ab6854f0692e0a55f728b028d4a1f261f9c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 11 Dec 2018 17:32:01 +0900 Subject: [PATCH] Change ready button to "Start" and make it enter player --- osu.Game/Screens/Multi/Header.cs | 7 ++- .../Screens/Multi/Match/Components/Info.cs | 63 ++----------------- .../Multi/Match/Components/ReadyButton.cs | 50 +++++++++++++++ osu.Game/Screens/Multi/Match/MatchScreen.cs | 17 +++++ osu.Game/Screens/Multi/Multiplayer.cs | 18 +++--- .../Screens/Multi/Play/TimeshiftPlayer.cs | 11 ++++ 6 files changed, 100 insertions(+), 66 deletions(-) create mode 100644 osu.Game/Screens/Multi/Match/Components/ReadyButton.cs create mode 100644 osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs diff --git a/osu.Game/Screens/Multi/Header.cs b/osu.Game/Screens/Multi/Header.cs index 8e5a7381e9..570db11d50 100644 --- a/osu.Game/Screens/Multi/Header.cs +++ b/osu.Game/Screens/Multi/Header.cs @@ -85,7 +85,12 @@ public Header(Screen initialScreen) }, }; - breadcrumbs.Current.ValueChanged += s => screenType.Text = ((IMultiplayerScreen)s).ShortTitle.ToLowerInvariant(); + breadcrumbs.Current.ValueChanged += s => + { + if (s is IMultiplayerScreen mpScreen) + screenType.Text = mpScreen.ShortTitle.ToLowerInvariant(); + }; + breadcrumbs.Current.TriggerChange(); } diff --git a/osu.Game/Screens/Multi/Match/Components/Info.cs b/osu.Game/Screens/Multi/Match/Components/Info.cs index b3de5abf67..f13bf710e6 100644 --- a/osu.Game/Screens/Multi/Match/Components/Info.cs +++ b/osu.Game/Screens/Multi/Match/Components/Info.cs @@ -1,17 +1,16 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System; using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; -using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Graphics; using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Overlays.SearchableList; using osu.Game.Screens.Multi.Components; @@ -23,13 +22,12 @@ public class Info : Container { public const float HEIGHT = 128; + public Action OnStart; + private readonly OsuSpriteText availabilityStatus; - private readonly ReadyButton readyButton; private OsuColour colours; - public Bindable Ready => readyButton.Ready; - public readonly Bindable Name = new Bindable(); public readonly Bindable Availability = new Bindable(); public readonly Bindable Status = new Bindable(); @@ -81,13 +79,14 @@ public Info() }, }, }, - readyButton = new ReadyButton + new ReadyButton { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Y, Size = new Vector2(200, 1), Padding = new MarginPadding { Vertical = 10 }, + Action = () => OnStart?.Invoke() }, }, }, @@ -125,57 +124,5 @@ private void updateAvailabilityStatus() availabilityStatus.Text = $"{Availability.Value.GetDescription()}, {Status.Value.Message}"; } } - - private class ReadyButton : TriangleButton - { - public readonly Bindable Ready = new Bindable(); - - protected override SpriteText CreateText() => new OsuSpriteText - { - Depth = -1, - Origin = Anchor.Centre, - Anchor = Anchor.Centre, - Font = @"Exo2.0-Light", - TextSize = 30, - }; - - [BackgroundDependencyLoader] - private void load() - { - BackgroundColour = OsuColour.FromHex(@"1187aa"); - Triangles.ColourLight = OsuColour.FromHex(@"277b9c"); - Triangles.ColourDark = OsuColour.FromHex(@"1f6682"); - Triangles.TriangleScale = 1.5f; - - Container active; - Add(active = new Container - { - RelativeSizeAxes = Axes.Both, - Alpha = 0f, - Child = new Box - { - RelativeSizeAxes = Axes.Both, - Alpha = 0.15f, - Blending = BlendingMode.Additive, - }, - }); - - Action = () => Ready.Value = !Ready.Value; - - Ready.BindValueChanged(value => - { - if (value) - { - Text = "Not Ready"; - active.FadeIn(200); - } - else - { - Text = "Ready"; - active.FadeOut(200); - } - }, true); - } - } } } diff --git a/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs new file mode 100644 index 0000000000..f0ca013b62 --- /dev/null +++ b/osu.Game/Screens/Multi/Match/Components/ReadyButton.cs @@ -0,0 +1,50 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Framework.Graphics.Sprites; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Screens.Multi.Match.Components +{ + public class ReadyButton : TriangleButton + { + [BackgroundDependencyLoader] + private void load() + { + BackgroundColour = OsuColour.FromHex(@"1187aa"); + + Triangles.ColourLight = OsuColour.FromHex(@"277b9c"); + Triangles.ColourDark = OsuColour.FromHex(@"1f6682"); + Triangles.TriangleScale = 1.5f; + + Text = "Start"; + + Add(new Container + { + RelativeSizeAxes = Axes.Both, + Alpha = 1f, + Child = new Box + { + RelativeSizeAxes = Axes.Both, + Alpha = 0.15f, + Blending = BlendingMode.Additive, + }, + }); + } + + protected override SpriteText CreateText() => new OsuSpriteText + { + Depth = -1, + Origin = Anchor.Centre, + Anchor = Anchor.Centre, + Font = @"Exo2.0-Light", + TextSize = 30, + }; + } +} diff --git a/osu.Game/Screens/Multi/Match/MatchScreen.cs b/osu.Game/Screens/Multi/Match/MatchScreen.cs index 755b071f30..bbc4e2f4e0 100644 --- a/osu.Game/Screens/Multi/Match/MatchScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchScreen.cs @@ -10,6 +10,8 @@ using osu.Game.Online.API; using osu.Game.Online.Multiplayer; using osu.Game.Screens.Multi.Match.Components; +using osu.Game.Screens.Multi.Play; +using osu.Game.Screens.Play; using osu.Game.Screens.Select; using osu.Game.Users; @@ -36,6 +38,9 @@ public class MatchScreen : MultiplayerScreen [Cached] private readonly Room room; + [Resolved] + private Multiplayer multiplayer { get; set; } + [Resolved] private BeatmapManager beatmapManager { get; set; } @@ -67,6 +72,7 @@ public MatchScreen(Room room) info = new Info { Margin = new MarginPadding { Top = Components.Header.HEIGHT }, + OnStart = onStart }, participants = new Participants { @@ -113,5 +119,16 @@ private void load() beatmapBind.BindValueChanged(b => Beatmap.Value = beatmapManager.GetWorkingBeatmap(room.Beatmap.Value), true); Beatmap.BindValueChanged(b => beatmapBind.Value = b.BeatmapInfo); } + + private void onStart() + { + switch (typeBind.Value) + { + default: + case GameTypeTimeshift _: + multiplayer.Push(new PlayerLoader(new TimeshiftPlayer())); + break; + } + } } } diff --git a/osu.Game/Screens/Multi/Multiplayer.cs b/osu.Game/Screens/Multi/Multiplayer.cs index d90e9ea33d..566621ffcd 100644 --- a/osu.Game/Screens/Multi/Multiplayer.cs +++ b/osu.Game/Screens/Multi/Multiplayer.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; @@ -13,21 +14,20 @@ namespace osu.Game.Screens.Multi { + [Cached] public class Multiplayer : OsuScreen { private readonly MultiplayerWaveContainer waves; - protected override Container Content => waves; - public Multiplayer() { - InternalChild = waves = new MultiplayerWaveContainer + Child = waves = new MultiplayerWaveContainer { RelativeSizeAxes = Axes.Both, }; LoungeScreen loungeScreen; - Children = new Drawable[] + waves.AddRange(new Drawable[] { new Container { @@ -56,7 +56,7 @@ public Multiplayer() Child = loungeScreen = new LoungeScreen(), }, new Header(loungeScreen), - }; + }); loungeScreen.Exited += s => Exit(); } @@ -76,13 +76,17 @@ protected override bool OnExiting(Screen next) protected override void OnResuming(Screen last) { base.OnResuming(last); - waves.Show(); + + Content.FadeIn(250); + Content.ScaleTo(1, 250, Easing.OutSine); } protected override void OnSuspending(Screen next) { + Content.ScaleTo(1.1f, 250, Easing.InSine); + Content.FadeOut(250); + base.OnSuspending(next); - waves.Hide(); } protected override void LogoExiting(OsuLogo logo) diff --git a/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs new file mode 100644 index 0000000000..114d90dc79 --- /dev/null +++ b/osu.Game/Screens/Multi/Play/TimeshiftPlayer.cs @@ -0,0 +1,11 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Screens.Play; + +namespace osu.Game.Screens.Multi.Play +{ + public class TimeshiftPlayer : Player + { + } +}