1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 03:22:54 +08:00

Split out setUserStatus() logic to multiple lines. +

Make UserStatusDoNotDisturb inherit from UserStatus
This commit is contained in:
Lucas A 2019-05-02 19:44:07 +02:00
parent e02def58f3
commit 84b41b3886
3 changed files with 13 additions and 5 deletions

View File

@ -12,6 +12,7 @@ using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play; using osu.Game.Screens.Play;
using osu.Game.Users;
using osuTK; using osuTK;
using osuTK.Input; using osuTK.Input;
@ -192,6 +193,8 @@ namespace osu.Game.Tests.Visual.Gameplay
public new HUDOverlay HUDOverlay => base.HUDOverlay; public new HUDOverlay HUDOverlay => base.HUDOverlay;
protected override UserStatus ScreenStatus => null;
public bool FailOverlayVisible => FailOverlay.State == Visibility.Visible; public bool FailOverlayVisible => FailOverlay.State == Visibility.Visible;
public bool PauseOverlayVisible => PauseOverlay.State == Visibility.Visible; public bool PauseOverlayVisible => PauseOverlay.State == Visibility.Visible;

View File

@ -143,7 +143,8 @@ namespace osu.Game.Screens
private void userStatusChanged(ValueChangedEvent<UserStatus> obj) private void userStatusChanged(ValueChangedEvent<UserStatus> obj)
{ {
if (obj.NewValue?.GetType() != ScreenStatus?.GetType()) //restore the status back to this screen's status when the user status is changed back to online after having being set to DND / offline if (obj.NewValue?.GetType() == ScreenStatus?.GetType()) return; //don't update the user's status if the current status is of the same type as the given one
setUserStatus(ScreenStatus); setUserStatus(ScreenStatus);
} }
@ -190,8 +191,12 @@ namespace osu.Game.Screens
private void setUserStatus(UserStatus status) private void setUserStatus(UserStatus status)
{ {
if (api != null && status != null && !(api.LocalUser.Value.Status.Value is UserStatusDoNotDisturb) && !(api.LocalUser.Value.Status.Value is UserStatusOffline)) //only sets the user's status to the given one if if (api == null) return;
api.LocalUser.Value.Status.Value = status; //status is not null and the current status isn't either UserStatusDoNotDisturb or UserStatusOffline if (status == null) return;
if (!(api.LocalUser.Value.Status.Value is UserStatusOnline)) return; //don't update the user's status if the current status doesn't allow to be modified by screens (eg: DND / Offline)
api.LocalUser.Value.Status.Value = status;
} }
/// <summary> /// <summary>

View File

@ -85,7 +85,7 @@ namespace osu.Game.Users
public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark; public override Color4 GetAppropriateColour(OsuColour colours) => colours.PurpleDark;
} }
public class UserStatusDoNotDisturb : UserStatusBusy public class UserStatusDoNotDisturb : UserStatus
{ {
public override string Message => @"Do not disturb"; public override string Message => @"Do not disturb";
public override Color4 GetAppropriateColour(OsuColour colours) => colours.RedDark; public override Color4 GetAppropriateColour(OsuColour colours) => colours.RedDark;