You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Main implementation by Dominik with build and switchboard support added by me. #jira UE-147235 #rb Dominik.Peacock #preflight 6284fa081f474f0660ecb74e [CL 20264867 by jason walter in ue5-main branch]
125 lines
2.7 KiB
C++
125 lines
2.7 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "UnrealMultiUserSlateServerRun.h"
|
|
#include "HAL/ExceptionHandling.h"
|
|
#include "LaunchEngineLoop.h"
|
|
#include "Misc/CommandLine.h"
|
|
#include "Mac/CocoaThread.h"
|
|
|
|
|
|
static FString GSavedCommandLine;
|
|
|
|
|
|
@interface UnrealAppDelegate : NSObject<NSApplicationDelegate, NSFileManagerDelegate>
|
|
{
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
@implementation UnrealAppDelegate
|
|
|
|
//handler for the quit apple event used by the Dock menu
|
|
- (void)handleQuitEvent:(NSAppleEventDescriptor*)Event withReplyEvent:(NSAppleEventDescriptor*)ReplyEvent
|
|
{
|
|
[self requestQuit:self];
|
|
}
|
|
|
|
- (IBAction)requestQuit:(id)Sender
|
|
{
|
|
RequestEngineExit(TEXT("requestQuit"));
|
|
}
|
|
|
|
- (void)runGameThread:(id)Arg
|
|
{
|
|
FPlatformMisc::SetGracefulTerminationHandler();
|
|
FPlatformMisc::SetCrashHandler(nullptr);
|
|
|
|
#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
|
|
{
|
|
RunUnrealMultiUserServer(*GSavedCommandLine);
|
|
}
|
|
else
|
|
{
|
|
GIsGuarded = 1;
|
|
RunUnrealMultiUserServer(*GSavedCommandLine);
|
|
GIsGuarded = 0;
|
|
}
|
|
|
|
[NSApp terminate: self];
|
|
}
|
|
|
|
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)Sender;
|
|
{
|
|
if(!IsEngineExitRequested() || ([NSThread gameThread] && [NSThread gameThread] != [NSThread mainThread]))
|
|
{
|
|
[self requestQuit:self];
|
|
return NSTerminateLater;
|
|
}
|
|
else
|
|
{
|
|
return NSTerminateNow;
|
|
}
|
|
}
|
|
|
|
- (void) applicationWillTerminate:(NSNotification*)notification
|
|
{
|
|
FTaskTagScope::SetTagStaticInit();
|
|
}
|
|
|
|
- (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[] )
|
|
{
|
|
FTaskTagScope::SetTagNone();
|
|
|
|
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:[UnrealAppDelegate new]];
|
|
[NSApp run];
|
|
return 0;
|
|
}
|