Cleanup code #1215 and add cook game icon
This commit is contained in:
BIN
Content/Editor/IconsAtlas.flax
(Stored with Git LFS)
BIN
Content/Editor/IconsAtlas.flax
(Stored with Git LFS)
Binary file not shown.
@@ -96,6 +96,7 @@ namespace FlaxEditor
|
|||||||
public SpriteHandle Link64;
|
public SpriteHandle Link64;
|
||||||
public SpriteHandle Build64;
|
public SpriteHandle Build64;
|
||||||
public SpriteHandle Add64;
|
public SpriteHandle Add64;
|
||||||
|
public SpriteHandle ShipIt64;
|
||||||
|
|
||||||
// 96px
|
// 96px
|
||||||
public SpriteHandle Toolbox96;
|
public SpriteHandle Toolbox96;
|
||||||
|
|||||||
@@ -2,106 +2,92 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
using FlaxEngine.GUI;
|
|
||||||
|
|
||||||
namespace FlaxEditor.GUI.ContextMenu
|
namespace FlaxEditor.GUI.ContextMenu
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Context menu single select group.
|
/// Context menu for a single selectable option from range of values (eg. enum).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[HideInEditor]
|
[HideInEditor]
|
||||||
class ContextMenuSingleSelectGroup<T>
|
class ContextMenuSingleSelectGroup<T>
|
||||||
{
|
{
|
||||||
public struct SingleSelectGroupItem<U>
|
private struct SingleSelectGroupItem
|
||||||
{
|
{
|
||||||
public string text;
|
public string Text;
|
||||||
public U value;
|
public string Tooltip;
|
||||||
public Action onSelected;
|
public T Value;
|
||||||
public List<ContextMenuButton> buttons;
|
public Action Selected;
|
||||||
|
public List<ContextMenuButton> Buttons;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ContextMenu> _menus = new List<ContextMenu>();
|
private List<ContextMenu> _menus = new List<ContextMenu>();
|
||||||
private List<SingleSelectGroupItem<T>> _items = new List<SingleSelectGroupItem<T>>();
|
private List<SingleSelectGroupItem> _items = new List<SingleSelectGroupItem>();
|
||||||
public Action<T> OnSelectionChanged;
|
private SingleSelectGroupItem _selectedItem;
|
||||||
|
|
||||||
public SingleSelectGroupItem<T> activeItem;
|
public T Selected
|
||||||
|
{
|
||||||
|
get => _selectedItem.Value;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
var index = _items.FindIndex(x => x.Value.Equals(value));
|
||||||
|
if (index != -1 && !_selectedItem.Value.Equals(value))
|
||||||
|
{
|
||||||
|
SetSelected(_items[index]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ContextMenuSingleSelectGroup<T> AddItem(string text, T value, Action onSelected = null)
|
public Action<T> SelectedChanged;
|
||||||
|
|
||||||
|
public ContextMenuSingleSelectGroup<T> AddItem(string text, T value, Action selected = null, string tooltip = null)
|
||||||
{
|
{
|
||||||
var item = new SingleSelectGroupItem<T>
|
var item = new SingleSelectGroupItem
|
||||||
{
|
{
|
||||||
text = text,
|
Text = text,
|
||||||
value = value,
|
Tooltip = tooltip,
|
||||||
onSelected = onSelected,
|
Value = value,
|
||||||
buttons = new List<ContextMenuButton>()
|
Selected = selected,
|
||||||
|
Buttons = new List<ContextMenuButton>()
|
||||||
};
|
};
|
||||||
_items.Add(item);
|
_items.Add(item);
|
||||||
|
|
||||||
foreach (var contextMenu in _menus)
|
foreach (var contextMenu in _menus)
|
||||||
AddItemToContextMenu(contextMenu, item);
|
AddItemToContextMenu(contextMenu, item);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContextMenuSingleSelectGroup<T> AddItemsToContextMenu(ContextMenu contextMenu)
|
public ContextMenuSingleSelectGroup<T> AddItemsToContextMenu(ContextMenu contextMenu)
|
||||||
{
|
{
|
||||||
_menus.Add(contextMenu);
|
_menus.Add(contextMenu);
|
||||||
|
|
||||||
for (int i = 0; i < _items.Count; i++)
|
for (int i = 0; i < _items.Count; i++)
|
||||||
{
|
|
||||||
AddItemToContextMenu(contextMenu, _items[i]);
|
AddItemToContextMenu(contextMenu, _items[i]);
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddItemToContextMenu(ContextMenu contextMenu, SingleSelectGroupItem<T> item)
|
private void AddItemToContextMenu(ContextMenu contextMenu, SingleSelectGroupItem item)
|
||||||
{
|
|
||||||
var btn = contextMenu.AddButton(item.text, () =>
|
|
||||||
{
|
|
||||||
SetItemAsActive(item);
|
|
||||||
});
|
|
||||||
|
|
||||||
item.buttons.Add(btn);
|
|
||||||
|
|
||||||
if (item.Equals(activeItem))
|
|
||||||
{
|
{
|
||||||
|
var btn = contextMenu.AddButton(item.Text, () => { SetSelected(item); });
|
||||||
|
if (item.Tooltip != null)
|
||||||
|
btn.TooltipText = item.Tooltip;
|
||||||
|
item.Buttons.Add(btn);
|
||||||
|
if (item.Equals(_selectedItem))
|
||||||
btn.Checked = true;
|
btn.Checked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetSelected(SingleSelectGroupItem item)
|
||||||
|
{
|
||||||
|
foreach (var e in _items)
|
||||||
|
{
|
||||||
|
foreach (var btn in e.Buttons)
|
||||||
|
btn.Checked = false;
|
||||||
}
|
}
|
||||||
|
_selectedItem = item;
|
||||||
|
|
||||||
private void DeselectAll()
|
SelectedChanged?.Invoke(item.Value);
|
||||||
{
|
item.Selected?.Invoke();
|
||||||
foreach (var item in _items)
|
|
||||||
{
|
|
||||||
foreach (var btn in item.buttons) btn.Checked = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetItemAsActive(T value)
|
foreach (var btn in item.Buttons)
|
||||||
{
|
|
||||||
var index = _items.FindIndex(x => x.value.Equals(value));
|
|
||||||
|
|
||||||
if (index == -1) return;
|
|
||||||
|
|
||||||
SetItemAsActive(_items[index]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetItemAsActive(SingleSelectGroupItem<T> item)
|
|
||||||
{
|
|
||||||
DeselectAll();
|
|
||||||
activeItem = item;
|
|
||||||
|
|
||||||
var index = _items.IndexOf(item);
|
|
||||||
OnSelectionChanged?.Invoke(item.value);
|
|
||||||
item.onSelected?.Invoke();
|
|
||||||
|
|
||||||
foreach (var btn in item.buttons)
|
|
||||||
{
|
|
||||||
btn.Checked = true;
|
btn.Checked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ namespace FlaxEditor.GUI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event fired when button gets clicked with the primary mouse button.
|
/// Event fired when button gets clicked with the primary mouse button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<ToolStripButton> ButtonPrimaryClicked;
|
public Action<ToolStripButton> ButtonClicked;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event fired when button gets clicked with the secondary mouse button.
|
/// Event fired when button gets clicked with the secondary mouse button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<ToolStripButton> ButtonSecondaryClicked;
|
public Action<ToolStripButton> SecondaryButtonClicked;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tries to get the last button.
|
/// Tries to get the last button.
|
||||||
@@ -96,7 +96,7 @@ namespace FlaxEditor.GUI
|
|||||||
Parent = this,
|
Parent = this,
|
||||||
};
|
};
|
||||||
if (onClick != null)
|
if (onClick != null)
|
||||||
button.PrimaryClicked += onClick;
|
button.Clicked += onClick;
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ namespace FlaxEditor.GUI
|
|||||||
Parent = this,
|
Parent = this,
|
||||||
};
|
};
|
||||||
if (onClick != null)
|
if (onClick != null)
|
||||||
button.PrimaryClicked += onClick;
|
button.Clicked += onClick;
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ namespace FlaxEditor.GUI
|
|||||||
Parent = this,
|
Parent = this,
|
||||||
};
|
};
|
||||||
if (onClick != null)
|
if (onClick != null)
|
||||||
button.PrimaryClicked += onClick;
|
button.Clicked += onClick;
|
||||||
return button;
|
return button;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,14 +146,14 @@ namespace FlaxEditor.GUI
|
|||||||
return AddChild(new ToolStripSeparator(ItemsHeight));
|
return AddChild(new ToolStripSeparator(ItemsHeight));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnButtonPrimaryClicked(ToolStripButton button)
|
internal void OnButtonClicked(ToolStripButton button)
|
||||||
{
|
{
|
||||||
ButtonPrimaryClicked?.Invoke(button);
|
ButtonClicked?.Invoke(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnButtonSecondaryClicked(ToolStripButton button)
|
internal void OnSecondaryButtonClicked(ToolStripButton button)
|
||||||
{
|
{
|
||||||
ButtonSecondaryClicked?.Invoke(button);
|
SecondaryButtonClicked?.Invoke(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
|
|||||||
@@ -11,12 +11,8 @@ namespace FlaxEditor.GUI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <seealso cref="FlaxEngine.GUI.Control" />
|
/// <seealso cref="FlaxEngine.GUI.Control" />
|
||||||
[HideInEditor]
|
[HideInEditor]
|
||||||
public partial class ToolStripButton : Control
|
public class ToolStripButton : Control
|
||||||
{
|
{
|
||||||
// TODO: abstracted for potential future in-editor input configuration (ex. for left handed mouse users)
|
|
||||||
private const MouseButton PRIMARY_MOUSE_BUTTON = MouseButton.Left;
|
|
||||||
private const MouseButton SECONDARY_MOUSE_BUTTON = MouseButton.Right;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default margin for button parts (icon, text, etc.).
|
/// The default margin for button parts (icon, text, etc.).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -30,7 +26,7 @@ namespace FlaxEditor.GUI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event fired when user clicks the button.
|
/// Event fired when user clicks the button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action PrimaryClicked;
|
public Action Clicked;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event fired when user clicks the button.
|
/// Event fired when user clicks the button.
|
||||||
@@ -140,13 +136,7 @@ namespace FlaxEditor.GUI
|
|||||||
if (!string.IsNullOrEmpty(_text))
|
if (!string.IsNullOrEmpty(_text))
|
||||||
{
|
{
|
||||||
textRect.Size.X = Width - DefaultMargin - textRect.Left;
|
textRect.Size.X = Width - DefaultMargin - textRect.Left;
|
||||||
Render2D.DrawText(
|
Render2D.DrawText(style.FontMedium, _text, textRect, enabled ? style.Foreground : style.ForegroundDisabled, TextAlignment.Near, TextAlignment.Center);
|
||||||
style.FontMedium,
|
|
||||||
_text,
|
|
||||||
textRect,
|
|
||||||
enabled ? style.Foreground : style.ForegroundDisabled,
|
|
||||||
TextAlignment.Near,
|
|
||||||
TextAlignment.Center);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,19 +159,15 @@ namespace FlaxEditor.GUI
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool OnMouseDown(Float2 location, MouseButton button)
|
public override bool OnMouseDown(Float2 location, MouseButton button)
|
||||||
{
|
{
|
||||||
if (button == PRIMARY_MOUSE_BUTTON)
|
if (button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
// Set flag
|
|
||||||
_primaryMouseDown = true;
|
_primaryMouseDown = true;
|
||||||
|
|
||||||
Focus();
|
Focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (button == SECONDARY_MOUSE_BUTTON)
|
if (button == MouseButton.Right)
|
||||||
{
|
{
|
||||||
// Set flag
|
|
||||||
_secondaryMouseDown = true;
|
_secondaryMouseDown = true;
|
||||||
|
|
||||||
Focus();
|
Focus();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -192,29 +178,22 @@ namespace FlaxEditor.GUI
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override bool OnMouseUp(Float2 location, MouseButton button)
|
public override bool OnMouseUp(Float2 location, MouseButton button)
|
||||||
{
|
{
|
||||||
if (button == PRIMARY_MOUSE_BUTTON && _primaryMouseDown)
|
if (button == MouseButton.Left && _primaryMouseDown)
|
||||||
{
|
{
|
||||||
// Clear flag
|
|
||||||
_primaryMouseDown = false;
|
_primaryMouseDown = false;
|
||||||
|
|
||||||
// Fire events
|
|
||||||
if (AutoCheck)
|
if (AutoCheck)
|
||||||
Checked = !Checked;
|
Checked = !Checked;
|
||||||
PrimaryClicked?.Invoke();
|
Clicked?.Invoke();
|
||||||
(Parent as ToolStrip)?.OnButtonPrimaryClicked(this);
|
(Parent as ToolStrip)?.OnButtonClicked(this);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (button == SECONDARY_MOUSE_BUTTON && _secondaryMouseDown)
|
if (button == MouseButton.Right && _secondaryMouseDown)
|
||||||
{
|
{
|
||||||
// Clear flag
|
|
||||||
_secondaryMouseDown = false;
|
_secondaryMouseDown = false;
|
||||||
|
|
||||||
SecondaryClicked?.Invoke();
|
SecondaryClicked?.Invoke();
|
||||||
(Parent as ToolStrip)?.OnButtonSecondaryClicked(this);
|
(Parent as ToolStrip)?.OnSecondaryButtonClicked(this);
|
||||||
|
|
||||||
ContextMenu?.Show(this, new Float2(0, Height));
|
ContextMenu?.Show(this, new Float2(0, Height));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -224,7 +203,6 @@ namespace FlaxEditor.GUI
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnMouseLeave()
|
public override void OnMouseLeave()
|
||||||
{
|
{
|
||||||
// Clear flag
|
|
||||||
_primaryMouseDown = false;
|
_primaryMouseDown = false;
|
||||||
_secondaryMouseDown = false;
|
_secondaryMouseDown = false;
|
||||||
|
|
||||||
@@ -234,7 +212,6 @@ namespace FlaxEditor.GUI
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnLostFocus()
|
public override void OnLostFocus()
|
||||||
{
|
{
|
||||||
// Clear flag
|
|
||||||
_primaryMouseDown = false;
|
_primaryMouseDown = false;
|
||||||
_secondaryMouseDown = false;
|
_secondaryMouseDown = false;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ using FlaxEngine.Json;
|
|||||||
using DockHintWindow = FlaxEditor.GUI.Docking.DockHintWindow;
|
using DockHintWindow = FlaxEditor.GUI.Docking.DockHintWindow;
|
||||||
using MasterDockPanel = FlaxEditor.GUI.Docking.MasterDockPanel;
|
using MasterDockPanel = FlaxEditor.GUI.Docking.MasterDockPanel;
|
||||||
using FlaxEditor.Content.Settings;
|
using FlaxEditor.Content.Settings;
|
||||||
using static FlaxEditor.Options.InterfaceOptions;
|
using FlaxEditor.Options;
|
||||||
|
|
||||||
namespace FlaxEditor.Modules
|
namespace FlaxEditor.Modules
|
||||||
{
|
{
|
||||||
@@ -203,6 +203,7 @@ namespace FlaxEditor.Modules
|
|||||||
_toolStripScale.Checked = gizmoMode == TransformGizmoBase.Mode.Scale;
|
_toolStripScale.Checked = gizmoMode == TransformGizmoBase.Mode.Scale;
|
||||||
//
|
//
|
||||||
_toolStripBuildScenes.Enabled = (canEditScene && !isPlayMode) || Editor.StateMachine.BuildingScenesState.IsActive;
|
_toolStripBuildScenes.Enabled = (canEditScene && !isPlayMode) || Editor.StateMachine.BuildingScenesState.IsActive;
|
||||||
|
_toolStripCook.Enabled = Editor.Windows.GameCookerWin.CanBuild(Platform.PlatformType) && !GameCooker.IsRunning;
|
||||||
//
|
//
|
||||||
var play = _toolStripPlay;
|
var play = _toolStripPlay;
|
||||||
var pause = _toolStripPause;
|
var pause = _toolStripPause;
|
||||||
@@ -418,6 +419,7 @@ namespace FlaxEditor.Modules
|
|||||||
Editor.Undo.UndoDone += OnUndoEvent;
|
Editor.Undo.UndoDone += OnUndoEvent;
|
||||||
Editor.Undo.RedoDone += OnUndoEvent;
|
Editor.Undo.RedoDone += OnUndoEvent;
|
||||||
Editor.Undo.ActionDone += OnUndoEvent;
|
Editor.Undo.ActionDone += OnUndoEvent;
|
||||||
|
GameCooker.Event += OnGameCookerEvent;
|
||||||
|
|
||||||
UpdateToolstrip();
|
UpdateToolstrip();
|
||||||
}
|
}
|
||||||
@@ -433,6 +435,11 @@ namespace FlaxEditor.Modules
|
|||||||
UpdateStatusBar();
|
UpdateStatusBar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnGameCookerEvent(GameCooker.EventType type)
|
||||||
|
{
|
||||||
|
UpdateToolstrip();
|
||||||
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public override void OnExit()
|
public override void OnExit()
|
||||||
{
|
{
|
||||||
@@ -477,23 +484,18 @@ namespace FlaxEditor.Modules
|
|||||||
|
|
||||||
private void InitSharedMenus()
|
private void InitSharedMenus()
|
||||||
{
|
{
|
||||||
for (int i = 1; i <= 4; i++) _numberOfClientsGroup.AddItem(i.ToString(), i);
|
for (int i = 1; i <= 4; i++)
|
||||||
|
_numberOfClientsGroup.AddItem(i.ToString(), i);
|
||||||
|
|
||||||
_numberOfClientsGroup.SetItemAsActive(Editor.Options.Options.Interface.NumberOfGameClientsToLaunch);
|
_numberOfClientsGroup.Selected = Editor.Options.Options.Interface.NumberOfGameClientsToLaunch;
|
||||||
_numberOfClientsGroup.OnSelectionChanged = (value) =>
|
_numberOfClientsGroup.SelectedChanged = value =>
|
||||||
{
|
{
|
||||||
var options = Editor.Options.Options;
|
var options = Editor.Options.Options;
|
||||||
options.Interface.NumberOfGameClientsToLaunch = value;
|
options.Interface.NumberOfGameClientsToLaunch = value;
|
||||||
Editor.Options.Apply(options);
|
Editor.Options.Apply(options);
|
||||||
};
|
};
|
||||||
|
|
||||||
Editor.Options.OptionsChanged += (options) =>
|
Editor.Options.OptionsChanged += options => { _numberOfClientsGroup.Selected = options.Interface.NumberOfGameClientsToLaunch; };
|
||||||
{
|
|
||||||
if (options.Interface.NumberOfGameClientsToLaunch != _numberOfClientsGroup.activeItem.value)
|
|
||||||
{
|
|
||||||
_numberOfClientsGroup.SetItemAsActive(options.Interface.NumberOfGameClientsToLaunch);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitMainMenu(RootControl mainWindow)
|
private void InitMainMenu(RootControl mainWindow)
|
||||||
@@ -665,43 +667,33 @@ namespace FlaxEditor.Modules
|
|||||||
_toolStripRotate = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Rotate32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate).LinkTooltip("Change Gizmo tool mode to Rotate (2)");
|
_toolStripRotate = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Rotate32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Rotate).LinkTooltip("Change Gizmo tool mode to Rotate (2)");
|
||||||
_toolStripScale = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Scale32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale).LinkTooltip("Change Gizmo tool mode to Scale (3)");
|
_toolStripScale = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Scale32, () => Editor.MainTransformGizmo.ActiveMode = TransformGizmoBase.Mode.Scale).LinkTooltip("Change Gizmo tool mode to Scale (3)");
|
||||||
ToolStrip.AddSeparator();
|
ToolStrip.AddSeparator();
|
||||||
_toolStripBuildScenes = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Build64, Editor.BuildScenesOrCancel).LinkTooltip("Build scenes data - CSG, navmesh, static lighting, env probes - configurable via Build Actions in editor options (Ctrl+F10)");
|
|
||||||
ToolStrip.AddSeparator();
|
|
||||||
|
|
||||||
// build
|
// Cook scenes
|
||||||
_toolStripCook = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.BuildSettings128, CookAndRun).LinkTooltip("Cook and run");
|
_toolStripBuildScenes = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Build64, Editor.BuildScenesOrCancel).LinkTooltip("Build scenes data - CSG, navmesh, static lighting, env probes - configurable via Build Actions in editor options (Ctrl+F10)");
|
||||||
|
|
||||||
|
// Cook and run
|
||||||
|
_toolStripCook = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.ShipIt64, CookAndRun).LinkTooltip("Cook & Run - build game for the current platform and run it locally");
|
||||||
_toolStripCook.ContextMenu = new ContextMenu();
|
_toolStripCook.ContextMenu = new ContextMenu();
|
||||||
_toolStripCook.ContextMenu.AddButton("Run cooked game", RunCookedGame);
|
_toolStripCook.ContextMenu.AddButton("Run cooked game", RunCookedGame);
|
||||||
_toolStripCook.ContextMenu.AddSeparator();
|
_toolStripCook.ContextMenu.AddSeparator();
|
||||||
var numberOfClientsMenu = _toolStripCook.ContextMenu.AddChildMenu("Number of game clients");
|
var numberOfClientsMenu = _toolStripCook.ContextMenu.AddChildMenu("Number of game clients");
|
||||||
_numberOfClientsGroup.AddItemsToContextMenu(numberOfClientsMenu.ContextMenu);
|
_numberOfClientsGroup.AddItemsToContextMenu(numberOfClientsMenu.ContextMenu);
|
||||||
|
|
||||||
// play
|
ToolStrip.AddSeparator();
|
||||||
|
|
||||||
|
// Play
|
||||||
_toolStripPlay = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Play64, OnPlayPressed).LinkTooltip("Play Game");
|
_toolStripPlay = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Play64, OnPlayPressed).LinkTooltip("Play Game");
|
||||||
_toolStripPlay.ContextMenu = new ContextMenu();
|
_toolStripPlay.ContextMenu = new ContextMenu();
|
||||||
ContextMenuChildMenu playSubMenu;
|
var playSubMenu = _toolStripPlay.ContextMenu.AddChildMenu("Play button action");
|
||||||
|
var playActionGroup = new ContextMenuSingleSelectGroup<InterfaceOptions.PlayAction>();
|
||||||
// play - button action
|
playActionGroup.AddItem("Play Game", InterfaceOptions.PlayAction.PlayGame, null, "Launches the game from the First Scene defined in the project settings.");
|
||||||
playSubMenu = _toolStripPlay.ContextMenu.AddChildMenu("Play button action");
|
playActionGroup.AddItem("Play Scenes", InterfaceOptions.PlayAction.PlayScenes, null, "Launches the game using the scenes currently loaded in the editor.");
|
||||||
var playActionGroup = new ContextMenuSingleSelectGroup<PlayAction>();
|
|
||||||
playActionGroup.AddItem("Play Game", PlayAction.PlayGame);
|
|
||||||
playActionGroup.AddItem("Play Scenes", PlayAction.PlayScenes);
|
|
||||||
playActionGroup.AddItemsToContextMenu(playSubMenu.ContextMenu);
|
playActionGroup.AddItemsToContextMenu(playSubMenu.ContextMenu);
|
||||||
playActionGroup.SetItemAsActive(Editor.Options.Options.Interface.PlayButtonAction);
|
playActionGroup.Selected = Editor.Options.Options.Interface.PlayButtonAction;
|
||||||
// important to add the handler after setting the initial item as active above or the editor will crash
|
playActionGroup.SelectedChanged = SetPlayAction;
|
||||||
playActionGroup.OnSelectionChanged = SetPlayAction;
|
Editor.Options.OptionsChanged += options => { playActionGroup.Selected = options.Interface.PlayButtonAction; };
|
||||||
// TODO: there is a hole in the syncing of these values:
|
|
||||||
// - when changing in the editor, the options will be updated, but the options UI in-editor will not
|
|
||||||
|
|
||||||
Editor.Options.OptionsChanged += (options) =>
|
_toolStripPause = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Pause64, Editor.Simulation.RequestResumeOrPause).LinkTooltip($"Pause/Resume game({inputOptions.Pause})");
|
||||||
{
|
|
||||||
if (options.Interface.PlayButtonAction != playActionGroup.activeItem.value)
|
|
||||||
{
|
|
||||||
playActionGroup.SetItemAsActive(options.Interface.PlayButtonAction);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
_toolStripPause = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Pause64, Editor.Simulation.RequestResumeOrPause).LinkTooltip($"Pause/Resume game({inputOptions.Pause.ToString()})");
|
|
||||||
_toolStripStep = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Skip64, Editor.Simulation.RequestPlayOneFrame).LinkTooltip("Step one frame in game");
|
_toolStripStep = (ToolStripButton)ToolStrip.AddButton(Editor.Icons.Skip64, Editor.Simulation.RequestPlayOneFrame).LinkTooltip("Step one frame in game");
|
||||||
|
|
||||||
UpdateToolstrip();
|
UpdateToolstrip();
|
||||||
@@ -736,10 +728,7 @@ namespace FlaxEditor.Modules
|
|||||||
var defaultTextColor = StatusBar.TextColor;
|
var defaultTextColor = StatusBar.TextColor;
|
||||||
_outputLogButton.HoverBegin += () => StatusBar.TextColor = Style.Current.BackgroundSelected;
|
_outputLogButton.HoverBegin += () => StatusBar.TextColor = Style.Current.BackgroundSelected;
|
||||||
_outputLogButton.HoverEnd += () => StatusBar.TextColor = defaultTextColor;
|
_outputLogButton.HoverEnd += () => StatusBar.TextColor = defaultTextColor;
|
||||||
_outputLogButton.Clicked += () =>
|
_outputLogButton.Clicked += () => { Editor.Windows.OutputLogWin.FocusOrShow(); };
|
||||||
{
|
|
||||||
Editor.Windows.OutputLogWin.FocusOrShow();
|
|
||||||
};
|
|
||||||
|
|
||||||
// Progress bar with label
|
// Progress bar with label
|
||||||
const float progressBarWidth = 120.0f;
|
const float progressBarWidth = 120.0f;
|
||||||
@@ -1043,7 +1032,7 @@ namespace FlaxEditor.Modules
|
|||||||
projectInfo.Save();
|
projectInfo.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetPlayAction(PlayAction newPlayAction)
|
private void SetPlayAction(InterfaceOptions.PlayAction newPlayAction)
|
||||||
{
|
{
|
||||||
var options = Editor.Options.Options;
|
var options = Editor.Options.Options;
|
||||||
options.Interface.PlayButtonAction = newPlayAction;
|
options.Interface.PlayButtonAction = newPlayAction;
|
||||||
@@ -1054,23 +1043,25 @@ namespace FlaxEditor.Modules
|
|||||||
{
|
{
|
||||||
switch (Editor.Options.Options.Interface.PlayButtonAction)
|
switch (Editor.Options.Options.Interface.PlayButtonAction)
|
||||||
{
|
{
|
||||||
case PlayAction.PlayGame:
|
case InterfaceOptions.PlayAction.PlayGame:
|
||||||
if (Editor.IsPlayMode)
|
if (Editor.IsPlayMode)
|
||||||
Editor.Simulation.RequestStopPlay();
|
Editor.Simulation.RequestStopPlay();
|
||||||
else
|
else
|
||||||
PlayGame();
|
PlayGame();
|
||||||
return;
|
return;
|
||||||
case PlayAction.PlayScenes: PlayScenes(); return;
|
case InterfaceOptions.PlayAction.PlayScenes:
|
||||||
|
PlayScenes();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlayGame()
|
private void PlayGame()
|
||||||
{
|
{
|
||||||
var firstScene = GameSettings.Load().FirstScene;
|
var firstScene = GameSettings.Load().FirstScene;
|
||||||
|
|
||||||
if (firstScene == Guid.Empty)
|
if (firstScene == Guid.Empty)
|
||||||
{
|
{
|
||||||
if (Level.IsAnySceneLoaded) Editor.Simulation.RequestStartPlay();
|
if (Level.IsAnySceneLoaded)
|
||||||
|
Editor.Simulation.RequestStartPlay();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -83,10 +83,11 @@ namespace FlaxEditor.Options
|
|||||||
/// Launches the game from the First Scene defined in the project settings.
|
/// Launches the game from the First Scene defined in the project settings.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PlayGame,
|
PlayGame,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Launches the game using the scenes currently loaded in the editor.
|
/// Launches the game using the scenes currently loaded in the editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PlayScenes
|
PlayScenes,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -97,14 +98,12 @@ namespace FlaxEditor.Options
|
|||||||
public float InterfaceScale { get; set; } = 1.0f;
|
public float InterfaceScale { get; set; } = 1.0f;
|
||||||
|
|
||||||
#if PLATFORM_WINDOWS
|
#if PLATFORM_WINDOWS
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating whether use native window title bar. Editor restart required.
|
/// Gets or sets a value indicating whether use native window title bar. Editor restart required.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(false)]
|
[DefaultValue(false)]
|
||||||
[EditorDisplay("Interface"), EditorOrder(70), Tooltip("Determines whether use native window title bar. Editor restart required.")]
|
[EditorDisplay("Interface"), EditorOrder(70), Tooltip("Determines whether use native window title bar. Editor restart required.")]
|
||||||
public bool UseNativeWindowSystem { get; set; } = false;
|
public bool UseNativeWindowSystem { get; set; } = false;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -215,15 +214,14 @@ namespace FlaxEditor.Options
|
|||||||
/// Gets or sets a value indicating what action should be taken upon pressing the play button.
|
/// Gets or sets a value indicating what action should be taken upon pressing the play button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(PlayAction.PlayScenes)]
|
[DefaultValue(PlayAction.PlayScenes)]
|
||||||
[EditorDisplay("Play In-Editor", "Play Button Action"), EditorOrder(410), Tooltip("Determines the action taken when the play button is pressed.")]
|
[EditorDisplay("Play In-Editor", "Play Button Action"), EditorOrder(410)]
|
||||||
public PlayAction PlayButtonAction { get; set; } = PlayAction.PlayScenes;
|
public PlayAction PlayButtonAction { get; set; } = PlayAction.PlayScenes;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets a value indicating the number of game clients to launch when building and/or running cooked game.
|
/// Gets or sets a value indicating the number of game clients to launch when building and/or running cooked game.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DefaultValue(1)]
|
[DefaultValue(1), Range(1, 4)]
|
||||||
[EditorDisplay("Cook & Run", "Number Of GameClients To Launch"), EditorOrder(500), Tooltip("Determines the number of game clients to launch when building and/or running cooked game.")]
|
[EditorDisplay("Cook & Run"), EditorOrder(500)]
|
||||||
[Range(1, 4)]
|
|
||||||
public int NumberOfGameClientsToLaunch = 1;
|
public int NumberOfGameClientsToLaunch = 1;
|
||||||
|
|
||||||
private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont);
|
private static FontAsset DefaultFont => FlaxEngine.Content.LoadAsyncInternal<FontAsset>(EditorAssets.PrimaryFont);
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ namespace FlaxEditor.Windows
|
|||||||
{
|
{
|
||||||
[EditorDisplay(null, "arm64")]
|
[EditorDisplay(null, "arm64")]
|
||||||
ARM64,
|
ARM64,
|
||||||
|
|
||||||
[EditorDisplay(null, "x64")]
|
[EditorDisplay(null, "x64")]
|
||||||
x64,
|
x64,
|
||||||
}
|
}
|
||||||
@@ -614,6 +615,18 @@ namespace FlaxEditor.Windows
|
|||||||
_exitOnBuildEnd = true;
|
_exitOnBuildEnd = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns true if can build for the given platform (both supported and available).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="platformType">The platform.</param>
|
||||||
|
/// <returns>True if can build, otherwise false.</returns>
|
||||||
|
public bool CanBuild(PlatformType platformType)
|
||||||
|
{
|
||||||
|
if (_buildTabProxy.PerPlatformOptions.TryGetValue(platformType, out var platform))
|
||||||
|
return platform.IsAvailable && platform.IsSupported;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Builds all the targets from the given preset.
|
/// Builds all the targets from the given preset.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -660,11 +673,11 @@ namespace FlaxEditor.Windows
|
|||||||
Editor.Log("Building and running");
|
Editor.Log("Building and running");
|
||||||
GameCooker.GetCurrentPlatform(out var platform, out var buildPlatform, out var buildConfiguration);
|
GameCooker.GetCurrentPlatform(out var platform, out var buildPlatform, out var buildConfiguration);
|
||||||
var numberOfClients = Editor.Options.Options.Interface.NumberOfGameClientsToLaunch;
|
var numberOfClients = Editor.Options.Options.Interface.NumberOfGameClientsToLaunch;
|
||||||
|
|
||||||
for (int i = 0; i < numberOfClients; i++)
|
for (int i = 0; i < numberOfClients; i++)
|
||||||
{
|
{
|
||||||
var buildOptions = BuildOptions.AutoRun;
|
var buildOptions = BuildOptions.AutoRun;
|
||||||
if (i > 0) buildOptions |= BuildOptions.NoCook;
|
if (i > 0)
|
||||||
|
buildOptions |= BuildOptions.NoCook;
|
||||||
|
|
||||||
_buildingQueue.Enqueue(new QueueItem
|
_buildingQueue.Enqueue(new QueueItem
|
||||||
{
|
{
|
||||||
@@ -687,7 +700,6 @@ namespace FlaxEditor.Windows
|
|||||||
Editor.Log("Running cooked build");
|
Editor.Log("Running cooked build");
|
||||||
GameCooker.GetCurrentPlatform(out var platform, out var buildPlatform, out var buildConfiguration);
|
GameCooker.GetCurrentPlatform(out var platform, out var buildPlatform, out var buildConfiguration);
|
||||||
var numberOfClients = Editor.Options.Options.Interface.NumberOfGameClientsToLaunch;
|
var numberOfClients = Editor.Options.Options.Interface.NumberOfGameClientsToLaunch;
|
||||||
|
|
||||||
for (int i = 0; i < numberOfClients; i++)
|
for (int i = 0; i < numberOfClients; i++)
|
||||||
{
|
{
|
||||||
_buildingQueue.Enqueue(new QueueItem
|
_buildingQueue.Enqueue(new QueueItem
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ namespace FlaxEditor.Windows.Profiler
|
|||||||
_liveRecordingButton = toolstrip.AddButton(editor.Icons.Play64);
|
_liveRecordingButton = toolstrip.AddButton(editor.Icons.Play64);
|
||||||
_liveRecordingButton.LinkTooltip("Live profiling events recording");
|
_liveRecordingButton.LinkTooltip("Live profiling events recording");
|
||||||
_liveRecordingButton.AutoCheck = true;
|
_liveRecordingButton.AutoCheck = true;
|
||||||
_liveRecordingButton.PrimaryClicked += () => _liveRecordingButton.Icon = LiveRecording ? editor.Icons.Stop64 : editor.Icons.Play64;
|
_liveRecordingButton.Clicked += () => _liveRecordingButton.Icon = LiveRecording ? editor.Icons.Stop64 : editor.Icons.Play64;
|
||||||
_clearButton = toolstrip.AddButton(editor.Icons.Rotate32, Clear);
|
_clearButton = toolstrip.AddButton(editor.Icons.Rotate32, Clear);
|
||||||
_clearButton.LinkTooltip("Clear data");
|
_clearButton.LinkTooltip("Clear data");
|
||||||
toolstrip.AddSeparator();
|
toolstrip.AddSeparator();
|
||||||
|
|||||||
Reference in New Issue
Block a user