// Copyright Epic Games, Inc. All Rights Reserved. /** * UI to pick options when importing a data table */ #pragma once #include "CoreMinimal.h" #include "Factories/CSVImportFactory.h" #include "Layout/Visibility.h" #include "Widgets/DeclarativeSyntaxSupport.h" #include "Input/Reply.h" #include "Widgets/SWidget.h" #include "Widgets/SCompoundWidget.h" #include "Widgets/Input/SComboBox.h" enum class ECSVImportOptionDlgResponse : uint8 { Import, ImportAll, Cancel }; class UNREALED_API SCSVImportOptions: public SCompoundWidget { private: /** Typedef for curve enum pointers */ typedef TSharedPtr CurveInterpModePtr; public: SLATE_BEGIN_ARGS(SCSVImportOptions) : _WidgetWindow(), _FullPath(), _TempImportDataTable() {} SLATE_ARGUMENT(TSharedPtr, WidgetWindow) SLATE_ARGUMENT(FText, FullPath) SLATE_ARGUMENT(UDataTable*, TempImportDataTable) SLATE_END_ARGS() SCSVImportOptions() : UserDlgResponse(ECSVImportOptionDlgResponse::Cancel), SelectedImportType(ECSVImportType::ECSV_DataTable), SelectedStruct(nullptr), TempImportDataTable(nullptr) {} void Construct(const FArguments& InArgs); /** If we should import */ bool ShouldImport(); /** If the current settings should be applied to all items being imported */ bool ShouldImportAll(); /** Get the row struct we selected */ UScriptStruct* GetSelectedRowStruct(); /** Get the import type we selected */ ECSVImportType GetSelectedImportType(); /** Get the interpolation mode we selected */ ERichCurveInterpMode GetSelectedCurveIterpMode(); /** Whether to show table row options */ EVisibility GetTableRowOptionVis() const; /** Whether to show curve type options */ EVisibility GetCurveTypeVis() const; /** Whether to show details panel */ EVisibility GetDetailsPanelVis() const; FString GetImportTypeText(TSharedPtr Type) const; /** Called to create a widget for each struct */ TSharedRef MakeImportTypeItemWidget(TSharedPtr Type); /** Called when import type changes */ void OnImportTypeSelected(TSharedPtr Selection, ESelectInfo::Type SelectionType); /** Called when datatable row is selected */ void OnStructSelected(UScriptStruct* NewStruct); FString GetCurveTypeText(CurveInterpModePtr InterpMode) const; /** Called to create a widget for each curve interpolation enum */ TSharedRef MakeCurveTypeWidget(CurveInterpModePtr InterpMode); /** Called when 'Apply' button is pressed */ FReply OnImport(); /** Do we have all of the data we need to import this asset? */ bool CanImport() const; /** Called when 'Cancel' button is pressed */ FReply OnCancel(); FText GetSelectedItemText() const; FText GetSelectedCurveTypeText() const; private: FReply HandleImport(); FReply OnImportAll(); /** Whether we should go ahead with import */ ECSVImportOptionDlgResponse UserDlgResponse; /** Window that owns us */ TWeakPtr WidgetWindow; // Import type /** List of import types to pick from, drives combo box */ TArray> ImportTypes; /** The combo box */ TSharedPtr>> ImportTypeCombo; /** Indicates what kind of asset we want to make from the CSV file */ ECSVImportType SelectedImportType; // Row type /** The row struct combo box */ TSharedPtr RowStructCombo; /** The selected row struct */ UScriptStruct* SelectedStruct; /** Temp DataTable to hold import options */ TWeakObjectPtr TempImportDataTable; /** The curve interpolation combo box */ TSharedPtr> CurveInterpCombo; /** A property view to edit advanced options */ TSharedPtr PropertyView; /** All available curve interpolation modes */ TArray CurveInterpModes; /** The selected curve interpolation type */ ERichCurveInterpMode SelectedCurveInterpMode; };