Add input bindings for game window mouse unlock and toggle fullscreen

This commit is contained in:
2023-10-24 22:27:12 +03:00
parent 081648ef06
commit 06f37794c2
2 changed files with 17 additions and 26 deletions

View File

@@ -271,8 +271,6 @@ namespace FlaxEditor.Windows
Title = "Game";
AutoFocus = true;
FlaxEditor.Utilities.Utils.SetupCommonInputActions(this);
var task = MainRenderTask.Instance;
// Setup viewport
@@ -304,6 +302,12 @@ namespace FlaxEditor.Windows
// Link editor options
Editor.Options.OptionsChanged += OnOptionsChanged;
OnOptionsChanged(Editor.Options.Options);
InputActions.Add(options => options.TakeScreenshot, () => Screenshot.Capture(string.Empty));
InputActions.Add(options => options.DebuggerUnlockMouse, UnlockMouseInPlay);
InputActions.Add(options => options.DebuggerToggleFullscreen, () => { if (Editor.IsPlayMode) IsMaximized = !IsMaximized; });
FlaxEditor.Utilities.Utils.SetupCommonInputActions(this);
}
private void ChangeViewportRatio(ViewportScaleOptions v)
@@ -945,27 +949,6 @@ namespace FlaxEditor.Windows
/// <inheritdoc />
public override bool OnKeyDown(KeyboardKeys key)
{
switch (key)
{
case KeyboardKeys.F12:
Screenshot.Capture(string.Empty);
return true;
case KeyboardKeys.F11:
if (Root.GetKey(KeyboardKeys.Shift))
{
// Unlock mouse in game mode
UnlockMouseInPlay();
return true;
}
else if (Editor.IsPlayMode)
{
// Maximized game window toggle
IsMaximized = !IsMaximized;
return true;
}
break;
}
// Prevent closing the game window tab during a play session
if (Editor.StateMachine.IsPlayMode && Editor.Options.Options.Input.CloseTab.Process(this, key))
{