You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden ========================== MAJOR FEATURES + CHANGES ========================== Change 2945310 on 2016/04/15 by Jon.Nabozny Fix UI locking Angular Rotation Offset for PhysicsConstraintComponents when the motion is for axes is Free or Locked. #JIRA UE-29368 Change 2945490 on 2016/04/15 by Jon.Nabozny Remove extraneous changes introduced in CL-2945310. Change 2946706 on 2016/04/18 by James.Golding Checkin of slice test assets Change 2947895 on 2016/04/19 by Benn.Gallagher PR #2292: Use ref instead of copy in FAnimNode_ModifyBone::EvaluateBoneTransforms (Contributed by MiKom) #jira UE-29567 Change 2947944 on 2016/04/19 by Benn.Gallagher Fixed a few extra needless bone container copies Change 2948279 on 2016/04/19 by Marc.Audy Add well defined Map and Set Property names Change 2948280 on 2016/04/19 by Marc.Audy Properly name parameters Change 2948792 on 2016/04/19 by Marc.Audy Remove unused ini class name settings Change 2948917 on 2016/04/19 by Aaron.McLeran UE-29654 FadeIn invalidates Audio Components in 4.11 Change 2949567 on 2016/04/20 by James.Golding - Add SliceProceduralMesh utility to UKismetProceduralMeshLibrary. It will slice the ProcMeshComp with a plan, including simple collision geom, and optionally create cap geometry, and create an addition ProceduralMeshComponent for the other half - Add support for simple collision on ProceduralMeshComponent, and added bUseComplexAsSimpleCollision to allow it to be used - Move GeomTools.h and .cpp from Editor to Engine module, so it can be used at runtime. Also move utils into an FGeomTools namespace. - Add GetSectionFromStaticMesh and CopyProceduralMeshFromStaticMeshComponent utilities to UKismetProceduralMeshLibrary - Expose UStaticMesh::GetNumLODs to BP, and add BP exposed UStaticMesh:: GetNumSections function Change 2950482 on 2016/04/20 by Aaron.McLeran FORT-22973 SoundMix Fade Time not fading audio properly - Bug was due to bApplyToChildren case where the FSoundClassAdjuster wasn't getting the interpolated value before calling RecursiveApplyAdjuster in the case of non-overriden sound mixes. Change 2951102 on 2016/04/21 by Thomas.Sarkanen Un-deprecated blueprint functions for attachment/detachment Renamed functions to <FuncName> (Deprecated). Hid functions in the BP context menu so new ones cant be added. #jira UE-23216 - "Snap to Target, Keep World Scale" when attaching doesn't work properly if parent is scaled. Change 2951173 on 2016/04/21 by James.Golding Fix cap geom generation when more than one polygon is generated Fix CIS warning in KismetProceduralMeshLibrary.cpp Change 2951334 on 2016/04/21 by Osman.Tsjardiwal Add CapMaterial param to SliceProceduralMesh util Change 2951528 on 2016/04/21 by Marc.Audy Fix spelling errors in comments Change 2952933 on 2016/04/22 by Lukasz.Furman fixed behavior tree getting stuck on instantly finished gameplay tasks copy of CL# 2952930 Change 2953948 on 2016/04/24 by James.Golding Put #if WITH_EDITOR back into FPoly::Triangulate to fix non-editor builds (FPoly::Finalize not available in non-editor) Change 2954558 on 2016/04/25 by Marc.Audy Make USceneComponent::Attach* members private and remove deprecation messages and pragmas disabling/enabling deprecation throughout SceneComponent.h/cpp #jira UE-29038 Change 2954865 on 2016/04/25 by Aaron.McLeran UE-29763 Use HMD audio device only in VR preview mode, not for other PIE session types. Change 2955009 on 2016/04/25 by Zak.Middleton #ue4 - Wrap call from UCharacterMovementComponent::PostPhysicsTickComponent() to UpdateBasedMovement() in a FScopedMovementUpdate to accumulate moves with better perf. Change 2955878 on 2016/04/26 by Benn.Gallagher [Epic Friday] - Added spherical constraints to anim dynamics Change 2956380 on 2016/04/26 by Lina.Halper PR #2298: Step interpolation for UAnimSequence (Contributed by douglaslassance) Change 2956383 on 2016/04/26 by Lina.Halper Fixed to match coding standard Change2957866on 2016/04/27 by Zak.Middleton #ue4 - Add max depenetration distance settings for CharacterMovementComponent. Add controls to throttle logging when character is stuck in geometry so it doesn't spam the log. - Depenetration settings are separated based on whether overlapping a Pawn versus other geometry, and furthermore by whether the Character is a proxy or not. Simulated proxies typically should not depenetrate a large amount because that effectively ignores the server authoritative location update. - "Stuck" logging is controlled by the console var "p.CharacterStuckWarningPeriod". Set to number of seconds between logged events, or less than zero to disable logging. #tests QA-Surfaces multiplayer, walking in to moving objects and pawns. Change 2957953 on 2016/04/27 by Aaron.McLeran UE-30018 Fixing up audio component ref-counting to prevent triggering notifications when an audio component is still active after a sound finishes playing. Change 2958011 on 2016/04/27 by Jon.Nabozny CalcAABB wasn't properly accounting for current transform on Convex elements, causing bad results. #JIRA UE-29525 Change 2958321 on 2016/04/27 by Lukasz.Furman path following update pass, added flags to request result, fixed AITask stacking vs scripted/BP move requests Change 2959506 on 2016/04/28 by Aaron.McLeran PR #2330: Fix for ambient sounds not stopping when active and told to play again (Contributed by hgamiel) Change 2959686 on 2016/04/28 by Marc.Audy Correctly handle multiple viewpoints when significance is being sorted descending Change 2959773 on 2016/04/28 by Marc.Audy Fix shadowing warning Change 2959785 on 2016/04/28 by Aaron.McLeran UE-30083 Sound concatenator node doesn't progress if child nodes don't produce wave instances Change 2960852 on 2016/04/29 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 2960738 Change 2960946 on 2016/04/29 by Marc.Audy Fix post merge compile error Change 2962501 on 2016/05/02 by Marc.Audy Remove interim GetMutableAttach accessors and use the variables directly now that they are private Change 2962535 on 2016/05/02 by Marc.Audy Merging //UE4/Dev-Main to Dev-Framework (//UE4/Dev-Framework) @ 2962478 Change 2962578 on 2016/05/02 by Marc.Audy Switch ObjectGraphMove to using UserFlags instead of custom move data Change 2962651 on 2016/05/02 by Marc.Audy VS2015 shadow variable fixes Change 2962662 on 2016/05/02 by Lukasz.Furman deprecated old implementation of gameplay debugger #jira UE-30011 Change 2962919 on 2016/05/02 by Marc.Audy VS2015 shadow variable fixes Change 2963475 on 2016/05/02 by Mieszko.Zielinski Made SimpleMoveToLocation/Actor not reset velocity if agent not already at goal #UE4 #jira UE-30176 Change2964098on 2016/05/03 by Marc.Audy Spelling fix Change 2964099 on 2016/05/03 by Marc.Audy VS2015 shadow variable fixes Change 2964156 on 2016/05/03 by Marc.Audy VS2015 shadow variable fixes Change 2964272 on 2016/05/03 by Marc.Audy VS2015 Shadow Variable fixes Change 2964395 on 2016/05/03 by Marc.Audy VS2015 Shadow Variable Fixes Change 2964460 on 2016/05/03 by Marc.Audy Reschedule coolingdown tick functions during pause frames. #jira UE-30221 Change 2964666 on 2016/05/03 by Marc.Audy Fix shipping compile error [CL 2964775 by Marc Audy in Main branch]
739 lines
21 KiB
C++
739 lines
21 KiB
C++
// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "DataTableEditorPrivatePCH.h"
|
|
|
|
#include "DataTableEditor.h"
|
|
#include "Toolkits/IToolkitHost.h"
|
|
#include "Editor/WorkspaceMenuStructure/Public/WorkspaceMenuStructureModule.h"
|
|
#include "SSearchBox.h"
|
|
#include "SDockTab.h"
|
|
#include "SRowEditor.h"
|
|
#include "Engine/DataTable.h"
|
|
#include "Json.h"
|
|
#include "Engine/UserDefinedStruct.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "DataTableEditor"
|
|
|
|
const FName FDataTableEditor::DataTableTabId("DataTableEditor_DataTable");
|
|
const FName FDataTableEditor::RowEditorTabId("DataTableEditor_RowEditor");
|
|
const FName FDataTableEditor::RowNameColumnId("RowName");
|
|
|
|
class SDataTableListViewRow : public SMultiColumnTableRow<FDataTableEditorRowListViewDataPtr>
|
|
{
|
|
public:
|
|
SLATE_BEGIN_ARGS(SDataTableListViewRow) {}
|
|
/** The widget that owns the tree. We'll only keep a weak reference to it. */
|
|
SLATE_ARGUMENT(TSharedPtr<FDataTableEditor>, DataTableEditor)
|
|
/** The list item for this row */
|
|
SLATE_ARGUMENT(FDataTableEditorRowListViewDataPtr, Item)
|
|
SLATE_END_ARGS()
|
|
|
|
/** Construct function for this widget */
|
|
void Construct(const FArguments& InArgs, const TSharedRef<STableViewBase>& InOwnerTableView)
|
|
{
|
|
DataTableEditor = InArgs._DataTableEditor;
|
|
Item = InArgs._Item;
|
|
SMultiColumnTableRow<FDataTableEditorRowListViewDataPtr>::Construct(
|
|
FSuperRowType::FArguments()
|
|
.Style(FEditorStyle::Get(), "DataTableEditor.CellListViewRow"),
|
|
InOwnerTableView
|
|
);
|
|
}
|
|
|
|
/** Overridden from SMultiColumnTableRow. Generates a widget for this column of the list view. */
|
|
virtual TSharedRef<SWidget> GenerateWidgetForColumn(const FName& ColumnName) override
|
|
{
|
|
TSharedPtr<FDataTableEditor> DataTableEditorPtr = DataTableEditor.Pin();
|
|
return (DataTableEditorPtr.IsValid())
|
|
? DataTableEditorPtr->MakeCellWidget(Item, IndexInList, ColumnName)
|
|
: SNullWidget::NullWidget;
|
|
}
|
|
|
|
private:
|
|
/** Weak reference to the data table editor that owns our list */
|
|
TWeakPtr<FDataTableEditor> DataTableEditor;
|
|
/** The item associated with this row of data */
|
|
FDataTableEditorRowListViewDataPtr Item;
|
|
};
|
|
|
|
void FDataTableEditor::RegisterTabSpawners(const TSharedRef<class FTabManager>& InTabManager)
|
|
{
|
|
WorkspaceMenuCategory = InTabManager->AddLocalWorkspaceMenuCategory(LOCTEXT("WorkspaceMenu_Data Table Editor", "Data Table Editor"));
|
|
|
|
InTabManager->RegisterTabSpawner( DataTableTabId, FOnSpawnTab::CreateSP(this, &FDataTableEditor::SpawnTab_DataTable) )
|
|
.SetDisplayName( LOCTEXT("DataTableTab", "Data Table") )
|
|
.SetGroup( WorkspaceMenuCategory.ToSharedRef() );
|
|
|
|
InTabManager->RegisterTabSpawner(RowEditorTabId, FOnSpawnTab::CreateSP(this, &FDataTableEditor::SpawnTab_RowEditor))
|
|
.SetDisplayName(LOCTEXT("RowEditorTab", "Row Editor"))
|
|
.SetGroup(WorkspaceMenuCategory.ToSharedRef());
|
|
}
|
|
|
|
void FDataTableEditor::UnregisterTabSpawners(const TSharedRef<class FTabManager>& InTabManager)
|
|
{
|
|
InTabManager->UnregisterTabSpawner( DataTableTabId );
|
|
InTabManager->UnregisterTabSpawner(RowEditorTabId);
|
|
}
|
|
|
|
FDataTableEditor::FDataTableEditor()
|
|
{
|
|
}
|
|
|
|
FDataTableEditor::~FDataTableEditor()
|
|
{
|
|
GEditor->UnregisterForUndo(this);
|
|
|
|
const UDataTable* Table = GetDataTable();
|
|
if (Table)
|
|
{
|
|
SaveLayoutData();
|
|
}
|
|
}
|
|
|
|
void FDataTableEditor::PostUndo(bool bSuccess)
|
|
{
|
|
HandleUndoRedo();
|
|
}
|
|
|
|
void FDataTableEditor::PostRedo(bool bSuccess)
|
|
{
|
|
HandleUndoRedo();
|
|
}
|
|
|
|
void FDataTableEditor::HandleUndoRedo()
|
|
{
|
|
const UDataTable* Table = GetDataTable();
|
|
if (Table)
|
|
{
|
|
HandlePostChange();
|
|
CallbackOnDataTableUndoRedo.ExecuteIfBound();
|
|
}
|
|
}
|
|
|
|
void FDataTableEditor::PreChange(const class UUserDefinedStruct* Struct, FStructureEditorUtils::EStructureEditorChangeInfo Info)
|
|
{
|
|
}
|
|
|
|
void FDataTableEditor::PostChange(const class UUserDefinedStruct* Struct, FStructureEditorUtils::EStructureEditorChangeInfo Info)
|
|
{
|
|
const UDataTable* Table = GetDataTable();
|
|
if (Struct && Table && (Table->RowStruct == Struct))
|
|
{
|
|
HandlePostChange();
|
|
}
|
|
}
|
|
|
|
void FDataTableEditor::PreChange(const UDataTable* Changed, FDataTableEditorUtils::EDataTableChangeInfo Info)
|
|
{
|
|
}
|
|
|
|
void FDataTableEditor::PostChange(const UDataTable* Changed, FDataTableEditorUtils::EDataTableChangeInfo Info)
|
|
{
|
|
const UDataTable* Table = GetDataTable();
|
|
if (Changed == Table)
|
|
{
|
|
HandlePostChange();
|
|
}
|
|
}
|
|
|
|
const UDataTable* FDataTableEditor::GetDataTable() const
|
|
{
|
|
return Cast<const UDataTable>(GetEditingObject());
|
|
}
|
|
|
|
void FDataTableEditor::HandlePostChange()
|
|
{
|
|
// We need to cache and restore the selection here as RefreshCachedDataTable will re-create the list view items
|
|
const FName CachedSelection = HighlightedRowName;
|
|
HighlightedRowName = NAME_None;
|
|
RefreshCachedDataTable();
|
|
RestoreCachedSelection(CachedSelection, true/*bUpdateEvenIfValid*/);
|
|
}
|
|
|
|
void FDataTableEditor::InitDataTableEditor( const EToolkitMode::Type Mode, const TSharedPtr< class IToolkitHost >& InitToolkitHost, UDataTable* Table )
|
|
{
|
|
TSharedRef<FTabManager::FLayout> StandaloneDefaultLayout = FTabManager::NewLayout( "Standalone_DataTableEditor_Layout" )
|
|
->AddArea
|
|
(
|
|
FTabManager::NewPrimaryArea()->SetOrientation(Orient_Vertical)
|
|
->Split
|
|
(
|
|
FTabManager::NewStack()
|
|
->AddTab( DataTableTabId, ETabState::OpenedTab )
|
|
)
|
|
->Split
|
|
(
|
|
FTabManager::NewStack()
|
|
->AddTab(RowEditorTabId, ETabState::OpenedTab)
|
|
)
|
|
);
|
|
|
|
const bool bCreateDefaultStandaloneMenu = true;
|
|
const bool bCreateDefaultToolbar = false;
|
|
FAssetEditorToolkit::InitAssetEditor( Mode, InitToolkitHost, FDataTableEditorModule::DataTableEditorAppIdentifier, StandaloneDefaultLayout, bCreateDefaultStandaloneMenu, bCreateDefaultToolbar, Table );
|
|
|
|
FDataTableEditorModule& DataTableEditorModule = FModuleManager::LoadModuleChecked<FDataTableEditorModule>( "DataTableEditor" );
|
|
AddMenuExtender(DataTableEditorModule.GetMenuExtensibilityManager()->GetAllExtenders(GetToolkitCommands(), GetEditingObjects()));
|
|
|
|
// Support undo/redo
|
|
GEditor->RegisterForUndo(this);
|
|
|
|
// @todo toolkit world centric editing
|
|
/*// Setup our tool's layout
|
|
if( IsWorldCentricAssetEditor() )
|
|
{
|
|
const FString TabInitializationPayload(TEXT("")); // NOTE: Payload not currently used for table properties
|
|
SpawnToolkitTab( DataTableTabId, TabInitializationPayload, EToolkitTabSpot::Details );
|
|
}*/
|
|
|
|
// NOTE: Could fill in asset editor commands here!
|
|
}
|
|
|
|
FName FDataTableEditor::GetToolkitFName() const
|
|
{
|
|
return FName("DataTableEditor");
|
|
}
|
|
|
|
FText FDataTableEditor::GetBaseToolkitName() const
|
|
{
|
|
return LOCTEXT( "AppLabel", "DataTable Editor" );
|
|
}
|
|
|
|
FString FDataTableEditor::GetWorldCentricTabPrefix() const
|
|
{
|
|
return LOCTEXT("WorldCentricTabPrefix", "DataTable ").ToString();
|
|
}
|
|
|
|
FLinearColor FDataTableEditor::GetWorldCentricTabColorScale() const
|
|
{
|
|
return FLinearColor( 0.0f, 0.0f, 0.2f, 0.5f );
|
|
}
|
|
|
|
FSlateColor FDataTableEditor::GetRowTextColor(FName RowName) const
|
|
{
|
|
if (RowName == HighlightedRowName)
|
|
{
|
|
return FSlateColor(FColorList::Orange);
|
|
}
|
|
return FSlateColor::UseForeground();
|
|
}
|
|
|
|
FOptionalSize FDataTableEditor::GetRowNameColumnWidth() const
|
|
{
|
|
return FOptionalSize(RowNameColumnWidth);
|
|
}
|
|
|
|
float FDataTableEditor::GetColumnWidth(const int32 ColumnIndex) const
|
|
{
|
|
if (ColumnWidths.IsValidIndex(ColumnIndex))
|
|
{
|
|
return ColumnWidths[ColumnIndex].CurrentWidth;
|
|
}
|
|
return 0.0f;
|
|
}
|
|
|
|
void FDataTableEditor::OnColumnResized(const float NewWidth, const int32 ColumnIndex)
|
|
{
|
|
if (ColumnWidths.IsValidIndex(ColumnIndex))
|
|
{
|
|
FColumnWidth& ColumnWidth = ColumnWidths[ColumnIndex];
|
|
ColumnWidth.bIsAutoSized = false;
|
|
ColumnWidth.CurrentWidth = NewWidth;
|
|
|
|
// Update the persistent column widths in the layout data
|
|
{
|
|
if (!LayoutData.IsValid())
|
|
{
|
|
LayoutData = MakeShareable(new FJsonObject());
|
|
}
|
|
|
|
TSharedPtr<FJsonObject> LayoutColumnWidths;
|
|
if (!LayoutData->HasField(TEXT("ColumnWidths")))
|
|
{
|
|
LayoutColumnWidths = MakeShareable(new FJsonObject());
|
|
LayoutData->SetObjectField(TEXT("ColumnWidths"), LayoutColumnWidths);
|
|
}
|
|
else
|
|
{
|
|
LayoutColumnWidths = LayoutData->GetObjectField(TEXT("ColumnWidths"));
|
|
}
|
|
|
|
const FString& ColumnName = AvailableColumns[ColumnIndex]->ColumnId.ToString();
|
|
LayoutColumnWidths->SetNumberField(ColumnName, NewWidth);
|
|
}
|
|
}
|
|
}
|
|
|
|
void FDataTableEditor::LoadLayoutData()
|
|
{
|
|
LayoutData.Reset();
|
|
|
|
const UDataTable* Table = GetDataTable();
|
|
if (!Table)
|
|
{
|
|
return;
|
|
}
|
|
|
|
const FString LayoutDataFilename = FPaths::GameSavedDir() / TEXT("AssetData") / TEXT("DataTableEditorLayout") / Table->GetName() + TEXT(".json");
|
|
|
|
FString JsonText;
|
|
if (FFileHelper::LoadFileToString(JsonText, *LayoutDataFilename))
|
|
{
|
|
TSharedRef< TJsonReader<TCHAR> > JsonReader = TJsonReaderFactory<TCHAR>::Create(JsonText);
|
|
FJsonSerializer::Deserialize(JsonReader, LayoutData);
|
|
}
|
|
}
|
|
|
|
void FDataTableEditor::SaveLayoutData()
|
|
{
|
|
const UDataTable* Table = GetDataTable();
|
|
if (!Table || !LayoutData.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
const FString LayoutDataFilename = FPaths::GameSavedDir() / TEXT("AssetData") / TEXT("DataTableEditorLayout") / Table->GetName() + TEXT(".json");
|
|
|
|
FString JsonText;
|
|
TSharedRef< TJsonWriter< TCHAR, TPrettyJsonPrintPolicy<TCHAR> > > JsonWriter = TJsonWriterFactory< TCHAR, TPrettyJsonPrintPolicy<TCHAR> >::Create(&JsonText);
|
|
if (FJsonSerializer::Serialize(LayoutData.ToSharedRef(), JsonWriter))
|
|
{
|
|
FFileHelper::SaveStringToFile(JsonText, *LayoutDataFilename);
|
|
}
|
|
}
|
|
|
|
TSharedRef<ITableRow> FDataTableEditor::MakeRowNameWidget(FDataTableEditorRowListViewDataPtr InRowDataPtr, const TSharedRef<STableViewBase>& OwnerTable)
|
|
{
|
|
return
|
|
SNew(STableRow<FDataTableEditorRowListViewDataPtr>, OwnerTable)
|
|
.Style(FEditorStyle::Get(), "DataTableEditor.NameListViewRow")
|
|
[
|
|
SNew(SBox)
|
|
.Padding(FMargin(4, 2, 4, 2))
|
|
[
|
|
SNew(SBox)
|
|
.HeightOverride(InRowDataPtr->DesiredRowHeight)
|
|
[
|
|
SNew(STextBlock)
|
|
.ColorAndOpacity(this, &FDataTableEditor::GetRowTextColor, InRowDataPtr->RowId)
|
|
.Text(InRowDataPtr->DisplayName)
|
|
.HighlightText(this, &FDataTableEditor::GetFilterText)
|
|
]
|
|
]
|
|
];
|
|
}
|
|
|
|
TSharedRef<ITableRow> FDataTableEditor::MakeRowWidget(FDataTableEditorRowListViewDataPtr InRowDataPtr, const TSharedRef<STableViewBase>& OwnerTable)
|
|
{
|
|
return
|
|
SNew(SDataTableListViewRow, OwnerTable)
|
|
.DataTableEditor(SharedThis(this))
|
|
.Item(InRowDataPtr);
|
|
}
|
|
|
|
TSharedRef<SWidget> FDataTableEditor::MakeCellWidget(FDataTableEditorRowListViewDataPtr InRowDataPtr, const int32 InRowIndex, const FName& InColumnId)
|
|
{
|
|
int32 ColumnIndex = 0;
|
|
for (; ColumnIndex < AvailableColumns.Num(); ++ColumnIndex)
|
|
{
|
|
const FDataTableEditorColumnHeaderDataPtr& ColumnData = AvailableColumns[ColumnIndex];
|
|
if (ColumnData->ColumnId == InColumnId)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Valid column ID?
|
|
if (AvailableColumns.IsValidIndex(ColumnIndex) && InRowDataPtr->CellData.IsValidIndex(ColumnIndex))
|
|
{
|
|
return SNew(SBox)
|
|
.Padding(FMargin(4, 2, 4, 2))
|
|
[
|
|
SNew(STextBlock)
|
|
.TextStyle(FEditorStyle::Get(), "DataTableEditor.CellText")
|
|
.ColorAndOpacity(this, &FDataTableEditor::GetRowTextColor, InRowDataPtr->RowId)
|
|
.Text(InRowDataPtr->CellData[ColumnIndex])
|
|
.HighlightText(this, &FDataTableEditor::GetFilterText)
|
|
.ToolTipText(FText::Format(LOCTEXT("ColumnRowNameFmt", "{0}: {1}"), AvailableColumns[ColumnIndex]->DisplayName, InRowDataPtr->CellData[ColumnIndex]))
|
|
];
|
|
}
|
|
|
|
return SNullWidget::NullWidget;
|
|
}
|
|
|
|
void FDataTableEditor::OnRowNamesListViewScrolled(double InScrollOffset)
|
|
{
|
|
// Synchronize the list views
|
|
CellsListView->SetScrollOffset(InScrollOffset);
|
|
}
|
|
|
|
void FDataTableEditor::OnCellsListViewScrolled(double InScrollOffset)
|
|
{
|
|
// Synchronize the list views
|
|
RowNamesListView->SetScrollOffset(InScrollOffset);
|
|
}
|
|
|
|
void FDataTableEditor::OnRowSelectionChanged(FDataTableEditorRowListViewDataPtr InNewSelection, ESelectInfo::Type InSelectInfo)
|
|
{
|
|
const bool bSelectionChanged = !InNewSelection.IsValid() || InNewSelection->RowId != HighlightedRowName;
|
|
const FName NewRowName = (InNewSelection.IsValid()) ? InNewSelection->RowId : NAME_None;
|
|
|
|
SetHighlightedRow(NewRowName);
|
|
|
|
if (bSelectionChanged)
|
|
{
|
|
CallbackOnRowHighlighted.ExecuteIfBound(HighlightedRowName);
|
|
}
|
|
}
|
|
|
|
FText FDataTableEditor::GetFilterText() const
|
|
{
|
|
return ActiveFilterText;
|
|
}
|
|
|
|
void FDataTableEditor::OnFilterTextChanged(const FText& InFilterText)
|
|
{
|
|
ActiveFilterText = InFilterText;
|
|
UpdateVisibleRows();
|
|
}
|
|
|
|
void FDataTableEditor::RefreshCachedDataTable()
|
|
{
|
|
const UDataTable* Table = GetDataTable();
|
|
FDataTableEditorUtils::CacheDataTableForEditing(Table, AvailableColumns, AvailableRows);
|
|
|
|
// Update the desired width of the row names column
|
|
// This prevents it growing or shrinking as you scroll the list view
|
|
{
|
|
TSharedRef<FSlateFontMeasure> FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
|
|
const FTextBlockStyle& CellTextStyle = FEditorStyle::GetWidgetStyle<FTextBlockStyle>("DataTableEditor.CellText");
|
|
static const float CellPadding = 10.0f;
|
|
|
|
RowNameColumnWidth = 10.0f;
|
|
for (const FDataTableEditorRowListViewDataPtr& RowData : AvailableRows)
|
|
{
|
|
const float RowNameWidth = FontMeasure->Measure(RowData->DisplayName, CellTextStyle.Font).X + CellPadding;
|
|
RowNameColumnWidth = FMath::Max(RowNameColumnWidth, RowNameWidth);
|
|
}
|
|
}
|
|
|
|
// Setup the default auto-sized columns
|
|
ColumnWidths.SetNum(AvailableColumns.Num());
|
|
for (int32 ColumnIndex = 0; ColumnIndex < AvailableColumns.Num(); ++ColumnIndex)
|
|
{
|
|
const FDataTableEditorColumnHeaderDataPtr& ColumnData = AvailableColumns[ColumnIndex];
|
|
FColumnWidth& ColumnWidth = ColumnWidths[ColumnIndex];
|
|
ColumnWidth.CurrentWidth = FMath::Clamp(ColumnData->DesiredColumnWidth, 10.0f, 400.0f); // Clamp auto-sized columns to a reasonable limit
|
|
}
|
|
|
|
// Load the persistent column widths from the layout data
|
|
{
|
|
const TSharedPtr<FJsonObject>* LayoutColumnWidths = nullptr;
|
|
if (LayoutData.IsValid() && LayoutData->TryGetObjectField(TEXT("ColumnWidths"), LayoutColumnWidths))
|
|
{
|
|
for(int32 ColumnIndex = 0; ColumnIndex < AvailableColumns.Num(); ++ColumnIndex)
|
|
{
|
|
const FDataTableEditorColumnHeaderDataPtr& ColumnData = AvailableColumns[ColumnIndex];
|
|
|
|
double LayoutColumnWidth = 0.0f;
|
|
if ((*LayoutColumnWidths)->TryGetNumberField(ColumnData->ColumnId.ToString(), LayoutColumnWidth))
|
|
{
|
|
FColumnWidth& ColumnWidth = ColumnWidths[ColumnIndex];
|
|
ColumnWidth.bIsAutoSized = false;
|
|
ColumnWidth.CurrentWidth = static_cast<float>(LayoutColumnWidth);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ColumnNamesHeaderRow->ClearColumns();
|
|
for (int32 ColumnIndex = 0; ColumnIndex < AvailableColumns.Num(); ++ColumnIndex)
|
|
{
|
|
const FDataTableEditorColumnHeaderDataPtr& ColumnData = AvailableColumns[ColumnIndex];
|
|
|
|
ColumnNamesHeaderRow->AddColumn(
|
|
SHeaderRow::Column(ColumnData->ColumnId)
|
|
.DefaultLabel(ColumnData->DisplayName)
|
|
.ManualWidth(TAttribute<float>::Create(TAttribute<float>::FGetter::CreateSP(this, &FDataTableEditor::GetColumnWidth, ColumnIndex)))
|
|
.OnWidthChanged(this, &FDataTableEditor::OnColumnResized, ColumnIndex)
|
|
);
|
|
}
|
|
|
|
UpdateVisibleRows();
|
|
}
|
|
|
|
void FDataTableEditor::UpdateVisibleRows()
|
|
{
|
|
if (ActiveFilterText.IsEmptyOrWhitespace())
|
|
{
|
|
VisibleRows = AvailableRows;
|
|
}
|
|
else
|
|
{
|
|
VisibleRows.Empty(AvailableRows.Num());
|
|
|
|
const FString& ActiveFilterString = ActiveFilterText.ToString();
|
|
for (const FDataTableEditorRowListViewDataPtr& RowData : AvailableRows)
|
|
{
|
|
bool bPassesFilter = false;
|
|
|
|
if (RowData->DisplayName.ToString().Contains(ActiveFilterString))
|
|
{
|
|
bPassesFilter = true;
|
|
}
|
|
else
|
|
{
|
|
for (const FText& CellText : RowData->CellData)
|
|
{
|
|
if (CellText.ToString().Contains(ActiveFilterString))
|
|
{
|
|
bPassesFilter = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (bPassesFilter)
|
|
{
|
|
VisibleRows.Add(RowData);
|
|
}
|
|
}
|
|
}
|
|
|
|
RowNamesListView->RequestListRefresh();
|
|
CellsListView->RequestListRefresh();
|
|
|
|
RestoreCachedSelection(HighlightedRowName);
|
|
}
|
|
|
|
void FDataTableEditor::RestoreCachedSelection(const FName InCachedSelection, const bool bUpdateEvenIfValid)
|
|
{
|
|
// Validate the requested selection to see if it matches a known row
|
|
bool bSelectedRowIsValid = false;
|
|
if (!InCachedSelection.IsNone())
|
|
{
|
|
bSelectedRowIsValid = VisibleRows.ContainsByPredicate([&InCachedSelection](const FDataTableEditorRowListViewDataPtr& RowData) -> bool
|
|
{
|
|
return RowData->RowId == InCachedSelection;
|
|
});
|
|
}
|
|
|
|
// Apply the new selection (if required)
|
|
if (!bSelectedRowIsValid)
|
|
{
|
|
SetHighlightedRow((VisibleRows.Num() > 1) ? VisibleRows[0]->RowId : NAME_None);
|
|
CallbackOnRowHighlighted.ExecuteIfBound(HighlightedRowName);
|
|
}
|
|
else if (bUpdateEvenIfValid)
|
|
{
|
|
SetHighlightedRow(InCachedSelection);
|
|
CallbackOnRowHighlighted.ExecuteIfBound(HighlightedRowName);
|
|
}
|
|
}
|
|
|
|
TSharedRef<SVerticalBox> FDataTableEditor::CreateContentBox()
|
|
{
|
|
TSharedRef<SScrollBar> HorizontalScrollBar = SNew(SScrollBar)
|
|
.Orientation(Orient_Horizontal)
|
|
.Thickness(FVector2D(8.0f, 8.0f));
|
|
|
|
TSharedRef<SScrollBar> VerticalScrollBar = SNew(SScrollBar)
|
|
.Orientation(Orient_Vertical)
|
|
.Thickness(FVector2D(8.0f, 8.0f));
|
|
|
|
TSharedRef<SHeaderRow> RowNamesHeaderRow = SNew(SHeaderRow);
|
|
RowNamesHeaderRow->AddColumn(
|
|
SHeaderRow::Column(RowNameColumnId)
|
|
.DefaultLabel(FText::GetEmpty())
|
|
);
|
|
|
|
ColumnNamesHeaderRow = SNew(SHeaderRow);
|
|
|
|
RowNamesListView = SNew(SListView<FDataTableEditorRowListViewDataPtr>)
|
|
.ListItemsSource(&VisibleRows)
|
|
.HeaderRow(RowNamesHeaderRow)
|
|
.OnGenerateRow(this, &FDataTableEditor::MakeRowNameWidget)
|
|
.OnListViewScrolled(this, &FDataTableEditor::OnRowNamesListViewScrolled)
|
|
.OnSelectionChanged(this, &FDataTableEditor::OnRowSelectionChanged)
|
|
.ScrollbarVisibility(EVisibility::Collapsed)
|
|
.ConsumeMouseWheel(EConsumeMouseWheel::Always)
|
|
.SelectionMode(ESelectionMode::Single)
|
|
.AllowOverscroll(EAllowOverscroll::No);
|
|
|
|
CellsListView = SNew(SListView<FDataTableEditorRowListViewDataPtr>)
|
|
.ListItemsSource(&VisibleRows)
|
|
.HeaderRow(ColumnNamesHeaderRow)
|
|
.OnGenerateRow(this, &FDataTableEditor::MakeRowWidget)
|
|
.OnListViewScrolled(this, &FDataTableEditor::OnCellsListViewScrolled)
|
|
.OnSelectionChanged(this, &FDataTableEditor::OnRowSelectionChanged)
|
|
.ExternalScrollbar(VerticalScrollBar)
|
|
.ConsumeMouseWheel(EConsumeMouseWheel::Always)
|
|
.SelectionMode(ESelectionMode::Single)
|
|
.AllowOverscroll(EAllowOverscroll::No);
|
|
|
|
RefreshCachedDataTable();
|
|
|
|
return SNew(SVerticalBox)
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
SNew(SSearchBox)
|
|
.InitialText(this, &FDataTableEditor::GetFilterText)
|
|
.OnTextChanged(this, &FDataTableEditor::OnFilterTextChanged)
|
|
]
|
|
+SVerticalBox::Slot()
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SNew(SBox)
|
|
.WidthOverride(this, &FDataTableEditor::GetRowNameColumnWidth)
|
|
[
|
|
RowNamesListView.ToSharedRef()
|
|
]
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
[
|
|
SNew(SScrollBox)
|
|
.Orientation(Orient_Horizontal)
|
|
.ExternalScrollbar(HorizontalScrollBar)
|
|
+SScrollBox::Slot()
|
|
[
|
|
CellsListView.ToSharedRef()
|
|
]
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
VerticalScrollBar
|
|
]
|
|
]
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SNew(SBox)
|
|
.WidthOverride(this, &FDataTableEditor::GetRowNameColumnWidth)
|
|
[
|
|
SNullWidget::NullWidget
|
|
]
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
[
|
|
HorizontalScrollBar
|
|
]
|
|
];
|
|
}
|
|
|
|
TSharedRef<SWidget> FDataTableEditor::CreateRowEditorBox()
|
|
{
|
|
UDataTable* Table = Cast<UDataTable>(GetEditingObject());
|
|
|
|
// Support undo/redo
|
|
if (Table)
|
|
{
|
|
Table->SetFlags(RF_Transactional);
|
|
}
|
|
|
|
auto RowEditor = SNew(SRowEditor, Table);
|
|
RowEditor->RowSelectedCallback.BindSP(this, &FDataTableEditor::SetHighlightedRow);
|
|
CallbackOnRowHighlighted.BindSP(RowEditor, &SRowEditor::SelectRow);
|
|
CallbackOnDataTableUndoRedo.BindSP(RowEditor, &SRowEditor::HandleUndoRedo);
|
|
return RowEditor;
|
|
}
|
|
|
|
TSharedRef<SDockTab> FDataTableEditor::SpawnTab_RowEditor(const FSpawnTabArgs& Args)
|
|
{
|
|
check(Args.GetTabId().TabType == RowEditorTabId);
|
|
|
|
return SNew(SDockTab)
|
|
.Icon(FEditorStyle::GetBrush("DataTableEditor.Tabs.Properties"))
|
|
.Label(LOCTEXT("RowEditorTitle", "Row Editor"))
|
|
.TabColorScale(GetTabColorScale())
|
|
[
|
|
SNew(SBorder)
|
|
.Padding(2)
|
|
.VAlign(VAlign_Top)
|
|
.HAlign(HAlign_Fill)
|
|
.BorderImage(FEditorStyle::GetBrush("ToolPanel.GroupBorder"))
|
|
[
|
|
CreateRowEditorBox()
|
|
]
|
|
];
|
|
}
|
|
|
|
|
|
TSharedRef<SDockTab> FDataTableEditor::SpawnTab_DataTable( const FSpawnTabArgs& Args )
|
|
{
|
|
check( Args.GetTabId().TabType == DataTableTabId );
|
|
|
|
UDataTable* Table = Cast<UDataTable>(GetEditingObject());
|
|
|
|
// Support undo/redo
|
|
if (Table)
|
|
{
|
|
Table->SetFlags(RF_Transactional);
|
|
}
|
|
|
|
LoadLayoutData();
|
|
|
|
return SNew(SDockTab)
|
|
.Icon( FEditorStyle::GetBrush("DataTableEditor.Tabs.Properties") )
|
|
.Label( LOCTEXT("DataTableTitle", "Data Table") )
|
|
.TabColorScale( GetTabColorScale() )
|
|
[
|
|
SNew(SBorder)
|
|
.Padding(2)
|
|
.BorderImage( FEditorStyle::GetBrush( "ToolPanel.GroupBorder" ) )
|
|
[
|
|
CreateContentBox()
|
|
]
|
|
];
|
|
}
|
|
|
|
void FDataTableEditor::SetHighlightedRow(FName Name)
|
|
{
|
|
if (Name == HighlightedRowName)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (Name.IsNone())
|
|
{
|
|
HighlightedRowName = NAME_None;
|
|
|
|
// Synchronize the list views
|
|
RowNamesListView->ClearSelection();
|
|
CellsListView->ClearSelection();
|
|
}
|
|
else
|
|
{
|
|
HighlightedRowName = Name;
|
|
|
|
FDataTableEditorRowListViewDataPtr* NewSelectionPtr = VisibleRows.FindByPredicate([&Name](const FDataTableEditorRowListViewDataPtr& RowData) -> bool
|
|
{
|
|
return RowData->RowId == Name;
|
|
});
|
|
|
|
// Synchronize the list views
|
|
if (NewSelectionPtr)
|
|
{
|
|
RowNamesListView->SetSelection(*NewSelectionPtr);
|
|
CellsListView->SetSelection(*NewSelectionPtr);
|
|
|
|
CellsListView->RequestScrollIntoView(*NewSelectionPtr);
|
|
}
|
|
else
|
|
{
|
|
RowNamesListView->ClearSelection();
|
|
CellsListView->ClearSelection();
|
|
}
|
|
}
|
|
}
|
|
|
|
#undef LOCTEXT_NAMESPACE
|