Files
UnrealEngineUWP/Engine/Source/Programs/UnrealFrontend/Private/Mac/MacUnrealFrontendMain.cpp
Michael Trepka e0b50589d2 Removed Mac MainMenu.xib, the app and window menus are now generated dynamically.
[CL 2088627 by Michael Trepka in Main branch]
2014-05-29 17:46:24 -04:00

103 lines
2.4 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
/*=============================================================================
MacUnrealFrontendMain.mm: Implements the main entry point for MacOS.
=============================================================================*/
#include "UnrealFrontendMain.h"
static FString GSavedCommandLine;
@interface UE4AppDelegate : NSObject<NSApplicationDelegate>
{
}
@end
@implementation UE4AppDelegate
//handler for the quit apple event used by the Dock menu
- (void)handleQuitEvent:(NSAppleEventDescriptor*)Event withReplyEvent:(NSAppleEventDescriptor*)ReplyEvent
{
[self requestQuit:self];
}
- (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];
// OS X always uses the CrashReportClient, since the other paths aren't reliable
GUseCrashReportClient = true;
FPlatformMisc::SetGracefulTerminationHandler();
FPlatformMisc::SetCrashHandler(NULL);
#if !UE_BUILD_SHIPPING
if (FParse::Param(*GSavedCommandLine,TEXT("crashreports")))
{
GAlwaysReportCrash = true;
}
#endif
#if UE_BUILD_DEBUG
if (!GAlwaysReportCrash)
#else
if (FPlatformMisc::IsDebuggerPresent() && !GAlwaysReportCrash)
#endif
{
UnrealFrontendMain(*GSavedCommandLine);
}
else
{
GIsGuarded = 1;
UnrealFrontendMain(*GSavedCommandLine);
GIsGuarded = 0;
}
FEngineLoop::AppExit();
[NSApp terminate: self];
}
- (IBAction)requestQuit:(id)Sender
{
GIsRequestingExit = true;
}
@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:[UE4AppDelegate new]];
[NSApp run];
return 0;
}