2015-04-22 16:39:20 -04:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2015-03-05 00:08:26 -05:00
# include "LocalizationDashboardPrivatePCH.h"
# include "LocalizationTargetDetailCustomization.h"
# include "DetailLayoutBuilder.h"
2015-03-28 19:17:15 -04:00
# include "LocalizationTargetTypes.h"
2015-03-05 00:08:26 -05:00
# include "DetailWidgetRow.h"
# include "SLocalizationTargetStatusButton.h"
# include "SLocalizationTargetEditorCultureRow.h"
# include "SCulturePicker.h"
# include "IDetailPropertyRow.h"
2015-03-05 06:15:45 -05:00
# include "DetailCategoryBuilder.h"
# include "IDetailsView.h"
# include "LocalizationCommandletTasks.h"
2015-03-06 17:12:46 -05:00
# include "ObjectEditorUtils.h"
2015-03-28 19:17:15 -04:00
# include "LocalizationDashboardSettings.h"
2015-03-05 00:08:26 -05:00
# define LOCTEXT_NAMESPACE "LocalizationTargetEditor"
2015-03-19 16:59:17 -04:00
namespace
{
struct FConfigValueIdentity
{
FString SectionName ;
FString KeyName ;
FString ConfigFilePath ;
} ;
TMap < ELocalizationTargetLoadingPolicy , FConfigValueIdentity > LoadingPolicyToConfigSettingMap = [ ] ( )
{
TMap < ELocalizationTargetLoadingPolicy , FConfigValueIdentity > Map ;
Map . Add ( ELocalizationTargetLoadingPolicy : : Always , FConfigValueIdentity { TEXT ( " Internationalization " ) , TEXT ( " LocalizationPaths " ) , GEngineIni } ) ;
Map . Add ( ELocalizationTargetLoadingPolicy : : Editor , FConfigValueIdentity { TEXT ( " Internationalization " ) , TEXT ( " LocalizationPaths " ) , GEditorIni } ) ;
Map . Add ( ELocalizationTargetLoadingPolicy : : Editor , FConfigValueIdentity { TEXT ( " Internationalization " ) , TEXT ( " LocalizationPaths " ) , GEditorIni } ) ;
Map . Add ( ELocalizationTargetLoadingPolicy : : PropertyNames , FConfigValueIdentity { TEXT ( " Internationalization " ) , TEXT ( " PropertyNameLocalizationPaths " ) , GEditorIni } ) ;
Map . Add ( ELocalizationTargetLoadingPolicy : : ToolTips , FConfigValueIdentity { TEXT ( " Internationalization " ) , TEXT ( " ToolTipLocalizationPaths " ) , GEditorIni } ) ;
Map . Add ( ELocalizationTargetLoadingPolicy : : Game , FConfigValueIdentity { TEXT ( " Internationalization " ) , TEXT ( " LocalizationPaths " ) , GGameIni } ) ;
return Map ;
} ( ) ;
}
2015-03-05 00:08:26 -05:00
FLocalizationTargetDetailCustomization : : FLocalizationTargetDetailCustomization ( )
: DetailLayoutBuilder ( nullptr )
, NewEntryIndexToBeInitialized ( INDEX_NONE )
{
}
class FLocalizationTargetEditorCommands : public TCommands < FLocalizationTargetEditorCommands >
{
public :
FLocalizationTargetEditorCommands ( )
: TCommands < FLocalizationTargetEditorCommands > ( " LocalizationTargetEditor " , NSLOCTEXT ( " Contexts " , " LocalizationTargetEditor " , " Localization Target Editor " ) , NAME_None , FEditorStyle : : GetStyleSetName ( ) )
{
}
TSharedPtr < FUICommandInfo > Gather ;
TSharedPtr < FUICommandInfo > ImportAllCultures ;
TSharedPtr < FUICommandInfo > ExportAllCultures ;
TSharedPtr < FUICommandInfo > RefreshWordCounts ;
TSharedPtr < FUICommandInfo > Compile ;
/** Initialize commands */
virtual void RegisterCommands ( ) override ;
} ;
void FLocalizationTargetEditorCommands : : RegisterCommands ( )
{
2015-03-17 11:36:28 -04:00
UI_COMMAND ( Gather , " Gather " , " Gathers text for this target. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
UI_COMMAND ( ImportAllCultures , " Import All " , " Imports translations for all cultures of this target. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
UI_COMMAND ( ExportAllCultures , " Export All " , " Exports translations for all cultures of this target. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
UI_COMMAND ( RefreshWordCounts , " Count Words " , " Recalculates the word counts for all cultures of this target. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
UI_COMMAND ( Compile , " Compile " , " Compiles translations for this target. " , EUserInterfaceActionType : : Button , FInputChord ( ) ) ;
2015-03-05 00:08:26 -05:00
}
void FLocalizationTargetDetailCustomization : : CustomizeDetails ( IDetailLayoutBuilder & DetailBuilder )
{
DetailLayoutBuilder = & DetailBuilder ;
{
TArray < TWeakObjectPtr < UObject > > ObjectsBeingCustomized ;
DetailLayoutBuilder - > GetObjectsBeingCustomized ( ObjectsBeingCustomized ) ;
LocalizationTarget = CastChecked < ULocalizationTarget > ( ObjectsBeingCustomized . Top ( ) . Get ( ) ) ;
TargetSet = CastChecked < ULocalizationTargetSet > ( LocalizationTarget - > GetOuter ( ) ) ;
}
TargetSettingsPropertyHandle = DetailBuilder . GetProperty ( GET_MEMBER_NAME_CHECKED ( ULocalizationTarget , Settings ) ) ;
if ( TargetSettingsPropertyHandle . IsValid ( ) & & TargetSettingsPropertyHandle - > IsValidHandle ( ) )
{
TargetSettingsPropertyHandle - > MarkHiddenByCustomization ( ) ;
}
2015-03-06 17:12:46 -05:00
typedef TFunction < void ( const TSharedRef < IPropertyHandle > & , IDetailCategoryBuilder & ) > FPropertyCustomizationFunction ;
TMap < FName , FPropertyCustomizationFunction > PropertyCustomizationMap ;
PropertyCustomizationMap . Add ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , Name ) , [ & ] ( const TSharedRef < IPropertyHandle > & MemberPropertyHandle , IDetailCategoryBuilder & DetailCategoryBuilder )
{
FDetailWidgetRow & DetailWidgetRow = DetailCategoryBuilder . AddCustomRow ( MemberPropertyHandle - > GetPropertyDisplayName ( ) ) ;
DetailWidgetRow . NameContent ( )
[
MemberPropertyHandle - > CreatePropertyNameWidget ( )
] ;
DetailWidgetRow . ValueContent ( )
[
SAssignNew ( TargetNameEditableTextBox , SEditableTextBox )
. Text ( this , & FLocalizationTargetDetailCustomization : : GetTargetName )
. RevertTextOnEscape ( true )
. OnTextChanged ( this , & FLocalizationTargetDetailCustomization : : OnTargetNameChanged )
. OnTextCommitted ( this , & FLocalizationTargetDetailCustomization : : OnTargetNameCommitted )
] ;
} ) ;
2015-03-18 19:14:43 -04:00
PropertyCustomizationMap . Add ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , ConflictStatus ) , [ & ] ( const TSharedRef < IPropertyHandle > & MemberPropertyHandle , IDetailCategoryBuilder & DetailCategoryBuilder )
2015-03-06 17:12:46 -05:00
{
FDetailWidgetRow & StatusRow = DetailCategoryBuilder . AddCustomRow ( MemberPropertyHandle - > GetPropertyDisplayName ( ) ) ;
StatusRow . NameContent ( )
[
MemberPropertyHandle - > CreatePropertyNameWidget ( )
] ;
StatusRow . ValueContent ( )
. HAlign ( HAlign_Left )
. VAlign ( VAlign_Center )
[
SNew ( SLocalizationTargetStatusButton , * LocalizationTarget )
] ;
} ) ;
PropertyCustomizationMap . Add ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , TargetDependencies ) , [ & ] ( const TSharedRef < IPropertyHandle > & MemberPropertyHandle , IDetailCategoryBuilder & DetailCategoryBuilder )
{
const auto & MenuContentLambda = [ this ] ( ) - > TSharedRef < SWidget >
{
RebuildTargetsList ( ) ;
if ( TargetDependenciesOptionsList . Num ( ) > 0 )
{
return SNew ( SBox )
. MaxDesiredHeight ( 400.0f )
. MaxDesiredWidth ( 300.0f )
[
SNew ( SListView < ULocalizationTarget * > )
. SelectionMode ( ESelectionMode : : None )
. ListItemsSource ( & TargetDependenciesOptionsList )
. OnGenerateRow ( this , & FLocalizationTargetDetailCustomization : : OnGenerateTargetRow )
] ;
}
else
{
return SNullWidget : : NullWidget ;
}
} ;
FDetailWidgetRow & TargetDependenciesRow = DetailCategoryBuilder . AddCustomRow ( MemberPropertyHandle - > GetPropertyDisplayName ( ) ) ;
TargetDependenciesRow . NameContent ( )
[
MemberPropertyHandle - > CreatePropertyNameWidget ( )
] ;
TargetDependenciesRow . ValueContent ( )
. HAlign ( HAlign_Left )
. VAlign ( VAlign_Center )
[
SNew ( SComboButton )
. ButtonContent ( )
[
SAssignNew ( TargetDependenciesHorizontalBox , SHorizontalBox )
]
. HasDownArrow ( true )
. OnGetMenuContent_Lambda ( MenuContentLambda )
] ;
RebuildTargetDependenciesBox ( ) ;
} ) ;
2015-04-22 16:39:20 -04:00
PropertyCustomizationMap . Add ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , NativeCultureIndex ) , [ & ] ( const TSharedRef < IPropertyHandle > & MemberPropertyHandle , IDetailCategoryBuilder & DetailCategoryBuilder )
2015-03-06 17:12:46 -05:00
{
2015-04-22 16:39:20 -04:00
NativeCultureIndexPropertyHandle = MemberPropertyHandle ;
2015-03-06 17:12:46 -05:00
} ) ;
PropertyCustomizationMap . Add ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , SupportedCulturesStatistics ) , [ & ] ( const TSharedRef < IPropertyHandle > & MemberPropertyHandle , IDetailCategoryBuilder & DetailCategoryBuilder )
{
SupportedCulturesStatisticsPropertyHandle = MemberPropertyHandle ;
SupportedCulturesStatisticsPropertyHandle_OnNumElementsChanged = FSimpleDelegate : : CreateSP ( this , & FLocalizationTargetDetailCustomization : : RebuildListedCulturesList ) ;
SupportedCulturesStatisticsPropertyHandle - > AsArray ( ) - > SetOnNumElementsChanged ( SupportedCulturesStatisticsPropertyHandle_OnNumElementsChanged ) ;
FLocalizationTargetEditorCommands : : Register ( ) ;
const TSharedRef < FUICommandList > CommandList = MakeShareable ( new FUICommandList ) ;
FToolBarBuilder ToolBarBuilder ( CommandList , FMultiBoxCustomization : : AllowCustomization ( " LocalizationTargetEditor " ) ) ;
CommandList - > MapAction ( FLocalizationTargetEditorCommands : : Get ( ) . Gather , FExecuteAction : : CreateSP ( this , & FLocalizationTargetDetailCustomization : : Gather ) ) ;
ToolBarBuilder . AddToolBarButton ( FLocalizationTargetEditorCommands : : Get ( ) . Gather , NAME_None , TAttribute < FText > ( ) , TAttribute < FText > ( ) , FSlateIcon ( FEditorStyle : : GetStyleSetName ( ) , " LocalizationTargetEditor.Gather " ) ) ;
CommandList - > MapAction ( FLocalizationTargetEditorCommands : : Get ( ) . ImportAllCultures , FExecuteAction : : CreateSP ( this , & FLocalizationTargetDetailCustomization : : ImportAllCultures ) ) ;
ToolBarBuilder . AddToolBarButton ( FLocalizationTargetEditorCommands : : Get ( ) . ImportAllCultures , NAME_None , TAttribute < FText > ( ) , TAttribute < FText > ( ) , FSlateIcon ( FEditorStyle : : GetStyleSetName ( ) , " LocalizationTargetEditor.ImportForAllCultures " ) ) ;
CommandList - > MapAction ( FLocalizationTargetEditorCommands : : Get ( ) . ExportAllCultures , FExecuteAction : : CreateSP ( this , & FLocalizationTargetDetailCustomization : : ExportAllCultures ) ) ;
ToolBarBuilder . AddToolBarButton ( FLocalizationTargetEditorCommands : : Get ( ) . ExportAllCultures , NAME_None , TAttribute < FText > ( ) , TAttribute < FText > ( ) , FSlateIcon ( FEditorStyle : : GetStyleSetName ( ) , " LocalizationTargetEditor.ExportForAllCultures " ) ) ;
CommandList - > MapAction ( FLocalizationTargetEditorCommands : : Get ( ) . RefreshWordCounts , FExecuteAction : : CreateSP ( this , & FLocalizationTargetDetailCustomization : : RefreshWordCounts ) ) ;
ToolBarBuilder . AddToolBarButton ( FLocalizationTargetEditorCommands : : Get ( ) . RefreshWordCounts , NAME_None , TAttribute < FText > ( ) , TAttribute < FText > ( ) , FSlateIcon ( FEditorStyle : : GetStyleSetName ( ) , " LocalizationTargetEditor.RefreshWordCounts " ) ) ;
CommandList - > MapAction ( FLocalizationTargetEditorCommands : : Get ( ) . Compile , FExecuteAction : : CreateSP ( this , & FLocalizationTargetDetailCustomization : : Compile ) ) ;
ToolBarBuilder . AddToolBarButton ( FLocalizationTargetEditorCommands : : Get ( ) . Compile , NAME_None , TAttribute < FText > ( ) , TAttribute < FText > ( ) , FSlateIcon ( FEditorStyle : : GetStyleSetName ( ) , " LocalizationTargetEditor.Compile " ) ) ;
BuildListedCulturesList ( ) ;
DetailCategoryBuilder . AddCustomRow ( SupportedCulturesStatisticsPropertyHandle - > GetPropertyDisplayName ( ) )
. WholeRowContent ( )
[
SNew ( SVerticalBox )
+ SVerticalBox : : Slot ( )
. AutoHeight ( )
[
ToolBarBuilder . MakeWidget ( )
]
+ SVerticalBox : : Slot ( )
. AutoHeight ( )
[
SAssignNew ( SupportedCultureListView , SListView < TSharedPtr < IPropertyHandle > > )
. OnGenerateRow ( this , & FLocalizationTargetDetailCustomization : : OnGenerateCultureRow )
. ListItemsSource ( & ListedCultureStatisticProperties )
. SelectionMode ( ESelectionMode : : None )
. HeaderRow
(
SNew ( SHeaderRow )
2015-04-22 16:39:20 -04:00
+ SHeaderRow : : Column ( " IsNative " )
. DefaultLabel ( NSLOCTEXT ( " LocalizationCulture " , " IsNativeColumnLabel " , " Native " ) )
. HAlignHeader ( HAlign_Center )
. HAlignCell ( HAlign_Center )
. VAlignCell ( VAlign_Center )
. FillWidth ( 0.1f )
2015-03-06 17:12:46 -05:00
+ SHeaderRow : : Column ( " Culture " )
. DefaultLabel ( NSLOCTEXT ( " LocalizationCulture " , " CultureColumnLabel " , " Culture " ) )
. HAlignHeader ( HAlign_Fill )
. HAlignCell ( HAlign_Fill )
. VAlignCell ( VAlign_Center )
2015-04-22 16:39:20 -04:00
. FillWidth ( 0.2f )
2015-03-06 17:12:46 -05:00
+ SHeaderRow : : Column ( " WordCount " )
. DefaultLabel ( NSLOCTEXT ( " LocalizationCulture " , " WordCountColumnLabel " , " Word Count " ) )
. HAlignHeader ( HAlign_Center )
. HAlignCell ( HAlign_Fill )
. VAlignCell ( VAlign_Center )
2015-04-22 16:39:20 -04:00
. FillWidth ( 0.4f )
2015-03-06 17:12:46 -05:00
+ SHeaderRow : : Column ( " Actions " )
. DefaultLabel ( NSLOCTEXT ( " LocalizationCulture " , " ActionsColumnLabel " , " Actions " ) )
. HAlignHeader ( HAlign_Center )
. HAlignCell ( HAlign_Center )
. VAlignCell ( VAlign_Center )
2015-04-22 16:39:20 -04:00
. FillWidth ( 0.3f )
2015-03-06 17:12:46 -05:00
)
]
+ SVerticalBox : : Slot ( )
. AutoHeight ( )
. VAlign ( VAlign_Center )
[
SAssignNew ( AddNewSupportedCultureComboButton , SComboButton )
. ButtonContent ( )
[
SNew ( STextBlock )
. Text ( NSLOCTEXT ( " LocalizationCulture " , " AddNewCultureButtonLabel " , " Add New Culture " ) )
]
. MenuContent ( )
[
SNew ( SBox )
. MaxDesiredHeight ( 400.0f )
. MaxDesiredWidth ( 300.0f )
[
SAssignNew ( SupportedCulturePicker , SCulturePicker )
. OnSelectionChanged ( this , & FLocalizationTargetDetailCustomization : : OnNewSupportedCultureSelected )
. IsCulturePickable ( this , & FLocalizationTargetDetailCustomization : : IsCultureSelectableAsSupported )
]
]
]
] ;
} ) ;
UStructProperty * const SettingsStructProperty = CastChecked < UStructProperty > ( TargetSettingsPropertyHandle - > GetProperty ( ) ) ;
for ( TFieldIterator < UProperty > Iterator ( SettingsStructProperty - > Struct ) ; Iterator ; + + Iterator )
{
UProperty * const MemberProperty = * Iterator ;
const bool IsEditable = MemberProperty - > HasAnyPropertyFlags ( CPF_Edit ) ;
if ( IsEditable )
{
const FName CategoryName = FObjectEditorUtils : : GetCategoryFName ( MemberProperty ) ;
IDetailCategoryBuilder & DetailCategoryBuilder = DetailBuilder . EditCategory ( CategoryName ) ;
const FName PropertyName = MemberProperty - > GetFName ( ) ;
const TSharedPtr < IPropertyHandle > MemberPropertyHandle = TargetSettingsPropertyHandle - > GetChildHandle ( MemberProperty - > GetFName ( ) ) ;
if ( MemberPropertyHandle . IsValid ( ) & & MemberPropertyHandle - > IsValidHandle ( ) )
{
FPropertyCustomizationFunction * const Function = PropertyCustomizationMap . Find ( PropertyName ) ;
if ( Function )
{
MemberPropertyHandle - > MarkHiddenByCustomization ( ) ;
( * Function ) ( MemberPropertyHandle . ToSharedRef ( ) , DetailCategoryBuilder ) ;
}
else
{
DetailCategoryBuilder . AddProperty ( MemberPropertyHandle ) ;
}
}
}
}
2015-03-19 16:59:17 -04:00
{
IDetailCategoryBuilder & DetailCategoryBuilder = DetailBuilder . EditCategory ( " Target " ) ;
FDetailWidgetRow & DetailWidgetRow = DetailCategoryBuilder . AddCustomRow ( LOCTEXT ( " LocalizationTargetLoadingPolicyRowFilterString " , " Loading Policy " ) ) ;
static const TArray < TSharedPtr < ELocalizationTargetLoadingPolicy > > LoadingPolicies = [ ] ( )
{
UEnum * const LoadingPolicyEnum = FindObjectChecked < UEnum > ( ANY_PACKAGE , TEXT ( " ELocalizationTargetLoadingPolicy " ) ) ;
TArray < TSharedPtr < ELocalizationTargetLoadingPolicy > > Array ;
2015-04-22 16:57:32 -04:00
for ( int32 i = 0 ; i < LoadingPolicyEnum - > NumEnums ( ) - 1 ; + + i )
2015-03-19 16:59:17 -04:00
{
Array . Add ( MakeShareable ( new ELocalizationTargetLoadingPolicy ( static_cast < ELocalizationTargetLoadingPolicy > ( i ) ) ) ) ;
}
return Array ;
} ( ) ;
DetailWidgetRow . NameContent ( )
[
SNew ( STextBlock )
. Text ( LOCTEXT ( " LocalizationTargetLoadingPolicyRowName " , " Loading Policy " ) )
] ;
DetailWidgetRow . ValueContent ( )
[
SNew ( SComboBox < TSharedPtr < ELocalizationTargetLoadingPolicy > > )
. OptionsSource ( & LoadingPolicies )
. OnSelectionChanged ( this , & FLocalizationTargetDetailCustomization : : OnLoadingPolicySelectionChanged )
. OnGenerateWidget ( this , & FLocalizationTargetDetailCustomization : : GenerateWidgetForLoadingPolicy )
. InitiallySelectedItem ( LoadingPolicies [ static_cast < int32 > ( GetLoadingPolicy ( ) ) ] )
. Content ( )
[
SNew ( STextBlock )
. Text_Lambda ( [ this ] ( )
{
UEnum * const LoadingPolicyEnum = FindObjectChecked < UEnum > ( ANY_PACKAGE , TEXT ( " ELocalizationTargetLoadingPolicy " ) ) ;
return LoadingPolicyEnum - > GetDisplayNameText ( static_cast < int32 > ( GetLoadingPolicy ( ) ) ) ;
} )
]
] ;
}
2015-03-05 00:08:26 -05:00
//{
// IDetailCategoryBuilder& ServiceProviderCategoryBuilder = DetailBuilder.EditCategory(FName("LocalizationServiceProvider"));
// ILocalizationServiceProvider* const LSP = ILocalizationDashboardModule::Get().GetCurrentLocalizationServiceProvider();
// if (LSP && LocalizationTarget)
// {
// LSP->CustomizeTargetDetails(ServiceProviderCategoryBuilder, *LocalizationTarget);
// }
//}
}
FLocalizationTargetSettings * FLocalizationTargetDetailCustomization : : GetTargetSettings ( ) const
{
return LocalizationTarget . IsValid ( ) ? & ( LocalizationTarget - > Settings ) : nullptr ;
}
TSharedPtr < IPropertyHandle > FLocalizationTargetDetailCustomization : : GetTargetSettingsPropertyHandle ( ) const
{
return TargetSettingsPropertyHandle ;
}
FText FLocalizationTargetDetailCustomization : : GetTargetName ( ) const
{
if ( LocalizationTarget . IsValid ( ) )
{
return FText : : FromString ( LocalizationTarget - > Settings . Name ) ;
}
return FText : : GetEmpty ( ) ;
}
bool FLocalizationTargetDetailCustomization : : IsTargetNameUnique ( const FString & Name ) const
{
2015-03-18 23:47:20 -04:00
TArray < ULocalizationTarget * > AllLocalizationTargets ;
2015-03-28 19:17:15 -04:00
ULocalizationTargetSet * EngineTargetSet = ULocalizationDashboardSettings : : GetEngineTargetSet ( ) ;
2015-03-18 23:47:20 -04:00
if ( EngineTargetSet ! = TargetSet )
{
AllLocalizationTargets . Append ( EngineTargetSet - > TargetObjects ) ;
}
AllLocalizationTargets . Append ( TargetSet - > TargetObjects ) ;
for ( ULocalizationTarget * const TargetObject : AllLocalizationTargets )
2015-03-05 00:08:26 -05:00
{
if ( TargetObject ! = LocalizationTarget )
{
if ( TargetObject - > Settings . Name = = LocalizationTarget - > Settings . Name )
{
return false ;
}
}
}
return true ;
}
void FLocalizationTargetDetailCustomization : : OnTargetNameChanged ( const FText & NewText )
{
const FString & NewName = NewText . ToString ( ) ;
// TODO: Target names must be valid directory names, because they are used as directory names.
// ValidatePath allows /, which is not a valid directory name character
FText Error ;
if ( ! FPaths : : ValidatePath ( NewName , & Error ) )
{
TargetNameEditableTextBox - > SetError ( Error ) ;
return ;
}
// Target name must be unique.
if ( ! IsTargetNameUnique ( NewName ) )
{
TargetNameEditableTextBox - > SetError ( LOCTEXT ( " DuplicateTargetNameError " , " Target name must be unique. " ) ) ;
return ;
}
// Clear error if nothing has failed.
TargetNameEditableTextBox - > SetError ( FText : : GetEmpty ( ) ) ;
}
void FLocalizationTargetDetailCustomization : : OnTargetNameCommitted ( const FText & NewText , ETextCommit : : Type Type )
{
// Target name must be unique.
if ( ! IsTargetNameUnique ( NewText . ToString ( ) ) )
{
return ;
}
if ( TargetSettingsPropertyHandle . IsValid ( ) & & TargetSettingsPropertyHandle - > IsValidHandle ( ) )
{
FLocalizationTargetSettings * const TargetSettings = GetTargetSettings ( ) ;
if ( TargetSettings )
{
// Early out if the committed name is the same as the current name.
if ( TargetSettings - > Name = = NewText . ToString ( ) )
{
return ;
}
const TSharedPtr < IPropertyHandle > TargetNamePropertyHandle = TargetSettingsPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , Name ) ) ;
if ( TargetNamePropertyHandle . IsValid ( ) & & TargetNamePropertyHandle - > IsValidHandle ( ) )
{
TargetNamePropertyHandle - > NotifyPreChange ( ) ;
}
2015-03-09 15:09:46 -04:00
LocalizationTarget - > RenameTargetAndFiles ( NewText . ToString ( ) ) ;
2015-03-05 00:08:26 -05:00
if ( TargetNamePropertyHandle . IsValid ( ) & & TargetNamePropertyHandle - > IsValidHandle ( ) )
{
TargetNamePropertyHandle - > NotifyPostChange ( ) ;
}
}
}
}
2015-03-19 16:59:17 -04:00
ELocalizationTargetLoadingPolicy FLocalizationTargetDetailCustomization : : GetLoadingPolicy ( ) const
{
const FString DataDirectory = LocalizationConfigurationScript : : GetDataDirectory ( LocalizationTarget . Get ( ) ) ;
for ( const TPair < ELocalizationTargetLoadingPolicy , FConfigValueIdentity > & Pair : LoadingPolicyToConfigSettingMap )
{
TArray < FString > LocalizationPaths ;
GConfig - > GetArray ( * Pair . Value . SectionName , * Pair . Value . KeyName , LocalizationPaths , Pair . Value . ConfigFilePath ) ;
if ( LocalizationPaths . Contains ( DataDirectory ) )
{
return Pair . Key ;
}
}
return ELocalizationTargetLoadingPolicy : : Never ;
}
void FLocalizationTargetDetailCustomization : : SetLoadingPolicy ( const ELocalizationTargetLoadingPolicy LoadingPolicy )
{
const FString DataDirectory = LocalizationConfigurationScript : : GetDataDirectory ( LocalizationTarget . Get ( ) ) ;
for ( const TPair < ELocalizationTargetLoadingPolicy , FConfigValueIdentity > & Pair : LoadingPolicyToConfigSettingMap )
{
TArray < FString > LocalizationPaths ;
GConfig - > GetArray ( * Pair . Value . SectionName , * Pair . Value . KeyName , LocalizationPaths , Pair . Value . ConfigFilePath ) ;
// Add this localization target's data directory to the appropriate localization path setting.
if ( Pair . Key = = LoadingPolicy & & ! LocalizationPaths . Contains ( DataDirectory ) )
{
LocalizationPaths . Add ( DataDirectory ) ;
GConfig - > SetArray ( * Pair . Value . SectionName , * Pair . Value . KeyName , LocalizationPaths , Pair . Value . ConfigFilePath ) ;
}
// Remove this localization target's data directory from any inappropriate localization path setting.
else if ( LocalizationPaths . Contains ( DataDirectory ) )
{
LocalizationPaths . Remove ( DataDirectory ) ;
GConfig - > SetArray ( * Pair . Value . SectionName , * Pair . Value . KeyName , LocalizationPaths , Pair . Value . ConfigFilePath ) ;
}
}
}
void FLocalizationTargetDetailCustomization : : OnLoadingPolicySelectionChanged ( TSharedPtr < ELocalizationTargetLoadingPolicy > LoadingPolicy , ESelectInfo : : Type SelectInfo )
{
SetLoadingPolicy ( * LoadingPolicy . Get ( ) ) ;
} ;
TSharedRef < SWidget > FLocalizationTargetDetailCustomization : : GenerateWidgetForLoadingPolicy ( TSharedPtr < ELocalizationTargetLoadingPolicy > LoadingPolicy )
{
UEnum * const LoadingPolicyEnum = FindObjectChecked < UEnum > ( ANY_PACKAGE , TEXT ( " ELocalizationTargetLoadingPolicy " ) ) ;
return SNew ( STextBlock )
. Text ( LoadingPolicyEnum - > GetDisplayNameText ( static_cast < int32 > ( * LoadingPolicy . Get ( ) ) ) ) ;
} ;
2015-03-05 00:08:26 -05:00
void FLocalizationTargetDetailCustomization : : RebuildTargetDependenciesBox ( )
{
if ( TargetDependenciesHorizontalBox . IsValid ( ) )
{
for ( const TSharedPtr < SWidget > & Widget : TargetDependenciesWidgets )
{
TargetDependenciesHorizontalBox - > RemoveSlot ( Widget . ToSharedRef ( ) ) ;
}
TargetDependenciesWidgets . Empty ( ) ;
2015-03-26 20:23:29 -04:00
TArray < ULocalizationTarget * > AllLocalizationTargets ;
2015-03-28 19:17:15 -04:00
ULocalizationTargetSet * EngineTargetSet = ULocalizationDashboardSettings : : GetEngineTargetSet ( ) ;
2015-03-26 20:23:29 -04:00
if ( EngineTargetSet ! = TargetSet )
2015-03-05 00:08:26 -05:00
{
2015-03-26 20:23:29 -04:00
AllLocalizationTargets . Append ( EngineTargetSet - > TargetObjects ) ;
}
AllLocalizationTargets . Append ( TargetSet - > TargetObjects ) ;
for ( const FGuid & TargetDependencyGuid : LocalizationTarget - > Settings . TargetDependencies )
{
ULocalizationTarget * * const TargetDependency = AllLocalizationTargets . FindByPredicate ( [ TargetDependencyGuid ] ( ULocalizationTarget * SomeLocalizationTarget ) - > bool { return SomeLocalizationTarget - > Settings . Guid = = TargetDependencyGuid ; } ) ;
if ( TargetDependency )
{
TWeakObjectPtr < ULocalizationTarget > TargetDependencyPtr = * TargetDependency ;
const auto & GetTargetDependencyName = [ TargetDependencyPtr ] { return FText : : FromString ( TargetDependencyPtr - > Settings . Name ) ; } ;
const TSharedRef < SWidget > Widget = SNew ( SBorder )
2015-03-05 00:08:26 -05:00
[
SNew ( STextBlock )
2015-03-26 20:23:29 -04:00
. Text_Lambda ( GetTargetDependencyName )
2015-03-05 00:08:26 -05:00
] ;
2015-03-26 20:23:29 -04:00
TargetDependenciesWidgets . Add ( Widget ) ;
TargetDependenciesHorizontalBox - > AddSlot ( )
2015-03-05 00:08:26 -05:00
[
Widget
] ;
2015-03-26 20:23:29 -04:00
}
2015-03-05 00:08:26 -05:00
}
}
}
void FLocalizationTargetDetailCustomization : : RebuildTargetsList ( )
{
TargetDependenciesOptionsList . Empty ( ) ;
TFunction < bool ( ULocalizationTarget * const ) > DoesTargetDependOnUs ;
DoesTargetDependOnUs = [ & , this ] ( ULocalizationTarget * const OtherTarget ) - > bool
{
2015-03-26 20:23:29 -04:00
if ( OtherTarget - > Settings . TargetDependencies . Contains ( LocalizationTarget - > Settings . Guid ) )
2015-03-05 00:08:26 -05:00
{
return true ;
}
2015-03-26 20:23:29 -04:00
for ( const FGuid & OtherTargetDependencyGuid : OtherTarget - > Settings . TargetDependencies )
2015-03-05 00:08:26 -05:00
{
2015-03-26 20:23:29 -04:00
ULocalizationTarget * * const OtherTargetDependency = TargetSet - > TargetObjects . FindByPredicate ( [ OtherTargetDependencyGuid ] ( ULocalizationTarget * SomeLocalizationTarget ) - > bool { return SomeLocalizationTarget - > Settings . Guid = = OtherTargetDependencyGuid ; } ) ;
2015-03-05 00:08:26 -05:00
if ( OtherTargetDependency & & DoesTargetDependOnUs ( * OtherTargetDependency ) )
{
return true ;
}
}
return false ;
} ;
2015-03-18 22:22:06 -04:00
TArray < ULocalizationTarget * > AllLocalizationTargets ;
2015-03-28 19:17:15 -04:00
ULocalizationTargetSet * EngineTargetSet = ULocalizationDashboardSettings : : GetEngineTargetSet ( ) ;
2015-03-18 22:22:06 -04:00
if ( EngineTargetSet ! = TargetSet )
{
AllLocalizationTargets . Append ( EngineTargetSet - > TargetObjects ) ;
}
AllLocalizationTargets . Append ( TargetSet - > TargetObjects ) ;
for ( ULocalizationTarget * const OtherTarget : AllLocalizationTargets )
2015-03-05 00:08:26 -05:00
{
if ( OtherTarget ! = LocalizationTarget )
{
if ( ! DoesTargetDependOnUs ( OtherTarget ) )
{
TargetDependenciesOptionsList . Add ( OtherTarget ) ;
}
}
}
if ( TargetDependenciesListView . IsValid ( ) )
{
TargetDependenciesListView - > RequestListRefresh ( ) ;
}
}
TSharedRef < ITableRow > FLocalizationTargetDetailCustomization : : OnGenerateTargetRow ( ULocalizationTarget * OtherLocalizationTarget , const TSharedRef < STableViewBase > & Table )
{
return SNew ( STableRow < ULocalizationTarget * > , Table )
. ShowSelection ( true )
. Content ( )
[
SNew ( SCheckBox )
. OnCheckStateChanged_Lambda ( [ this , OtherLocalizationTarget ] ( ECheckBoxState State )
{
OnTargetDependencyCheckStateChanged ( OtherLocalizationTarget , State ) ;
} )
. IsChecked_Lambda ( [ this , OtherLocalizationTarget ] ( ) - > ECheckBoxState
{
return IsTargetDependencyChecked ( OtherLocalizationTarget ) ;
} )
. Content ( )
[
SNew ( STextBlock )
. Text ( FText : : FromString ( OtherLocalizationTarget - > Settings . Name ) )
]
] ;
}
void FLocalizationTargetDetailCustomization : : OnTargetDependencyCheckStateChanged ( ULocalizationTarget * const OtherLocalizationTarget , const ECheckBoxState State )
{
const TSharedPtr < IPropertyHandle > TargetDependenciesPropertyHandle = TargetSettingsPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , TargetDependencies ) ) ;
if ( TargetDependenciesPropertyHandle . IsValid ( ) & & TargetDependenciesPropertyHandle - > IsValidHandle ( ) )
{
TargetDependenciesPropertyHandle - > NotifyPreChange ( ) ;
}
switch ( State )
{
case ECheckBoxState : : Checked :
2015-03-26 20:23:29 -04:00
LocalizationTarget - > Settings . TargetDependencies . Add ( OtherLocalizationTarget - > Settings . Guid ) ;
2015-03-05 00:08:26 -05:00
break ;
case ECheckBoxState : : Unchecked :
2015-03-26 20:23:29 -04:00
LocalizationTarget - > Settings . TargetDependencies . Remove ( OtherLocalizationTarget - > Settings . Guid ) ;
2015-03-05 00:08:26 -05:00
break ;
}
if ( TargetDependenciesPropertyHandle . IsValid ( ) & & TargetDependenciesPropertyHandle - > IsValidHandle ( ) )
{
TargetDependenciesPropertyHandle - > NotifyPostChange ( ) ;
}
RebuildTargetDependenciesBox ( ) ;
}
ECheckBoxState FLocalizationTargetDetailCustomization : : IsTargetDependencyChecked ( ULocalizationTarget * const OtherLocalizationTarget ) const
{
2015-03-26 20:23:29 -04:00
return LocalizationTarget - > Settings . TargetDependencies . Contains ( OtherLocalizationTarget - > Settings . Guid ) ? ECheckBoxState : : Checked : ECheckBoxState : : Unchecked ;
2015-03-05 00:08:26 -05:00
}
void FLocalizationTargetDetailCustomization : : Gather ( )
{
if ( LocalizationTarget . IsValid ( ) )
{
// Save unsaved packages.
const bool bPromptUserToSave = true ;
const bool bSaveMapPackages = true ;
const bool bSaveContentPackages = true ;
const bool bFastSave = false ;
const bool bNotifyNoPackagesSaved = false ;
const bool bCanBeDeclined = true ;
bool DidPackagesNeedSaving ;
const bool WerePackagesSaved = FEditorFileUtils : : SaveDirtyPackages ( bPromptUserToSave , bSaveMapPackages , bSaveContentPackages , bFastSave , bNotifyNoPackagesSaved , bCanBeDeclined , & DidPackagesNeedSaving ) ;
if ( DidPackagesNeedSaving & & ! WerePackagesSaved )
{
// Give warning dialog.
const FText MessageText = NSLOCTEXT ( " LocalizationCultureActions " , " UnsavedPackagesWarningDialogMessage " , " There are unsaved changes. These changes may not be gathered from correctly. " ) ;
const FText TitleText = NSLOCTEXT ( " LocalizationCultureActions " , " UnsavedPackagesWarningDialogTitle " , " Unsaved Changes Before Gather " ) ;
switch ( FMessageDialog : : Open ( EAppMsgType : : OkCancel , MessageText , & TitleText ) )
{
case EAppReturnType : : Cancel :
{
return ;
}
break ;
}
}
// Execute gather.
const TSharedPtr < SWindow > ParentWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( DetailLayoutBuilder - > GetDetailsView ( ) . AsShared ( ) ) ;
2015-03-09 15:38:32 -04:00
LocalizationCommandletTasks : : GatherTarget ( ParentWindow . ToSharedRef ( ) , LocalizationTarget . Get ( ) ) ;
2015-03-05 00:08:26 -05:00
UpdateTargetFromReports ( ) ;
}
}
void FLocalizationTargetDetailCustomization : : ImportAllCultures ( )
{
IDesktopPlatform * DesktopPlatform = FDesktopPlatformModule : : Get ( ) ;
if ( LocalizationTarget . IsValid ( ) & & DesktopPlatform )
{
void * ParentWindowWindowHandle = NULL ;
const TSharedPtr < SWindow > ParentWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( DetailLayoutBuilder - > GetDetailsView ( ) . AsShared ( ) ) ;
if ( ParentWindow . IsValid ( ) & & ParentWindow - > GetNativeWindow ( ) . IsValid ( ) )
{
ParentWindowWindowHandle = ParentWindow - > GetNativeWindow ( ) - > GetOSWindowHandle ( ) ;
}
2015-03-09 15:38:32 -04:00
const FString DefaultPath = FPaths : : ConvertRelativePathToFull ( LocalizationConfigurationScript : : GetDataDirectory ( LocalizationTarget . Get ( ) ) ) ;
2015-03-05 00:08:26 -05:00
FText DialogTitle ;
{
FFormatNamedArguments FormatArguments ;
FormatArguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( LocalizationTarget - > Settings . Name ) ) ;
DialogTitle = FText : : Format ( LOCTEXT ( " ImportAllTranslationsForTargetDialogTitleFormat " , " Import All Translations for {TargetName} from Directory " ) , FormatArguments ) ;
}
// Prompt the user for the directory
FString OutputDirectory ;
if ( DesktopPlatform - > OpenDirectoryDialog ( ParentWindowWindowHandle , DialogTitle . ToString ( ) , DefaultPath , OutputDirectory ) )
{
2015-03-09 15:38:32 -04:00
LocalizationCommandletTasks : : ImportTarget ( ParentWindow . ToSharedRef ( ) , LocalizationTarget . Get ( ) , TOptional < FString > ( OutputDirectory ) ) ;
2015-03-05 00:08:26 -05:00
UpdateTargetFromReports ( ) ;
}
}
}
void FLocalizationTargetDetailCustomization : : ExportAllCultures ( )
{
IDesktopPlatform * DesktopPlatform = FDesktopPlatformModule : : Get ( ) ;
if ( LocalizationTarget . IsValid ( ) & & DesktopPlatform )
{
void * ParentWindowWindowHandle = NULL ;
const TSharedPtr < SWindow > ParentWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( DetailLayoutBuilder - > GetDetailsView ( ) . AsShared ( ) ) ;
if ( ParentWindow . IsValid ( ) & & ParentWindow - > GetNativeWindow ( ) . IsValid ( ) )
{
ParentWindowWindowHandle = ParentWindow - > GetNativeWindow ( ) - > GetOSWindowHandle ( ) ;
}
2015-03-09 15:38:32 -04:00
const FString DefaultPath = FPaths : : ConvertRelativePathToFull ( LocalizationConfigurationScript : : GetDataDirectory ( LocalizationTarget . Get ( ) ) ) ;
2015-03-05 00:08:26 -05:00
FText DialogTitle ;
{
FFormatNamedArguments FormatArguments ;
FormatArguments . Add ( TEXT ( " TargetName " ) , FText : : FromString ( LocalizationTarget - > Settings . Name ) ) ;
DialogTitle = FText : : Format ( LOCTEXT ( " ExportAllTranslationsForTargetDialogTitleFormat " , " Export All Translations for {TargetName} to Directory " ) , FormatArguments ) ;
}
// Prompt the user for the directory
FString OutputDirectory ;
if ( DesktopPlatform - > OpenDirectoryDialog ( ParentWindowWindowHandle , DialogTitle . ToString ( ) , DefaultPath , OutputDirectory ) )
{
2015-03-09 15:38:32 -04:00
LocalizationCommandletTasks : : ExportTarget ( ParentWindow . ToSharedRef ( ) , LocalizationTarget . Get ( ) , TOptional < FString > ( OutputDirectory ) ) ;
2015-03-05 00:08:26 -05:00
}
}
}
void FLocalizationTargetDetailCustomization : : Compile ( )
{
if ( LocalizationTarget . IsValid ( ) )
{
// Execute compile.
const TSharedPtr < SWindow > ParentWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( DetailLayoutBuilder - > GetDetailsView ( ) . AsShared ( ) ) ;
2015-03-09 15:38:32 -04:00
LocalizationCommandletTasks : : CompileTarget ( ParentWindow . ToSharedRef ( ) , LocalizationTarget . Get ( ) ) ;
2015-03-05 00:08:26 -05:00
}
}
void FLocalizationTargetDetailCustomization : : RefreshWordCounts ( )
{
if ( LocalizationTarget . IsValid ( ) )
{
const TSharedPtr < SWindow > ParentWindow = FSlateApplication : : Get ( ) . FindWidgetWindow ( DetailLayoutBuilder - > GetDetailsView ( ) . AsShared ( ) ) ;
2015-03-18 19:14:43 -04:00
LocalizationCommandletTasks : : GenerateWordCountReportForTarget ( ParentWindow . ToSharedRef ( ) , LocalizationTarget . Get ( ) ) ;
2015-03-05 00:08:26 -05:00
UpdateTargetFromReports ( ) ;
}
}
void FLocalizationTargetDetailCustomization : : UpdateTargetFromReports ( )
{
2015-03-09 15:09:46 -04:00
if ( LocalizationTarget . IsValid ( ) )
2015-03-05 00:08:26 -05:00
{
TArray < TSharedPtr < IPropertyHandle > > WordCountPropertyHandles ;
if ( TargetSettingsPropertyHandle . IsValid ( ) & & TargetSettingsPropertyHandle - > IsValidHandle ( ) )
{
2015-04-10 11:23:49 -04:00
const TSharedPtr < IPropertyHandle > SupportedCulturesStatisticsPropHandle = TargetSettingsPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FLocalizationTargetSettings , SupportedCulturesStatistics ) ) ;
if ( SupportedCulturesStatisticsPropHandle . IsValid ( ) & & SupportedCulturesStatisticsPropHandle - > IsValidHandle ( ) )
2015-03-05 00:08:26 -05:00
{
uint32 SupportedCultureCount = 0 ;
2015-04-10 11:23:49 -04:00
SupportedCulturesStatisticsPropHandle - > GetNumChildren ( SupportedCultureCount ) ;
2015-03-05 00:08:26 -05:00
for ( uint32 i = 0 ; i < SupportedCultureCount ; + + i )
{
2015-04-10 11:23:49 -04:00
const TSharedPtr < IPropertyHandle > ElementPropertyHandle = SupportedCulturesStatisticsPropHandle - > GetChildHandle ( i ) ;
2015-03-05 00:08:26 -05:00
if ( ElementPropertyHandle . IsValid ( ) & & ElementPropertyHandle - > IsValidHandle ( ) )
{
2015-04-10 11:23:49 -04:00
const TSharedPtr < IPropertyHandle > WordCountPropertyHandle = SupportedCulturesStatisticsPropHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FCultureStatistics , WordCount ) ) ;
2015-03-05 00:08:26 -05:00
if ( WordCountPropertyHandle . IsValid ( ) & & WordCountPropertyHandle - > IsValidHandle ( ) )
{
WordCountPropertyHandles . Add ( WordCountPropertyHandle ) ;
}
}
}
}
}
for ( const TSharedPtr < IPropertyHandle > & WordCountPropertyHandle : WordCountPropertyHandles )
{
WordCountPropertyHandle - > NotifyPreChange ( ) ;
}
2015-03-09 15:09:46 -04:00
LocalizationTarget - > UpdateWordCountsFromCSV ( ) ;
LocalizationTarget - > UpdateStatusFromConflictReport ( ) ;
2015-03-05 00:08:26 -05:00
for ( const TSharedPtr < IPropertyHandle > & WordCountPropertyHandle : WordCountPropertyHandles )
{
WordCountPropertyHandle - > NotifyPostChange ( ) ;
}
}
}
void FLocalizationTargetDetailCustomization : : BuildListedCulturesList ( )
{
const TSharedPtr < IPropertyHandleArray > SupportedCulturesStatisticsArrayPropertyHandle = SupportedCulturesStatisticsPropertyHandle - > AsArray ( ) ;
if ( SupportedCulturesStatisticsArrayPropertyHandle . IsValid ( ) )
{
uint32 ElementCount = 0 ;
SupportedCulturesStatisticsArrayPropertyHandle - > GetNumElements ( ElementCount ) ;
for ( uint32 i = 0 ; i < ElementCount ; + + i )
{
const TSharedPtr < IPropertyHandle > CultureStatisticsProperty = SupportedCulturesStatisticsArrayPropertyHandle - > GetElement ( i ) ;
ListedCultureStatisticProperties . AddUnique ( CultureStatisticsProperty ) ;
}
}
2015-04-22 16:39:20 -04:00
const auto & CultureSorter = [ ] ( const TSharedPtr < IPropertyHandle > & Left , const TSharedPtr < IPropertyHandle > & Right ) - > bool
{
const TSharedPtr < IPropertyHandle > LeftNameHandle = Left - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FCultureStatistics , CultureName ) ) ;
const TSharedPtr < IPropertyHandle > RightNameHandle = Right - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FCultureStatistics , CultureName ) ) ;
FString LeftName ;
LeftNameHandle - > GetValue ( LeftName ) ;
FString RightName ;
RightNameHandle - > GetValue ( RightName ) ;
return LeftName < RightName ;
} ;
ListedCultureStatisticProperties . Sort ( CultureSorter ) ;
2015-03-05 00:08:26 -05:00
}
void FLocalizationTargetDetailCustomization : : RebuildListedCulturesList ( )
{
if ( NewEntryIndexToBeInitialized ! = INDEX_NONE )
{
const TSharedPtr < IPropertyHandle > SupportedCultureStatisticsPropertyHandle = SupportedCulturesStatisticsPropertyHandle - > GetChildHandle ( NewEntryIndexToBeInitialized ) ;
const TSharedPtr < IPropertyHandle > CultureNamePropertyHandle = SupportedCultureStatisticsPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FCultureStatistics , CultureName ) ) ;
if ( CultureNamePropertyHandle . IsValid ( ) & & CultureNamePropertyHandle - > IsValidHandle ( ) )
{
CultureNamePropertyHandle - > SetValue ( SelectedNewCulture - > GetName ( ) ) ;
}
const TSharedPtr < IPropertyHandle > WordCountPropertyHandle = SupportedCultureStatisticsPropertyHandle - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FCultureStatistics , WordCount ) ) ;
if ( WordCountPropertyHandle . IsValid ( ) & & WordCountPropertyHandle - > IsValidHandle ( ) )
{
WordCountPropertyHandle - > SetValue ( 0 ) ;
}
AddNewSupportedCultureComboButton - > SetIsOpen ( false ) ;
NewEntryIndexToBeInitialized = INDEX_NONE ;
}
ListedCultureStatisticProperties . Empty ( ) ;
BuildListedCulturesList ( ) ;
if ( SupportedCultureListView . IsValid ( ) )
{
SupportedCultureListView - > RequestListRefresh ( ) ;
}
}
TSharedRef < ITableRow > FLocalizationTargetDetailCustomization : : OnGenerateCultureRow ( TSharedPtr < IPropertyHandle > CultureStatisticsPropertyHandle , const TSharedRef < STableViewBase > & Table )
{
return SNew ( SLocalizationTargetEditorCultureRow , Table , DetailLayoutBuilder - > GetPropertyUtilities ( ) , TargetSettingsPropertyHandle . ToSharedRef ( ) , CultureStatisticsPropertyHandle - > GetIndexInArray ( ) ) ;
}
bool FLocalizationTargetDetailCustomization : : IsCultureSelectableAsSupported ( FCulturePtr Culture )
{
auto Is = [ & ] ( const TSharedPtr < IPropertyHandle > & SupportedCultureStatisticProperty )
{
// Can't select existing supported cultures.
const TSharedPtr < IPropertyHandle > SupportedCultureNamePropertyHandle = SupportedCultureStatisticProperty - > GetChildHandle ( GET_MEMBER_NAME_CHECKED ( FCultureStatistics , CultureName ) ) ;
if ( SupportedCultureNamePropertyHandle . IsValid ( ) & & SupportedCultureNamePropertyHandle - > IsValidHandle ( ) )
{
FString SupportedCultureName ;
SupportedCultureNamePropertyHandle - > GetValue ( SupportedCultureName ) ;
const FCulturePtr SupportedCulture = FInternationalization : : Get ( ) . GetCulture ( SupportedCultureName ) ;
return SupportedCulture = = Culture ;
}
return false ;
} ;
return ! ListedCultureStatisticProperties . ContainsByPredicate ( Is ) ;
}
void FLocalizationTargetDetailCustomization : : OnNewSupportedCultureSelected ( FCulturePtr SelectedCulture , ESelectInfo : : Type SelectInfo )
{
if ( SupportedCulturesStatisticsPropertyHandle . IsValid ( ) & & SupportedCulturesStatisticsPropertyHandle - > IsValidHandle ( ) )
{
uint32 NewElementIndex ;
SupportedCulturesStatisticsPropertyHandle - > AsArray ( ) - > GetNumElements ( NewElementIndex ) ;
// Add element, set info for later initialization.
SupportedCulturesStatisticsPropertyHandle - > AsArray ( ) - > AddItem ( ) ;
SelectedNewCulture = SelectedCulture ;
NewEntryIndexToBeInitialized = NewElementIndex ;
2015-04-22 16:39:20 -04:00
if ( NativeCultureIndexPropertyHandle . IsValid ( ) & & NativeCultureIndexPropertyHandle - > IsValidHandle ( ) )
{
int32 NativeCultureIndex ;
NativeCultureIndexPropertyHandle - > GetValue ( NativeCultureIndex ) ;
if ( NativeCultureIndex = = INDEX_NONE )
{
NativeCultureIndex = NewElementIndex ;
NativeCultureIndexPropertyHandle - > SetValue ( NativeCultureIndex ) ;
}
}
2015-03-05 00:08:26 -05:00
// Refresh UI.
if ( SupportedCulturePicker . IsValid ( ) )
{
SupportedCulturePicker - > RequestTreeRefresh ( ) ;
}
}
}
# undef LOCTEXT_NAMESPACE