Optimize some includes and use automatic serializers for platform settings

This commit is contained in:
Wojtek Figat
2023-11-13 23:54:07 +01:00
parent 348ed463fc
commit eaafb72ca9
14 changed files with 20 additions and 124 deletions

View File

@@ -3,7 +3,7 @@
#pragma once
#include "Engine/Core/Config/Settings.h"
#include "Engine/Serialization/Serialization.h"
#include "Engine/Serialization/SerializationFwd.h"
/// <summary>
/// Specifies the display mode of a game window.

View File

@@ -3,7 +3,6 @@
#pragma once
#include "../Enums.h"
#include "Engine/Core/Math/Math.h"
/// <summary>
/// Material domain type. Material domain defines the target usage of the material shader.

View File

@@ -4,6 +4,7 @@
#include "Engine/Graphics/GPUDevice.h"
#include "Engine/Graphics/GPUResource.h"
#include "Engine/Core/Collections/Dictionary.h"
#include "../GPUDeviceDX.h"
#include "../IncludeDirectXHeaders.h"

View File

@@ -7,6 +7,7 @@
#include "Engine/Graphics/GPUPipelineState.h"
#include "GPUDeviceDX12.h"
#include "Types.h"
#include "Engine/Core/Collections/Dictionary.h"
#include "../IncludeDirectXHeaders.h"
class GPUTextureViewDX12;

View File

@@ -6,16 +6,15 @@
#include "Engine/Core/Config/PlatformSettingsBase.h"
#include "Engine/Scripting/SoftObjectReference.h"
class Texture;
#include "Engine/Content/Assets/Texture.h"
/// <summary>
/// Android platform settings.
/// </summary>
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API AndroidPlatformSettings : public SettingsBase
{
DECLARE_SCRIPTING_TYPE_MINIMAL(AndroidPlatformSettings);
public:
DECLARE_SCRIPTING_TYPE_MINIMAL(AndroidPlatformSettings);
API_AUTO_SERIALIZATION();
/// <summary>
/// The application package name (eg. com.company.product). Custom tokens: ${PROJECT_NAME}, ${COMPANY_NAME}.
@@ -35,20 +34,10 @@ public:
API_FIELD(Attributes="EditorOrder(1030), EditorDisplay(\"Other\")")
SoftObjectReference<Texture> OverrideIcon;
public:
/// <summary>
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
/// </summary>
static AndroidPlatformSettings* Get();
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
DESERIALIZE(PackageName);
DESERIALIZE(Permissions);
DESERIALIZE(OverrideIcon);
}
};
#if PLATFORM_ANDROID

View File

@@ -16,6 +16,7 @@ class Texture;
API_CLASS(Abstract, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API ApplePlatformSettings : public SettingsBase
{
DECLARE_SCRIPTING_TYPE_MINIMAL(ApplePlatformSettings);
API_AUTO_SERIALIZATION();
/// <summary>
/// The app identifier (reversed DNS, eg. com.company.product). Custom tokens: ${PROJECT_NAME}, ${COMPANY_NAME}.
@@ -28,14 +29,6 @@ API_CLASS(Abstract, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_AP
/// </summary>
API_FIELD(Attributes="EditorOrder(1000), EditorDisplay(\"Other\")")
SoftObjectReference<Texture> OverrideIcon;
public:
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override
{
DESERIALIZE(AppIdentifier);
DESERIALIZE(OverrideIcon);
}
};
#endif

View File

@@ -16,7 +16,8 @@ class Texture;
API_CLASS(Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API GDKPlatformSettings : public SettingsBase
{
DECLARE_SCRIPTING_TYPE_MINIMAL(GDKPlatformSettings);
public:
API_AUTO_SERIALIZATION();
/// <summary>
/// Game identity name stored in game package manifest (for store). If empty the product name will be used from Game Settings.
/// </summary>
@@ -118,28 +119,6 @@ public:
/// </summary>
API_FIELD(Attributes="EditorOrder(420), EditorDisplay(\"Media Capture\")")
bool BlockGameDVR = false;
public:
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override
{
DESERIALIZE(Name);
DESERIALIZE(PublisherName);
DESERIALIZE(PublisherDisplayName);
DESERIALIZE(Square150x150Logo);
DESERIALIZE(Square480x480Logo);
DESERIALIZE(Square44x44Logo);
DESERIALIZE(SplashScreenImage);
DESERIALIZE(StoreLogo);
DESERIALIZE(BackgroundColor);
DESERIALIZE(TitleId);
DESERIALIZE(StoreId);
DESERIALIZE(RequiresXboxLive);
DESERIALIZE(SCID);
DESERIALIZE(GameDVRSystemComponent);
DESERIALIZE(BlockBroadcast);
DESERIALIZE(BlockGameDVR);
}
};
#endif

View File

@@ -14,8 +14,8 @@ class Texture;
/// </summary>
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API LinuxPlatformSettings : public SettingsBase
{
DECLARE_SCRIPTING_TYPE_MINIMAL(LinuxPlatformSettings);
public:
DECLARE_SCRIPTING_TYPE_MINIMAL(LinuxPlatformSettings);
API_AUTO_SERIALIZATION();
/// <summary>
/// The default game window mode.
@@ -65,25 +65,10 @@ public:
API_FIELD(Attributes="EditorOrder(2000), DefaultValue(true), EditorDisplay(\"Graphics\")")
bool SupportVulkan = true;
public:
/// <summary>
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
/// </summary>
static LinuxPlatformSettings* Get();
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
DESERIALIZE(WindowMode);
DESERIALIZE(ScreenWidth);
DESERIALIZE(ScreenHeight);
DESERIALIZE(RunInBackground);
DESERIALIZE(ResizableWindow);
DESERIALIZE(ForceSingleInstance);
DESERIALIZE(OverrideIcon);
DESERIALIZE(SupportVulkan);
}
};
#if PLATFORM_LINUX

View File

@@ -12,6 +12,7 @@
API_CLASS(Sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API MacPlatformSettings : public ApplePlatformSettings
{
DECLARE_SCRIPTING_TYPE_MINIMAL(MacPlatformSettings);
API_AUTO_SERIALIZATION();
/// <summary>
/// The default game window mode.
@@ -43,22 +44,10 @@ API_CLASS(Sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
API_FIELD(Attributes="EditorOrder(1010), EditorDisplay(\"Other\", \"Run In Background\")")
bool RunInBackground = false;
public:
/// <summary>
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
/// </summary>
static MacPlatformSettings* Get();
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
ApplePlatformSettings::Deserialize(stream, modifier);
DESERIALIZE(WindowMode);
DESERIALIZE(ScreenWidth);
DESERIALIZE(ScreenHeight);
DESERIALIZE(ResizableWindow);
DESERIALIZE(RunInBackground);
}
};
#if PLATFORM_MAC

View File

@@ -11,8 +11,8 @@
/// </summary>
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API UWPPlatformSettings : public SettingsBase
{
DECLARE_SCRIPTING_TYPE_MINIMAL(UWPPlatformSettings);
public:
DECLARE_SCRIPTING_TYPE_MINIMAL(UWPPlatformSettings);
API_AUTO_SERIALIZATION();
/// <summary>
/// The preferred launch windowing mode.
@@ -66,8 +66,6 @@ public:
All = Landscape | LandscapeFlipped | Portrait | PortraitFlipped
};
public:
/// <summary>
/// The preferred launch windowing mode. Always fullscreen on Xbox.
/// </summary>
@@ -98,22 +96,10 @@ public:
API_FIELD(Attributes="EditorOrder(2010), DefaultValue(false), EditorDisplay(\"Graphics\", \"Support DirectX 10\")")
bool SupportDX10 = false;
public:
/// <summary>
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
/// </summary>
static UWPPlatformSettings* Get();
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
DESERIALIZE(PreferredLaunchWindowingMode);
DESERIALIZE(AutoRotationPreferences);
DESERIALIZE(CertificateLocation);
DESERIALIZE(SupportDX11);
DESERIALIZE(SupportDX10);
}
};
#if PLATFORM_UWP

View File

@@ -14,8 +14,8 @@ class Texture;
/// </summary>
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API WindowsPlatformSettings : public SettingsBase
{
DECLARE_SCRIPTING_TYPE_MINIMAL(WindowsPlatformSettings);
public:
DECLARE_SCRIPTING_TYPE_MINIMAL(WindowsPlatformSettings);
API_AUTO_SERIALIZATION();
/// <summary>
/// The default game window mode.
@@ -83,28 +83,10 @@ public:
API_FIELD(Attributes="EditorOrder(2030), DefaultValue(false), EditorDisplay(\"Graphics\")")
bool SupportVulkan = false;
public:
/// <summary>
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
/// </summary>
static WindowsPlatformSettings* Get();
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
DESERIALIZE(WindowMode);
DESERIALIZE(ScreenWidth);
DESERIALIZE(ScreenHeight);
DESERIALIZE(RunInBackground);
DESERIALIZE(ResizableWindow);
DESERIALIZE(ForceSingleInstance);
DESERIALIZE(OverrideIcon);
DESERIALIZE(SupportDX12);
DESERIALIZE(SupportDX11);
DESERIALIZE(SupportDX10);
DESERIALIZE(SupportVulkan);
}
};
#if PLATFORM_WINDOWS

View File

@@ -12,6 +12,7 @@
API_CLASS(Sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API iOSPlatformSettings : public ApplePlatformSettings
{
DECLARE_SCRIPTING_TYPE_MINIMAL(ApplePlatformSettings);
API_AUTO_SERIALIZATION();
/// <summary>
/// The app export destination methods.
@@ -79,17 +80,6 @@ API_CLASS(Sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
/// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use.
/// </summary>
static iOSPlatformSettings* Get();
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
ApplePlatformSettings::Deserialize(stream, modifier);
DESERIALIZE(AppTeamId);
DESERIALIZE(AppVersion);
DESERIALIZE(ExportMethod);
DESERIALIZE(SupportedInterfaceOrientationsiPhone);
DESERIALIZE(SupportedInterfaceOrientationsiPad);
}
};
#if PLATFORM_IOS

View File

@@ -3,6 +3,7 @@
#pragma once
#include "SerializationFwd.h"
#include "ISerializeModifier.h"
#include "Engine/Core/Collections/Array.h"
#include "Engine/Core/Collections/Dictionary.h"
#include "Engine/Scripting/ScriptingObject.h"

View File

@@ -3,10 +3,11 @@
#pragma once
#include "Engine/Core/ISerializable.h"
#include "ISerializeModifier.h"
#include "Json.h"
#include "JsonWriter.h"
class ISerializeModifier;
// The floating-point values serialization epsilon for equality checks precision
#define SERIALIZE_EPSILON 1e-7f
#define SERIALIZE_EPSILON_DOUBLE 1e-17