2019-01-24 08:43:03 +00:00
// 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.
2018-04-13 09:19:50 +00:00
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Linq ;
using osu.Framework.Graphics ;
using osu.Framework.Input ;
using osu.Framework.Input.Bindings ;
namespace osu.Game.Input.Bindings
{
2019-08-27 09:42:49 +00:00
public class GlobalActionContainer : DatabasedKeyBindingContainer < GlobalAction > , IHandleGlobalKeyboardInput
2018-04-13 09:19:50 +00:00
{
private readonly Drawable handler ;
2021-04-08 06:17:53 +00:00
private InputManager parentInputManager ;
2018-04-13 09:19:50 +00:00
public GlobalActionContainer ( OsuGameBase game )
2020-03-02 09:54:00 +00:00
: base ( matchingMode : KeyCombinationMatchingMode . Modifiers )
2018-04-13 09:19:50 +00:00
{
if ( game is IKeyBindingHandler < GlobalAction > )
handler = game ;
}
2021-04-08 06:17:53 +00:00
protected override void LoadComplete ( )
{
base . LoadComplete ( ) ;
parentInputManager = GetContainingInputManager ( ) ;
}
2021-04-07 08:13:25 +00:00
public override IEnumerable < IKeyBinding > DefaultKeyBindings = > GlobalKeyBindings
2021-04-07 08:41:05 +00:00
. Concat ( EditorKeyBindings )
2021-04-07 08:13:25 +00:00
. Concat ( InGameKeyBindings )
. Concat ( SongSelectKeyBindings )
2021-04-07 08:41:05 +00:00
. Concat ( AudioControlKeyBindings ) ;
2018-04-13 09:19:50 +00:00
public IEnumerable < KeyBinding > GlobalKeyBindings = > new [ ]
{
2020-01-11 19:43:51 +00:00
new KeyBinding ( InputKey . F6 , GlobalAction . ToggleNowPlaying ) ,
2018-04-13 09:19:50 +00:00
new KeyBinding ( InputKey . F8 , GlobalAction . ToggleChat ) ,
new KeyBinding ( InputKey . F9 , GlobalAction . ToggleSocial ) ,
2018-05-02 10:42:03 +00:00
new KeyBinding ( InputKey . F10 , GlobalAction . ToggleGameplayMouseButtons ) ,
2018-05-14 17:27:05 +00:00
new KeyBinding ( InputKey . F12 , GlobalAction . TakeScreenshot ) ,
2018-04-13 09:19:50 +00:00
new KeyBinding ( new [ ] { InputKey . Control , InputKey . Alt , InputKey . R } , GlobalAction . ResetInputSettings ) ,
new KeyBinding ( new [ ] { InputKey . Control , InputKey . T } , GlobalAction . ToggleToolbar ) ,
new KeyBinding ( new [ ] { InputKey . Control , InputKey . O } , GlobalAction . ToggleSettings ) ,
2021-01-06 14:12:56 +00:00
new KeyBinding ( new [ ] { InputKey . Control , InputKey . D } , GlobalAction . ToggleBeatmapListing ) ,
2020-07-10 19:05:23 +00:00
new KeyBinding ( new [ ] { InputKey . Control , InputKey . N } , GlobalAction . ToggleNotifications ) ,
2018-05-14 17:27:05 +00:00
new KeyBinding ( InputKey . Escape , GlobalAction . Back ) ,
2019-07-11 13:21:37 +00:00
new KeyBinding ( InputKey . ExtraMouseButton1 , GlobalAction . Back ) ,
2018-07-03 09:37:21 +00:00
2020-06-14 18:22:38 +00:00
new KeyBinding ( new [ ] { InputKey . Alt , InputKey . Home } , GlobalAction . Home ) ,
2020-03-02 09:55:28 +00:00
new KeyBinding ( InputKey . Up , GlobalAction . SelectPrevious ) ,
new KeyBinding ( InputKey . Down , GlobalAction . SelectNext ) ,
2018-07-03 09:37:21 +00:00
new KeyBinding ( InputKey . Space , GlobalAction . Select ) ,
new KeyBinding ( InputKey . Enter , GlobalAction . Select ) ,
2018-11-13 17:09:28 +00:00
new KeyBinding ( InputKey . KeypadEnter , GlobalAction . Select ) ,
2020-11-11 04:05:03 +00:00
new KeyBinding ( new [ ] { InputKey . Control , InputKey . Shift , InputKey . R } , GlobalAction . RandomSkin ) ,
2018-04-13 09:19:50 +00:00
} ;
2020-09-22 06:55:25 +00:00
public IEnumerable < KeyBinding > EditorKeyBindings = > new [ ]
{
new KeyBinding ( new [ ] { InputKey . F1 } , GlobalAction . EditorComposeMode ) ,
new KeyBinding ( new [ ] { InputKey . F2 } , GlobalAction . EditorDesignMode ) ,
new KeyBinding ( new [ ] { InputKey . F3 } , GlobalAction . EditorTimingMode ) ,
new KeyBinding ( new [ ] { InputKey . F4 } , GlobalAction . EditorSetupMode ) ,
2021-04-12 07:15:27 +00:00
new KeyBinding ( new [ ] { InputKey . Control , InputKey . Shift , InputKey . A } , GlobalAction . EditorVerifyMode ) ,
2020-09-22 06:55:25 +00:00
} ;
2018-04-13 09:19:50 +00:00
public IEnumerable < KeyBinding > InGameKeyBindings = > new [ ]
{
new KeyBinding ( InputKey . Space , GlobalAction . SkipCutscene ) ,
2020-08-18 06:21:44 +00:00
new KeyBinding ( InputKey . ExtraMouseButton2 , GlobalAction . SkipCutscene ) ,
2018-05-31 03:06:50 +00:00
new KeyBinding ( InputKey . Tilde , GlobalAction . QuickRetry ) ,
2019-06-24 09:19:17 +00:00
new KeyBinding ( new [ ] { InputKey . Control , InputKey . Tilde } , GlobalAction . QuickExit ) ,
2018-05-31 03:06:50 +00:00
new KeyBinding ( new [ ] { InputKey . Control , InputKey . Plus } , GlobalAction . IncreaseScrollSpeed ) ,
new KeyBinding ( new [ ] { InputKey . Control , InputKey . Minus } , GlobalAction . DecreaseScrollSpeed ) ,
2020-12-01 02:38:16 +00:00
new KeyBinding ( new [ ] { InputKey . Shift , InputKey . Tab } , GlobalAction . ToggleInGameInterface ) ,
2020-07-12 14:03:03 +00:00
new KeyBinding ( InputKey . MouseMiddle , GlobalAction . PauseGameplay ) ,
2020-11-26 11:04:44 +00:00
new KeyBinding ( InputKey . Space , GlobalAction . TogglePauseReplay ) ,
2020-10-30 05:19:40 +00:00
new KeyBinding ( InputKey . Control , GlobalAction . HoldForHUD ) ,
2018-04-13 09:19:50 +00:00
} ;
2020-06-03 05:55:15 +00:00
public IEnumerable < KeyBinding > SongSelectKeyBindings = > new [ ]
{
2020-06-03 06:13:02 +00:00
new KeyBinding ( InputKey . F1 , GlobalAction . ToggleModSelection ) ,
new KeyBinding ( InputKey . F2 , GlobalAction . SelectNextRandom ) ,
new KeyBinding ( new [ ] { InputKey . Shift , InputKey . F2 } , GlobalAction . SelectPreviousRandom ) ,
new KeyBinding ( InputKey . F3 , GlobalAction . ToggleBeatmapOptions )
2020-06-03 05:55:15 +00:00
} ;
2019-08-13 03:40:20 +00:00
public IEnumerable < KeyBinding > AudioControlKeyBindings = > new [ ]
{
2020-03-02 09:59:05 +00:00
new KeyBinding ( new [ ] { InputKey . Alt , InputKey . Up } , GlobalAction . IncreaseVolume ) ,
new KeyBinding ( new [ ] { InputKey . Alt , InputKey . Down } , GlobalAction . DecreaseVolume ) ,
2020-09-23 03:31:50 +00:00
new KeyBinding ( new [ ] { InputKey . Control , InputKey . F4 } , GlobalAction . ToggleMute ) ,
2019-08-13 03:40:20 +00:00
new KeyBinding ( InputKey . TrackPrevious , GlobalAction . MusicPrev ) ,
new KeyBinding ( InputKey . F1 , GlobalAction . MusicPrev ) ,
new KeyBinding ( InputKey . TrackNext , GlobalAction . MusicNext ) ,
new KeyBinding ( InputKey . F5 , GlobalAction . MusicNext ) ,
new KeyBinding ( InputKey . PlayPause , GlobalAction . MusicPlay ) ,
new KeyBinding ( InputKey . F3 , GlobalAction . MusicPlay )
} ;
2021-04-05 13:30:51 +00:00
protected override IEnumerable < Drawable > KeyBindingInputQueue
{
get
{
2021-04-08 06:17:53 +00:00
// To ensure the global actions are handled with priority, this GlobalActionContainer is actually placed after game content.
// It does not contain children as expected, so we need to forward the NonPositionalInputQueue from the parent input manager to correctly
// allow the whole game to handle these actions.
// An eventual solution to this hack is to create localised action containers for individual components like SongSelect, but this will take some rearranging.
var inputQueue = parentInputManager ? . NonPositionalInputQueue ? ? base . KeyBindingInputQueue ;
2021-03-30 10:03:15 +00:00
2021-04-05 13:30:51 +00:00
return handler ! = null ? inputQueue . Prepend ( handler ) : inputQueue ;
}
}
2018-04-13 09:19:50 +00:00
}
public enum GlobalAction
{
[Description("Toggle chat overlay")]
ToggleChat ,
2019-02-28 04:31:40 +00:00
2018-04-13 09:19:50 +00:00
[Description("Toggle social overlay")]
ToggleSocial ,
2019-02-28 04:31:40 +00:00
2018-04-13 09:19:50 +00:00
[Description("Reset input settings")]
ResetInputSettings ,
2019-02-28 04:31:40 +00:00
2018-04-13 09:19:50 +00:00
[Description("Toggle toolbar")]
ToggleToolbar ,
2019-02-28 04:31:40 +00:00
2018-04-13 09:19:50 +00:00
[Description("Toggle settings")]
ToggleSettings ,
2019-02-28 04:31:40 +00:00
2021-01-06 13:56:10 +00:00
[Description("Toggle beatmap listing")]
2021-01-06 14:12:56 +00:00
ToggleBeatmapListing ,
2019-02-28 04:31:40 +00:00
2018-09-15 14:30:11 +00:00
[Description("Increase volume")]
2018-04-13 09:19:50 +00:00
IncreaseVolume ,
2019-02-28 04:31:40 +00:00
2018-09-15 14:30:11 +00:00
[Description("Decrease volume")]
2018-04-13 09:19:50 +00:00
DecreaseVolume ,
2019-02-28 04:31:40 +00:00
2018-04-13 09:19:50 +00:00
[Description("Toggle mute")]
ToggleMute ,
// In-Game Keybindings
2018-09-15 14:30:11 +00:00
[Description("Skip cutscene")]
2018-04-13 09:19:50 +00:00
SkipCutscene ,
2019-02-28 04:31:40 +00:00
2018-09-15 14:30:11 +00:00
[Description("Quick retry (hold)")]
2018-04-13 09:19:50 +00:00
QuickRetry ,
[Description("Take screenshot")]
2018-05-14 17:27:05 +00:00
TakeScreenshot ,
2019-02-28 04:31:40 +00:00
2018-05-02 10:37:47 +00:00
[Description("Toggle gameplay mouse buttons")]
2018-05-02 10:42:03 +00:00
ToggleGameplayMouseButtons ,
2018-05-14 17:27:05 +00:00
2018-07-03 09:37:21 +00:00
[Description("Back")]
2018-05-31 03:06:50 +00:00
Back ,
[Description("Increase scroll speed")]
IncreaseScrollSpeed ,
[Description("Decrease scroll speed")]
DecreaseScrollSpeed ,
2018-07-03 09:37:21 +00:00
[Description("Select")]
Select ,
2019-06-25 08:16:19 +00:00
2020-12-04 08:51:46 +00:00
[Description("Quick exit (hold)")]
2019-06-25 08:16:19 +00:00
QuickExit ,
2019-08-11 17:14:49 +00:00
2020-09-22 06:55:25 +00:00
// Game-wide beatmap music controller keybindings
2019-08-13 03:06:57 +00:00
[Description("Next track")]
2019-08-11 17:14:49 +00:00
MusicNext ,
2019-08-13 03:06:57 +00:00
[Description("Previous track")]
2019-08-11 17:14:49 +00:00
MusicPrev ,
2019-08-13 03:06:57 +00:00
[Description("Play / pause")]
2019-08-11 17:14:49 +00:00
MusicPlay ,
2020-01-11 19:43:51 +00:00
[Description("Toggle now playing overlay")]
ToggleNowPlaying ,
2020-03-02 09:55:28 +00:00
2020-11-26 11:07:16 +00:00
[Description("Previous selection")]
2020-03-02 09:55:28 +00:00
SelectPrevious ,
2020-11-26 11:07:16 +00:00
[Description("Next selection")]
2020-03-02 09:55:28 +00:00
SelectNext ,
2020-06-14 18:22:38 +00:00
[Description("Home")]
Home ,
2020-07-12 14:03:03 +00:00
2020-07-10 19:05:23 +00:00
[Description("Toggle notifications")]
2020-07-13 22:39:02 +00:00
ToggleNotifications ,
2020-07-14 11:37:21 +00:00
2020-11-26 11:07:16 +00:00
[Description("Pause gameplay")]
2020-07-12 14:03:03 +00:00
PauseGameplay ,
2020-09-22 06:55:25 +00:00
// Editor
2020-11-26 11:07:16 +00:00
[Description("Setup mode")]
2020-09-22 06:55:25 +00:00
EditorSetupMode ,
2020-11-26 11:07:16 +00:00
[Description("Compose mode")]
2020-09-22 06:55:25 +00:00
EditorComposeMode ,
2020-11-26 11:07:16 +00:00
[Description("Design mode")]
2020-09-22 06:55:25 +00:00
EditorDesignMode ,
2020-11-26 11:07:16 +00:00
[Description("Timing mode")]
2020-09-22 06:55:25 +00:00
EditorTimingMode ,
2020-10-30 05:19:40 +00:00
[Description("Hold for HUD")]
HoldForHUD ,
2020-11-11 04:05:03 +00:00
2020-11-26 11:07:16 +00:00
[Description("Random skin")]
2020-11-11 04:05:03 +00:00
RandomSkin ,
2020-11-24 06:41:56 +00:00
2020-11-26 11:04:44 +00:00
[Description("Pause / resume replay")]
TogglePauseReplay ,
2020-12-01 02:38:16 +00:00
[Description("Toggle in-game interface")]
ToggleInGameInterface ,
2021-04-07 08:13:25 +00:00
2020-06-07 03:37:19 +00:00
// Song select keybindings
2020-06-15 09:44:38 +00:00
[Description("Toggle Mod Select")]
2020-06-07 03:37:19 +00:00
ToggleModSelection ,
2020-06-15 09:44:38 +00:00
[Description("Random")]
2020-06-07 03:37:19 +00:00
SelectNextRandom ,
2020-06-15 09:44:38 +00:00
[Description("Rewind")]
2020-06-07 03:37:19 +00:00
SelectPreviousRandom ,
2020-06-15 09:44:38 +00:00
[Description("Beatmap Options")]
2020-06-07 03:37:19 +00:00
ToggleBeatmapOptions ,
2021-04-12 07:15:27 +00:00
[Description("Verify mode")]
EditorVerifyMode ,
2018-04-13 09:19:50 +00:00
}
}