本文整理汇总了C++中FConfigFile类的典型用法代码示例。如果您正苦于以下问题:C++ FConfigFile类的具体用法?C++ FConfigFile怎么用?C++ FConfigFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FConfigFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
bool FGenericPlatformMisc::GetStoredValue(const FString& InStoreId, const FString& InSectionName, const FString& InKeyName, FString& OutValue)
{
check(!InStoreId.IsEmpty());
check(!InSectionName.IsEmpty());
check(!InKeyName.IsEmpty());
// This assumes that FPlatformProcess::ApplicationSettingsDir() returns a user-specific directory; it doesn't on Windows, but Windows overrides this behavior to use the registry
const FString ConfigPath = FString(FPlatformProcess::ApplicationSettingsDir()) / InStoreId / FString(TEXT("KeyValueStore.ini"));
FConfigFile ConfigFile;
ConfigFile.Read(ConfigPath);
const FConfigSection* const Section = ConfigFile.Find(InSectionName);
if(Section)
{
const FString* const KeyValue = Section->Find(*InKeyName);
if(KeyValue)
{
OutValue = *KeyValue;
return true;
}
}
return false;
}
示例2: GetConfigFile
bool UOnlineHotfixManager::HotfixPakIniFile(const FString& FileName)
{
FConfigFile* ConfigFile = GetConfigFile(FileName);
ConfigFile->Combine(FileName);
UE_LOG(LogHotfixManager, Log, TEXT("Hotfix merged INI (%s) found in a PAK file"), *FileName);
FName IniFileName(*FileName, FNAME_Find);
int32 NumObjectsReloaded = 0;
const double StartTime = FPlatformTime::Seconds();
// Now that we have a list of classes to update, we can iterate objects and
// reload if they match the INI file that was changed
for (FObjectIterator It; It; ++It)
{
UClass* Class = It->GetClass();
if (Class->HasAnyClassFlags(CLASS_Config) &&
Class->ClassConfigName == IniFileName)
{
// Force a reload of the config vars
It->ReloadConfig();
NumObjectsReloaded++;
}
}
UE_LOG(LogHotfixManager, Log, TEXT("Updating config from %s took %f seconds reloading %d objects"),
*FileName, FPlatformTime::Seconds() - StartTime, NumObjectsReloaded);
return true;
}
示例3: CanCookForPlatformInThisProcess
bool CanCookForPlatformInThisProcess( const FString& PlatformName )
{
////////////////////////////////////////
// hack remove this hack when we properly support changing the mobileHDR setting
// check if our mobile hdr setting in memory is different from the one which is saved in the config file
FConfigFile PlatformEngineIni;
GConfig->LoadLocalIniFile(PlatformEngineIni, TEXT("Engine"), true, *PlatformName );
FString IniValueString;
bool ConfigSetting = false;
if ( PlatformEngineIni.GetString( TEXT("/Script/Engine.RendererSettings"), TEXT("r.MobileHDR"), IniValueString ) == false )
{
// must always match the RSetting setting because we don't have a config setting
return true;
}
ConfigSetting = IniValueString.ToBool();
// this was stolen from void IsMobileHDR()
static auto* MobileHDRCvar = IConsoleManager::Get().FindTConsoleVariableDataInt(TEXT("r.MobileHDR"));
const bool CurrentRSetting = MobileHDRCvar->GetValueOnAnyThread() == 1;
if ( CurrentRSetting != ConfigSetting )
{
UE_LOG(LogUnrealEdEngine, Warning, TEXT("Unable to use cook in editor because r.MobileHDR from Engine ini doesn't match console value r.MobileHDR"));
return false;
}
////////////////////////////////////////
return true;
}
示例4: MigrateConfigSection
void FConfigManifest::MigrateConfigSection(FConfigFile& ConfigFile, const TCHAR* OldSectionName, const TCHAR* NewSectionName)
{
const FConfigSection* OldSection = ConfigFile.Find(OldSectionName);
if (OldSection)
{
FConfigSection* NewSection = ConfigFile.Find(NewSectionName);
if (NewSection)
{
for (auto& Setting : *OldSection)
{
if (!NewSection->Contains(Setting.Key))
{
NewSection->Add(Setting.Key, Setting.Value);
}
}
}
else
{
// Add the new section and remove the old
FConfigSection SectionCopy = *OldSection;
ConfigFile.Add(NewSectionName, MoveTemp(SectionCopy));
ConfigFile.Remove(OldSectionName);
}
ConfigFile.Dirty = true;
}
}
示例5: CombineConfig
/** Combine 2 config files together, putting the result in a third */
void CombineConfig(const TCHAR* Base, const TCHAR* Other, const TCHAR* Output)
{
FConfigFile Config;
Config.Read(Base);
Config.Combine(Other);
Config.Write(Output, false /*bDoRemoteWrite*/);
}
示例6: EnumerateLauncherEngineInstallations
void FDesktopPlatformLinux::EnumerateEngineInstallations(TMap<FString, FString> &OutInstallations)
{
EnumerateLauncherEngineInstallations(OutInstallations);
FString UProjectPath = FString(FPlatformProcess::ApplicationSettingsDir()) / "Unreal.uproject";
FArchive* File = IFileManager::Get().CreateFileWriter(*UProjectPath, FILEWRITE_EvenIfReadOnly);
if (File)
{
File->Close();
delete File;
}
else
{
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Unable to write to Settings Directory", TCHAR_TO_UTF8(*UProjectPath), NULL);
}
FConfigFile ConfigFile;
FString ConfigPath = FString(FPlatformProcess::ApplicationSettingsDir()) / FString(TEXT("UnrealEngine")) / FString(TEXT("Install.ini"));
ConfigFile.Read(ConfigPath);
FConfigSection &Section = ConfigFile.FindOrAdd(TEXT("Installations"));
// @todo: currently we can enumerate only this installation
FString EngineDir = FPaths::EngineDir();
FString EngineId;
const FName* Key = Section.FindKey(EngineDir);
if (Key)
{
EngineId = Key->ToString();
}
else
{
if (!OutInstallations.FindKey(EngineDir))
{
EngineId = FGuid::NewGuid().ToString(EGuidFormats::DigitsWithHyphens);
Section.AddUnique(*EngineId, EngineDir);
ConfigFile.Dirty = true;
}
}
if (!EngineId.IsEmpty() && !OutInstallations.Find(EngineId))
{
OutInstallations.Add(EngineId, EngineDir);
}
ConfigFile.Write(ConfigPath);
IFileManager::Get().Delete(*UProjectPath);
}
示例7: SetProjectConfigOverrides
void FCrashReportClientConfig::SetProjectConfigOverrides(const FConfigFile& InConfigFile)
{
const FConfigSection* Section = InConfigFile.Find(FGenericCrashContext::ConfigSectionName);
// Default to false (show the option) when config is missing.
bHideLogFilesOption = false;
// Default to true (Allow the user to close without sending) when config is missing.
bIsAllowedToCloseWithoutSending = true;
// Try to read values from override config file
if (Section != nullptr)
{
const FConfigValue* HideLogFilesOptionValue = Section->Find(TEXT("bHideLogFilesOption"));
if (HideLogFilesOptionValue != nullptr)
{
bHideLogFilesOption = FCString::ToBool(*HideLogFilesOptionValue->GetValue());
}
const FConfigValue* IsAllowedToCloseWithoutSendingValue = Section->Find(TEXT("bIsAllowedToCloseWithoutSending"));
if (IsAllowedToCloseWithoutSendingValue != nullptr)
{
bIsAllowedToCloseWithoutSending = FCString::ToBool(*IsAllowedToCloseWithoutSendingValue->GetValue());
}
}
}
示例8: ProjectSpecificIniPath
void FConfigManifest::MigrateEditorUserSettings()
{
const FString EditorUserSettingsFilename = ProjectSpecificIniPath(TEXT("EditorUserSettings.ini"));
if (!FPaths::FileExists(EditorUserSettingsFilename))
{
return;
}
// Handle upgrading editor user settings to the new path
FConfigFile OldIni;
OldIni.NoSave = true;
OldIni.Read(EditorUserSettingsFilename);
if (OldIni.Num() != 0)
{
// Rename the config section
MigrateConfigSection(OldIni, TEXT("/Script/UnrealEd.EditorUserSettings"), TEXT("/Script/UnrealEd.EditorPerProjectUserSettings"));
const FString EditorPerProjectUserSettingsFilename = ProjectSpecificIniPath(TEXT("EditorPerProjectUserSettings.ini"));
FConfigFile NewIni;
NewIni.Read(EditorPerProjectUserSettingsFilename);
NewIni.AddMissingProperties(OldIni);
if (!NewIni.Write(EditorPerProjectUserSettingsFilename, false))
{
return;
}
}
IFileManager::Get().Move(*(EditorUserSettingsFilename + TEXT(".bak")), *EditorUserSettingsFilename);
}
示例9: RegisterEngineInstallation
bool FDesktopPlatformLinux::RegisterEngineInstallation(const FString &RootDir, FString &OutIdentifier)
{
bool bRes = false;
if (IsValidRootDirectory(RootDir))
{
FConfigFile ConfigFile;
FString ConfigPath = FString(FPlatformProcess::ApplicationSettingsDir()) / FString(TEXT("UnrealEngine")) / FString(TEXT("Install.ini"));
ConfigFile.Read(ConfigPath);
FConfigSection &Section = ConfigFile.FindOrAdd(TEXT("Installations"));
OutIdentifier = FGuid::NewGuid().ToString(EGuidFormats::DigitsWithHyphens);
Section.AddUnique(*OutIdentifier, RootDir);
ConfigFile.Dirty = true;
ConfigFile.Write(ConfigPath);
}
return bRes;
}
示例10: UpgradeFromPreviousVersions
void FConfigManifest::UpgradeFromPreviousVersions()
{
// First off, load the manifest config if it exists
FConfigFile Manifest;
const FString ManifestFilename = ProjectAgnosticIniPath(TEXT("Manifest.ini"));
if (!FPaths::FileExists(ManifestFilename) && IsDirectoryEmpty(*FPaths::GetPath(ManifestFilename)))
{
// Copy files from previous versions of the engine, if possible
MigratePreviousEngineInis();
}
const EConfigManifestVersion LatestVersion = (EConfigManifestVersion)((int32)EConfigManifestVersion::NumOfVersions - 1);
EConfigManifestVersion CurrentVersion = EConfigManifestVersion::Initial;
if (FPaths::FileExists(ManifestFilename))
{
// Load the manifest from the file
Manifest.Read(*ManifestFilename);
int64 Version = 0;
if (Manifest.GetInt64(TEXT("Manifest"), TEXT("Version"), Version) && Version < (int64)EConfigManifestVersion::NumOfVersions)
{
CurrentVersion = (EConfigManifestVersion)Version;
}
}
if (CurrentVersion == LatestVersion)
{
return;
}
CurrentVersion = UpgradeFromVersion(CurrentVersion);
// Set the version in the manifest, and write it out
Manifest.SetInt64(TEXT("Manifest"), TEXT("Version"), (int64)CurrentVersion);
Manifest.Write(ManifestFilename);
}
示例11: ProjectAgnosticIniPath
EConfigManifestVersion FConfigManifest::UpgradeFromVersion(EConfigManifestVersion FromVersion)
{
// Perform upgrades sequentially...
if (FromVersion < EConfigManifestVersion::RenameEditorAgnosticSettings)
{
// First off, rename the Editor game agnostic ini config to EditorSettings
auto Path = ProjectAgnosticIniPath(TEXT("EditorSettings.ini"));
RenameIni(*ProjectAgnosticIniPath(TEXT("EditorGameAgnostic.ini")), *Path);
FConfigFile EditorSettings;
EditorSettings.Read(Path);
MigrateConfigSection(EditorSettings, TEXT("/Script/UnrealEd.EditorGameAgnosticSettings"), TEXT("/Script/UnrealEd.EditorSettings"));
EditorSettings.Write(Path, false /*bDoRemoteWrite*/);
FromVersion = EConfigManifestVersion::RenameEditorAgnosticSettings;
}
if (FromVersion < EConfigManifestVersion::MigrateProjectSpecificInisToAgnostic)
{
if (!FApp::HasGameName())
{
// We can't upgrade game settings if there is no game.
return FromVersion;
}
// The initial versioning made the following changes:
// 1. Move EditorLayout.ini from Game/Saved/Config to Engine/Saved/Config, thus making it project-agnostic
// 2. Move EditorKeyBindings.ini from Game/Saved/Config to Engine/Saved/Config, thus making it project-agnostic
MigrateToAgnosticIni(TEXT("EditorLayout.ini"));
MigrateToAgnosticIni(TEXT("EditorKeyBindings.ini"));
FromVersion = EConfigManifestVersion::MigrateProjectSpecificInisToAgnostic;
}
return FromVersion;
}
示例12: TEXT
//.........这里部分代码省略.........
if (!IProjectManager::Get().SetPluginEnabled(*Plugin.Name, false, FailReason))
{
FMessageDialog::Open(EAppMsgType::Ok, FailReason);
}
}
}
}
}
// If we made it here, we have all the required plugins
bHaveAllRequiredPlugins = true;
for(const TSharedRef<FPlugin>& Plugin: AllPlugins)
{
if (Plugin->bEnabled)
{
// Add the plugin binaries directory
const FString PluginBinariesPath = FPaths::Combine(*FPaths::GetPath(Plugin->FileName), TEXT("Binaries"), FPlatformProcess::GetBinariesSubdirectory());
FModuleManager::Get().AddBinariesDirectory(*PluginBinariesPath, Plugin->LoadedFrom == EPluginLoadedFrom::GameProject);
#if !IS_MONOLITHIC
// Only check this when in a non-monolithic build where modules could be in separate binaries
if (Project != NULL && Project->Modules.Num() == 0)
{
// Content only project - check whether any plugins are incompatible and offer to disable instead of trying to build them later
TArray<FString> IncompatibleFiles;
if (!FModuleDescriptor::CheckModuleCompatibility(Plugin->Descriptor.Modules, Plugin->LoadedFrom == EPluginLoadedFrom::GameProject, IncompatibleFiles))
{
// Ask whether to disable plugin if incompatible
FText Caption(LOCTEXT("IncompatiblePluginCaption", "Plugin missing or incompatible"));
if (FMessageDialog::Open(EAppMsgType::YesNo, FText::Format(LOCTEXT("IncompatiblePluginText", "Missing or incompatible modules in {0} plugin - would you like to disable it? You will no longer be able to open any assets created using it."), FText::FromString(Plugin->Name)), &Caption) == EAppReturnType::No)
{
return false;
}
FText FailReason;
if (!IProjectManager::Get().SetPluginEnabled(*Plugin->Name, false, FailReason))
{
FMessageDialog::Open(EAppMsgType::Ok, FailReason);
}
}
}
#endif //!IS_MONOLITHIC
// Build the list of content folders
if (Plugin->Descriptor.bCanContainContent)
{
if (auto EngineConfigFile = GConfig->Find(GEngineIni, false))
{
if (auto CoreSystemSection = EngineConfigFile->Find(TEXT("Core.System")))
{
CoreSystemSection->AddUnique("Paths", Plugin->GetContentDir());
}
}
}
// Load Default<PluginName>.ini config file if it exists
FString PluginConfigDir = FPaths::GetPath(Plugin->FileName) / TEXT("Config/");
FConfigFile PluginConfig;
FConfigCacheIni::LoadExternalIniFile(PluginConfig, *Plugin->Name, *FPaths::EngineConfigDir(), *PluginConfigDir, true);
if (PluginConfig.Num() > 0)
{
FString PlaformName = FPlatformProperties::PlatformName();
FString PluginConfigFilename = FString::Printf(TEXT("%s%s/%s.ini"), *FPaths::GeneratedConfigDir(), *PlaformName, *Plugin->Name);
FConfigFile& NewConfigFile = GConfig->Add(PluginConfigFilename, FConfigFile());
NewConfigFile.AddMissingProperties(PluginConfig);
NewConfigFile.Write(PluginConfigFilename);
}
}
}
// Mount all the plugin content folders and pak files
TArray<FString> FoundPaks;
FPakFileSearchVisitor PakVisitor(FoundPaks);
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
for(TSharedRef<IPlugin> Plugin: GetEnabledPlugins())
{
if (Plugin->CanContainContent() && ensure(RegisterMountPointDelegate.IsBound()))
{
FString ContentDir = Plugin->GetContentDir();
RegisterMountPointDelegate.Execute(Plugin->GetMountedAssetPath(), ContentDir);
// Pak files are loaded from <PluginName>/Content/Paks/<PlatformName>
if (FPlatformProperties::RequiresCookedData())
{
FoundPaks.Reset();
PlatformFile.IterateDirectoryRecursively(*(ContentDir / TEXT("Paks") / FPlatformProperties::PlatformName()), PakVisitor);
for (const auto& PakPath : FoundPaks)
{
if (FCoreDelegates::OnMountPak.IsBound())
{
FCoreDelegates::OnMountPak.Execute(PakPath, 0);
}
}
}
}
}
}
return bHaveAllRequiredPlugins;
}
示例13: GetEngineSavedConfigDirectory
bool FDesktopPlatformBase::EnumerateProjectsKnownByEngine(const FString &Identifier, bool bIncludeNativeProjects, TArray<FString> &OutProjectFileNames)
{
// Get the engine root directory
FString RootDir;
if (!GetEngineRootDirFromIdentifier(Identifier, RootDir))
{
return false;
}
FString GameAgnosticConfigDir = GetEngineSavedConfigDirectory(Identifier);
if (GameAgnosticConfigDir.Len() == 0)
{
return false;
}
// Find all the created project directories. Start with the default project creation path.
TArray<FString> SearchDirectories;
SearchDirectories.AddUnique(GetDefaultProjectCreationPath());
// Load the config file
FConfigFile GameAgnosticConfig;
FConfigCacheIni::LoadExternalIniFile(GameAgnosticConfig, TEXT("EditorSettings"), NULL, *GameAgnosticConfigDir, false);
// Find the editor game-agnostic settings
FConfigSection* Section = GameAgnosticConfig.Find(TEXT("/Script/UnrealEd.EditorSettings"));
if (Section == NULL)
{
FConfigCacheIni::LoadExternalIniFile(GameAgnosticConfig, TEXT("EditorGameAgnostic"), NULL, *GameAgnosticConfigDir, false);
Section = GameAgnosticConfig.Find(TEXT("/Script/UnrealEd.EditorGameAgnosticSettings"));
}
if(Section != NULL)
{
// Add in every path that the user has ever created a project file. This is to catch new projects showing up in the user's project folders
TArray<FString> AdditionalDirectories;
Section->MultiFind(TEXT("CreatedProjectPaths"), AdditionalDirectories);
for(int Idx = 0; Idx < AdditionalDirectories.Num(); Idx++)
{
FPaths::NormalizeDirectoryName(AdditionalDirectories[Idx]);
SearchDirectories.AddUnique(AdditionalDirectories[Idx]);
}
// Also add in all the recently opened projects
TArray<FString> RecentlyOpenedFiles;
Section->MultiFind(TEXT("RecentlyOpenedProjectFiles"), RecentlyOpenedFiles);
for(int Idx = 0; Idx < RecentlyOpenedFiles.Num(); Idx++)
{
FPaths::NormalizeFilename(RecentlyOpenedFiles[Idx]);
OutProjectFileNames.AddUnique(RecentlyOpenedFiles[Idx]);
}
}
// Find all the other projects that are in the search directories
for(int Idx = 0; Idx < SearchDirectories.Num(); Idx++)
{
TArray<FString> ProjectFolders;
IFileManager::Get().FindFiles(ProjectFolders, *(SearchDirectories[Idx] / TEXT("*")), false, true);
for(int32 FolderIdx = 0; FolderIdx < ProjectFolders.Num(); FolderIdx++)
{
TArray<FString> ProjectFiles;
IFileManager::Get().FindFiles(ProjectFiles, *(SearchDirectories[Idx] / ProjectFolders[FolderIdx] / TEXT("*.uproject")), true, false);
for(int32 FileIdx = 0; FileIdx < ProjectFiles.Num(); FileIdx++)
{
OutProjectFileNames.AddUnique(SearchDirectories[Idx] / ProjectFolders[FolderIdx] / ProjectFiles[FileIdx]);
}
}
}
// Find all the native projects, and either add or remove them from the list depending on whether we want native projects
const FUProjectDictionary &Dictionary = GetCachedProjectDictionary(RootDir);
if(bIncludeNativeProjects)
{
TArray<FString> NativeProjectPaths = Dictionary.GetProjectPaths();
for(int Idx = 0; Idx < NativeProjectPaths.Num(); Idx++)
{
if(!NativeProjectPaths[Idx].Contains(TEXT("/Templates/")))
{
OutProjectFileNames.AddUnique(NativeProjectPaths[Idx]);
}
}
}
else
{
TArray<FString> NativeProjectPaths = Dictionary.GetProjectPaths();
for(int Idx = 0; Idx < NativeProjectPaths.Num(); Idx++)
{
OutProjectFileNames.Remove(NativeProjectPaths[Idx]);
}
}
return true;
}
示例14: ReadEntry
void FTextureLODSettings::ReadEntry( int32 GroupId, const TCHAR* GroupName, const FConfigFile& IniFile, const TCHAR* IniSection )
{
// Look for string in filename/ section.
FString Entry;
if (IniFile.GetString(IniSection, GroupName, Entry))
{
// Trim whitespace at the beginning.
Entry = Entry.Trim();
// Remove brackets.
Entry = Entry.Replace( TEXT("("), TEXT("") );
Entry = Entry.Replace( TEXT(")"), TEXT("") );
// Parse minimum LOD mip count.
int32 MinLODSize = 0;
if( FParse::Value( *Entry, TEXT("MinLODSize="), MinLODSize ) )
{
TextureLODGroups[GroupId].MinLODMipCount = FMath::CeilLogTwo( MinLODSize );
}
// Parse maximum LOD mip count.
int32 MaxLODSize = 0;
if( FParse::Value( *Entry, TEXT("MaxLODSize="), MaxLODSize ) )
{
TextureLODGroups[GroupId].MaxLODMipCount = FMath::CeilLogTwo( MaxLODSize );
}
// Parse LOD bias.
int32 LODBias = 0;
if( FParse::Value( *Entry, TEXT("LODBias="), LODBias ) )
{
TextureLODGroups[GroupId].LODBias = LODBias;
}
// Parse min/map/mip filter names.
FName MinMagFilter = NAME_Aniso;
FParse::Value( *Entry, TEXT("MinMagFilter="), MinMagFilter );
FName MipFilter = NAME_Point;
FParse::Value( *Entry, TEXT("MipFilter="), MipFilter );
{
FString MipGenSettings;
FParse::Value( *Entry, TEXT("MipGenSettings="), MipGenSettings );
TextureLODGroups[GroupId].MipGenSettings = UTexture::GetMipGenSettingsFromString(*MipGenSettings, true);
}
// Convert into single filter enum. The code is layed out such that invalid input will
// map to the default state of highest quality filtering.
// Linear filtering
if( MinMagFilter == NAME_Linear )
{
if( MipFilter == NAME_Point )
{
TextureLODGroups[GroupId].Filter = SF_Bilinear;
}
else
{
TextureLODGroups[GroupId].Filter = SF_Trilinear;
}
}
// Point. Don't even care about mip filter.
else if( MinMagFilter == NAME_Point )
{
TextureLODGroups[GroupId].Filter = SF_Point;
}
// Aniso or unknown.
else
{
if( MipFilter == NAME_Point )
{
TextureLODGroups[GroupId].Filter = SF_AnisotropicPoint;
}
else
{
TextureLODGroups[GroupId].Filter = SF_AnisotropicLinear;
}
}
// Parse NumStreamedMips
int32 NumStreamedMips = -1;
if( FParse::Value( *Entry, TEXT("NumStreamedMips="), NumStreamedMips ) )
{
TextureLODGroups[GroupId].NumStreamedMips = NumStreamedMips;
}
}
}
示例15: UE_LOG
int32 UGatherTextCommandlet::Main( const FString& Params )
{
const TCHAR* Parms = *Params;
TArray<FString> Tokens;
TArray<FString> Switches;
TMap<FString, FString> ParamVals;
UCommandlet::ParseCommandLine(*Params, Tokens, Switches, ParamVals);
// find the file corresponding to this object's loc file, loading it if necessary
FString GatherTextConfigPath;
const FString* ParamVal = ParamVals.Find(FString(TEXT("Config")));
if (ParamVal)
{
GatherTextConfigPath = *ParamVal;
}
else
{
UE_LOG(LogGatherTextCommandlet, Error, TEXT("-Config not specified.\n%s"), *UsageText);
return -1;
}
if(FPaths::IsRelative(GatherTextConfigPath))
{
FString ProjectBasePath;
if (!FPaths::GameDir().IsEmpty())
{
ProjectBasePath = FPaths::GameDir();
}
else
{
ProjectBasePath = FPaths::EngineDir();
}
GatherTextConfigPath = FPaths::Combine( *ProjectBasePath, *GatherTextConfigPath );
}
GConfig->LoadFile(*GatherTextConfigPath);
FConfigFile* ConfigFile = GConfig->FindConfigFile(*GatherTextConfigPath);
if( NULL == ConfigFile )
{
UE_LOG(LogGatherTextCommandlet, Error, TEXT("Loading Config File \"%s\" failed."), *GatherTextConfigPath);
return -1;
}
const bool bEnableSourceControl = Switches.Contains(TEXT("EnableSCC"));
const bool bDisableSubmit = Switches.Contains(TEXT("DisableSCCSubmit"));
UE_LOG(LogGatherTextCommandlet, Log,TEXT("Beginning GatherText Commandlet."));
TSharedPtr< FGatherTextSCC > CommandletSourceControlInfo = nullptr;
if( bEnableSourceControl )
{
CommandletSourceControlInfo = MakeShareable( new FGatherTextSCC() );
FText SCCErrorStr;
if( !CommandletSourceControlInfo->IsReady( SCCErrorStr ) )
{
UE_LOG( LogGatherTextCommandlet, Error, TEXT("Source Control error: %s"), *SCCErrorStr.ToString() );
return -1;
}
}
// Basic helper that can be used only to gather a new manifest for writing
TSharedRef<FLocTextHelper> CommandletGatherManifestHelper = MakeShareable(new FLocTextHelper(MakeShareable(new FLocFileSCCNotifies(CommandletSourceControlInfo))));
CommandletGatherManifestHelper->LoadManifest(ELocTextHelperLoadFlags::Create);
int32 NumSteps = (ConfigFile->Find("CommonSettings") != NULL) ? ConfigFile->Num() - 1 : ConfigFile->Num();
//Execute each step defined in the config file.
for( int32 i=0; i<NumSteps ; ++i )
{
FString SectionName = FString::Printf(TEXT("GatherTextStep%d"),i);
FConfigSection* CurrCommandletSection = ConfigFile->Find(SectionName);
if( NULL == CurrCommandletSection )
{
UE_LOG(LogGatherTextCommandlet, Error, TEXT("Could not find %s"),*SectionName);
continue;
}
FString CommandletClassName = GConfig->GetStr( *SectionName, TEXT("CommandletClass"), GatherTextConfigPath ) + TEXT("Commandlet");
UClass* CommandletClass = FindObject<UClass>(ANY_PACKAGE,*CommandletClassName,false);
if (!CommandletClass)
{
UE_LOG(LogGatherTextCommandlet, Error,TEXT("The commandlet name %s in section %s is invalid."), *CommandletClassName, *SectionName);
continue;
}
UGatherTextCommandletBase* Commandlet = NewObject<UGatherTextCommandletBase>(GetTransientPackage(), CommandletClass);
check(Commandlet);
Commandlet->AddToRoot();
Commandlet->Initialize( CommandletGatherManifestHelper, CommandletSourceControlInfo );
// Execute the commandlet.
double CommandletExecutionStartTime = FPlatformTime::Seconds();
UE_LOG(LogGatherTextCommandlet, Log,TEXT("Executing %s: %s"), *SectionName, *CommandletClassName);
//.........这里部分代码省略.........