Files
UnrealEngineUWP/Engine/Source/Editor/UnrealEd/Public/DataTableEditorUtils.h
Jamie Dale 4b3576349f Data table undo/redo support
UETOOL-281 - Improve data table workflows
UETOOL-304 - Data table editor doesn't support undo/redo properly

Undo/redo is now supported when adding, removing, moving, or renaming rows, as well as changing the properties of any given data table row.

This also adds highlighting when filtering the data table view, and slightly adjusts the selected row color so it doesn't blend into the background, as well as ensuring the data table is emptied prior to loading (as undo/redo loads on top of an existing object).

[CL 2511605 by Jamie Dale in Main branch]
2015-04-14 09:30:09 -04:00

74 lines
2.2 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Engine/DataTable.h"
#include "ListenerManager.h"
struct FDataTableEditorColumnHeaderData
{
/** Unique ID used to identify this column */
FName ColumnId;
/** Display name of this column */
FText DisplayName;
/** The calculated width of this column taking into account the cell data for each row */
float DesiredColumnWidth;
};
struct FDataTableEditorRowListViewData
{
/** Unique ID used to identify this row */
FName RowId;
/** Display name of this row */
FText DisplayName;
/** Array corresponding to each cell in this row */
TArray<FText> CellData;
};
typedef TSharedPtr<FDataTableEditorColumnHeaderData> FDataTableEditorColumnHeaderDataPtr;
typedef TSharedPtr<FDataTableEditorRowListViewData> FDataTableEditorRowListViewDataPtr;
struct UNREALED_API FDataTableEditorUtils
{
enum class EDataTableChangeInfo
{
/** The data corresponding to a single row has been changed */
RowData,
/** The data corresponding to the entire list of rows has been changed */
RowList,
};
enum class ERowMoveDirection
{
Up,
Down,
};
class FDataTableEditorManager : public FListenerManager < UDataTable, EDataTableChangeInfo >
{
FDataTableEditorManager() {}
public:
UNREALED_API static FDataTableEditorManager& Get();
class UNREALED_API ListenerType : public InnerListenerType<FDataTableEditorManager>
{
};
};
typedef FDataTableEditorManager::ListenerType INotifyOnDataTableChanged;
static bool RemoveRow(UDataTable* DataTable, FName Name);
static uint8* AddRow(UDataTable* DataTable, FName RowName);
static bool RenameRow(UDataTable* DataTable, FName OldName, FName NewName);
static bool MoveRow(UDataTable* DataTable, FName RowName, ERowMoveDirection Direction, int32 NumRowsToMoveBy = 1);
static void BroadcastPreChange(UDataTable* DataTable, EDataTableChangeInfo Info);
static void BroadcastPostChange(UDataTable* DataTable, EDataTableChangeInfo Info);
static void CacheDataTableForEditing(const UDataTable* DataTable, TArray<FDataTableEditorColumnHeaderDataPtr>& OutAvailableColumns, TArray<FDataTableEditorRowListViewDataPtr>& OutAvailableRows);
static TArray<UScriptStruct*> GetPossibleStructs();
};