2021-09-28 13:33:17 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "SStateTreeView.h"
|
|
|
|
|
|
|
|
|
|
#include "Framework/MultiBox/MultiBoxBuilder.h"
|
|
|
|
|
|
|
|
|
|
|
2023-01-19 00:48:07 -05:00
|
|
|
#include "Framework/Views/TableViewMetadata.h"
|
2021-09-28 13:33:17 -04:00
|
|
|
#include "Widgets/Layout/SScrollBox.h"
|
2022-09-30 11:31:57 -04:00
|
|
|
#include "SPositiveActionButton.h"
|
2021-09-28 13:33:17 -04:00
|
|
|
#include "SStateTreeViewRow.h"
|
|
|
|
|
|
|
|
|
|
#include "StateTreeViewModel.h"
|
|
|
|
|
#include "StateTreeState.h"
|
2023-01-19 00:48:07 -05:00
|
|
|
#include "Widgets/Views/STreeView.h"
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "StateTreeEditor"
|
|
|
|
|
|
|
|
|
|
SStateTreeView::SStateTreeView()
|
|
|
|
|
: RequestedRenameState(nullptr)
|
|
|
|
|
, bItemsDirty(false)
|
|
|
|
|
, bUpdatingSelection(false)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SStateTreeView::~SStateTreeView()
|
|
|
|
|
{
|
|
|
|
|
if (StateTreeViewModel)
|
|
|
|
|
{
|
|
|
|
|
StateTreeViewModel->GetOnAssetChanged().RemoveAll(this);
|
|
|
|
|
StateTreeViewModel->GetOnStatesRemoved().RemoveAll(this);
|
|
|
|
|
StateTreeViewModel->GetOnStatesMoved().RemoveAll(this);
|
|
|
|
|
StateTreeViewModel->GetOnStateAdded().RemoveAll(this);
|
|
|
|
|
StateTreeViewModel->GetOnStatesChanged().RemoveAll(this);
|
|
|
|
|
StateTreeViewModel->GetOnSelectionChanged().RemoveAll(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::Construct(const FArguments& InArgs, TSharedRef<FStateTreeViewModel> InStateTreeViewModel)
|
|
|
|
|
{
|
|
|
|
|
StateTreeViewModel = InStateTreeViewModel;
|
|
|
|
|
|
|
|
|
|
StateTreeViewModel->GetOnAssetChanged().AddSP(this, &SStateTreeView::HandleModelAssetChanged);
|
|
|
|
|
StateTreeViewModel->GetOnStatesRemoved().AddSP(this, &SStateTreeView::HandleModelStatesRemoved);
|
|
|
|
|
StateTreeViewModel->GetOnStatesMoved().AddSP(this, &SStateTreeView::HandleModelStatesMoved);
|
|
|
|
|
StateTreeViewModel->GetOnStateAdded().AddSP(this, &SStateTreeView::HandleModelStateAdded);
|
|
|
|
|
StateTreeViewModel->GetOnStatesChanged().AddSP(this, &SStateTreeView::HandleModelStatesChanged);
|
|
|
|
|
StateTreeViewModel->GetOnSelectionChanged().AddSP(this, &SStateTreeView::HandleModelSelectionChanged);
|
|
|
|
|
|
|
|
|
|
bUpdatingSelection = false;
|
|
|
|
|
|
2021-11-12 05:48:11 -05:00
|
|
|
TSharedRef<SScrollBar> HorizontalScrollBar = SNew(SScrollBar)
|
|
|
|
|
.Orientation(Orient_Horizontal)
|
|
|
|
|
.Thickness(FVector2D(12.0f, 12.0f));
|
|
|
|
|
|
|
|
|
|
TSharedRef<SScrollBar> VerticalScrollBar = SNew(SScrollBar)
|
|
|
|
|
.Orientation(Orient_Vertical)
|
|
|
|
|
.Thickness(FVector2D(12.0f, 12.0f));
|
|
|
|
|
|
2022-09-30 11:31:57 -04:00
|
|
|
StateTreeViewModel->GetSubTrees(Subtrees);
|
|
|
|
|
|
|
|
|
|
TreeView = SNew(STreeView<TWeakObjectPtr<UStateTreeState>>)
|
2021-09-28 13:33:17 -04:00
|
|
|
.OnGenerateRow(this, &SStateTreeView::HandleGenerateRow)
|
|
|
|
|
.OnGetChildren(this, &SStateTreeView::HandleGetChildren)
|
2022-09-30 11:31:57 -04:00
|
|
|
.TreeItemsSource(&Subtrees)
|
2021-09-28 13:33:17 -04:00
|
|
|
.ItemHeight(32)
|
|
|
|
|
.OnSelectionChanged(this, &SStateTreeView::HandleTreeSelectionChanged)
|
2023-01-24 08:45:29 -05:00
|
|
|
.OnExpansionChanged(this, &SStateTreeView::HandleTreeExpansionChanged)
|
2021-11-12 05:48:11 -05:00
|
|
|
.OnContextMenuOpening(this, &SStateTreeView::HandleContextMenuOpening)
|
|
|
|
|
.AllowOverscroll(EAllowOverscroll::No)
|
|
|
|
|
.ExternalScrollbar(VerticalScrollBar);
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
ChildSlot
|
|
|
|
|
[
|
|
|
|
|
SNew(SVerticalBox)
|
|
|
|
|
|
|
|
|
|
+ SVerticalBox::Slot()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
[
|
|
|
|
|
SNew(SBorder)
|
2022-05-09 13:12:28 -04:00
|
|
|
.BorderImage(FAppStyle::GetBrush("ToolPanel.GroupBorder"))
|
2021-09-28 13:33:17 -04:00
|
|
|
.Padding(2.0f)
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
|
|
|
|
|
// New State
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.VAlign(VAlign_Center)
|
|
|
|
|
.Padding(4.0f, 2.0f)
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
2022-09-30 11:31:57 -04:00
|
|
|
SNew(SPositiveActionButton)
|
2022-01-28 03:38:15 -05:00
|
|
|
.ToolTipText(LOCTEXT("AddStateToolTip", "Add New State"))
|
2022-09-30 11:31:57 -04:00
|
|
|
.Icon(FAppStyle::Get().GetBrush("Icons.Plus"))
|
|
|
|
|
.Text(LOCTEXT("AddState", "Add State"))
|
2022-01-28 03:38:15 -05:00
|
|
|
.OnClicked(this, &SStateTreeView::HandleAddStateButton)
|
2021-09-28 13:33:17 -04:00
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
+SVerticalBox::Slot()
|
|
|
|
|
.Padding(0.0f, 6.0f, 0.0f, 0.0f)
|
|
|
|
|
[
|
|
|
|
|
SNew(SHorizontalBox)
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.FillWidth(1.0f)
|
|
|
|
|
.Padding(0.0f)
|
|
|
|
|
[
|
2022-06-30 03:06:38 -04:00
|
|
|
SAssignNew(ViewBox, SScrollBox)
|
2021-09-28 13:33:17 -04:00
|
|
|
.Orientation(Orient_Horizontal)
|
2021-11-12 05:48:11 -05:00
|
|
|
.ExternalScrollbar(HorizontalScrollBar)
|
|
|
|
|
+SScrollBox::Slot()
|
2022-10-31 15:13:40 -04:00
|
|
|
.FillSize(1.0f)
|
2021-09-28 13:33:17 -04:00
|
|
|
[
|
2021-11-12 05:48:11 -05:00
|
|
|
TreeView.ToSharedRef()
|
2021-09-28 13:33:17 -04:00
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
+ SHorizontalBox::Slot()
|
|
|
|
|
.AutoWidth()
|
|
|
|
|
[
|
2021-11-12 05:48:11 -05:00
|
|
|
VerticalScrollBar
|
2021-09-28 13:33:17 -04:00
|
|
|
]
|
|
|
|
|
]
|
2021-11-12 05:48:11 -05:00
|
|
|
+SVerticalBox::Slot()
|
|
|
|
|
.AutoHeight()
|
|
|
|
|
[
|
|
|
|
|
HorizontalScrollBar
|
|
|
|
|
]
|
2021-09-28 13:33:17 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
UpdateTree(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::SavePersistentExpandedStates()
|
|
|
|
|
{
|
|
|
|
|
if (!StateTreeViewModel)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-30 11:31:57 -04:00
|
|
|
TSet<TWeakObjectPtr<UStateTreeState>> ExpandedStates;
|
2021-09-28 13:33:17 -04:00
|
|
|
TreeView->GetExpandedItems(ExpandedStates);
|
|
|
|
|
StateTreeViewModel->SetPersistentExpandedStates(ExpandedStates);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::Tick(const FGeometry& AllottedGeometry, const double InCurrentTime, const float InDeltaTime)
|
|
|
|
|
{
|
|
|
|
|
if (bItemsDirty)
|
|
|
|
|
{
|
2022-04-21 08:02:21 -04:00
|
|
|
UpdateTree(/*bExpandPersistent*/true);
|
2021-09-28 13:33:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (RequestedRenameState && !TreeView->IsPendingRefresh())
|
|
|
|
|
{
|
|
|
|
|
if (TSharedPtr<SStateTreeViewRow> Row = StaticCastSharedPtr<SStateTreeViewRow>(TreeView->WidgetFromItem(RequestedRenameState)))
|
|
|
|
|
{
|
|
|
|
|
Row->RequestRename();
|
|
|
|
|
}
|
|
|
|
|
RequestedRenameState = nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::UpdateTree(bool bExpandPersistent)
|
|
|
|
|
{
|
|
|
|
|
if (!StateTreeViewModel)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-30 11:31:57 -04:00
|
|
|
TSet<TWeakObjectPtr<UStateTreeState>> ExpandedStates;
|
2021-09-28 13:33:17 -04:00
|
|
|
if (bExpandPersistent)
|
|
|
|
|
{
|
|
|
|
|
// Get expanded state from the tree data.
|
|
|
|
|
StateTreeViewModel->GetPersistentExpandedStates(ExpandedStates);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// Restore current expanded state.
|
|
|
|
|
TreeView->GetExpandedItems(ExpandedStates);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remember selection
|
2022-09-30 11:31:57 -04:00
|
|
|
TArray<TWeakObjectPtr<UStateTreeState>> SelectedStates;
|
2021-09-28 13:33:17 -04:00
|
|
|
StateTreeViewModel->GetSelectedStates(SelectedStates);
|
|
|
|
|
|
|
|
|
|
// Regenerate items
|
2022-09-30 11:31:57 -04:00
|
|
|
StateTreeViewModel->GetSubTrees(Subtrees);
|
|
|
|
|
TreeView->SetTreeItemsSource(&Subtrees);
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
// Restore expanded state
|
2022-09-30 11:31:57 -04:00
|
|
|
for (const TWeakObjectPtr<UStateTreeState>& State : ExpandedStates)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
|
|
|
|
TreeView->SetItemExpansion(State, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Restore selected state
|
|
|
|
|
TreeView->ClearSelection();
|
|
|
|
|
TreeView->SetItemSelection(SelectedStates, true);
|
|
|
|
|
|
|
|
|
|
bItemsDirty = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::HandleModelAssetChanged()
|
|
|
|
|
{
|
|
|
|
|
bItemsDirty = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::HandleModelStatesRemoved(const TSet<UStateTreeState*>& AffectedParents)
|
|
|
|
|
{
|
|
|
|
|
bItemsDirty = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::HandleModelStatesMoved(const TSet<UStateTreeState*>& AffectedParents, const TSet<UStateTreeState*>& MovedStates)
|
|
|
|
|
{
|
|
|
|
|
bItemsDirty = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::HandleModelStateAdded(UStateTreeState* ParentState, UStateTreeState* NewState)
|
|
|
|
|
{
|
|
|
|
|
bItemsDirty = true;
|
|
|
|
|
|
|
|
|
|
HandleRenameState(NewState);
|
2023-01-24 08:45:29 -05:00
|
|
|
|
|
|
|
|
if (StateTreeViewModel.IsValid())
|
|
|
|
|
{
|
|
|
|
|
StateTreeViewModel->SetSelection(NewState);
|
|
|
|
|
}
|
2021-09-28 13:33:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::HandleModelStatesChanged(const TSet<UStateTreeState*>& AffectedStates, const FPropertyChangedEvent& PropertyChangedEvent)
|
|
|
|
|
{
|
|
|
|
|
bool bArraysChanged = false;
|
|
|
|
|
|
2022-05-16 05:13:27 -04:00
|
|
|
// The purpose of the rebuild below is to update the task visualization (number of widgets change).
|
2021-09-28 13:33:17 -04:00
|
|
|
// This method is called when anything in a state changes, make sure to only rebuild when needed.
|
|
|
|
|
if (PropertyChangedEvent.MemberProperty->GetFName() == GET_MEMBER_NAME_CHECKED(UStateTreeState, Tasks))
|
|
|
|
|
{
|
|
|
|
|
bArraysChanged = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (bArraysChanged)
|
|
|
|
|
{
|
|
|
|
|
TreeView->RebuildList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-30 11:31:57 -04:00
|
|
|
void SStateTreeView::HandleModelSelectionChanged(const TArray<TWeakObjectPtr<UStateTreeState>>& SelectedStates)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
|
|
|
|
if (bUpdatingSelection)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TreeView->ClearSelection();
|
|
|
|
|
|
|
|
|
|
if (SelectedStates.Num() > 0)
|
|
|
|
|
{
|
|
|
|
|
TreeView->SetItemSelection(SelectedStates, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-09-30 11:31:57 -04:00
|
|
|
TSharedRef<ITableRow> SStateTreeView::HandleGenerateRow(TWeakObjectPtr<UStateTreeState> InState, const TSharedRef<STableViewBase>& InOwnerTableView)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
2022-06-30 03:06:38 -04:00
|
|
|
return SNew(SStateTreeViewRow, InOwnerTableView, InState, ViewBox, StateTreeViewModel.ToSharedRef());
|
2021-09-28 13:33:17 -04:00
|
|
|
}
|
|
|
|
|
|
2022-09-30 11:31:57 -04:00
|
|
|
void SStateTreeView::HandleGetChildren(TWeakObjectPtr<UStateTreeState> InParent, TArray<TWeakObjectPtr<UStateTreeState>>& OutChildren)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
2022-09-30 11:31:57 -04:00
|
|
|
if (const UStateTreeState* Parent = InParent.Get())
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
2022-09-30 11:31:57 -04:00
|
|
|
OutChildren.Append(Parent->Children);
|
2021-09-28 13:33:17 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-30 11:31:57 -04:00
|
|
|
void SStateTreeView::HandleTreeSelectionChanged(TWeakObjectPtr<UStateTreeState> InSelectedItem, ESelectInfo::Type SelectionType)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
|
|
|
|
if (!StateTreeViewModel)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Do not report code based selection changes.
|
|
|
|
|
if (SelectionType == ESelectInfo::Direct)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-30 11:31:57 -04:00
|
|
|
TArray<TWeakObjectPtr<UStateTreeState>> SelectedItems = TreeView->GetSelectedItems();
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
bUpdatingSelection = true;
|
|
|
|
|
StateTreeViewModel->SetSelection(SelectedItems);
|
|
|
|
|
bUpdatingSelection = false;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-24 08:45:29 -05:00
|
|
|
void SStateTreeView::HandleTreeExpansionChanged(TWeakObjectPtr<UStateTreeState> InSelectedItem, bool bExpanded)
|
|
|
|
|
{
|
|
|
|
|
// Not calling Modify() on the state as we don't want the expansion to dirty the asset.
|
|
|
|
|
// @todo: this is temporary fix for a bug where adding a state will reset the expansion state.
|
|
|
|
|
if (UStateTreeState* State = InSelectedItem.Get())
|
|
|
|
|
{
|
|
|
|
|
State->bExpanded = bExpanded;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-28 13:33:17 -04:00
|
|
|
TSharedPtr<SWidget> SStateTreeView::HandleContextMenuOpening()
|
|
|
|
|
{
|
|
|
|
|
if (!StateTreeViewModel)
|
|
|
|
|
{
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<UStateTreeState*> SelectedStates;
|
|
|
|
|
StateTreeViewModel->GetSelectedStates(SelectedStates);
|
|
|
|
|
UStateTreeState* FirstSelectedState = SelectedStates.Num() > 0 ? SelectedStates[0] : nullptr;
|
|
|
|
|
|
|
|
|
|
FMenuBuilder MenuBuilder(true, nullptr);
|
|
|
|
|
|
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
|
|
|
LOCTEXT("AddState", "Add State"),
|
|
|
|
|
FText(),
|
|
|
|
|
FSlateIcon(),
|
|
|
|
|
FUIAction(FExecuteAction::CreateSP(this, &SStateTreeView::HandleAddState, FirstSelectedState)));
|
|
|
|
|
|
|
|
|
|
if (FirstSelectedState)
|
|
|
|
|
{
|
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
|
|
|
LOCTEXT("AddChildState", "Add Child State"),
|
|
|
|
|
FText(),
|
|
|
|
|
FSlateIcon(),
|
|
|
|
|
FUIAction(FExecuteAction::CreateSP(this, &SStateTreeView::HandleAddChildState, FirstSelectedState)));
|
|
|
|
|
|
|
|
|
|
MenuBuilder.AddSeparator();
|
|
|
|
|
|
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
|
|
|
LOCTEXT("RenameNodeGroup", "Rename"),
|
|
|
|
|
FText(),
|
|
|
|
|
FSlateIcon(),
|
|
|
|
|
FUIAction(FExecuteAction::CreateSP(this, &SStateTreeView::HandleRenameState, FirstSelectedState)));
|
|
|
|
|
|
|
|
|
|
MenuBuilder.AddMenuEntry(
|
|
|
|
|
LOCTEXT("DeleteState", "Delete Selected"),
|
|
|
|
|
FText(),
|
|
|
|
|
FSlateIcon(),
|
|
|
|
|
FUIAction(FExecuteAction::CreateSP(this, &SStateTreeView::HandleDeleteItems)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return MenuBuilder.MakeWidget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-01-28 03:38:15 -05:00
|
|
|
FReply SStateTreeView::HandleAddStateButton()
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
2022-01-28 03:38:15 -05:00
|
|
|
if (StateTreeViewModel == nullptr)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
2022-01-28 03:38:15 -05:00
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<UStateTreeState*> SelectedStates;
|
|
|
|
|
StateTreeViewModel->GetSelectedStates(SelectedStates);
|
|
|
|
|
UStateTreeState* FirstSelectedState = SelectedStates.Num() > 0 ? SelectedStates[0] : nullptr;
|
|
|
|
|
|
|
|
|
|
if (FirstSelectedState != nullptr)
|
|
|
|
|
{
|
|
|
|
|
// If the state is root, add child state, else sibling.
|
|
|
|
|
if (FirstSelectedState->Parent == nullptr)
|
|
|
|
|
{
|
|
|
|
|
StateTreeViewModel->AddChildState(FirstSelectedState);
|
|
|
|
|
TreeView->SetItemExpansion(FirstSelectedState, true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
StateTreeViewModel->AddState(FirstSelectedState);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-09-30 11:31:57 -04:00
|
|
|
// Add root state at the lowest level.
|
|
|
|
|
StateTreeViewModel->AddState(nullptr);
|
2022-01-28 03:38:15 -05:00
|
|
|
}
|
2021-09-28 13:33:17 -04:00
|
|
|
|
|
|
|
|
return FReply::Handled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::HandleAddState(UStateTreeState* AfterState)
|
|
|
|
|
{
|
2022-01-28 03:38:15 -05:00
|
|
|
if (StateTreeViewModel == nullptr)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
2022-01-28 03:38:15 -05:00
|
|
|
return;
|
2021-09-28 13:33:17 -04:00
|
|
|
}
|
2022-01-28 03:38:15 -05:00
|
|
|
|
|
|
|
|
StateTreeViewModel->AddState(AfterState);
|
2021-09-28 13:33:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::HandleRenameState(UStateTreeState* State)
|
|
|
|
|
{
|
|
|
|
|
RequestedRenameState = State;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::HandleAddChildState(UStateTreeState* ParentState)
|
|
|
|
|
{
|
2022-01-28 03:38:15 -05:00
|
|
|
if (StateTreeViewModel == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ParentState)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
|
|
|
|
StateTreeViewModel->AddChildState(ParentState);
|
|
|
|
|
TreeView->SetItemExpansion(ParentState, true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SStateTreeView::HandleDeleteItems()
|
|
|
|
|
{
|
2022-01-28 03:38:15 -05:00
|
|
|
if (StateTreeViewModel == nullptr)
|
2021-09-28 13:33:17 -04:00
|
|
|
{
|
2022-01-28 03:38:15 -05:00
|
|
|
return;
|
2021-09-28 13:33:17 -04:00
|
|
|
}
|
2022-01-28 03:38:15 -05:00
|
|
|
|
|
|
|
|
StateTreeViewModel->RemoveSelectedStates();
|
2021-09-28 13:33:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#undef LOCTEXT_NAMESPACE
|