Files
UnrealEngineUWP/Engine/Source/Editor/Localization/Public/SCulturePicker.h
Saul Abreu 3e89a8d6f6 #codereview Jamie.Dale, Justin.Sargent
Largely rewritten Editor Region & Language Settings page. Far less error prone compared to the old implementation. I'd like to do a lot more to make this not so lame in the future - move the game's native culture to something not editor-specific and leverage it as the default for new game targets in the localization dashboard.

[CL 2706823 by Saul Abreu in Main branch]
2015-09-25 16:24:07 -04:00

98 lines
2.9 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "SCompoundWidget.h"
#include "SlateDelegates.h"
#include "CulturePointer.h"
struct FCultureEntry
{
FCulturePtr Culture;
TArray< TSharedPtr<FCultureEntry> > Children;
bool IsSelectable;
FCultureEntry(const FCulturePtr& InCulture, const bool InIsSelectable = true)
: Culture(InCulture)
, IsSelectable(InIsSelectable)
{}
FCultureEntry(const FCultureEntry& Source)
: Culture(Source.Culture)
, IsSelectable(Source.IsSelectable)
{
Children.Reserve(Source.Children.Num());
for (const auto& Child : Source.Children)
{
Children.Add( MakeShareable( new FCultureEntry(*Child) ) );
}
}
};
class LOCALIZATION_API SCulturePicker : public SCompoundWidget
{
public:
/** A delegate type invoked when a selection changes somewhere. */
DECLARE_DELEGATE_RetVal_OneParam(bool, FIsCulturePickable, FCulturePtr);
typedef TSlateDelegates< FCulturePtr >::FOnSelectionChanged FOnSelectionChanged;
public:
SLATE_BEGIN_ARGS( SCulturePicker )
: _UseNativeDisplayNames(false)
, _CanSelectNone(false)
{}
SLATE_EVENT( FOnSelectionChanged, OnSelectionChanged )
SLATE_EVENT( FIsCulturePickable, IsCulturePickable )
SLATE_ARGUMENT( FCulturePtr, InitialSelection )
SLATE_ARGUMENT(bool, UseNativeDisplayNames)
SLATE_ARGUMENT(bool, CanSelectNone)
SLATE_END_ARGS()
SCulturePicker()
: UseNativeDisplayNames(false)
, CanSelectNone(false)
, SupressSelectionCallback(false)
{}
void Construct( const FArguments& InArgs );
void RequestTreeRefresh();
private:
void BuildStockEntries();
void RebuildEntries();
void OnFilterStringChanged(const FText& InFilterString);
TSharedRef<ITableRow> OnGenerateRow(TSharedPtr<FCultureEntry> Entry, const TSharedRef<STableViewBase>& Table);
void OnGetChildren(TSharedPtr<FCultureEntry> Entry, TArray< TSharedPtr<FCultureEntry> >& Children);
void OnSelectionChanged(TSharedPtr<FCultureEntry> Entry, ESelectInfo::Type SelectInfo);
private:
TSharedPtr< STreeView< TSharedPtr<FCultureEntry> > > TreeView;
/* The provided cultures array. */
TArray<FCulturePtr> Cultures;
/* The top level culture entries for all possible stock cultures. */
TArray< TSharedPtr<FCultureEntry> > StockEntries;
/* The top level culture entries to be displayed in the tree view. */
TArray< TSharedPtr<FCultureEntry> > RootEntries;
/* The string by which to filter cultures names. */
FString FilterString;
/** Delegate to invoke when selection changes. */
FOnSelectionChanged OnCultureSelectionChanged;
/** Delegate to invoke to set whether a culture is "pickable". */
FIsCulturePickable IsCulturePickable;
/* Should the cultures use their display names displayed as localized in their own (IE: native) culture? */
bool UseNativeDisplayNames;
/** Should a null culture option be available? */
bool CanSelectNone;
/* Flags that the selection callback shouldn't be called when selecting - useful for initial selection, for instance. */
bool SupressSelectionCallback;
};