2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-06-25 13:09:31 -04:00
# pragma once
# include "Json.h"
2014-06-27 08:41:46 -04:00
enum class EModuleLoadResult ;
2014-06-25 13:09:31 -04:00
/**
* Phase at which this module should be loaded during startup .
*/
namespace ELoadingPhase
{
enum Type
{
/** Loaded at the default loading point during startup (during engine init, after game modules are loaded.) */
Default ,
/** Right after the default phase */
PostDefault ,
/** Right before the default phase */
PreDefault ,
/** Loaded before the engine is fully initialized, immediately after the config system has been initialized. Necessary only for very low-level hooks */
PostConfigInit ,
/** Loaded before the engine is fully initialized for modules that need to hook into the loading screen before it triggers */
PreLoadingScreen ,
2014-07-10 21:04:34 -04:00
/** After the engine has been initialized */
PostEngineInit ,
// NOTE: If you add a new value, make sure to update the ToString() method below!
2014-06-25 13:09:31 -04:00
Max
} ;
/**
* Converts a string to a ELoadingPhase : : Type value
*
* @ param The string to convert to a value
* @ return The corresponding value , or ' Max ' if the string is not valid .
*/
2014-07-22 15:58:02 -04:00
PROJECTS_API ELoadingPhase : : Type FromString ( const TCHAR * Text ) ;
2014-06-25 13:09:31 -04:00
/**
* Returns the name of a module load phase .
*
* @ param The value to convert to a string
* @ return The string representation of this enum value
*/
2014-07-22 15:58:02 -04:00
PROJECTS_API const TCHAR * ToString ( const ELoadingPhase : : Type Value ) ;
2014-06-25 13:09:31 -04:00
} ;
/**
* Environment that can load a module .
*/
namespace EHostType
{
enum Type
{
Runtime ,
RuntimeNoCommandlet ,
Developer ,
Editor ,
EditorNoCommandlet ,
Program , //!< Program-only plugin type
// NOTE: If you add a new value, make sure to update the ToString() method below!
Max
} ;
/**
* Converts a string to a EHostType : : Type value
*
* @ param The string to convert to a value
* @ return The corresponding value , or ' Max ' if the string is not valid .
*/
2014-07-22 15:58:02 -04:00
PROJECTS_API EHostType : : Type FromString ( const TCHAR * Text ) ;
2014-06-25 13:09:31 -04:00
/**
* Converts an EHostType : : Type value to a string literal
*
* @ param The value to convert to a string
* @ return The string representation of this enum value
*/
2014-07-22 15:58:02 -04:00
PROJECTS_API const TCHAR * ToString ( const EHostType : : Type Value ) ;
2014-06-25 13:09:31 -04:00
} ;
/**
* Description of a loadable module .
*/
2014-07-22 15:58:02 -04:00
struct PROJECTS_API FModuleDescriptor
2014-06-25 13:09:31 -04:00
{
/** Name of this module */
FName Name ;
/** Usage type of module */
EHostType : : Type Type ;
/** When should the module be loaded during the startup sequence? This is sort of an advanced setting. */
ELoadingPhase : : Type LoadingPhase ;
/** List of allowed platforms */
TArray < FString > WhitelistPlatforms ;
/** List of disallowed platforms */
TArray < FString > BlacklistPlatforms ;
2015-03-17 09:34:18 -04:00
/** List of additional dependencies for building this module. */
TArray < FString > AdditionalDependencies ;
2014-06-27 08:41:46 -04:00
/** Normal constructor */
FModuleDescriptor ( const FName InName = NAME_None , EHostType : : Type InType = EHostType : : Runtime , ELoadingPhase : : Type InLoadingPhase = ELoadingPhase : : Default ) ;
2014-06-25 13:09:31 -04:00
/** Reads a descriptor from the given JSON object */
bool Read ( const FJsonObject & Object , FText & OutFailReason ) ;
/** Reads an array of modules from the given JSON object */
static bool ReadArray ( const FJsonObject & Object , const TCHAR * Name , TArray < FModuleDescriptor > & OutModules , FText & OutFailReason ) ;
/** Writes a descriptor to JSON */
void Write ( TJsonWriter < > & Writer ) const ;
/** Writes an array of modules to JSON */
static void WriteArray ( TJsonWriter < > & Writer , const TCHAR * Name , const TArray < FModuleDescriptor > & Modules ) ;
/** Tests whether the module should be built for the current engine configuration */
bool IsCompiledInCurrentConfiguration ( ) const ;
/** Tests whether the module should be loaded for the current engine configuration */
bool IsLoadedInCurrentConfiguration ( ) const ;
2014-06-27 08:41:46 -04:00
/** Loads all the modules for a given loading phase. Returns a map of module names to load errors */
static void LoadModulesForPhase ( ELoadingPhase : : Type LoadingPhase , const TArray < FModuleDescriptor > & Modules , TMap < FName , EModuleLoadResult > & ModuleLoadErrors ) ;
2014-09-10 12:43:07 -04:00
/** Checks that all modules are compatible with the current engine version. Returns false and appends a list of names to OutIncompatibleFiles if not. */
static bool CheckModuleCompatbility ( const TArray < FModuleDescriptor > & Modules , bool bGameModules , TArray < FString > & OutIncompatibleFiles ) ;
2014-06-25 13:09:31 -04:00
} ;