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

@@ -76,6 +76,10 @@ namespace FlaxEditor.Options
[EditorDisplay("Common"), EditorOrder(230)] [EditorDisplay("Common"), EditorOrder(230)]
public InputBinding RotateSelection = new InputBinding(KeyboardKeys.R); public InputBinding RotateSelection = new InputBinding(KeyboardKeys.R);
[DefaultValue(typeof(InputBinding), "F11")]
[EditorDisplay("Common"), EditorOrder(240)]
public InputBinding ToggleFullscreen = new InputBinding(KeyboardKeys.F11);
#endregion #endregion
#region File #region File
@@ -208,16 +212,20 @@ namespace FlaxEditor.Options
[EditorDisplay("Debugger", "Continue"), EditorOrder(810)] [EditorDisplay("Debugger", "Continue"), EditorOrder(810)]
public InputBinding DebuggerContinue = new InputBinding(KeyboardKeys.F5); public InputBinding DebuggerContinue = new InputBinding(KeyboardKeys.F5);
[DefaultValue(typeof(InputBinding), "Shift+F11")]
[EditorDisplay("Debugger", "Unlock mouse in Play Mode"), EditorOrder(820)]
public InputBinding DebuggerUnlockMouse = new InputBinding(KeyboardKeys.F11, KeyboardKeys.Shift);
[DefaultValue(typeof(InputBinding), "F10")] [DefaultValue(typeof(InputBinding), "F10")]
[EditorDisplay("Debugger", "Step Over"), EditorOrder(820)] [EditorDisplay("Debugger", "Step Over"), EditorOrder(830)]
public InputBinding DebuggerStepOver = new InputBinding(KeyboardKeys.F10); public InputBinding DebuggerStepOver = new InputBinding(KeyboardKeys.F10);
[DefaultValue(typeof(InputBinding), "F11")] [DefaultValue(typeof(InputBinding), "F11")]
[EditorDisplay("Debugger", "Step Into"), EditorOrder(830)] [EditorDisplay("Debugger", "Step Into"), EditorOrder(840)]
public InputBinding DebuggerStepInto = new InputBinding(KeyboardKeys.F11); public InputBinding DebuggerStepInto = new InputBinding(KeyboardKeys.F11);
[DefaultValue(typeof(InputBinding), "Shift+F11")] [DefaultValue(typeof(InputBinding), "Shift+F11")]
[EditorDisplay("Debugger", "Step Out"), EditorOrder(840)] [EditorDisplay("Debugger", "Step Out"), EditorOrder(850)]
public InputBinding DebuggerStepOut = new InputBinding(KeyboardKeys.F11, KeyboardKeys.Shift); public InputBinding DebuggerStepOut = new InputBinding(KeyboardKeys.F11, KeyboardKeys.Shift);
#endregion #endregion

View File

@@ -271,8 +271,6 @@ namespace FlaxEditor.Windows
Title = "Game"; Title = "Game";
AutoFocus = true; AutoFocus = true;
FlaxEditor.Utilities.Utils.SetupCommonInputActions(this);
var task = MainRenderTask.Instance; var task = MainRenderTask.Instance;
// Setup viewport // Setup viewport
@@ -304,6 +302,12 @@ namespace FlaxEditor.Windows
// Link editor options // Link editor options
Editor.Options.OptionsChanged += OnOptionsChanged; Editor.Options.OptionsChanged += OnOptionsChanged;
OnOptionsChanged(Editor.Options.Options); 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) private void ChangeViewportRatio(ViewportScaleOptions v)
@@ -945,27 +949,6 @@ namespace FlaxEditor.Windows
/// <inheritdoc /> /// <inheritdoc />
public override bool OnKeyDown(KeyboardKeys key) 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 // Prevent closing the game window tab during a play session
if (Editor.StateMachine.IsPlayMode && Editor.Options.Options.Input.CloseTab.Process(this, key)) if (Editor.StateMachine.IsPlayMode && Editor.Options.Options.Input.CloseTab.Process(this, key))
{ {