diff --git a/Source/Engine/Platform/Apple/ApplePlatform.h b/Source/Engine/Platform/Apple/ApplePlatform.h index f072bf222..fdc0f45c7 100644 --- a/Source/Engine/Platform/Apple/ApplePlatform.h +++ b/Source/Engine/Platform/Apple/ApplePlatform.h @@ -89,9 +89,7 @@ public: static void CreateGuid(Guid& result); static bool CanOpenUrl(const StringView& url); static void OpenUrl(const StringView& url); - static Rectangle GetMonitorBounds(const Float2& screenPos); static Float2 GetDesktopSize(); - static Rectangle GetVirtualDesktopBounds(); static String GetMainDirectory(); static String GetExecutableFilePath(); static String GetWorkingDirectory(); diff --git a/Source/Engine/Platform/iOS/iOSPlatform.cpp b/Source/Engine/Platform/iOS/iOSPlatform.cpp index c327b57e4..8960ff452 100644 --- a/Source/Engine/Platform/iOS/iOSPlatform.cpp +++ b/Source/Engine/Platform/iOS/iOSPlatform.cpp @@ -6,8 +6,13 @@ #include "iOSWindow.h" #include "Engine/Core/Log.h" #include "Engine/Core/Types/String.h" +#include "Engine/Core/Collections/Array.h" +#include "Engine/Platform/Apple/AppleUtils.h" #include "Engine/Platform/StringUtils.h" #include "Engine/Platform/MessageBox.h" +#include "Engine/Platform/Window.h" +#include "Engine/Platform/WindowsManager.h" +#include "Engine/Threading/Threading.h" #include #include @@ -16,7 +21,20 @@ Guid DeviceId; DialogResult MessageBox::Show(Window* parent, const StringView& text, const StringView& caption, MessageBoxButtons buttons, MessageBoxIcon icon) { - // TODO: implement message box popup on iOS + NSString* title = (NSString*)AppleUtils::ToString(caption); + NSString* message = (NSString*)AppleUtils::ToString(text); + UIAlertController* alert = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; + UIAlertAction* button = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:^(id){ }]; + [alert addAction:button]; + ScopeLock lock(WindowsManager::WindowsLocker); + for (auto window : WindowsManager::Windows) + { + if (window->IsVisible()) + { + [(UIViewController*)window->GetViewController() presentViewController:alert animated:YES completion:nil]; + break; + } + } return DialogResult::OK; } @@ -29,6 +47,13 @@ bool iOSPlatform::Init() CustomDpiScale *= ScreenScale; Dpi = 72; // TODO: calculate screen dpi (probably hardcoded map for iPhone model) + // Get device identifier + NSString* uuid = [UIDevice currentDevice].identifierForVendor.UUIDString; + String uuidStr = AppleUtils::ToString((CFStringRef)uuid); + Guid::Parse(uuidStr, DeviceId); + + // TODO: add Gamepad for vibrations usability + return false; } @@ -57,7 +82,7 @@ int32 iOSPlatform::GetDpi() Guid iOSPlatform::GetUniqueDeviceId() { - return Guid::Empty; // TODO: use MAC address of the iPhone to generate device id (at least within network connection state) + return DeviceId; } String iOSPlatform::GetComputerName() diff --git a/Source/Engine/Platform/iOS/iOSWindow.cpp b/Source/Engine/Platform/iOS/iOSWindow.cpp index a4d7ec619..f7a2b83a5 100644 --- a/Source/Engine/Platform/iOS/iOSWindow.cpp +++ b/Source/Engine/Platform/iOS/iOSWindow.cpp @@ -85,7 +85,6 @@ iOSWindow::iOSWindow(const CreateWindowSettings& settings) [v setNeedsDisplay]; [v setHidden:NO]; [v setOpaque:YES]; - [v setAutoResizeDrawable:YES]; v.backgroundColor = [UIColor clearColor]; v.window = this; diff --git a/Source/Engine/Platform/iOS/iOSWindow.h b/Source/Engine/Platform/iOS/iOSWindow.h index 1c934df1e..86a7fb67b 100644 --- a/Source/Engine/Platform/iOS/iOSWindow.h +++ b/Source/Engine/Platform/iOS/iOSWindow.h @@ -26,6 +26,7 @@ public: ~iOSWindow(); void CheckForResize(float width, float height); + void* GetViewController() const { return _viewController; } public: