Add more iOS platform impl

This commit is contained in:
Wojtek Figat
2023-03-18 22:43:13 +01:00
parent c615ad18a8
commit 0232197cdc
4 changed files with 28 additions and 5 deletions

View File

@@ -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();

View File

@@ -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 <UIKit/UIKit.h>
#include <sys/utsname.h>
@@ -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()

View File

@@ -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;

View File

@@ -26,6 +26,7 @@ public:
~iOSWindow();
void CheckForResize(float width, float height);
void* GetViewController() const { return _viewController; }
public: