Files
UnrealEngineUWP/Engine/Source/Editor/CSVtoSVG/Private/SStatList.cpp
Jason Nadro 07ecbb32ac [CSVtoSVG][UI] - Adding a UI wrapper around the CSV to SVG Tool command line tool.
- The arguments are stored as a UObject with reflected properties so I can get a "free" UI by using the property window.  Also, this lets me serialized arguments so I can potentially re-use the settings.  I can also programmatically generate the arugment list to pass to CSVtoSVG by iterating the relfected properties.
- Add SCSVtoSVG widget which contains/owns the arugment UObject, a property window to edit it, and a SStatList.
- When the CSV file property on the arugment changes we infer an output directory and output file name from the input csv file.  These can be overriden.
- I also parse the CSV file to find all the available stats in it to populate a SListView.
- When you click generate to make the SVG graph we automatically open the graph in a web browser.
- Save the current arugments to config when you close the editor.

#rb Dave.Jones2
#preflight 6180006956ec0b000161efd2

[CL 18003230 by Jason Nadro in ue5-main branch]
2021-11-01 11:36:46 -04:00

64 lines
1.3 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "SStatList.h"
#include "Widgets/Views/SListView.h"
#define LOCTEXT_NAMESPACE "CSVtoSVG"
void SStatList::Construct(const FArguments& Args)
{
StatListView = SNew(SListView<TSharedPtr<FString>>)
.ItemHeight(20.0f)
.ListItemsSource(&StatList)
.OnGenerateRow(this, &SStatList::OnGenerateWidgetForList);
ChildSlot
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
StatListView.ToSharedRef()
]
];
}
TSharedRef<ITableRow> SStatList::OnGenerateWidgetForList(TSharedPtr<FString> InItem, const TSharedRef<STableViewBase>& OwnerTable)
{
return
SNew(STableRow<TSharedPtr<FString>>, OwnerTable)
[
SNew(STextBlock)
.Text(FText::FromString(*InItem.Get()))
];
}
void SStatList::UpdateStatList(const TArray<FString>& StatNames)
{
StatList.Empty();
for (const auto& StatName : StatNames)
{
StatList.Add(MakeShared<FString>(StatName));
}
StatListView->RequestListRefresh();
}
TArray<FString> SStatList::GetSelectedStats() const
{
TArray<TSharedPtr<FString>> SelectedItems = StatListView->GetSelectedItems();
TArray<FString> SelectedStats;
for (const TSharedPtr<FString>& Item : SelectedItems)
{
if (Item.IsValid())
{
SelectedStats.Add(*Item);
}
}
return SelectedStats;
}
#undef LOCTEXT_NAMESPACE