From 5e07a424170fef522e032ca5c18dc7abeed98bab Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 10 Jun 2023 12:43:10 +0200 Subject: [PATCH] Add app version and ui orientation settings to iOS --- .../Cooker/Platform/iOS/iOSPlatformTools.cpp | 22 +++++++++-- .../Engine/Platform/iOS/iOSPlatformSettings.h | 38 +++++++++++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/Source/Editor/Cooker/Platform/iOS/iOSPlatformTools.cpp b/Source/Editor/Cooker/Platform/iOS/iOSPlatformTools.cpp index 9d9142511..eccd2d733 100644 --- a/Source/Editor/Cooker/Platform/iOS/iOSPlatformTools.cpp +++ b/Source/Editor/Cooker/Platform/iOS/iOSPlatformTools.cpp @@ -19,8 +19,6 @@ #include "Editor/ProjectInfo.h" #include "Editor/Cooker/GameCooker.h" #include "Editor/Utilities/EditorUtilities.h" -#include -using namespace pugi; IMPLEMENT_SETTINGS_GETTER(iOSPlatformSettings, iOSPlatform); @@ -35,6 +33,21 @@ namespace productName.Replace(TEXT("-"), TEXT("")); return productName; } + + String GetUIInterfaceOrientation(iOSPlatformSettings::UIInterfaceOrientations orientations) + { + String result; + if (EnumHasAnyFlags(orientations, iOSPlatformSettings::UIInterfaceOrientations::Portrait)) + result += TEXT("UIInterfaceOrientationPortrait "); + if (EnumHasAnyFlags(orientations, iOSPlatformSettings::UIInterfaceOrientations::PortraitUpsideDown)) + result += TEXT("UIInterfaceOrientationPortraitUpsideDown "); + if (EnumHasAnyFlags(orientations, iOSPlatformSettings::UIInterfaceOrientations::LandscapeLeft)) + result += TEXT("UIInterfaceOrientationLandscapeLeft "); + if (EnumHasAnyFlags(orientations, iOSPlatformSettings::UIInterfaceOrientations::LandscapeRight)) + result += TEXT("UIInterfaceOrientationLandscapeRight "); + result = result.TrimTrailing(); + return result; + } } const Char* iOSPlatformTools::GetDisplayName() const @@ -179,11 +192,12 @@ bool iOSPlatformTools::OnPostProcess(CookingData& data) configReplaceMap[TEXT("${AppName}")] = appName; configReplaceMap[TEXT("${AppIdentifier}")] = appIdentifier; configReplaceMap[TEXT("${AppTeamId}")] = platformSettings->AppTeamId; - configReplaceMap[TEXT("${AppVersion}")] = TEXT("1"); // TODO: expose to iOS platform settings (matches CURRENT_PROJECT_VERSION in XCode) + configReplaceMap[TEXT("${AppVersion}")] = platformSettings->AppVersion; configReplaceMap[TEXT("${ProjectName}")] = gameSettings->ProductName; configReplaceMap[TEXT("${ProjectVersion}")] = projectVersion; configReplaceMap[TEXT("${HeaderSearchPaths}")] = Globals::StartupFolder; - // TODO: screen rotation settings in XCode project from iOS Platform Settings + configReplaceMap[TEXT("${UISupportedInterfaceOrientations_iPhone}")] = GetUIInterfaceOrientation(platformSettings->SupportedInterfaceOrientationsiPhone); + configReplaceMap[TEXT("${UISupportedInterfaceOrientations_iPad}")] = GetUIInterfaceOrientation(platformSettings->SupportedInterfaceOrientationsiPad); { // Initialize auto-generated areas as empty configReplaceMap[TEXT("${PBXBuildFile}")] = String::Empty; diff --git a/Source/Engine/Platform/iOS/iOSPlatformSettings.h b/Source/Engine/Platform/iOS/iOSPlatformSettings.h index f2b4ee64f..5794c18f5 100644 --- a/Source/Engine/Platform/iOS/iOSPlatformSettings.h +++ b/Source/Engine/Platform/iOS/iOSPlatformSettings.h @@ -13,12 +13,47 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API { DECLARE_SCRIPTING_TYPE_MINIMAL(ApplePlatformSettings); + /// + /// The display orientation modes. Can be combined as flags. + /// + API_ENUM(Attributes="Flags") enum class UIInterfaceOrientations + { + // The device is in portrait mode, with the device upright and the Home button on the bottom. + Portrait = 1, + // The device is in portrait mode but is upside down, with the device upright and the Home button at the top. + PortraitUpsideDown = 2, + // The device is in landscape mode, with the device upright and the Home button on the left. + LandscapeLeft = 4, + // The device is in landscape mode, with the device upright and the Home button on the right. + LandscapeRight = 8, + // The all modes. + All = Portrait | PortraitUpsideDown | LandscapeLeft | LandscapeRight + }; + /// /// The app developer name - App Store Team ID. /// API_FIELD(Attributes="EditorOrder(10), EditorDisplay(\"General\")") String AppTeamId; + /// + /// The app version number (matches CURRENT_PROJECT_VERSION in XCode). + /// + API_FIELD(Attributes="EditorOrder(20), EditorDisplay(\"General\")") + String AppVersion = TEXT("1"); + + /// + /// The UI interface orientation modes supported on iPhone devices. + /// + API_FIELD(Attributes="EditorOrder(200), EditorDisplay(\"UI\", \"Supported Interface Orientations (iPhone)\")") + UIInterfaceOrientations SupportedInterfaceOrientationsiPhone = UIInterfaceOrientations::All; + + /// + /// The UI interface orientation modes supported on iPad devices. + /// + API_FIELD(Attributes="EditorOrder(210), EditorDisplay(\"UI\", \"Supported Interface Orientations (iPad)\")") + UIInterfaceOrientations SupportedInterfaceOrientationsiPad = UIInterfaceOrientations::All; + /// /// Gets the instance of the settings asset (default value if missing). Object returned by this method is always loaded with valid data to use. /// @@ -29,6 +64,9 @@ API_CLASS(sealed, Namespace="FlaxEditor.Content.Settings") class FLAXENGINE_API { ApplePlatformSettings::Deserialize(stream, modifier); DESERIALIZE(AppTeamId); + DESERIALIZE(AppVersion); + DESERIALIZE(SupportedInterfaceOrientationsiPhone); + DESERIALIZE(SupportedInterfaceOrientationsiPad); } };