mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 09:35:25 +00:00
Update option widget buttons on AddOption
This commit is contained in:
parent
d3045cc463
commit
4f25ffed56
@ -165,6 +165,15 @@ void UOptionWidgetBase::SetSelectedIndex(int NewIndex)
|
||||
if (GamepadText)
|
||||
GamepadText->SetText(NewText);
|
||||
|
||||
UpdateUpDownButtons();
|
||||
|
||||
if (bRaiseEvent)
|
||||
OnSelectedOptionChanged.Broadcast(this, SelectedIndex);
|
||||
|
||||
}
|
||||
|
||||
void UOptionWidgetBase::UpdateUpDownButtons()
|
||||
{
|
||||
const bool CanDecrease = SelectedIndex > 0;
|
||||
const bool CanIncrease = SelectedIndex < Options.Num() - 1;
|
||||
if (MouseDownButton)
|
||||
@ -175,15 +184,22 @@ void UOptionWidgetBase::SetSelectedIndex(int NewIndex)
|
||||
GamepadDownImage->SetVisibility(CanDecrease ? ESlateVisibility::Visible : ESlateVisibility::Hidden);
|
||||
if (GamepadUpImage)
|
||||
GamepadUpImage->SetVisibility(CanIncrease ? ESlateVisibility::Visible : ESlateVisibility::Hidden);
|
||||
|
||||
if (bRaiseEvent)
|
||||
OnSelectedOptionChanged.Broadcast(this, SelectedIndex);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int UOptionWidgetBase::AddOption(FText Option)
|
||||
{
|
||||
return Options.Add(Option);
|
||||
const int Ret = Options.Add(Option);
|
||||
if (GetSelectedIndex() == -1)
|
||||
{
|
||||
SetSelectedIndex(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateUpDownButtons();
|
||||
}
|
||||
return Ret;
|
||||
}
|
||||
|
||||
void UOptionWidgetBase::SetOptions(const TArray<FText>& InOptions, int NewSelectedIndex)
|
||||
|
@ -111,6 +111,7 @@ protected:
|
||||
virtual void ChangeOption(int Delta);
|
||||
UFUNCTION(BlueprintCallable)
|
||||
virtual EInputMode GetCurrentInputMode() const;
|
||||
virtual void UpdateUpDownButtons();
|
||||
|
||||
|
||||
protected:
|
||||
|
Loading…
x
Reference in New Issue
Block a user