mirror of
https://github.com/sinbad/StevesUEHelpers.git
synced 2025-02-23 17:45:23 +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)
|
if (GamepadText)
|
||||||
GamepadText->SetText(NewText);
|
GamepadText->SetText(NewText);
|
||||||
|
|
||||||
|
UpdateUpDownButtons();
|
||||||
|
|
||||||
|
if (bRaiseEvent)
|
||||||
|
OnSelectedOptionChanged.Broadcast(this, SelectedIndex);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void UOptionWidgetBase::UpdateUpDownButtons()
|
||||||
|
{
|
||||||
const bool CanDecrease = SelectedIndex > 0;
|
const bool CanDecrease = SelectedIndex > 0;
|
||||||
const bool CanIncrease = SelectedIndex < Options.Num() - 1;
|
const bool CanIncrease = SelectedIndex < Options.Num() - 1;
|
||||||
if (MouseDownButton)
|
if (MouseDownButton)
|
||||||
@ -176,14 +185,21 @@ void UOptionWidgetBase::SetSelectedIndex(int NewIndex)
|
|||||||
if (GamepadUpImage)
|
if (GamepadUpImage)
|
||||||
GamepadUpImage->SetVisibility(CanIncrease ? ESlateVisibility::Visible : ESlateVisibility::Hidden);
|
GamepadUpImage->SetVisibility(CanIncrease ? ESlateVisibility::Visible : ESlateVisibility::Hidden);
|
||||||
|
|
||||||
if (bRaiseEvent)
|
|
||||||
OnSelectedOptionChanged.Broadcast(this, SelectedIndex);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int UOptionWidgetBase::AddOption(FText Option)
|
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)
|
void UOptionWidgetBase::SetOptions(const TArray<FText>& InOptions, int NewSelectedIndex)
|
||||||
|
@ -111,6 +111,7 @@ protected:
|
|||||||
virtual void ChangeOption(int Delta);
|
virtual void ChangeOption(int Delta);
|
||||||
UFUNCTION(BlueprintCallable)
|
UFUNCTION(BlueprintCallable)
|
||||||
virtual EInputMode GetCurrentInputMode() const;
|
virtual EInputMode GetCurrentInputMode() const;
|
||||||
|
virtual void UpdateUpDownButtons();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user