Files
UnrealEngineUWP/Engine/Source/Editor/UnrealEd/Private/Commandlets/GenerateTextLocalizationResourceCommandlet.cpp
Andrew Grant 69f9d6f648 Copying //UE4/Orion-Staging to //UE4/Main (originated from //Orion/Dev-General @ 2831630)
#lockdown Nick.Penwarden

==========================
MAJOR FEATURES + CHANGES
==========================

Change 2831624 on 2016/01/17 by Marcus.Wassmer

	Merge disable of FCachedReadPlatformData on PS4.  Reduces memory spikes. 2830986
	#rb none
	#test none
	#codereview Michael.Noland,James.Golding

Change 2831402 on 2016/01/17 by Marcus.Wassmer

	HLOD priority and streamout changes.
	Give texture pool an extra 200MB which we can afford thanks to James/Michael
	#rb Chris.Gagnon
	#test run agora, notice nice textures.
	#lockdown Andrew.Grant

Change 2831398 on 2016/01/17 by Marcus.Wassmer

	Fix 3 logic bugs with Relocate
	#rb chris.gagnon
	#test run game, look for corruption.
	#lockdown Andrew.Grant

Change 2831372 on 2016/01/16 by Marcus.Wassmer

	Update param.sfo's and lockdown version in prep for good PS4 playtest build.
	#rb none
	#test build from last night...
	#lockdown Andrew.Grant

Change 2831274 on 2016/01/16 by Graeme.Thornton

	Disable platform file cache wrapper on PS4

	#codereview James.Golding
	#rb none
	#tests ran cooked ps4 build, timed loading (no real change), measured memory used for file handles (small)

Change 2831237 on 2016/01/16 by Sammy.James

	Fix PS4 compile error

	#codereview Andrew.Grant
	#rb none
	#tests none

Change 2831219 on 2016/01/16 by Matt.Kuhlenschmidt

	Fix possible invalid access to shared  movie player resource across threads causing startup crash.

	#codereview marcus.wassmer
	#rb none, #tests initial load

Change 2831218 on 2016/01/16 by Marcus.Wassmer

	Fix bad warning case.
	#codereview Martin.Mittring
	#rb none
	#test none

Change 2831201 on 2016/01/16 by Andrew.Grant

	Added extra info about referencer to missing asset reference message
	#rb none
	#tests cooked, ran editor

Change 2831183 on 2016/01/16 by David.Nikdel

	#OSS #PS4 #Purchasing #StoreV2
	- Force failure if we have no receipts after a "successful" checkout.
	- Report consumed entitlements as well as unconsumed but leave ValidationInfo empty so we can tell the difference at the application level
	- Convert productIds to skuIds at checkout time
	- Added PS4 Implementation of IOnlineStoreV2
	- Bugfix: set bSuccessfullyStartedUp=false when InitNPGameSettings() fails
	- Adjusted FOnlineStoreOffer to use FText::AsCurrencyBase
	#RB: Paul.Moore
	#TESTS: login, purchase redemption, store MTX purchasing on PS4 & PC

Change 2831129 on 2016/01/16 by David.Nikdel

	#MCP
	- Added a ctor to make converting from FOnlineError to FMcpQueryResult easier (for stuff that was already using FMcpQueryResult).
	#RB: none
	#TESTS: frontend

Change 2830986 on 2016/01/15 by Michael.Noland

	PS4: Disabling FCachedReadPlatformFile on PS4 to significantly reduce high watermark memory consumption during blocking loads
	#rb marcus.wassmer
	#tests Ran Paragon PS4 down a bad path that currently does a blocking map and hero load
	#lockdown andrew.grant

Change 2830943 on 2016/01/15 by Max.Chen

	Sequencer: Fix bug introduced with preroll. It was also causing a crash in particle track instance.

	#tests Master sequence trailer plays without crashing
	#rb none

Change 2830912 on 2016/01/15 by Michael.Noland

	Rendering: Exposed GRHIDeviceId (only filled in on D3D11 and D3D12 RHI's under the same circumstances as GRHIAdapterName, etc..., 0 otherwise)
	#rb mieszko.zielinski
	#tests Tested printing the value out
	#codereview martin.mittring

Change 2830910 on 2016/01/15 by Michael.Noland

	Rendering: Improved GPU driver detection logic to handle more cases
	#codereview martin.mittring
	#rb mieszko.zielinski
	#tests Tested on my machine which was previous reporting Unknown for the values as some entries contained the key in the Settings subfolder

Change 2830776 on 2016/01/15 by Martin.Mittring

	from Dev-Rendering
	added ensure to track down multiple issues like
	OR-11771 CRASH: User Crashed when pressing the Play button
	OR-12430 CRASH: OT2 user crashed with FRHIResource::AddRef()
	#rb:Gil.Gribb
	#code_review:Gil.Gribb,Mark.Satterthwaite,Marcus.Wassmer
2016-01-20 11:32:08 -05:00

179 lines
5.9 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#include "UnrealEd.h"
#include "TextLocalizationResourceGenerator.h"
#include "Json.h"
#include "InternationalizationManifest.h"
#include "InternationalizationArchive.h"
#include "JsonInternationalizationManifestSerializer.h"
#include "JsonInternationalizationArchiveSerializer.h"
DEFINE_LOG_CATEGORY_STATIC(LogGenerateTextLocalizationResourceCommandlet, Log, All);
UGenerateTextLocalizationResourceCommandlet::UGenerateTextLocalizationResourceCommandlet(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
int32 UGenerateTextLocalizationResourceCommandlet::Main(const FString& Params)
{
// Parse command line - we're interested in the param vals
TArray<FString> Tokens;
TArray<FString> Switches;
TMap<FString, FString> ParamVals;
UCommandlet::ParseCommandLine(*Params, Tokens, Switches, ParamVals);
// Set config file.
const FString* ParamVal = ParamVals.Find(FString(TEXT("Config")));
FString GatherTextConfigPath;
if ( ParamVal )
{
GatherTextConfigPath = *ParamVal;
}
else
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("No config specified."));
return -1;
}
// Set config section.
ParamVal = ParamVals.Find(FString(TEXT("Section")));
FString SectionName;
if ( ParamVal )
{
SectionName = *ParamVal;
}
else
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("No config section specified."));
return -1;
}
// Get source path.
FString SourcePath;
if( !( GetPathFromConfig( *SectionName, TEXT("SourcePath"), SourcePath, GatherTextConfigPath ) ) )
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("No source path specified."));
return -1;
}
// Get manifest name.
FString ManifestName;
if( !( GetStringFromConfig( *SectionName, TEXT("ManifestName"), ManifestName, GatherTextConfigPath ) ) )
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("No manifest name specified."));
return -1;
}
// Get cultures to generate.
FString NativeCultureName;
if( !( GetStringFromConfig( *SectionName, TEXT("NativeCulture"), NativeCultureName, GatherTextConfigPath ) ) )
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("No native culture specified."));
return -1;
}
// Get cultures to generate.
TArray<FString> CulturesToGenerate;
GetStringArrayFromConfig( *SectionName, TEXT("CulturesToGenerate"), CulturesToGenerate, GatherTextConfigPath );
if( CulturesToGenerate.Num() == 0 )
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("No cultures specified for generation."));
return -1;
}
for(int32 i = 0; i < CulturesToGenerate.Num(); ++i)
{
if( FInternationalization::Get().GetCulture( CulturesToGenerate[i] ).IsValid() )
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Verbose, TEXT("Specified culture is not a valid runtime culture, but may be a valid base language: %s"), *(CulturesToGenerate[i]));
}
}
// Get destination path.
FString DestinationPath;
if( !( GetPathFromConfig( *SectionName, TEXT("DestinationPath"), DestinationPath, GatherTextConfigPath ) ) )
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("No destination path specified."));
return -1;
}
// Get resource name.
FString ResourceName;
if( !( GetStringFromConfig( *SectionName, TEXT("ResourceName"), ResourceName, GatherTextConfigPath ) ) )
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("No resource name specified."));
return -1;
}
// Read the manifest file from the source path.
FString ManifestFilePath = (SourcePath / ManifestName);
ManifestFilePath = FPaths::ConvertRelativePathToFull(ManifestFilePath);
TSharedPtr<FJsonObject> ManifestJSONObject = ReadJSONTextFile(ManifestFilePath);
if( !(ManifestJSONObject.IsValid()) )
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("No manifest found at %s."), *ManifestFilePath);
return -1;
}
TSharedRef<FInternationalizationManifest> InternationalizationManifest = MakeShareable( new FInternationalizationManifest );
{
FJsonInternationalizationManifestSerializer ManifestSerializer;
ManifestSerializer.DeserializeManifest(ManifestJSONObject.ToSharedRef(), InternationalizationManifest);
}
// For each culture:
for(int32 Culture = 0; Culture < CulturesToGenerate.Num(); Culture++)
{
const FString CultureName = *(CulturesToGenerate[Culture]);
const FString CulturePath = SourcePath / CultureName;
// Write resource.
const FString TextLocalizationResourcePath = DestinationPath / CultureName / ResourceName;
const bool DidFileExist = FPaths::FileExists(TextLocalizationResourcePath);
if (DidFileExist)
{
if( SourceControlInfo.IsValid() )
{
FText SCCErrorText;
if (!SourceControlInfo->CheckOutFile(TextLocalizationResourcePath, SCCErrorText))
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("Check out of file %s failed: %s"), *TextLocalizationResourcePath, *SCCErrorText.ToString());
return -1;
}
}
}
TAutoPtr<FArchive> TextLocalizationResourceArchive(IFileManager::Get().CreateFileWriter(*TextLocalizationResourcePath));
if (TextLocalizationResourceArchive)
{
FJsonInternationalizationArchiveSerializer ArchiveSerializer;
if( !(FTextLocalizationResourceGenerator::Generate(SourcePath, InternationalizationManifest, NativeCultureName, CultureName, TextLocalizationResourceArchive, ArchiveSerializer)) )
{
IFileManager::Get().Delete( *TextLocalizationResourcePath );
}
TextLocalizationResourceArchive->Close();
}
if (!DidFileExist)
{
// Checkout on a new file will cause it to be added
if( SourceControlInfo.IsValid() )
{
FText SCCErrorText;
if (!SourceControlInfo->CheckOutFile(TextLocalizationResourcePath, SCCErrorText))
{
UE_LOG(LogGenerateTextLocalizationResourceCommandlet, Error, TEXT("Check out of file %s failed: %s"), *TextLocalizationResourcePath, *SCCErrorText.ToString());
return -1;
}
}
}
}
return 0;
}