Merge iOS and macOS platform settings into shared base class

This commit is contained in:
Wojtek Figat
2023-05-12 23:27:57 +02:00
parent 226b1307c0
commit 4a165d0661
3 changed files with 48 additions and 42 deletions

View File

@@ -0,0 +1,41 @@
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
#pragma once
#if PLATFORM_IOS || PLATFORM_MAC || USE_EDITOR
#include "Engine/Core/Config/PlatformSettingsBase.h"
#include "Engine/Core/Types/String.h"
#include "Engine/Scripting/SoftObjectReference.h"
class Texture;
/// <summary>
/// Apple platform settings.
/// </summary>
API_CLASS(abstract, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API ApplePlatformSettings : public SettingsBase
{
DECLARE_SCRIPTING_TYPE_MINIMAL(ApplePlatformSettings);
/// <summary>
/// The app identifier (reversed DNS, eg. com.company.product). Custom tokens: ${PROJECT_NAME}, ${COMPANY_NAME}.
/// </summary>
API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"General\")")
String AppIdentifier = TEXT("com.${COMPANY_NAME}.${PROJECT_NAME}");
/// <summary>
/// Custom icon texture to use for the application (overrides the default one).
/// </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

@@ -4,25 +4,15 @@
#if PLATFORM_MAC || USE_EDITOR
#include "Engine/Core/Config/PlatformSettingsBase.h"
#include "Engine/Core/Types/String.h"
#include "Engine/Scripting/SoftObjectReference.h"
class Texture;
#include "../Apple/ApplePlatformSettings.h"
/// <summary>
/// Mac platform settings.
/// </summary>
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API MacPlatformSettings : public SettingsBase
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API MacPlatformSettings : public ApplePlatformSettings
{
DECLARE_SCRIPTING_TYPE_MINIMAL(MacPlatformSettings);
/// <summary>
/// The app identifier (reversed DNS, eg. com.company.product). Custom tokens: ${PROJECT_NAME}, ${COMPANY_NAME}.
/// </summary>
API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"General\")")
String AppIdentifier = TEXT("com.${COMPANY_NAME}.${PROJECT_NAME}");
/// <summary>
/// The default game window mode.
/// </summary>
@@ -47,12 +37,6 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API
API_FIELD(Attributes="EditorOrder(140), EditorDisplay(\"Window\")")
bool ResizableWindow = false;
/// <summary>
/// Custom icon texture to use for the application (overrides the default one).
/// </summary>
API_FIELD(Attributes="EditorOrder(1000), EditorDisplay(\"Other\")")
SoftObjectReference<Texture> OverrideIcon;
/// <summary>
/// Enables game running when application window loses focus.
/// </summary>
@@ -68,12 +52,11 @@ public:
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
DESERIALIZE(AppIdentifier);
ApplePlatformSettings::Deserialize(stream, modifier);
DESERIALIZE(WindowMode);
DESERIALIZE(ScreenWidth);
DESERIALIZE(ScreenHeight);
DESERIALIZE(ResizableWindow);
DESERIALIZE(OverrideIcon);
DESERIALIZE(RunInBackground);
}
};

View File

@@ -4,32 +4,15 @@
#if PLATFORM_IOS || USE_EDITOR
#include "Engine/Core/Config/PlatformSettingsBase.h"
#include "Engine/Core/Types/String.h"
#include "Engine/Scripting/SoftObjectReference.h"
class Texture;
#include "../Apple/ApplePlatformSettings.h"
/// <summary>
/// iOS platform settings.
/// </summary>
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API iOSPlatformSettings : public SettingsBase
API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API iOSPlatformSettings : public ApplePlatformSettings
{
DECLARE_SCRIPTING_TYPE_MINIMAL(iOSPlatformSettings);
DECLARE_SCRIPTING_TYPE_MINIMAL(ApplePlatformSettings);
/// <summary>
/// The app identifier (reversed DNS, eg. com.company.product). Custom tokens: ${PROJECT_NAME}, ${COMPANY_NAME}.
/// </summary>
API_FIELD(Attributes="EditorOrder(0), EditorDisplay(\"General\")")
String AppIdentifier = TEXT("com.${COMPANY_NAME}.${PROJECT_NAME}");
/// <summary>
/// Custom icon texture to use for the application (overrides the default one).
/// </summary>
API_FIELD(Attributes="EditorOrder(1000), 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>
@@ -38,8 +21,7 @@ public:
// [SettingsBase]
void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) final override
{
DESERIALIZE(AppIdentifier);
DESERIALIZE(OverrideIcon);
ApplePlatformSettings::Deserialize(stream, modifier);
}
};