You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
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]
73 lines
2.5 KiB
C++
73 lines
2.5 KiB
C++
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#pragma once
|
|
|
|
#include "Kismet2/StructureEditorUtils.h"
|
|
#include "DataTableEditorUtils.h"
|
|
|
|
DECLARE_DELEGATE_OneParam(FOnRowModified, FName /*Row name*/);
|
|
DECLARE_DELEGATE_OneParam(FOnRowSelected, FName /*Row name*/);
|
|
|
|
class SRowEditor : public SCompoundWidget
|
|
, public FNotifyHook
|
|
, public FStructureEditorUtils::INotifyOnStructChanged
|
|
, public FDataTableEditorUtils::INotifyOnDataTableChanged
|
|
{
|
|
public:
|
|
SLATE_BEGIN_ARGS(SRowEditor) {}
|
|
SLATE_END_ARGS()
|
|
|
|
SRowEditor();
|
|
virtual ~SRowEditor();
|
|
|
|
// FNotifyHook
|
|
virtual void NotifyPreChange( UProperty* PropertyAboutToChange ) override;
|
|
virtual void NotifyPostChange( const FPropertyChangedEvent& PropertyChangedEvent, UProperty* PropertyThatChanged ) override;
|
|
|
|
// INotifyOnStructChanged
|
|
virtual void PreChange(const class UUserDefinedStruct* Struct, FStructureEditorUtils::EStructureEditorChangeInfo Info) override;
|
|
virtual void PostChange(const class UUserDefinedStruct* Struct, FStructureEditorUtils::EStructureEditorChangeInfo Info) override;
|
|
|
|
// INotifyOnDataTableChanged
|
|
virtual void PreChange(const UDataTable* Changed, FDataTableEditorUtils::EDataTableChangeInfo Info) override;
|
|
virtual void PostChange(const UDataTable* Changed, FDataTableEditorUtils::EDataTableChangeInfo Info) override;
|
|
|
|
FOnRowSelected RowSelectedCallback;
|
|
|
|
private:
|
|
|
|
TArray<TSharedPtr<FName>> CachedRowNames;
|
|
TSharedPtr<FStructOnScope> CurrentRow;
|
|
TAssetPtr<UDataTable> DataTable; // weak obj ptr couldn't handle reimporting
|
|
TSharedPtr<class IStructureDetailsView> StructureDetailsView;
|
|
TSharedPtr<FName> SelectedName;
|
|
TSharedPtr<SComboBox<TSharedPtr<FName>>> RowComboBox;
|
|
TSharedPtr<SEditableTextBox> RenameTextBox;
|
|
|
|
void RefreshNameList();
|
|
void CleanBeforeChange();
|
|
void Restore();
|
|
|
|
UScriptStruct* GetScriptStruct() const;
|
|
|
|
FName GetCurrentName() const;
|
|
FText GetCurrentNameAsText() const;
|
|
FString GetStructureDisplayName() const;
|
|
TSharedRef<SWidget> OnGenerateWidget(TSharedPtr<FName> InItem);
|
|
void OnSelectionChanged(TSharedPtr<FName> InItem, ESelectInfo::Type InSeletionInfo);
|
|
|
|
FReply OnAddClicked();
|
|
FReply OnRemoveClicked();
|
|
FReply OnMoveRowClicked(FDataTableEditorUtils::ERowMoveDirection MoveDirection);
|
|
FReply OnMoveToExtentClicked(FDataTableEditorUtils::ERowMoveDirection MoveDirection);
|
|
void OnRowRenamed(const FText& Text, ETextCommit::Type CommitType);
|
|
|
|
public:
|
|
|
|
void Construct(const FArguments& InArgs, UDataTable* Changed);
|
|
|
|
void SelectRow(FName Name);
|
|
|
|
void HandleUndoRedo();
|
|
};
|