mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 16:12:54 +08:00
Split out setUserStatus() logic to multiple lines. +
Make UserStatusDoNotDisturb inherit from UserStatus
This commit is contained in:
parent
e02def58f3
commit
84b41b3886
@ -12,6 +12,7 @@ using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Users;
|
||||
using osuTK;
|
||||
using osuTK.Input;
|
||||
|
||||
@ -192,6 +193,8 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
public new HUDOverlay HUDOverlay => base.HUDOverlay;
|
||||
|
||||
protected override UserStatus ScreenStatus => null;
|
||||
|
||||
public bool FailOverlayVisible => FailOverlay.State == Visibility.Visible;
|
||||
|
||||
public bool PauseOverlayVisible => PauseOverlay.State == Visibility.Visible;
|
||||
|
@ -143,8 +143,9 @@ namespace osu.Game.Screens
|
||||
|
||||
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
|
||||
setUserStatus(ScreenStatus);
|
||||
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);
|
||||
}
|
||||
|
||||
public override void OnSuspending(IScreen next)
|
||||
@ -190,8 +191,12 @@ namespace osu.Game.Screens
|
||||
|
||||
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
|
||||
api.LocalUser.Value.Status.Value = status; //status is not null and the current status isn't either UserStatusDoNotDisturb or UserStatusOffline
|
||||
if (api == null) return;
|
||||
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>
|
||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Users
|
||||
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 Color4 GetAppropriateColour(OsuColour colours) => colours.RedDark;
|
||||
|
Loading…
Reference in New Issue
Block a user