As you guys can see, I’m using an array of button templates as Slate arguments, but I have no idea how to iterate within the Slate UI construction structure.
So is there a way to vary the amount of buttons constructed in a Slate construction such as defining a separate function for buttons?
struct FDHDialogTemplate
{
public:
/** Default constructor */
FDHDialogTemplate() {}
FDHDialogTemplate(FText InTitle, FDHTextStyle InTitleStyle, FText InText, FDHTextStyle InTextStyle, TArray<FDHButtonTemplate> InButtons);
/** Text displayed in the title slot of the dialog */
FText DialogTitle;
/** Style to display the title text */
FDHTextStyle TitleStyle;
/** Text displayed in the top of the contents in the dialog */
FText DialogText;
/** Style to display the content text */
FDHTextStyle TextStyle;
/** Buttons to be displayed in the dialog */
TArray<FDHButtonTemplate> DialogButtons;
};
void SDHDialogWidget::Construct(const FArguments& InArgs)
{
Template = InArgs._Template;
SNew(SBorder)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.BorderBackgroundColor(FLinearColor(1.0f, 1.0f, 1.0f, 0.1f))
[
SNew(SBorder)
.HAlign(HAlign_Fill)
.VAlign(VAlign_Top)
.Padding(FMargin(0.0f, 150.0f))
.BorderBackgroundColor(FLinearColor::Gray)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.HAlign(HAlign_Left)
.VAlign(VAlign_Top)
.Padding(FMargin(100.0f, 5.0f))
[
SNew(STextBlock)
.ColorAndOpacity(Template.TitleStyle.TextColor)
.ShadowColorAndOpacity(Template.TitleStyle.ShadowColor)
.Font(Template.TitleStyle.Font)
.Text(Template.DialogTitle)
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Fill)
.VAlign(VAlign_Fill)
.Padding(FMargin(100.0f, 5.0f))
[
SNew(STextBlock)
.ColorAndOpacity(Template.TextStyle.TextColor)
.ShadowColorAndOpacity(Template.TextStyle.ShadowColor)
.Font(Template.TextStyle.Font)
.Text(Template.DialogText)
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Right)
.VAlign(VAlign_Bottom)
.Padding(FMargin(5.0f))
[
// Iteration required here
]
]
];
}