You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
NOTE: Restoring CL 22626782 after it was backed out in CL 22658209. Resolved the problem by using a different FParse::Token overload. Previously, it was assumed that the first parameter was the project path (.uproject) or the game name. The next one was optionally a map override name or a commandlet. While this expectation makes sense, it was difficult to comply given that on some platforms and some launch modes we combine command-line parameters provided to the executable (e.g. from Visual Studio) with ones in uecommandline.txt script. We had some conflicting requirements and because of that certain launch scenarios didn't work. Modified the code to look for the game name / project path withing all the parameters, regardless of the position. Other than that, I've tried to preserve the preexisting behavior. In a few places I've updated the code to allow other switches at arbitrary location withing the command line. Testing done: * Editor: no parameters (project selector); running commandlets (short and long names and/or -run=) with different sets of parameters; running the editor with different parameters; running the game (-game) * Game (cpp + bp): running commandlets (short and long names) with different parameters; running the game with different combonations of project, map and other switches. #preflight #rb David.Harvey #jira UE-99467 UE-159599 #rn fix core Allowed more flexibility when looking for the project name command-line parameter. Previously, it was expected to be always the first parameter. Now, we check all the provided parameters. It fixes some launch scenarios (e.g. launching blueprint-only projects with additional command-line parameters) that didn't work due to the fixed order in which we combine command-line parameters with the contents of uecommandline.txt script. [CL 22666957 by wojciech krywult in ue5-main branch]
217 lines
5.6 KiB
C++
217 lines
5.6 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
#if WITH_ENGINE
|
|
#include "UnrealEngine.h"
|
|
#endif
|
|
|
|
class FEngineService;
|
|
class FPendingCleanupObjects;
|
|
class ISessionService;
|
|
class FSlateRenderer;
|
|
|
|
struct FScopedSlowTask;
|
|
|
|
struct FPreInitContext
|
|
{
|
|
bool bDumpEarlyConfigReads = false;
|
|
bool bDumpEarlyPakFileReads = false;
|
|
bool bForceQuitAfterEarlyReads = false;
|
|
bool bWithConfigPatching = false;
|
|
bool bDisableDisregardForGC = false;
|
|
bool bHasEditorToken = false;
|
|
bool bIsRegularClient = false;
|
|
UE_DEPRECATED(5.1, "Use bIsPossiblyUnrecognizedCommandlet instead")
|
|
bool bTokenDoesNotHaveDash = false;
|
|
bool bIsPossiblyUnrecognizedCommandlet = false;
|
|
|
|
FString Token;
|
|
FString CommandletCommandLine;
|
|
|
|
FScopedSlowTask* SlowTaskPtr = nullptr;
|
|
|
|
void Cleanup();
|
|
|
|
#if WITH_ENGINE && !UE_SERVER
|
|
TSharedPtr<FSlateRenderer> SlateRenderer;
|
|
#endif // WITH_ENGINE && !UE_SERVER
|
|
};
|
|
|
|
/**
|
|
* Implements the main engine loop.
|
|
*/
|
|
class FEngineLoop
|
|
#if WITH_ENGINE
|
|
: public IEngineLoop
|
|
#endif
|
|
{
|
|
public:
|
|
|
|
/** Default constructor. */
|
|
FEngineLoop();
|
|
|
|
virtual ~FEngineLoop() { }
|
|
|
|
public:
|
|
|
|
/**
|
|
* Pre-Initialize the main loop, and generates the commandline from standard ArgC/ArgV from main().
|
|
*
|
|
* @param ArgC The number of strings in ArgV.
|
|
* @param ArgV The command line parameters (ArgV[0] is expected to be the executable name).
|
|
* @param AdditionalCommandLine Optional string to append to the command line (after ArgV is put together).
|
|
* @return Returns the error level, 0 if successful and > 0 if there were errors.
|
|
*/
|
|
int32 PreInit(int32 ArgC, TCHAR* ArgV[], const TCHAR* AdditionalCommandline = nullptr);
|
|
|
|
/**
|
|
* Pre-Initialize the main loop - parse command line, sets up GIsEditor, etc.
|
|
*
|
|
* @param CmdLine The command line.
|
|
* @return The error level; 0 if successful, > 0 if there were errors.
|
|
*/
|
|
int32 PreInit(const TCHAR* CmdLine);
|
|
|
|
/** First part of PreInit. */
|
|
int32 PreInitPreStartupScreen(const TCHAR* CmdLine);
|
|
|
|
/** Second part of PreInit. */
|
|
int32 PreInitPostStartupScreen(const TCHAR* CmdLine);
|
|
|
|
/** Load all modules needed before Init. */
|
|
void LoadPreInitModules();
|
|
|
|
/** Load core modules. */
|
|
bool LoadCoreModules();
|
|
|
|
/** Clean up PreInit context. */
|
|
void CleanupPreInitContext();
|
|
|
|
#if WITH_ENGINE
|
|
|
|
/** Load all core modules needed at startup time. */
|
|
bool LoadStartupCoreModules();
|
|
|
|
/** Load all modules needed at startup time. */
|
|
bool LoadStartupModules();
|
|
|
|
/**
|
|
* Initialize the main loop (the rest of the initialization).
|
|
*
|
|
* @return The error level; 0 if successful, > 0 if there were errors.
|
|
*/
|
|
virtual int32 Init() override;
|
|
|
|
/** Initialize the timing options from the command line. */
|
|
void InitTime();
|
|
|
|
/** Performs shut down. */
|
|
void Exit();
|
|
|
|
/** Whether the engine should operate in an idle mode that uses no CPU or GPU time. */
|
|
bool ShouldUseIdleMode() const;
|
|
|
|
/** Advances the main loop. */
|
|
virtual void Tick() override;
|
|
|
|
/** Removes references to any objects pending cleanup by deleting them. */
|
|
virtual void ClearPendingCleanupObjects() override;
|
|
|
|
#endif // WITH_ENGINE
|
|
|
|
/** RHI post-init initialization */
|
|
static void PostInitRHI();
|
|
|
|
/** Pre-init HMD device (if necessary). */
|
|
static void PreInitHMDDevice();
|
|
|
|
public:
|
|
|
|
/** Initializes the application. */
|
|
static bool AppInit();
|
|
|
|
/**
|
|
* Prepares the application for shutdown.
|
|
*
|
|
* This function is called from within guarded exit code, only during non-error exits.
|
|
*/
|
|
static void AppPreExit();
|
|
|
|
/**
|
|
* Shuts down the application.
|
|
*
|
|
* This function called outside guarded exit code, during all exits (including error exits).
|
|
*/
|
|
static void AppExit();
|
|
|
|
private:
|
|
|
|
/** Utility function that processes Slate operations. */
|
|
void ProcessLocalPlayerSlateOperations() const;
|
|
|
|
protected:
|
|
|
|
/** Holds a dynamically expanding array of frame times in milliseconds (if FApp::IsBenchmarking() is set). */
|
|
TArray<float> FrameTimes;
|
|
|
|
/** Holds the total time spent ticking engine. */
|
|
double TotalTickTime;
|
|
|
|
/** Holds the maximum number of seconds engine should be ticked. */
|
|
double MaxTickTime;
|
|
|
|
/** Holds the maximum number of frames to render in benchmarking mode. */
|
|
uint64 MaxFrameCounter;
|
|
|
|
/** Holds the number of cycles in the last frame. */
|
|
uint32 LastFrameCycles;
|
|
|
|
#if WITH_ENGINE
|
|
|
|
/** Holds the objects which need to be cleaned up when the rendering thread finishes the previous frame. */
|
|
FPendingCleanupObjects* PendingCleanupObjects;
|
|
|
|
#endif //WITH_ENGINE
|
|
|
|
private:
|
|
|
|
/** Enumeration representing the type of the command-line argument representing the game (typically the first argument). */
|
|
enum class EGameStringType
|
|
{
|
|
GameName,
|
|
ProjectPath,
|
|
ProjectShortName,
|
|
Unknown
|
|
};
|
|
|
|
/** Takes a command-line string and returns an array of tokens (splits arguments using whitespaces). */
|
|
static TArray<FString> TokenizeCommandline(const TCHAR* CmdLine);
|
|
|
|
/**
|
|
* Finds a command-line argument representing the game, removes it from the array and returns.
|
|
*
|
|
* @param TokenArray Array of the tokenized command line
|
|
* @param OutStringType Type of the game string found.
|
|
* @return String representing the game command-line parameter; empty string if not found (OutStringType == Unknown in such case).
|
|
*/
|
|
static FString ExtractGameStringArgument(TArray<FString>& TokenArray, EGameStringType& OutStringType);
|
|
|
|
#if WITH_ENGINE
|
|
|
|
/** Holds the engine service. */
|
|
FEngineService* EngineService;
|
|
|
|
/** Holds the application session service. */
|
|
TSharedPtr<ISessionService> SessionService;
|
|
|
|
#endif // WITH_ENGINE
|
|
FPreInitContext PreInitContext;
|
|
};
|
|
|
|
|
|
/** Global engine loop object. This is needed so wxWindows can access it. */
|
|
extern FEngineLoop GEngineLoop;
|