mirror of
https://github.com/ppy/osu.git
synced 2026-05-20 19:40:38 +08:00
update to new API
This commit is contained in:
@@ -128,8 +128,7 @@ namespace osu.Desktop
|
||||
|
||||
LoadComponentAsync(new ElevatedPrivilegesChecker(), Add);
|
||||
|
||||
if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows)
|
||||
LoadComponentAsync(new BossKeyManager(), Add);
|
||||
LoadComponentAsync(new BossKeyManager(), Add);
|
||||
|
||||
osuSchemeLinkIPCChannel = new OsuSchemeLinkIPCChannel(Host, this);
|
||||
archiveImportIPCChannel = new ArchiveImportIPCChannel(Host, this);
|
||||
|
||||
@@ -2,11 +2,13 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Platform.SDL3;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Framework.Logging;
|
||||
using System;
|
||||
|
||||
namespace osu.Desktop.Platform
|
||||
{
|
||||
@@ -18,6 +20,8 @@ namespace osu.Desktop.Platform
|
||||
[Resolved]
|
||||
private VolumeOverlay volumeOverlay { get; set; } = null!;
|
||||
|
||||
private IDisposable? activeTrayIcon = null!;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@@ -27,14 +31,40 @@ namespace osu.Desktop.Platform
|
||||
{
|
||||
if (e.Action == GlobalAction.BossKey && !e.Repeat)
|
||||
{
|
||||
host.Window.Hide();
|
||||
bool previousState = volumeOverlay.IsMuted.Value;
|
||||
|
||||
host.Window.CreateNotificationTrayIcon("osu!", () => Schedule(() => onShow(previousState)));
|
||||
Logger.Log($"Created notification tray icon");
|
||||
volumeOverlay.IsMuted.Value = true;
|
||||
|
||||
return true;
|
||||
if (host.Window is ISDLWindow window)
|
||||
{
|
||||
// TODO: add icon
|
||||
var icon = new TrayIcon
|
||||
{
|
||||
Label = "osu!",
|
||||
Menu = new TrayMenuEntry[]
|
||||
{
|
||||
new TrayButton
|
||||
{
|
||||
Label = "Open osu!",
|
||||
Action = () => Schedule(() => onShow(previousState)),
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
Schedule(() => { activeTrayIcon = window.CreateTrayIcon(icon); });
|
||||
}
|
||||
catch (PlatformNotSupportedException ex)
|
||||
{
|
||||
Logger.Log($"aaaa");
|
||||
return false;
|
||||
}
|
||||
|
||||
host.Window.Hide();
|
||||
Logger.Log($"Created notification tray icon");
|
||||
volumeOverlay.IsMuted.Value = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -45,7 +75,8 @@ namespace osu.Desktop.Platform
|
||||
Logger.Log($"Notification tray icon clicked");
|
||||
host.Window.Show();
|
||||
host.Window.Raise();
|
||||
host.Window.RemoveNotificationTrayIcon();
|
||||
|
||||
activeTrayIcon.Dispose();
|
||||
Logger.Log($"Notification tray icon removed");
|
||||
volumeOverlay.IsMuted.Value = previousState;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user