Merge remote-tracking branch 'origin/master' into 1.7

This commit is contained in:
Wojtek Figat
2023-08-28 09:11:29 +02:00
29 changed files with 324 additions and 34 deletions

View File

@@ -248,6 +248,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=bitangent/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=bitangent/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=bitangents/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=bitangents/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bokeh/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=Bokeh/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=borderless/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=BRDF/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=BRDF/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=coeff/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=coeff/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=colliders/@EntryIndexedValue">True</s:Boolean> <s:Boolean x:Key="/Default/UserDictionary/Words/=colliders/@EntryIndexedValue">True</s:Boolean>

View File

@@ -253,6 +253,12 @@ namespace FlaxEditor.GUI.Docking
tabColor = style.BackgroundHighlighted; tabColor = style.BackgroundHighlighted;
Render2D.FillRectangle(tabRect, tabColor); Render2D.FillRectangle(tabRect, tabColor);
} }
else
{
tabColor = style.BackgroundHighlighted;
Render2D.DrawLine(tabRect.BottomLeft - new Float2(0 , 1), tabRect.UpperLeft, tabColor);
Render2D.DrawLine(tabRect.BottomRight - new Float2(0 , 1), tabRect.UpperRight, tabColor);
}
if (tab.Icon.IsValid) if (tab.Icon.IsValid)
{ {

View File

@@ -282,7 +282,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
var x = time * zoom + Timeline.StartOffset; var x = time * zoom + Timeline.StartOffset;
// Header line // Header line
var lineRect = new Rectangle(x - 0.5f, -verticalLinesHeaderExtend + timeAxisHeaderOffset, 1.0f, verticalLinesHeaderExtend); var lineRect = new Rectangle(x - 0.5f, -verticalLinesHeaderExtend * 0.6f + timeAxisHeaderOffset, 1.0f, verticalLinesHeaderExtend * 0.6f);
Render2D.FillRectangle(lineRect, lineColor); Render2D.FillRectangle(lineRect, lineColor);
// Time label // Time label
@@ -300,7 +300,7 @@ namespace FlaxEditor.GUI.Timeline.GUI
break; break;
default: throw new ArgumentOutOfRangeException(); default: throw new ArgumentOutOfRangeException();
} }
var labelRect = new Rectangle(x + 2, -verticalLinesHeaderExtend + timeAxisHeaderOffset, 50, verticalLinesHeaderExtend); var labelRect = new Rectangle(x + 2, -verticalLinesHeaderExtend * 0.8f + timeAxisHeaderOffset, 50, verticalLinesHeaderExtend);
Render2D.DrawText(style.FontSmall, labelText, labelRect, labelColor, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, 0.8f); Render2D.DrawText(style.FontSmall, labelText, labelRect, labelColor, TextAlignment.Near, TextAlignment.Center, TextWrapping.NoWrap, 1.0f, 0.8f);
} }
} }

View File

@@ -1,5 +1,7 @@
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. // Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
using System;
using System.Globalization;
using FlaxEngine; using FlaxEngine;
using FlaxEngine.GUI; using FlaxEngine.GUI;
@@ -30,11 +32,33 @@ namespace FlaxEditor.GUI.Timeline.GUI
var timeAxisOverlap = Timeline.HeaderTopAreaHeight * 0.5f; var timeAxisOverlap = Timeline.HeaderTopAreaHeight * 0.5f;
var timeAxisHeaderOffset = -_timeline.MediaBackground.ViewOffset.Y - timeAxisOverlap; var timeAxisHeaderOffset = -_timeline.MediaBackground.ViewOffset.Y - timeAxisOverlap;
// Time label
string labelText;
switch (_timeline.TimeShowMode)
{
case Timeline.TimeShowModes.Frames:
labelText = _timeline.CurrentFrame.ToString("###0", CultureInfo.InvariantCulture);
break;
case Timeline.TimeShowModes.Seconds:
labelText = _timeline.CurrentTime.ToString("###0.##'s'", CultureInfo.InvariantCulture);
break;
case Timeline.TimeShowModes.Time:
labelText = TimeSpan.FromSeconds(_timeline.CurrentTime).ToString("g");
break;
default: throw new ArgumentOutOfRangeException();
}
var color = (_timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground).AlphaMultiplied(0.6f);
Matrix3x3.RotationZ(Mathf.PiOverTwo, out var m1); Matrix3x3.RotationZ(Mathf.PiOverTwo, out var m1);
var m2 = Matrix3x3.Translation2D(0, timeAxisHeaderOffset); var m2 = Matrix3x3.Translation2D(0, timeAxisHeaderOffset);
Matrix3x3.Multiply(ref m1, ref m2, out var m3); Matrix3x3.Multiply(ref m1, ref m2, out var m3);
Render2D.PushTransform(ref m3); Render2D.PushTransform(ref m3);
Render2D.DrawSprite(icon, new Rectangle(new Float2(4, -Width), Size), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground); // TODO: Convert to its own sprite or 9 slice
Render2D.DrawSprite(icon, new Rectangle(new Float2(10, -icon.Size.X * 0.5f - 1), Size + new Float2(0, 1)), color);
Render2D.FillRectangle(new Rectangle(new Float2(-6, -icon.Size.Y * 0.5f + 7), new Float2(timeAxisOverlap, 5)), color);
Render2D.PopTransform();
var textMatrix = Matrix3x3.Translation2D(12, timeAxisHeaderOffset);
Render2D.PushTransform(ref textMatrix);
Render2D.DrawText(style.FontSmall, labelText, style.Foreground, new Float2(2, -6));
Render2D.PopTransform(); Render2D.PopTransform();
Render2D.FillRectangle(new Rectangle(Width * 0.5f, Height + timeAxisHeaderOffset, 1, _timeline.MediaPanel.Height - timeAxisHeaderOffset - timeAxisOverlap), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground.RGBMultiplied(0.8f)); Render2D.FillRectangle(new Rectangle(Width * 0.5f, Height + timeAxisHeaderOffset, 1, _timeline.MediaPanel.Height - timeAxisHeaderOffset - timeAxisOverlap), _timeline.IsMovingPositionHandle ? style.ProgressNormal : style.Foreground.RGBMultiplied(0.8f));

View File

@@ -50,6 +50,27 @@ namespace FlaxEditor.GUI.Timeline
} }
} }
/// <inheritdoc />
public override void OnMouseEnter(Float2 location)
{
base.OnMouseEnter(location);
Cursor = CursorType.Hand;
}
/// <inheritdoc />
public override void OnMouseLeave()
{
Cursor = CursorType.Default;
base.OnMouseLeave();
}
/// <inheritdoc />
public override void Defocus()
{
Cursor = CursorType.Default;
base.Defocus();
}
private void Seek(ref Float2 location) private void Seek(ref Float2 location)
{ {
if (_timeline.PlaybackState == PlaybackStates.Disabled) if (_timeline.PlaybackState == PlaybackStates.Disabled)

View File

@@ -167,7 +167,7 @@ namespace FlaxEditor.GUI.Timeline
/// <summary> /// <summary>
/// The header top area height (in pixels). /// The header top area height (in pixels).
/// </summary> /// </summary>
public static readonly float HeaderTopAreaHeight = 22.0f; public static readonly float HeaderTopAreaHeight = 40.0f;
/// <summary> /// <summary>
/// The timeline units per second (on time axis). /// The timeline units per second (on time axis).

View File

@@ -298,7 +298,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
var animEventTypes = Editor.Instance.CodeEditing.All.Get().Where(x => new ScriptType(typeof(AnimEvent)).IsAssignableFrom(x)); var animEventTypes = Editor.Instance.CodeEditing.All.Get().Where(x => new ScriptType(typeof(AnimEvent)).IsAssignableFrom(x));
foreach (var type in animEventTypes) foreach (var type in animEventTypes)
{ {
if (type.IsAbstract || !type.CanCreateInstance) if (type.IsAbstract || !type.CanCreateInstance || type.HasAttribute(typeof(HideInEditorAttribute), true))
continue; continue;
var add = new ScriptType(typeof(AnimContinuousEvent)).IsAssignableFrom(type) ? addContinuousEvent : addEvent; var add = new ScriptType(typeof(AnimContinuousEvent)).IsAssignableFrom(type) ? addContinuousEvent : addEvent;
var b = add.ContextMenu.AddButton(type.Name); var b = add.ContextMenu.AddButton(type.Name);
@@ -307,6 +307,10 @@ namespace FlaxEditor.GUI.Timeline.Tracks
b.Parent.Tag = time; b.Parent.Tag = time;
b.ButtonClicked += OnAddAnimEvent; b.ButtonClicked += OnAddAnimEvent;
} }
if (!addEvent.ContextMenu.Items.Any())
addEvent.ContextMenu.AddButton("No Anim Events found").CloseMenuOnClick = false;
if (!addContinuousEvent.ContextMenu.Items.Any())
addContinuousEvent.ContextMenu.AddButton("No Continuous Anim Events found").CloseMenuOnClick = false;
} }

View File

@@ -479,6 +479,7 @@ namespace FlaxEditor.Viewport
{ {
InitFpsCounter(); InitFpsCounter();
_showFpsButon = ViewWidgetShowMenu.AddButton("FPS Counter", () => ShowFpsCounter = !ShowFpsCounter); _showFpsButon = ViewWidgetShowMenu.AddButton("FPS Counter", () => ShowFpsCounter = !ShowFpsCounter);
_showFpsButon.CloseMenuOnClick = false;
} }
} }

View File

@@ -397,9 +397,11 @@ namespace FlaxEditor.Viewport
// Show grid widget // Show grid widget
_showGridButton = ViewWidgetShowMenu.AddButton("Grid", () => Grid.Enabled = !Grid.Enabled); _showGridButton = ViewWidgetShowMenu.AddButton("Grid", () => Grid.Enabled = !Grid.Enabled);
_showGridButton.Icon = Style.Current.CheckBoxTick; _showGridButton.Icon = Style.Current.CheckBoxTick;
_showGridButton.CloseMenuOnClick = false;
// Show navigation widget // Show navigation widget
_showNavigationButton = ViewWidgetShowMenu.AddButton("Navigation", () => ShowNavigation = !ShowNavigation); _showNavigationButton = ViewWidgetShowMenu.AddButton("Navigation", () => ShowNavigation = !ShowNavigation);
_showNavigationButton.CloseMenuOnClick = false;
// Create camera widget // Create camera widget
ViewWidgetButtonMenu.AddSeparator(); ViewWidgetButtonMenu.AddSeparator();

View File

@@ -194,16 +194,20 @@ namespace FlaxEditor.Viewport.Previews
{ {
// Show Bounds // Show Bounds
_showBoundsButton = ViewWidgetShowMenu.AddButton("Bounds", () => ShowBounds = !ShowBounds); _showBoundsButton = ViewWidgetShowMenu.AddButton("Bounds", () => ShowBounds = !ShowBounds);
_showBoundsButton.CloseMenuOnClick = false;
// Show Skeleton // Show Skeleton
_showNodesButton = ViewWidgetShowMenu.AddButton("Skeleton", () => ShowNodes = !ShowNodes); _showNodesButton = ViewWidgetShowMenu.AddButton("Skeleton", () => ShowNodes = !ShowNodes);
_showNodesButton.CloseMenuOnClick = false;
// Show Skeleton Names // Show Skeleton Names
_showNodesNamesButton = ViewWidgetShowMenu.AddButton("Skeleton Names", () => ShowNodesNames = !ShowNodesNames); _showNodesNamesButton = ViewWidgetShowMenu.AddButton("Skeleton Names", () => ShowNodesNames = !ShowNodesNames);
_showNodesNamesButton.CloseMenuOnClick = false;
// Show Floor // Show Floor
_showFloorButton = ViewWidgetShowMenu.AddButton("Floor", button => ShowFloor = !ShowFloor); _showFloorButton = ViewWidgetShowMenu.AddButton("Floor", button => ShowFloor = !ShowFloor);
_showFloorButton.IndexInParent = 1; _showFloorButton.IndexInParent = 1;
_showFloorButton.CloseMenuOnClick = false;
} }
// Enable shadows // Enable shadows

View File

@@ -171,6 +171,7 @@ namespace FlaxEditor.Viewport.Previews
// Show Default Scene // Show Default Scene
_showDefaultSceneButton = ViewWidgetShowMenu.AddButton("Default Scene", () => ShowDefaultSceneActors = !ShowDefaultSceneActors); _showDefaultSceneButton = ViewWidgetShowMenu.AddButton("Default Scene", () => ShowDefaultSceneActors = !ShowDefaultSceneActors);
_showDefaultSceneButton.Checked = true; _showDefaultSceneButton.Checked = true;
_showDefaultSceneButton.CloseMenuOnClick = false;
} }
// Setup preview scene // Setup preview scene

View File

@@ -199,13 +199,18 @@ namespace FlaxEditor.Viewport.Previews
if (useWidgets) if (useWidgets)
{ {
_showBoundsButton = ViewWidgetShowMenu.AddButton("Bounds", () => ShowBounds = !ShowBounds); _showBoundsButton = ViewWidgetShowMenu.AddButton("Bounds", () => ShowBounds = !ShowBounds);
_showBoundsButton.CloseMenuOnClick = false;
_showNormalsButton = ViewWidgetShowMenu.AddButton("Normals", () => ShowNormals = !ShowNormals); _showNormalsButton = ViewWidgetShowMenu.AddButton("Normals", () => ShowNormals = !ShowNormals);
_showNormalsButton.CloseMenuOnClick = false;
_showTangentsButton = ViewWidgetShowMenu.AddButton("Tangents", () => ShowTangents = !ShowTangents); _showTangentsButton = ViewWidgetShowMenu.AddButton("Tangents", () => ShowTangents = !ShowTangents);
_showTangentsButton.CloseMenuOnClick = false;
_showBitangentsButton = ViewWidgetShowMenu.AddButton("Bitangents", () => ShowBitangents = !ShowBitangents); _showBitangentsButton = ViewWidgetShowMenu.AddButton("Bitangents", () => ShowBitangents = !ShowBitangents);
_showBitangentsButton.CloseMenuOnClick = false;
// Show Floor // Show Floor
_showFloorButton = ViewWidgetShowMenu.AddButton("Floor", button => ShowFloor = !ShowFloor); _showFloorButton = ViewWidgetShowMenu.AddButton("Floor", button => ShowFloor = !ShowFloor);
_showFloorButton.IndexInParent = 1; _showFloorButton.IndexInParent = 1;
_showFloorButton.CloseMenuOnClick = false;
// Show current LOD widget // Show current LOD widget
_showCurrentLODButton = ViewWidgetShowMenu.AddButton("Current LOD", button => _showCurrentLODButton = ViewWidgetShowMenu.AddButton("Current LOD", button =>
@@ -214,6 +219,7 @@ namespace FlaxEditor.Viewport.Previews
_showCurrentLODButton.Icon = _showCurrentLOD ? Style.Current.CheckBoxTick : SpriteHandle.Invalid; _showCurrentLODButton.Icon = _showCurrentLOD ? Style.Current.CheckBoxTick : SpriteHandle.Invalid;
}); });
_showCurrentLODButton.IndexInParent = 2; _showCurrentLODButton.IndexInParent = 2;
_showCurrentLODButton.CloseMenuOnClick = false;
// Preview LODs mode widget // Preview LODs mode widget
var PreviewLODsMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); var PreviewLODsMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight);

View File

@@ -186,8 +186,11 @@ namespace FlaxEditor.Viewport.Previews
if (!useWidgets) if (!useWidgets)
return; return;
_showBoundsButton = ViewWidgetShowMenu.AddButton("Bounds", () => ShowBounds = !ShowBounds); _showBoundsButton = ViewWidgetShowMenu.AddButton("Bounds", () => ShowBounds = !ShowBounds);
_showBoundsButton.CloseMenuOnClick = false;
_showOriginButton = ViewWidgetShowMenu.AddButton("Origin", () => ShowOrigin = !ShowOrigin); _showOriginButton = ViewWidgetShowMenu.AddButton("Origin", () => ShowOrigin = !ShowOrigin);
_showOriginButton.CloseMenuOnClick = false;
_showParticleCounterButton = ViewWidgetShowMenu.AddButton("Particles Counter", () => ShowParticlesCounter = !ShowParticlesCounter); _showParticleCounterButton = ViewWidgetShowMenu.AddButton("Particles Counter", () => ShowParticlesCounter = !ShowParticlesCounter);
_showParticleCounterButton.CloseMenuOnClick = false;
// Play/Pause widget // Play/Pause widget
{ {

View File

@@ -49,6 +49,7 @@ namespace FlaxEditor.Viewport.Previews
_showCurrentLODButton.Icon = _showCurrentLOD ? Style.Current.CheckBoxTick : SpriteHandle.Invalid; _showCurrentLODButton.Icon = _showCurrentLOD ? Style.Current.CheckBoxTick : SpriteHandle.Invalid;
}); });
_showCurrentLODButton.IndexInParent = 2; _showCurrentLODButton.IndexInParent = 2;
_showCurrentLODButton.CloseMenuOnClick = false;
// PreviewLODS mode widget // PreviewLODS mode widget
var PreviewLODSMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight); var PreviewLODSMode = new ViewportWidgetsContainer(ViewportWidgetLocation.UpperRight);

View File

@@ -23,6 +23,7 @@ namespace FlaxEditor.Windows.Assets
private readonly Undo _undo; private readonly Undo _undo;
private object _object; private object _object;
private bool _isRegisteredForScriptsReload; private bool _isRegisteredForScriptsReload;
private Label _typeText;
/// <summary> /// <summary>
/// Gets the instance of the Json asset object that is being edited. /// Gets the instance of the Json asset object that is being edited.
@@ -136,6 +137,22 @@ namespace FlaxEditor.Windows.Assets
} }
} }
_presenter.Select(_object); _presenter.Select(_object);
if (_typeText != null)
_typeText.Dispose();
var typeText = new ClickableLabel
{
Text = $"{Asset.DataTypeName}",
TooltipText = "Asset data type (full name)",
AnchorPreset = AnchorPresets.TopRight,
AutoWidth = true,
Parent = this,
};
typeText.LocalX += -(typeText.Width + 4);
typeText.LocalY += (_toolstrip.Height - typeText.Height) * 0.5f;
typeText.RightClick = () => Clipboard.Text = Asset.DataTypeName;
_typeText = typeText;
_undo.Clear(); _undo.Clear();
ClearEditedFlag(); ClearEditedFlag();
@@ -175,6 +192,7 @@ namespace FlaxEditor.Windows.Assets
_isRegisteredForScriptsReload = false; _isRegisteredForScriptsReload = false;
ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin; ScriptsBuilder.ScriptsReloadBegin -= OnScriptsReloadBegin;
} }
_typeText = null;
base.OnDestroy(); base.OnDestroy();
} }

View File

@@ -247,8 +247,17 @@ namespace FlaxEditor.Windows
for (int i = 0; i < _viewDropdown.Items.Count; i++) for (int i = 0; i < _viewDropdown.Items.Count; i++)
{ {
var filterButton = filters.ContextMenu.AddButton(_viewDropdown.Items[i], OnFilterClicked); var filterButton = filters.ContextMenu.AddButton(_viewDropdown.Items[i], OnFilterClicked);
filterButton.CloseMenuOnClick = false;
filterButton.Tag = i; filterButton.Tag = i;
} }
filters.ContextMenu.ButtonClicked += button =>
{
foreach (var item in (filters.ContextMenu).Items)
{
if (item is ContextMenuButton filterButton)
filterButton.Checked = _viewDropdown.IsSelected(filterButton.Text);
}
};
filters.ContextMenu.VisibleChanged += control => filters.ContextMenu.VisibleChanged += control =>
{ {
if (!control.Visible) if (!control.Visible)
@@ -340,6 +349,9 @@ namespace FlaxEditor.Windows
/// <returns>The created renaming popup.</returns> /// <returns>The created renaming popup.</returns>
public void Rename(ContentItem item) public void Rename(ContentItem item)
{ {
if (!item.CanRename)
return;
// Show element in the view // Show element in the view
Select(item, true); Select(item, true);

View File

@@ -5,6 +5,7 @@
#include "AudioBackendXAudio2.h" #include "AudioBackendXAudio2.h"
#include "Engine/Audio/AudioSettings.h" #include "Engine/Audio/AudioSettings.h"
#include "Engine/Core/Collections/Array.h" #include "Engine/Core/Collections/Array.h"
#include "Engine/Core/Collections/ChunkedArray.h"
#include "Engine/Core/Log.h" #include "Engine/Core/Log.h"
#include "Engine/Audio/Audio.h" #include "Engine/Audio/Audio.h"
#include "Engine/Audio/AudioSource.h" #include "Engine/Audio/AudioSource.h"
@@ -208,8 +209,8 @@ namespace XAudio2
bool ForceDirty = true; bool ForceDirty = true;
Listener Listeners[AUDIO_MAX_LISTENERS]; Listener Listeners[AUDIO_MAX_LISTENERS];
CriticalSection Locker; CriticalSection Locker;
Array<Source> Sources(32); // TODO: use ChunkedArray for better performance ChunkedArray<Source, 32> Sources;
Array<Buffer*> Buffers(64); // TODO: use ChunkedArray for better performance or use buffers pool? ChunkedArray<Buffer*, 64> Buffers; // TODO: use ChunkedArray for better performance or use buffers pool?
EngineCallback Callback; EngineCallback Callback;
Listener* GetListener() Listener* GetListener()

View File

@@ -135,6 +135,52 @@ void Screen::SetCursorLock(CursorLockMode mode)
CursorLock = mode; CursorLock = mode;
} }
GameWindowMode Screen::GetGameWindowMode()
{
GameWindowMode result = GameWindowMode::Windowed;
#if !USE_EDITOR
auto win = Engine::MainWindow;
if (win)
{
if (GetIsFullscreen() || win->IsFullscreen())
result = GameWindowMode::Fullscreen;
else if (win->GetSettings().HasBorder)
result = GameWindowMode::Windowed;
else if (win->GetClientPosition().IsZero() && win->GetSize() == Platform::GetDesktopSize())
result = GameWindowMode::FullscreenBorderless;
else
result = GameWindowMode::Borderless;
}
#endif
return result;
}
void Screen::SetGameWindowMode(GameWindowMode windowMode)
{
#if !USE_EDITOR
auto win = Engine::MainWindow;
if (!win)
return;
switch (windowMode)
{
case GameWindowMode::Windowed:
if (GetIsFullscreen())
SetIsFullscreen(false);
win->SetBorderless(false, false);
break;
case GameWindowMode::Fullscreen:
SetIsFullscreen(true);
break;
case GameWindowMode::Borderless:
win->SetBorderless(true, false);
break;
case GameWindowMode::FullscreenBorderless:
win->SetBorderless(true, true);
break;
}
#endif
}
void ScreenService::Update() void ScreenService::Update()
{ {
#if USE_EDITOR #if USE_EDITOR

View File

@@ -2,6 +2,7 @@
#pragma once #pragma once
#include "Engine/Core/Config/PlatformSettingsBase.h"
#include "Engine/Scripting/ScriptingType.h" #include "Engine/Scripting/ScriptingType.h"
#include "Engine/Input/Enums.h" #include "Engine/Input/Enums.h"
#include "Engine/Core/Math/Vector2.h" #include "Engine/Core/Math/Vector2.h"
@@ -80,4 +81,19 @@ DECLARE_SCRIPTING_TYPE_NO_SPAWN(Screen);
/// </summary> /// </summary>
/// <param name="mode">The mode.</param> /// <param name="mode">The mode.</param>
API_PROPERTY() static void SetCursorLock(CursorLockMode mode); API_PROPERTY() static void SetCursorLock(CursorLockMode mode);
/// <summary>
/// Gets the game window mode.
/// </summary>
/// <returns>The current window mode.</returns>
API_PROPERTY() static GameWindowMode GetGameWindowMode();
/// <summary>
/// Sets the game window mode.
/// </summary>
/// <remarks>
/// A fullscreen mode switch may not happen immediately. It will be performed before next frame rendering. Will not work in editor.
/// </remarks>
/// <param name="windowMode">The window mode.</param>
API_PROPERTY() static void SetGameWindowMode(GameWindowMode windowMode);
}; };

View File

@@ -675,20 +675,12 @@ bool Prefab::ApplyAll(Actor* targetActor)
} }
} }
// Setup default instances // Setup default instances (skip invalid prefabs)
for (int32 i = 0; i < allPrefabs.Count(); i++) for (int32 i = allPrefabs.Count() - 1; i >= 0; i--)
{ {
Prefab* prefab = allPrefabs[i]; Prefab* prefab = allPrefabs[i];
if (prefab->WaitForLoaded()) if (prefab->WaitForLoaded() || prefab->GetDefaultInstance() == nullptr)
{ allPrefabs.RemoveAt(i);
LOG(Warning, "Waiting for nesting prefab asset load failed.");
return true;
}
if (prefab->GetDefaultInstance() == nullptr)
{
LOG(Warning, "Failed to create default prefab instance for the nested prefab asset.");
return true;
}
} }
} }

View File

@@ -1412,9 +1412,9 @@ void NetworkInternal::NetworkReplicatorUpdate()
if (!CachedReplicationResult) if (!CachedReplicationResult)
CachedReplicationResult = New<NetworkReplicationHierarchyUpdateResult>(); CachedReplicationResult = New<NetworkReplicationHierarchyUpdateResult>();
CachedReplicationResult->Init(); CachedReplicationResult->Init();
if (!isClient && NetworkManager::Clients.IsEmpty()) if ((!isClient && NetworkManager::Clients.IsEmpty()) || NetworkManager::NetworkFPS < -ZeroTolerance)
{ {
// No need to update replication when nobody's around // No need to update replication when nobody's around or when replication is disabled
} }
else if (Hierarchy) else if (Hierarchy)
{ {

View File

@@ -445,6 +445,15 @@ public:
{ {
} }
/// <summary>
/// Sets the window to be borderless or not and to be fullscreen.
/// </summary>
/// <param name="isBorderless">Whether or not to have borders on window.</param>
/// <param name="maximized">Whether or not to make the borderless window fullscreen (maximize to cover whole screen).</param>
API_FUNCTION() virtual void SetBorderless(bool isBorderless, bool maximized = false)
{
}
/// <summary> /// <summary>
/// Restores the window state before minimizing or maximizing. /// Restores the window state before minimizing or maximizing.
/// </summary> /// </summary>

View File

@@ -202,8 +202,7 @@ void GetDragDropData(const MacWindow* window, id<NSDraggingInfo> sender, Float2&
{ {
NSRect frame = [(NSWindow*)window->GetNativePtr() frame]; NSRect frame = [(NSWindow*)window->GetNativePtr() frame];
NSPoint point = [sender draggingLocation]; NSPoint point = [sender draggingLocation];
Float2 titleSize = GetWindowTitleSize(window); mousePos = Float2(point.x, frame.size.height - point.y) * MacPlatform::ScreenScale - GetWindowTitleSize(window);
mousePos = Float2(point.x, frame.size.height - point.y) - titleSize;
NSPasteboard* pasteboard = [sender draggingPasteboard]; NSPasteboard* pasteboard = [sender draggingPasteboard];
if ([[pasteboard types] containsObject:NSPasteboardTypeString]) if ([[pasteboard types] containsObject:NSPasteboardTypeString])
{ {

View File

@@ -316,7 +316,8 @@ bool WindowsFileSystem::ShowBrowseFolderDialog(Window* parentWindow, const Strin
if (SUCCEEDED(SHCreateItemFromParsingName(initialDirectory.Get(), NULL, IID_PPV_ARGS(&defaultFolder)))) if (SUCCEEDED(SHCreateItemFromParsingName(initialDirectory.Get(), NULL, IID_PPV_ARGS(&defaultFolder))))
fd->SetFolder(defaultFolder); fd->SetFolder(defaultFolder);
if (SUCCEEDED(fd->Show(parentWindow->GetHWND()))) HWND hwndOwner = parentWindow ? parentWindow->GetHWND() : NULL;
if (SUCCEEDED(fd->Show(hwndOwner)))
{ {
ComPtr<IShellItem> si; ComPtr<IShellItem> si;
if (SUCCEEDED(fd->GetResult(&si))) if (SUCCEEDED(fd->GetResult(&si)))

View File

@@ -260,6 +260,75 @@ void WindowsWindow::Maximize()
_isDuringMaximize = false; _isDuringMaximize = false;
} }
void WindowsWindow::SetBorderless(bool isBorderless, bool maximized)
{
ASSERT(HasHWND());
if (IsFullscreen())
SetIsFullscreen(false);
// Fixes issue of borderless window not going full screen
if (IsMaximized())
Restore();
_settings.HasBorder = !isBorderless;
BringToFront();
if (isBorderless)
{
LONG lStyle = GetWindowLong(_handle, GWL_STYLE);
lStyle &= ~(WS_THICKFRAME | WS_SYSMENU | WS_OVERLAPPED | WS_BORDER | WS_CAPTION);
lStyle |= WS_POPUP;
lStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
#if WINDOWS_USE_NEW_BORDER_LESS
if (_settings.IsRegularWindow)
style |= WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | WS_THICKFRAME | WS_GROUP;
#elif WINDOWS_USE_NEWER_BORDER_LESS
if (_settings.IsRegularWindow)
lStyle |= WS_THICKFRAME | WS_SYSMENU;
#endif
SetWindowLong(_handle, GWL_STYLE, lStyle);
SetWindowPos(_handle, HWND_TOP, 0, 0,0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
if (maximized)
{
ShowWindow(_handle, SW_SHOWMAXIMIZED);
}
else
{
ShowWindow(_handle, SW_SHOW);
}
}
else
{
LONG lStyle = GetWindowLong(_handle, GWL_STYLE);
lStyle &= ~(WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS);
if (_settings.AllowMaximize)
lStyle |= WS_MAXIMIZEBOX;
if (_settings.AllowMinimize)
lStyle |= WS_MINIMIZEBOX;
if (_settings.HasSizingFrame)
lStyle |= WS_THICKFRAME;
lStyle |= WS_OVERLAPPED | WS_SYSMENU | WS_BORDER | WS_CAPTION;
SetWindowLong(_handle, GWL_STYLE, lStyle);
SetWindowPos(_handle, nullptr, 0, 0, (int)_settings.Size.X, (int)_settings.Size.Y, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
if (maximized)
{
Maximize();
}
else
{
ShowWindow(_handle, SW_SHOW);
}
}
CheckForWindowResize();
}
void WindowsWindow::Restore() void WindowsWindow::Restore()
{ {
ASSERT(HasHWND()); ASSERT(HasHWND());

View File

@@ -100,6 +100,7 @@ public:
void Hide() override; void Hide() override;
void Minimize() override; void Minimize() override;
void Maximize() override; void Maximize() override;
void SetBorderless(bool isBorderless, bool maximized = false) override;
void Restore() override; void Restore() override;
bool IsClosed() const override; bool IsClosed() const override;
bool IsForegroundWindow() const override; bool IsForegroundWindow() const override;

View File

@@ -1125,42 +1125,67 @@ bool TerrainPatch::InitializeHeightMap()
float* TerrainPatch::GetHeightmapData() float* TerrainPatch::GetHeightmapData()
{ {
PROFILE_CPU_NAMED("Terrain.GetHeightmapData");
if (_cachedHeightMap.HasItems()) if (_cachedHeightMap.HasItems())
return _cachedHeightMap.Get(); return _cachedHeightMap.Get();
PROFILE_CPU_NAMED("Terrain.GetHeightmapData");
CacheHeightData(); CacheHeightData();
return _cachedHeightMap.Get(); return _cachedHeightMap.Get();
} }
void TerrainPatch::ClearHeightmapCache()
{
PROFILE_CPU_NAMED("Terrain.ClearHeightmapCache");
_cachedHeightMap.Clear();
}
byte* TerrainPatch::GetHolesMaskData() byte* TerrainPatch::GetHolesMaskData()
{ {
PROFILE_CPU_NAMED("Terrain.GetHolesMaskData");
if (_cachedHolesMask.HasItems()) if (_cachedHolesMask.HasItems())
return _cachedHolesMask.Get(); return _cachedHolesMask.Get();
PROFILE_CPU_NAMED("Terrain.GetHolesMaskData");
CacheHeightData(); CacheHeightData();
return _cachedHolesMask.Get(); return _cachedHolesMask.Get();
} }
void TerrainPatch::ClearHolesMaskCache()
{
PROFILE_CPU_NAMED("Terrain.ClearHolesMaskCache");
_cachedHolesMask.Clear();
}
Color32* TerrainPatch::GetSplatMapData(int32 index) Color32* TerrainPatch::GetSplatMapData(int32 index)
{ {
ASSERT(index >= 0 && index < TERRAIN_MAX_SPLATMAPS_COUNT); ASSERT(index >= 0 && index < TERRAIN_MAX_SPLATMAPS_COUNT);
PROFILE_CPU_NAMED("Terrain.GetSplatMapData");
if (_cachedSplatMap[index].HasItems()) if (_cachedSplatMap[index].HasItems())
return _cachedSplatMap[index].Get(); return _cachedSplatMap[index].Get();
PROFILE_CPU_NAMED("Terrain.GetSplatMapData");
CacheSplatData(); CacheSplatData();
return _cachedSplatMap[index].Get(); return _cachedSplatMap[index].Get();
} }
void TerrainPatch::ClearSplatMapCache()
{
PROFILE_CPU_NAMED("Terrain.ClearSplatMapCache");
_cachedSplatMap->Clear();
}
void TerrainPatch::ClearCache()
{
ClearHeightmapCache();
ClearHolesMaskCache();
ClearSplatMapCache();
}
void TerrainPatch::CacheHeightData() void TerrainPatch::CacheHeightData()
{ {
PROFILE_CPU_NAMED("Terrain.CacheHeightData"); PROFILE_CPU_NAMED("Terrain.CacheHeightData");

View File

@@ -229,12 +229,22 @@ public:
/// <returns>The heightmap data.</returns> /// <returns>The heightmap data.</returns>
float* GetHeightmapData(); float* GetHeightmapData();
/// <summary>
/// Clears cache of the heightmap data.
/// </summary>
void ClearHeightmapCache();
/// <summary> /// <summary>
/// Gets the raw pointer to the holes mask data. /// Gets the raw pointer to the holes mask data.
/// </summary> /// </summary>
/// <returns>The holes mask data.</returns> /// <returns>The holes mask data.</returns>
byte* GetHolesMaskData(); byte* GetHolesMaskData();
/// <summary>
/// Clears cache of the holes mask data.
/// </summary>
void ClearHolesMaskCache();
/// <summary> /// <summary>
/// Gets the raw pointer to the splat map data. /// Gets the raw pointer to the splat map data.
/// </summary> /// </summary>
@@ -242,6 +252,16 @@ public:
/// <returns>The splat map data.</returns> /// <returns>The splat map data.</returns>
Color32* GetSplatMapData(int32 index); Color32* GetSplatMapData(int32 index);
/// <summary>
/// Clears cache of the splat map data.
/// </summary>
void ClearSplatMapCache();
/// <summary>
/// Clears all caches.
/// </summary>
void ClearCache();
/// <summary> /// <summary>
/// Modifies the terrain patch heightmap with the given samples. /// Modifies the terrain patch heightmap with the given samples.
/// </summary> /// </summary>

View File

@@ -80,21 +80,27 @@ namespace FlaxEngine.GUI
public Color BackgroundColorSelected { get; set; } public Color BackgroundColorSelected { get; set; }
/// <summary> /// <summary>
/// Gets or sets the color of the border. /// Gets or sets whether the button has a border.
/// </summary> /// </summary>
[EditorDisplay("Border Style"), EditorOrder(2010), ExpandGroups] [EditorDisplay("Border Style"), EditorOrder(2010), ExpandGroups]
public bool HasBorder { get; set; } = true;
/// <summary>
/// Gets or sets the color of the border.
/// </summary>
[EditorDisplay("Border Style"), EditorOrder(2011), ExpandGroups]
public Color BorderColor { get; set; } public Color BorderColor { get; set; }
/// <summary> /// <summary>
/// Gets or sets the border color when button is highlighted. /// Gets or sets the border color when button is highlighted.
/// </summary> /// </summary>
[EditorDisplay("Border Style"), EditorOrder(2011)] [EditorDisplay("Border Style"), EditorOrder(2012)]
public Color BorderColorHighlighted { get; set; } public Color BorderColorHighlighted { get; set; }
/// <summary> /// <summary>
/// Gets or sets the border color when button is selected. /// Gets or sets the border color when button is selected.
/// </summary> /// </summary>
[EditorDisplay("Border Style"), EditorOrder(2012)] [EditorDisplay("Border Style"), EditorOrder(2013)]
public Color BorderColorSelected { get; set; } public Color BorderColorSelected { get; set; }
/// <summary> /// <summary>
@@ -245,7 +251,8 @@ namespace FlaxEngine.GUI
BackgroundBrush.Draw(clientRect, backgroundColor); BackgroundBrush.Draw(clientRect, backgroundColor);
else else
Render2D.FillRectangle(clientRect, backgroundColor); Render2D.FillRectangle(clientRect, backgroundColor);
Render2D.DrawRectangle(clientRect, borderColor); if (HasBorder)
Render2D.DrawRectangle(clientRect, borderColor);
// Draw text // Draw text
Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center); Render2D.DrawText(_font?.GetFont(), TextMaterial, _text, clientRect, textColor, TextAlignment.Center, TextAlignment.Center);