From fa838694309f50c28ed67396be92146bb1d2925c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 4 Jan 2022 23:56:54 +0100 Subject: [PATCH] Add minor changes --- Source/Editor/GUI/Timeline/Media.cs | 4 ++-- Source/Editor/GUI/Timeline/Timeline.cs | 8 ++++---- Source/Editor/Scripting/ScriptsBuilder.h | 1 - Source/Engine/Animations/AnimationUtils.h | 8 +++++++- Source/Engine/Content/Assets/Animation.h | 2 +- Source/Engine/Level/Level.cpp | 6 +++--- .../Attributes/Editor/TypeReferenceAttribute.cs | 2 +- Source/Engine/Serialization/JsonSerializer.h | 11 +++++++++++ 8 files changed, 29 insertions(+), 13 deletions(-) diff --git a/Source/Editor/GUI/Timeline/Media.cs b/Source/Editor/GUI/Timeline/Media.cs index 0df13d1d3..f902345fa 100644 --- a/Source/Editor/GUI/Timeline/Media.cs +++ b/Source/Editor/GUI/Timeline/Media.cs @@ -91,7 +91,7 @@ namespace FlaxEditor.GUI.Timeline /// The media. protected ProxyBase(TTrack track, TMedia media) { - Track = track ?? throw new ArgumentNullException(nameof(track)); + Track = track; Media = media ?? throw new ArgumentNullException(nameof(media)); } } @@ -341,7 +341,7 @@ namespace FlaxEditor.GUI.Timeline var style = Style.Current; var bounds = new Rectangle(Vector2.Zero, Size); - var fillColor = style.Background * 1.5f; + var fillColor = BackgroundColor.A > 0.0f ? BackgroundColor : style.Background * 1.5f; Render2D.FillRectangle(bounds, fillColor); var isMovingWholeMedia = _isMoving && !_startMoveRightEdge && !_startMoveLeftEdge; diff --git a/Source/Editor/GUI/Timeline/Timeline.cs b/Source/Editor/GUI/Timeline/Timeline.cs index 0067d8010..e20ae0a69 100644 --- a/Source/Editor/GUI/Timeline/Timeline.cs +++ b/Source/Editor/GUI/Timeline/Timeline.cs @@ -1898,16 +1898,16 @@ namespace FlaxEditor.GUI.Timeline media.OnTimelineShowContextMenu(menu, controlUnderMouse); if (media.PropertiesEditObject != null) { - menu.AddButton("Edit media", () => ShowEditPopup(media.PropertiesEditObject, ref location, media.Track)); + menu.AddButton("Edit media", () => ShowEditPopup(media.PropertiesEditObject, location, media.Track)); } } if (PropertiesEditObject != null) { - menu.AddButton("Edit timeline", () => ShowEditPopup(PropertiesEditObject, ref location, this)); + menu.AddButton("Edit timeline", () => ShowEditPopup(PropertiesEditObject, location, this)); } if (_tracks.Count > 1) { - menu.AddButton("Sort tracks", SortTracks).TooltipText = "Sorts sub tracks alphabetically"; + menu.AddButton("Sort tracks", SortTracks).TooltipText = "Sorts tracks alphabetically"; } menu.AddSeparator(); menu.AddButton("Reset zoom", () => Zoom = 1.0f); @@ -2089,7 +2089,7 @@ namespace FlaxEditor.GUI.Timeline /// The object. /// The show location (in timeline space). /// The undo context object. - protected virtual void ShowEditPopup(object obj, ref Vector2 location, object undoContext = null) + public virtual void ShowEditPopup(object obj, Vector2 location, object undoContext = null) { var popup = new PropertiesEditPopup(this, obj, undoContext); popup.Show(this, location); diff --git a/Source/Editor/Scripting/ScriptsBuilder.h b/Source/Editor/Scripting/ScriptsBuilder.h index d72f4bcb3..7597ffdef 100644 --- a/Source/Editor/Scripting/ScriptsBuilder.h +++ b/Source/Editor/Scripting/ScriptsBuilder.h @@ -4,7 +4,6 @@ #include "Engine/Core/Delegate.h" #include "Engine/Core/Types/String.h" -#include "Engine/Core/Collections/Array.h" #include "Engine/Scripting/ScriptingType.h" /// diff --git a/Source/Engine/Animations/AnimationUtils.h b/Source/Engine/Animations/AnimationUtils.h index c73753964..5afe6bd1b 100644 --- a/Source/Engine/Animations/AnimationUtils.h +++ b/Source/Engine/Animations/AnimationUtils.h @@ -14,7 +14,13 @@ namespace AnimationUtils template FORCE_INLINE static T GetZero() { - return 0.0f; + return T(); + } + + template<> + FORCE_INLINE int32 GetZero() + { + return 0; } template<> diff --git a/Source/Engine/Content/Assets/Animation.h b/Source/Engine/Content/Assets/Animation.h index 0bdb9bdd4..950b7a45a 100644 --- a/Source/Engine/Content/Assets/Animation.h +++ b/Source/Engine/Content/Assets/Animation.h @@ -18,7 +18,7 @@ DECLARE_BINARY_ASSET_HEADER(Animation, 1); /// /// Contains basic information about the animation asset contents. /// - API_STRUCT() struct InfoData + API_STRUCT() struct FLAXENGINE_API InfoData { DECLARE_SCRIPTING_TYPE_NO_SPAWN(InfoData); diff --git a/Source/Engine/Level/Level.cpp b/Source/Engine/Level/Level.cpp index 5c13fc402..89d43046d 100644 --- a/Source/Engine/Level/Level.cpp +++ b/Source/Engine/Level/Level.cpp @@ -605,9 +605,9 @@ public: ScriptingObjectReference ParentActor; SpawnActorAction(Actor* actor, Actor* parent) + : TargetActor(actor) + , ParentActor(parent) { - TargetActor = actor; - ParentActor = parent; } bool Do() const override @@ -623,8 +623,8 @@ public: ScriptingObjectReference TargetActor; DeleteActorAction(Actor* actor) + : TargetActor(actor) { - TargetActor = actor; } bool Do() const override diff --git a/Source/Engine/Scripting/Attributes/Editor/TypeReferenceAttribute.cs b/Source/Engine/Scripting/Attributes/Editor/TypeReferenceAttribute.cs index 94ba188d8..448db8fc6 100644 --- a/Source/Engine/Scripting/Attributes/Editor/TypeReferenceAttribute.cs +++ b/Source/Engine/Scripting/Attributes/Editor/TypeReferenceAttribute.cs @@ -5,7 +5,7 @@ using System; namespace FlaxEngine { /// - /// Specifies a options for an type reference picker in the editor. Allows to customize view or provide custom value assign policy (eg/ restrict types to inherit from a given type). + /// Specifies a options for an type reference picker in the editor. Allows to customize view or provide custom value assign policy (eg. restrict types to inherit from a given type). /// /// [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter)] diff --git a/Source/Engine/Serialization/JsonSerializer.h b/Source/Engine/Serialization/JsonSerializer.h index fd831cfc2..de73026a5 100644 --- a/Source/Engine/Serialization/JsonSerializer.h +++ b/Source/Engine/Serialization/JsonSerializer.h @@ -20,6 +20,17 @@ API_CLASS(Static, Namespace="FlaxEngine.Json") class FLAXENGINE_API JsonSerializ /// The output data. API_FUNCTION() static Array SaveToBytes(ISerializable* obj); + /// + /// Performs object Json deserialization from the raw bytes. + /// + /// The object to deserialize (can be null). + /// The source data to read from. + /// The engine build number of the saved data. Used to resolve old object formats when loading deprecated data. + FORCE_INLINE static void LoadFromBytes(ISerializable* obj, const Array& data, int32 engineBuild) + { + LoadFromBytes(obj, Span(data.Get(), data.Count()), engineBuild); + } + /// /// Performs object Json deserialization from the raw bytes. ///