Skip to content

Commit

Permalink
Merge branch '5.4' into 5.5
Browse files Browse the repository at this point in the history
  • Loading branch information
goncasmage1 committed Dec 1, 2024
2 parents 6f8be31 + 197affe commit f424461
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 13 deletions.
45 changes: 45 additions & 0 deletions Source/UINavigation/Private/UINavPCComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "UINavInputContainer.h"
#include "UINavMacros.h"
#include "UINavInputBox.h"
#include "UINavInputDisplay.h"
#include "UINavigationConfig.h"
#include "SwapKeysWidget.h"
#include "Components/ScrollBox.h"
Expand All @@ -18,6 +19,7 @@
#include "Data/InputNameMapping.h"
#include "Data/PlatformConfigData.h"
#include "UINavBlueprintFunctionLibrary.h"
#include "Blueprint/WidgetBlueprintLibrary.h"
#include "UINavInputProcessor.h"
#include "GenericPlatform/GenericPlatformInputDeviceMapper.h"
#include "Framework/Application/SlateApplication.h"
Expand Down Expand Up @@ -105,6 +107,11 @@ void UUINavPCComponent::BeginPlay()
{
Super::BeginPlay();

if (PC == nullptr)
{
return;
}

if (!PC->IsLocalController())
{
SetComponentTickEnabled(false);
Expand Down Expand Up @@ -747,6 +754,44 @@ void UUINavPCComponent::SetAllowSectionInput(const bool bAllowInput)
RefreshNavigationKeys();
}

void UUINavPCComponent::SetGamepadInputDataTables(UDataTable* NewKeyIconTable, UDataTable* NewKeyNameTable, const bool bUpdateInputDisplays /*= true*/)
{
CurrentPlatformData.GamepadKeyIconData = NewKeyIconTable;
CurrentPlatformData.GamepadKeyNameData = NewKeyNameTable;

if (bUpdateInputDisplays && CurrentInputType == EInputType::Gamepad)
{
ForceUpdateAllInputDisplays();
}
}

void UUINavPCComponent::SetKeyboardInputDataTables(UDataTable* NewKeyIconTable, UDataTable* NewKeyNameTable, const bool bUpdateInputDisplays /*= true*/)
{
KeyboardMouseKeyIconData = NewKeyIconTable;
KeyboardMouseKeyNameData = NewKeyNameTable;

if (bUpdateInputDisplays && CurrentInputType != EInputType::Gamepad)
{
ForceUpdateAllInputDisplays();
}
}

void UUINavPCComponent::ForceUpdateAllInputDisplays(const bool bOnlyTopLevel /*= false*/)
{
TArray<UUserWidget*> Widgets;
UWidgetBlueprintLibrary::GetAllWidgetsOfClass(this, Widgets, UUINavInputDisplay::StaticClass(), /*bTopLevel*/ bOnlyTopLevel);
for (UUserWidget* Widget : Widgets)
{
UUINavInputDisplay* InputDisplay = Cast<UUINavInputDisplay>(Widget);
if (!IsValid(InputDisplay))
{
continue;
}

InputDisplay->UpdateInputVisuals();
}
}

void UUINavPCComponent::HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& InKeyEvent)
{
const bool bIsSelectKey = StaticCastSharedRef<FUINavigationConfig>(FSlateApplication::Get().GetNavigationConfig())->IsGamepadSelectKey(InKeyEvent.GetKey());
Expand Down
25 changes: 13 additions & 12 deletions Source/UINavigation/Private/UINavWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,28 +220,23 @@ void UUINavWidget::SetupSections()
return;
}

if (!IsValid(UINavSectionsPanel))
{
return;
}

UUINavSectionsWidget* SectionsWidget = Cast<UUINavSectionsWidget>(UINavSectionsPanel);
UPanelWidget* SectionsPanel = IsValid(SectionsWidget) ? SectionsWidget->SectionButtonsPanel : Cast<UPanelWidget>(UINavSectionsPanel);
if (!IsValid(SectionsPanel))
UPanelWidget* TargetSectionsPanel = IsValid(SectionsWidget) ? SectionsWidget->SectionButtonsPanel : Cast<UPanelWidget>(UINavSectionsPanel);
if (IsValid(UINavSectionsPanel) && !IsValid(TargetSectionsPanel))
{
DISPLAYERROR("UINavSectionsPanel isn't a PanelWidget child or UINavSectionsWidget!");
return;
}

if (SectionButtons.IsEmpty())
if (SectionButtons.IsEmpty() && IsValid(TargetSectionsPanel))
{
#if WITH_EDITOR
static const TArray<TSubclassOf<UWidget>> ButtonClassArray = { UButton::StaticClass(), UUINavSectionButton::StaticClass(), UUINavComponent::StaticClass() };
#else
static const TArray<TSubclassOf<UWidget>> ButtonClassArray = { UButton::StaticClass(), UUINavSectionButton::StaticClass() };
#endif

for (UWidget* const ChildWidget : SectionsPanel->GetAllChildren())
for (UWidget* const ChildWidget : TargetSectionsPanel->GetAllChildren())
{
UWidget* TargetWidget = UUINavBlueprintFunctionLibrary::FindWidgetOfClassesInWidget(ChildWidget, ButtonClassArray);

Expand Down Expand Up @@ -279,10 +274,10 @@ void UUINavWidget::SetupSections()
{
case 0:
SectionButtons[i]->OnClicked.AddUniqueDynamic(this, &UUINavWidget::OnSectionButtonPressed1);
break;
break;
case 1:
SectionButtons[i]->OnClicked.AddUniqueDynamic(this, &UUINavWidget::OnSectionButtonPressed2);
break;
break;
case 2:
SectionButtons[i]->OnClicked.AddUniqueDynamic(this, &UUINavWidget::OnSectionButtonPressed3);
break;
Expand Down Expand Up @@ -1920,7 +1915,13 @@ bool UUINavWidget::IsSelectorValid()

void UUINavWidget::OnHoveredComponent(UUINavComponent* Component)
{
if (!IsValid(Component) || UINavPC == nullptr || (UINavPC->HidingMouseCursor() && !UINavPC->OverrideConsiderHover())) return;
if (!IsValid(Component) || UINavPC == nullptr) return;

if (UINavPC->HidingMouseCursor() && !UINavPC->OverrideConsiderHover())
{
Component->SwitchButtonStyle(EButtonStyle::Normal);
return;
}

UINavPC->CancelRebind();

Expand Down
14 changes: 14 additions & 0 deletions Source/UINavigation/Public/UINavPCComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,20 @@ class UINAVIGATION_API UUINavPCComponent : public UActorComponent
UFUNCTION(BlueprintCallable, Category = UINavController)
void SetAllowSectionInput(const bool bAllowInput);

UFUNCTION(BlueprintCallable, Category = UINavController)
void SetGamepadInputDataTables(UDataTable* NewKeyIconTable, UDataTable* NewKeyNameTable, const bool bUpdateInputDisplays = true);

UFUNCTION(BlueprintCallable, Category = UINavController)
void SetKeyboardInputDataTables(UDataTable* NewKeyIconTable, UDataTable* NewKeyNameTable, const bool bUpdateInputDisplays = true);

/*
* Fetches all UINavInputDisplays and forces them to update their visuals.
*
* @param bOnlyTopLevel Whether to update only direct children of the viewport.
*/
UFUNCTION(BlueprintCallable, Category = UINavController)
void ForceUpdateAllInputDisplays(const bool bOnlyTopLevel = false);

void SetIgnoreFocusByNavigation(const bool bIgnore) { bIgnoreFocusByNavigation = bIgnore; }
bool IgnoreFocusByNavigation() const { return bIgnoreFocusByNavigation; }

Expand Down
2 changes: 1 addition & 1 deletion UINavigation.uplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"FileVersion": 3,
"Version": 1,
"VersionName": "3.11.2",
"VersionName": "3.11.3",
"FriendlyName": "UI Navigation",
"Description": "A plugin that allows you to easily setup mouse, keyboard and controller navigation in UMG, among other things.",
"Category": "User Interface",
Expand Down

0 comments on commit f424461

Please sign in to comment.