2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-11-07 09:55:57 -05:00
# pragma once
2015-07-13 05:58:38 -04:00
# include "Private/IContentSource.h"
2015-06-17 03:25:33 -04:00
# include "FeaturePackContentSource.generated.h"
2015-05-31 12:48:56 -04:00
class UObject ;
struct FPackData
{
FString PackSource ;
FString PackName ;
FString PackMap ;
TArray < UObject * > ImportedObjects ;
} ;
2015-04-27 05:56:20 -04:00
class FLocalizedTextArray
{
public :
FLocalizedTextArray ( )
{
}
/** Creates a new FLocalizedText
@ param InTwoLetterLanguage - The iso 2 - letter language specifier .
@ param InText - The text in the language specified */
FLocalizedTextArray ( FString InTwoLetterLanguage , FString InText )
{
TwoLetterLanguage = InTwoLetterLanguage ;
TArray < FString > AsArray ;
InText . ParseIntoArray ( AsArray , TEXT ( " , " ) ) ;
for ( int32 iString = 0 ; iString < AsArray . Num ( ) ; iString + + )
{
Tags . Add ( FText : : FromString ( AsArray [ iString ] ) ) ;
}
}
/** Gets the iso 2-letter language specifier for this text. */
FString GetTwoLetterLanguage ( ) const
{
return TwoLetterLanguage ;
}
/** Gets the array of tags in the language specified. */
TArray < FText > GetTags ( ) const
{
return Tags ;
}
private :
FString TwoLetterLanguage ;
TArray < FText > Tags ;
} ;
2014-11-07 09:55:57 -05:00
2015-06-17 03:25:33 -04:00
/** Defines categories for shared template resource levels. */
UENUM ( )
enum class EFeaturePackDetailLevel : uint8
{
Standard ,
High ,
} ;
/* Structure that defines a shared feature pack resource. */
USTRUCT ( )
struct FFeaturePackLevelSet
{
GENERATED_BODY ( )
FFeaturePackLevelSet ( ) { } ;
/** Creates a new FFeaturePackLevelSet
@ param InMountName - Name of the pack / folder to insert to
@ param InDetailLevels - The levels available for this pack */
FFeaturePackLevelSet ( FString InMountName , TArray < EFeaturePackDetailLevel > InDetailLevels )
{
MountName = InMountName ;
DetailLevels = InDetailLevels ;
}
/* List of shared resource levels for this shared resource.*/
UPROPERTY ( )
TArray < EFeaturePackDetailLevel > DetailLevels ;
/* Mount name for the shared resource - this is the folder the resource will be copied to on project generation as well as the name of the folder that will appear in the content browser. */
UPROPERTY ( )
FString MountName ;
FString GetFeaturePackNameForLevel ( EFeaturePackDetailLevel InLevel , bool bLevelRequired = false )
{
check ( DetailLevels . Num ( ) > 0 ) ; // We need at least one detail level defined
int32 Index = DetailLevels . Find ( InLevel ) ;
FString DetailString ;
if ( Index ! = INDEX_NONE )
{
UEnum : : GetValueAsString ( TEXT ( " /Script/AddContentDialog.EFeaturePackDetailLevel " ) , InLevel , DetailString ) ;
}
else
{
check ( bLevelRequired = = false ) ; // The level is REQUIRED and we don't have it !
// If we didn't have the requested level, use the first
UEnum : : GetValueAsString ( TEXT ( " /Script/AddContentDialog.EFeaturePackDetailLevel " ) , DetailLevels [ 0 ] , DetailString ) ;
}
FString NameString = MountName + DetailString + TEXT ( " .upack " ) ;
return NameString ;
}
} ;
2015-07-13 05:47:36 -04:00
/* Structure that defines a shared feature pack resource. */
USTRUCT ( )
struct FFeatureAdditionalFiles
{
GENERATED_BODY ( )
FFeatureAdditionalFiles ( ) { } ;
/* Name of the folder to insert the files to */
UPROPERTY ( )
FString DestinationFilesFolder ;
/* List of files to insert */
UPROPERTY ( )
TArray < FString > AdditionalFilesList ;
} ;
2014-11-07 09:55:57 -05:00
class FPakPlatformFile ;
2015-04-30 09:40:21 -04:00
struct FSearchEntry ;
2014-11-07 09:55:57 -05:00
/** A content source which represents a content upack. */
2015-07-13 05:47:36 -04:00
class ADDCONTENTDIALOG_API FFeaturePackContentSource : public IContentSource
2014-11-07 09:55:57 -05:00
{
public :
2015-07-13 05:47:36 -04:00
FFeaturePackContentSource ( ) ;
FFeaturePackContentSource ( FString InFeaturePackPath , bool bDontRegister = false ) ;
2015-06-25 06:48:13 -04:00
virtual ~ FFeaturePackContentSource ( ) ;
2014-11-07 09:55:57 -05:00
2015-04-27 05:56:20 -04:00
virtual TArray < FLocalizedText > GetLocalizedNames ( ) const override ;
virtual TArray < FLocalizedText > GetLocalizedDescriptions ( ) const override ;
2014-11-07 09:55:57 -05:00
2015-04-27 05:56:20 -04:00
virtual EContentSourceCategory GetCategory ( ) const override ;
virtual TArray < FLocalizedText > GetLocalizedAssetTypes ( ) const override ;
2015-03-19 07:47:41 -04:00
virtual FString GetSortKey ( ) const override ;
2015-04-27 05:56:20 -04:00
virtual FString GetClassTypesUsed ( ) const override ;
virtual TSharedPtr < FImageData > GetIconData ( ) const override ;
virtual TArray < TSharedPtr < FImageData > > GetScreenshotData ( ) const override ;
2015-07-13 05:47:36 -04:00
FString GetFocusAssetName ( ) const ;
2014-11-07 09:55:57 -05:00
2014-12-01 08:44:00 -05:00
virtual bool InstallToProject ( FString InstallPath ) override ;
2015-06-17 08:24:23 -04:00
void InsertAdditionalFeaturePacks ( ) ;
2015-07-13 05:47:36 -04:00
bool InsertAdditionalResources ( TArray < FFeaturePackLevelSet > InAdditionalFeaturePacks , EFeaturePackDetailLevel RequiredLevel , const FString & InDestinationFolder , TArray < FString > & InFilesCopied ) ;
2015-06-17 08:24:23 -04:00
2014-12-01 08:44:00 -05:00
virtual bool IsDataValid ( ) const override ;
2015-01-30 10:48:17 -05:00
2014-12-01 08:44:00 -05:00
2015-04-30 09:40:21 -04:00
void HandleActOnSearchText ( TSharedPtr < FSearchEntry > SearchEntry ) ;
void HandleSuperSearchTextChanged ( const FString & InText , TArray < TSharedPtr < FSearchEntry > > & OutSuggestions ) ;
2015-06-17 03:25:33 -04:00
/*
* Copies the list of files specified in ' AdditionFilesToInclude ' section in the config . ini of the feature pack .
*
* @ param DestinationFolder Destination folder for the files
* @ param FilesCopied List of files copied
* @ param bContainsSource Set to true if the file list contains any source files
* @ returns true if config file was read and parsed successfully
*/
2015-07-13 05:47:36 -04:00
void CopyAdditionalFilesToFolder ( const FString & DestinationFolder , TArray < FString > & FilesCopied , bool & bHasSourceFiles , FString InGameFolder = FString ( ) ) ;
2015-06-17 03:25:33 -04:00
/*
* Returns a list of additional files ( including the path ) as specified in the config file if one exists in the pack file .
*
* @ param FileList array to receive list of files
* @ param bContainsSource did the file list contain any source files
* @ returns true if config file was read and parsed successfully
*/
2015-07-13 05:47:36 -04:00
bool GetAdditionalFilesForPack ( TArray < FString > & FileList , bool & bContainsSource ) ;
2015-04-27 05:56:20 -04:00
2015-07-13 05:47:36 -04:00
static void ImportPendingPacks ( ) ;
2015-06-17 03:25:33 -04:00
2015-07-13 05:47:36 -04:00
/* Errors found when parsing manifest (if any) */
2015-05-31 12:48:56 -04:00
TArray < FString > ParseErrors ;
2015-06-17 03:25:33 -04:00
2015-07-13 05:47:36 -04:00
void BuildListOfAdditionalFiles ( TArray < FString > & AdditionalFileSourceList , TArray < FString > & FileList , bool & bContainsSourceFiles ) ;
/* Get the identifier of the pack. */
virtual FString GetIdent ( ) const ;
2014-11-07 09:55:57 -05:00
private :
2015-05-31 12:48:56 -04:00
static void ParseAndImportPacks ( ) ;
2014-12-01 08:44:00 -05:00
bool LoadPakFileToBuffer ( FPakPlatformFile & PakPlatformFile , FString Path , TArray < uint8 > & Buffer ) ;
2015-07-13 05:47:36 -04:00
2015-06-17 03:25:33 -04:00
/*
* Extract the list of additional files defined in config file to an array
*
* @ param ConfigFile config file as a string
* @ param FileList array to receive list of files
* @ param bContainsSource did the file list contain any source files
*/
2015-07-13 05:47:36 -04:00
bool ExtractListOfAdditionalFiles ( const FString & ConfigFile , TArray < FString > & FileList , bool & bContainsSource ) ;
2014-11-07 09:55:57 -05:00
2015-05-31 12:48:56 -04:00
void RecordAndLogError ( const FString & ErrorString ) ;
2015-07-13 05:47:36 -04:00
/* Load the images for the icon and screen shots directly from disk */
bool LoadFeaturePackImageData ( ) ;
/* extract the images for the icon and screen shots from a pak file */
bool LoadFeaturePackImageDataFromPackFile ( FPakPlatformFile & PakPlatformFile ) ;
/* Parse the manifest string describing this pack file */
bool ParseManifestString ( const FString & ManifestString ) ;
2015-04-27 05:56:20 -04:00
/** Selects an FLocalizedText from an array which matches either the supplied language code, or the default language code. */
FLocalizedTextArray ChooseLocalizedTextArray ( TArray < FLocalizedTextArray > Choices , FString LanguageCode ) ;
FLocalizedText ChooseLocalizedText ( TArray < FLocalizedText > Choices , FString LanguageCode ) ;
void TryAddFeaturePackCategory ( FString CategoryTitle , TArray < TSharedPtr < FSearchEntry > > & OutSuggestions ) ;
2015-07-13 05:47:36 -04:00
/* The path of the file we used to create this feature pack instance */
2014-11-07 09:55:57 -05:00
FString FeaturePackPath ;
2015-07-13 05:47:36 -04:00
/* Array of localised names */
2014-11-07 09:55:57 -05:00
TArray < FLocalizedText > LocalizedNames ;
2015-07-13 05:47:36 -04:00
/* Array of localised descriptions */
2014-11-07 09:55:57 -05:00
TArray < FLocalizedText > LocalizedDescriptions ;
2015-07-13 05:47:36 -04:00
/* Defines the type of feature pack this is */
2014-11-07 09:55:57 -05:00
EContentSourceCategory Category ;
2015-07-13 05:47:36 -04:00
/* Filename of the icon */
FString IconFilename ;
/* Image data for the icon */
2014-11-07 09:55:57 -05:00
TSharedPtr < FImageData > IconData ;
2015-07-13 05:47:36 -04:00
/* Filenames of the preview screenshots */
TArray < TSharedPtr < FJsonValue > > ScreenshotFilenameArray ;
/* Image data of the preview screenshots */
2014-11-07 09:55:57 -05:00
TArray < TSharedPtr < FImageData > > ScreenshotData ;
2015-07-13 05:47:36 -04:00
/* Array of localised assset type names */
2014-12-18 10:27:15 -05:00
TArray < FLocalizedText > LocalizedAssetTypesList ;
2015-07-13 05:47:36 -04:00
/* Comma delimited string listing the class types */
2014-12-18 10:27:15 -05:00
FString ClassTypes ;
2015-07-13 05:47:36 -04:00
/* true if the pack is valid */
2014-12-01 08:44:00 -05:00
bool bPackValid ;
2015-07-13 05:47:36 -04:00
/* Asset to focus after loading the pack */
2015-01-30 10:48:17 -05:00
FString FocusAssetIdent ;
2015-07-13 05:47:36 -04:00
/* Key used when sorting in the add dialog */
2015-03-19 07:47:41 -04:00
FString SortKey ;
2015-07-13 05:47:36 -04:00
/* Tags searched when typing in the super search box */
2015-04-27 05:56:20 -04:00
TArray < FLocalizedTextArray > LocalizedSearchTags ;
2015-07-13 05:47:36 -04:00
/* Other feature packs this pack needs (shared assets) */
2015-06-17 03:25:33 -04:00
TArray < FFeaturePackLevelSet > AdditionalFeaturePacks ;
2015-07-13 05:47:36 -04:00
/* Handle for the search clicked delegate handler */
2015-06-25 06:48:13 -04:00
FDelegateHandle SearchClickedHandle ;
2015-07-13 05:47:36 -04:00
/* Handle for the search changed delegate handler */
2015-06-25 06:48:13 -04:00
FDelegateHandle SearchChangedHandle ;
2015-07-13 05:47:36 -04:00
/* Additional files to copy when installing this pack */
FFeatureAdditionalFiles AdditionalFilesForPack ;
/* Are the contents in a pack file or did we just read a manifest for the pack */
bool bContentsInPakFile ;
/* Feature pack mount point */
FString MountPoint ;
FString Identity ;
FString VersionNumber ;
2014-11-07 09:55:57 -05:00
} ;