1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 14:57:25 +08:00
osu-lazer/osu.Game/Users/UserStatus.cs
Bartłomiej Dach d66fa09320
Simplify UserStatus to be an enumeration type
There were absolutely no gains from having it be a reference type /
class, only complications, especially when coming from the serialisation
angle.
2023-12-06 18:52:27 +01:00

46 lines
1.3 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.ComponentModel;
using osu.Framework.Localisation;
using osuTK.Graphics;
using osu.Game.Graphics;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Users
{
public enum UserStatus
{
[LocalisableDescription(typeof(UsersStrings), nameof(UsersStrings.StatusOffline))]
Offline,
[Description("Do not disturb")]
DoNotDisturb,
[LocalisableDescription(typeof(UsersStrings), nameof(UsersStrings.StatusOnline))]
Online,
}
public static class UserStatusExtensions
{
public static Color4 GetAppropriateColour(this UserStatus userStatus, OsuColour colours)
{
switch (userStatus)
{
case UserStatus.Offline:
return Color4.Black;
case UserStatus.DoNotDisturb:
return colours.RedDark;
case UserStatus.Online:
return colours.GreenDark;
default:
throw new ArgumentOutOfRangeException(nameof(userStatus), userStatus, "Unsupported user status");
}
}
}
}