From b251129c596a62841f34c9830f75e8c5e2f6a397 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Tue, 4 Dec 2018 17:43:27 +0900 Subject: [PATCH] Block going into multiplayer while logged out --- osu.Game/Screens/Menu/ButtonSystem.cs | 33 +++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/Menu/ButtonSystem.cs b/osu.Game/Screens/Menu/ButtonSystem.cs index ae1f27610b..943dfa53af 100644 --- a/osu.Game/Screens/Menu/ButtonSystem.cs +++ b/osu.Game/Screens/Menu/ButtonSystem.cs @@ -17,7 +17,9 @@ using osu.Game.Graphics; using osu.Game.Input; using osu.Game.Input.Bindings; +using osu.Game.Online.API; using osu.Game.Overlays; +using osu.Game.Overlays.Notifications; using osuTK; using osuTK.Graphics; using osuTK.Input; @@ -90,7 +92,7 @@ public ButtonSystem() buttonArea.Flow.CentreTarget = iconFacade; buttonsPlay.Add(new Button(@"solo", @"button-solo-select", FontAwesome.fa_user, new Color4(102, 68, 204, 255), () => OnSolo?.Invoke(), WEDGE_WIDTH, Key.P)); - buttonsPlay.Add(new Button(@"multi", @"button-generic-select", FontAwesome.fa_users, new Color4(94, 63, 186, 255), () => OnMulti?.Invoke(), 0, Key.M)); + buttonsPlay.Add(new Button(@"multi", @"button-generic-select", FontAwesome.fa_users, new Color4(94, 63, 186, 255), onMulti, 0, Key.M)); buttonsPlay.Add(new Button(@"chart", @"button-generic-select", FontAwesome.fa_osu_charts, new Color4(80, 53, 160, 255), () => OnChart?.Invoke())); buttonsPlay.ForEach(b => b.VisibleState = ButtonSystemState.Play); @@ -103,19 +105,40 @@ public ButtonSystem() buttonArea.AddRange(buttonsTopLevel); } - private OsuGame game; + [Resolved] + private OsuGame game { get; set; } + + [Resolved] + private APIAccess api { get; set; } + + [Resolved] + private NotificationOverlay notifications { get; set; } [BackgroundDependencyLoader(true)] - private void load(AudioManager audio, OsuGame game, IdleTracker idleTracker) + private void load(AudioManager audio, IdleTracker idleTracker) { - this.game = game; - isIdle.ValueChanged += updateIdleState; + if (idleTracker != null) isIdle.BindTo(idleTracker.IsIdle); sampleBack = audio.Sample.Get(@"Menu/button-back-select"); } + private void onMulti() + { + if (!api.IsLoggedIn) + { + notifications.Post(new SimpleNotification + { + Text = "You gotta be logged in to multi 'yo!", + Icon = FontAwesome.fa_globe + }); + + return; + } + OnMulti?.Invoke(); + } + private void updateIdleState(bool isIdle) { if (isIdle && State != ButtonSystemState.Exit)