1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-13 20:33:35 +08:00
Files
osu-lazer/osu.Desktop/Security/ElevatedPrivilegesChecker.cs
T
苦涩的冰 bca54380f1 Warn macOS users if game is not in location which can be automatically updated (#37083)
Updates can fail on macOS when osu! is run outside /Applications or
~/Applications, but users currently get no actionable guidance.

Add a startup notification that warns when the install location is
outside those directories, and skip this check for package-managed
installs where in-app updates are not used.

Resolves #36662.

---------

Co-authored-by: Dean Herbert <pe@ppy.sh>
2026-03-25 18:13:53 +09:00

50 lines
1.5 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 osu.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics;
using osu.Game.Localisation;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
namespace osu.Desktop.Security
{
/// <summary>
/// Checks if the game is running with elevated privileges (as admin in Windows, root in Unix) and displays a warning notification if so.
/// </summary>
public partial class ElevatedPrivilegesChecker : Component
{
[Resolved]
private INotificationOverlay notifications { get; set; } = null!;
protected override void LoadComplete()
{
base.LoadComplete();
if (Environment.IsPrivilegedProcess)
notifications.Post(new ElevatedPrivilegesNotification());
Expire();
}
private partial class ElevatedPrivilegesNotification : SimpleNotification
{
public ElevatedPrivilegesNotification()
{
Text = NotificationsStrings.ElevatedPrivileges(RuntimeInfo.IsUnix ? "root" : "Administrator");
}
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
Icon = FontAwesome.Solid.ShieldAlt;
IconContent.Colour = colours.YellowDark;
}
}
}
}