Merge branch 'AutoSwitchGamePanel' of https://github.com/xxSeys1/FlaxEngine into xxSeys1-AutoSwitchGamePanel
This commit is contained in:
@@ -39,6 +39,28 @@ namespace FlaxEditor.Windows
|
||||
private bool _useAspect = false;
|
||||
private bool _freeAspect = true;
|
||||
|
||||
private List<PlayModeFocusOptions> _focusOptions = new List<PlayModeFocusOptions>()
|
||||
{
|
||||
new PlayModeFocusOptions
|
||||
{
|
||||
Name = "None",
|
||||
Tooltip = "Don't change focus.",
|
||||
FocusOption = InterfaceOptions.PlayModeFocus.None,
|
||||
},
|
||||
new PlayModeFocusOptions
|
||||
{
|
||||
Name = "Game Window",
|
||||
Tooltip = "Focus the Game Window.",
|
||||
FocusOption = InterfaceOptions.PlayModeFocus.GameWindow,
|
||||
},
|
||||
new PlayModeFocusOptions
|
||||
{
|
||||
Name = "Game Window Then Restore",
|
||||
Tooltip = "Focus the Game Window. On play mode end restore focus to the previous window.",
|
||||
FocusOption = InterfaceOptions.PlayModeFocus.GameWindowThenRestore,
|
||||
},
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the viewport.
|
||||
/// </summary>
|
||||
@@ -162,9 +184,9 @@ namespace FlaxEditor.Windows
|
||||
public bool CenterMouseOnFocus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether auto-focus game window on play mode start.
|
||||
/// Gets or sets a value indicating what panel should be focused when play mode start.
|
||||
/// </summary>
|
||||
public bool FocusOnPlay { get; set; }
|
||||
public InterfaceOptions.PlayModeFocus FocusOnPlayOption { get; set; }
|
||||
|
||||
private enum ViewportScaleType
|
||||
{
|
||||
@@ -195,6 +217,29 @@ namespace FlaxEditor.Windows
|
||||
public bool Active;
|
||||
}
|
||||
|
||||
private class PlayModeFocusOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// The name.
|
||||
/// </summary>
|
||||
public string Name;
|
||||
|
||||
/// <summary>
|
||||
/// The tooltip.
|
||||
/// </summary>
|
||||
public string Tooltip;
|
||||
|
||||
/// <summary>
|
||||
/// The type of focus.
|
||||
/// </summary>
|
||||
public InterfaceOptions.PlayModeFocus FocusOption;
|
||||
|
||||
/// <summary>
|
||||
/// If the option is active.
|
||||
/// </summary>
|
||||
public bool Active;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Root control for game UI preview in Editor. Supports basic UI editing via <see cref="UIEditorRoot"/>.
|
||||
/// </summary>
|
||||
@@ -430,7 +475,7 @@ namespace FlaxEditor.Windows
|
||||
private void OnOptionsChanged(EditorOptions options)
|
||||
{
|
||||
CenterMouseOnFocus = options.Interface.CenterMouseOnGameWinFocus;
|
||||
FocusOnPlay = options.Interface.FocusGameWinOnPlay;
|
||||
FocusOnPlayOption = options.Interface.FocusOnPlayMode;
|
||||
}
|
||||
|
||||
private void PlayingStateOnSceneDuplicating()
|
||||
@@ -495,10 +540,15 @@ namespace FlaxEditor.Windows
|
||||
|
||||
// Focus on play
|
||||
{
|
||||
var focus = menu.AddButton("Start Focused");
|
||||
focus.CloseMenuOnClick = false;
|
||||
var checkbox = new CheckBox(140, 2, FocusOnPlay) { Parent = focus };
|
||||
checkbox.StateChanged += state => FocusOnPlay = state.Checked;
|
||||
var pfMenu = menu.AddChildMenu("Focus On Play Override").ContextMenu;
|
||||
|
||||
GenerateFocusOptionsContextMenu(pfMenu);
|
||||
|
||||
pfMenu.AddSeparator();
|
||||
|
||||
var button = pfMenu.AddButton("Remove override");
|
||||
button.TooltipText = "Reset the override to the value set in the editor options.";
|
||||
button.Clicked += () => FocusOnPlayOption = Editor.Instance.Options.Options.Interface.FocusOnPlayMode;
|
||||
}
|
||||
|
||||
menu.AddSeparator();
|
||||
@@ -600,6 +650,40 @@ namespace FlaxEditor.Windows
|
||||
menu.AddSeparator();
|
||||
}
|
||||
|
||||
private void GenerateFocusOptionsContextMenu(ContextMenu pfMenu)
|
||||
{
|
||||
foreach (PlayModeFocusOptions f in _focusOptions)
|
||||
{
|
||||
f.Active = f.FocusOption == FocusOnPlayOption;
|
||||
|
||||
var button = pfMenu.AddButton(f.Name);
|
||||
button.CloseMenuOnClick = false;
|
||||
button.Tag = f;
|
||||
button.TooltipText = f.Tooltip;
|
||||
button.Icon = f.Active ? Style.Current.CheckBoxTick : SpriteHandle.Invalid;
|
||||
button.Clicked += () =>
|
||||
{
|
||||
foreach (var child in pfMenu.Items)
|
||||
{
|
||||
if (child is ContextMenuButton cmb && cmb.Tag is PlayModeFocusOptions p)
|
||||
{
|
||||
if (cmb == button)
|
||||
{
|
||||
p.Active = true;
|
||||
button.Icon = Style.Current.CheckBoxTick;
|
||||
FocusOnPlayOption = p.FocusOption;
|
||||
}
|
||||
else if (p.Active)
|
||||
{
|
||||
cmb.Icon = SpriteHandle.Invalid;
|
||||
p.Active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateViewportSizingContextMenu(ContextMenu vsMenu)
|
||||
{
|
||||
// Add default viewport sizing options
|
||||
|
||||
Reference in New Issue
Block a user