Block going into multiplayer while logged out

This commit is contained in:
smoogipoo 2018-12-04 17:43:27 +09:00
parent f2a57ce270
commit b251129c59
1 changed files with 28 additions and 5 deletions

View File

@ -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)