Files
UnrealEngineUWP/Engine/Source/Programs/SlateUGS/Private/Platforms/Mac/SlateUGSMainMac.cpp
robert seiver 3810bb1598 Add experimental Slate UGS prototype that has UI frontend, no data layer yet.
See the attached Jira for a current screenshot of the UI

#jira UE-148909
#review @Brandon.Schaefer, @editor-ux
#preflight none

[CL 20368463 by robert seiver in ue5-main branch]
2022-05-25 14:02:29 -04:00

86 lines
2.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SlateUGSApp.h"
#include "HAL/ExceptionHandling.h"
#include "Mac/CocoaThread.h"
static FString GSavedCommandLine;
@interface UEAppDelegate : NSObject <NSApplicationDelegate, NSFileManagerDelegate>
{
}
@end
@implementation UEAppDelegate
//handler for the quit apple event used by the Dock menu
- (void)handleQuitEvent:(NSAppleEventDescriptor*)Event withReplyEvent:(NSAppleEventDescriptor*)ReplyEvent
{
[NSApp terminate:self];
}
- (void) runGameThread:(id)Arg
{
FPlatformMisc::SetGracefulTerminationHandler();
FPlatformMisc::SetCrashHandler(nullptr);
RunSlateUGS(*GSavedCommandLine);
[NSApp terminate: self];
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)Sender;
{
if(!IsEngineExitRequested() || ([NSThread gameThread] && [NSThread gameThread] != [NSThread mainThread]))
{
RequestEngineExit(TEXT("applicationShouldTerminate"));
return NSTerminateLater;
}
else
{
return NSTerminateNow;
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)Notification
{
//install the custom quit event handler
NSAppleEventManager* appleEventManager = [NSAppleEventManager sharedAppleEventManager];
[appleEventManager setEventHandler:self andSelector:@selector(handleQuitEvent:withReplyEvent:) forEventClass:kCoreEventClass andEventID:kAEQuitApplication];
RunGameThread(self, @selector(runGameThread:));
}
@end
int main(int argc, char *argv[])
{
for (int32 Option = 1; Option < argc; Option++)
{
GSavedCommandLine += TEXT(" ");
FString Argument(ANSI_TO_TCHAR(argv[Option]));
if (Argument.Contains(TEXT(" ")))
{
if (Argument.Contains(TEXT("=")))
{
FString ArgName;
FString ArgValue;
Argument.Split( TEXT("="), &ArgName, &ArgValue );
Argument = FString::Printf( TEXT("%s=\"%s\""), *ArgName, *ArgValue );
}
else
{
Argument = FString::Printf(TEXT("\"%s\""), *Argument);
}
}
GSavedCommandLine += Argument;
}
SCOPED_AUTORELEASE_POOL;
[NSApplication sharedApplication];
[NSApp setDelegate:[UEAppDelegate new]];
[NSApp run];
return 0;
}