Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add boss key on windows #28972

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions osu.Desktop/OsuGameDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.Win32;
using osu.Desktop.Performance;
using osu.Desktop.Security;
using osu.Desktop.Platform;
using osu.Framework.Platform;
using osu.Game;
using osu.Desktop.Updater;
Expand Down Expand Up @@ -144,6 +145,9 @@ protected override void LoadComplete()

LoadComponentAsync(new ElevatedPrivilegesChecker(), Add);

if (RuntimeInfo.OS == RuntimeInfo.Platform.Windows)
LoadComponentAsync(new BossKeyManager(), Add);

osuSchemeLinkIPCChannel = new OsuSchemeLinkIPCChannel(Host, this);
archiveImportIPCChannel = new ArchiveImportIPCChannel(Host, this);
}
Expand Down
57 changes: 57 additions & 0 deletions osu.Desktop/Platform/BossKeyManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Framework.Allocation;
using osu.Framework.Platform;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Input.Bindings;
using osu.Game.Overlays;
using osu.Framework.Logging;

namespace osu.Desktop.Platform
{
internal partial class BossKeyManager : Component, IKeyBindingHandler<GlobalAction>, IHandleGlobalKeyboardInput
{
[Resolved]
private GameHost host { get; set; } = null!;

[Resolved]
private VolumeOverlay volumeOverlay { get; set; } = null!;

[BackgroundDependencyLoader]
private void load()
{
}

public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Action == GlobalAction.BossKey && !e.Repeat)
{
host.Window.Hide();
bool previousState = volumeOverlay.IsMuted.Value;

Check failure on line 32 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)

Check failure on line 32 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Code Quality

Fix formatting (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0055)
host.Window.CreateNotificationTrayIcon("osu!", () => Schedule(() => onShow(previousState)));

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 33 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'IWindow' does not contain a definition for 'CreateNotificationTrayIcon' and no accessible extension method 'CreateNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)
Logger.Log($"Created notification tray icon");
volumeOverlay.IsMuted.Value = true;

return true;
}

return false;
}

private void onShow(bool previousState)
{
Logger.Log($"Notification tray icon clicked");
host.Window.Show();
host.Window.Raise();
host.Window.RemoveNotificationTrayIcon();

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 48 in osu.Desktop/Platform/BossKeyManager.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'IWindow' does not contain a definition for 'RemoveNotificationTrayIcon' and no accessible extension method 'RemoveNotificationTrayIcon' accepting a first argument of type 'IWindow' could be found (are you missing a using directive or an assembly reference?)
Logger.Log($"Notification tray icon removed");
volumeOverlay.IsMuted.Value = previousState;
}

public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}
}
}
52 changes: 33 additions & 19 deletions osu.Game/Input/Bindings/GlobalActionContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,45 @@ public static IEnumerable<GlobalAction> GetGlobalActionsFor(GlobalActionCategory

public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e) => handler?.OnReleased(e);

private static IEnumerable<KeyBinding> globalKeyBindings => new[]
private static IEnumerable<KeyBinding> globalKeyBindings
{
new KeyBinding(InputKey.Up, GlobalAction.SelectPrevious),
new KeyBinding(InputKey.Down, GlobalAction.SelectNext),
get
{
KeyBinding[] bindings = new[]
{
new KeyBinding(InputKey.Up, GlobalAction.SelectPrevious),
new KeyBinding(InputKey.Down, GlobalAction.SelectNext),

new KeyBinding(InputKey.Left, GlobalAction.SelectPreviousGroup),
new KeyBinding(InputKey.Right, GlobalAction.SelectNextGroup),
new KeyBinding(InputKey.Left, GlobalAction.SelectPreviousGroup),
new KeyBinding(InputKey.Right, GlobalAction.SelectNextGroup),

new KeyBinding(InputKey.Space, GlobalAction.Select),
new KeyBinding(InputKey.Enter, GlobalAction.Select),
new KeyBinding(InputKey.KeypadEnter, GlobalAction.Select),
new KeyBinding(InputKey.Space, GlobalAction.Select),
new KeyBinding(InputKey.Enter, GlobalAction.Select),
new KeyBinding(InputKey.KeypadEnter, GlobalAction.Select),

new KeyBinding(InputKey.Escape, GlobalAction.Back),
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),
new KeyBinding(InputKey.Escape, GlobalAction.Back),
new KeyBinding(InputKey.ExtraMouseButton1, GlobalAction.Back),

new KeyBinding(new[] { InputKey.Alt, InputKey.Home }, GlobalAction.Home),
new KeyBinding(new[] { InputKey.Alt, InputKey.Home }, GlobalAction.Home),

new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.F }, GlobalAction.ToggleFPSDisplay),
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.S }, GlobalAction.ToggleSkinEditor),
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.F }, GlobalAction.ToggleFPSDisplay),
new KeyBinding(new[] { InputKey.Control, InputKey.T }, GlobalAction.ToggleToolbar),
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.S }, GlobalAction.ToggleSkinEditor),

new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),
new KeyBinding(new[] { InputKey.Control, InputKey.Alt, InputKey.R }, GlobalAction.ResetInputSettings),

new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.R }, GlobalAction.RandomSkin),
new KeyBinding(new[] { InputKey.Control, InputKey.Shift, InputKey.R }, GlobalAction.RandomSkin),

new KeyBinding(InputKey.F10, GlobalAction.ToggleGameplayMouseButtons),
new KeyBinding(InputKey.F12, GlobalAction.TakeScreenshot),
};
new KeyBinding(InputKey.F10, GlobalAction.ToggleGameplayMouseButtons),
new KeyBinding(InputKey.F12, GlobalAction.TakeScreenshot),
};

if (OperatingSystem.IsWindows())
return bindings.Append(new KeyBinding(InputKey.Insert, GlobalAction.BossKey));

return bindings;
}
}

private static IEnumerable<KeyBinding> overlayKeyBindings => new[]
{
Expand Down Expand Up @@ -456,6 +467,9 @@ public enum GlobalAction

[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorTestPlayQuickExitToCurrentTime))]
EditorTestPlayQuickExitToCurrentTime,

[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.BossKey))]
BossKey,
}

public enum GlobalActionCategory
Expand Down
5 changes: 5 additions & 0 deletions osu.Game/Localisation/GlobalActionKeyBindingStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ public static class GlobalActionKeyBindingStrings
/// </summary>
public static LocalisableString DecreaseModSpeed => new TranslatableString(getKey(@"decrease_mod_speed"), @"Decrease mod speed");

/// <summary>
/// "Boss Key"
/// </summary>
public static LocalisableString BossKey => new TranslatableString(getKey(@"boss_key"), @"Boss Key");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
Loading