fix: input mapping

This commit is contained in:
2025-10-12 15:51:44 +02:00
parent 5c474baefb
commit 768ecf5ee3
4 changed files with 26 additions and 17 deletions

BIN
Content/UI/WBP_SkillNode.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Content/UI/WBP_SkillTree.uasset (Stored with Git LFS)

Binary file not shown.

View File

@@ -490,6 +490,7 @@ void USkillTreeComponent::UpdateSkillStates()
{
for (auto& Pair : AllSkills)
{
const FName& SkillID = Pair.Key;
FSkillNodeRuntime& SkillNode = Pair.Value;
// Only update Locked and Available states based on prerequisites
@@ -503,14 +504,18 @@ void USkillTreeComponent::UpdateSkillStates()
case ESkillNodeState::Locked:
case ESkillNodeState::Available:
// Update state based on prerequisites
if (ArePrerequisitesMet(SkillNode.NodeData))
{
SkillNode.CurrentState = ESkillNodeState::Available;
}
else
{
SkillNode.CurrentState = ESkillNodeState::Locked;
// Calculate new state based on prerequisites
ESkillNodeState NewState = ArePrerequisitesMet(SkillNode.NodeData)
? ESkillNodeState::Available
: ESkillNodeState::Locked;
// Only broadcast if state actually changed
if (SkillNode.CurrentState != NewState)
{
SkillNode.CurrentState = NewState;
OnSkillStateChanged.Broadcast(SkillID);
}
}
break;
}

View File

@@ -196,19 +196,21 @@ void AUTAD_UIPlayerController::ShowSkillTree()
{
SkillTreeWidget->AddToViewport(1);
// Switch to UI-only input mode to block gameplay actions (like click-to-move)
FInputModeUIOnly InputMode;
InputMode.SetWidgetToFocus(SkillTreeWidget->TakeWidget());
// Use GameAndUI mode - allows Enhanced Input to work while UI is open
// Mouse clicks will be consumed by UI widgets automatically
FInputModeGameAndUI InputMode;
InputMode.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock);
InputMode.SetHideCursorDuringCapture(false);
SetInputMode(InputMode);
bShowMouseCursor = true;
// Switch input mapping context from gameplay to UI
// This allows UI-specific controls (like Tab to close) to work
if (UEnhancedInputLocalPlayerSubsystem* Subsystem =
ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(
GetLocalPlayer()))
{
// Remove gameplay context
// Remove gameplay context to prevent movement actions
if (DefaultMappingContext)
{
Subsystem->RemoveMappingContext(DefaultMappingContext);
@@ -227,9 +229,11 @@ void AUTAD_UIPlayerController::HideSkillTree()
if (SkillTreeWidget && SkillTreeWidget->IsInViewport())
{
// Clear any unconfirmed skill selections
if (AUTAD_UICharacter* Character = Cast<AUTAD_UICharacter>(GetPawn()))
if (const AUTAD_UICharacter* PlayerCharacter =
Cast<AUTAD_UICharacter>(GetPawn()))
{
if (USkillTreeComponent* SkillTreeComp = Character->GetSkillTreeComponent())
if (USkillTreeComponent* SkillTreeComp =
PlayerCharacter->GetSkillTreeComponent())
{
SkillTreeComp->ClearSelection();
}