From f33c43689bf905bc720fb4342e34efc2d5b5f434 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 30 Jan 2023 21:07:36 +0000 Subject: [PATCH] Updated Interaction,TempCharacter.cpp Fixed being able to open the text widget while the selector is open so merchant is fully working now. --- .../MerchantInteraction/Interaction.cpp | 8 ++++ .../MerchantInteraction/Interaction.h | 1 + .../PlayerTemp/TempCharacter.cpp | 39 ++++++++++++++----- .../PlayerTemp/TempCharacter.h | 2 + 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index f8589fd..beaad39 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -93,6 +93,14 @@ void AInteraction::RemoveWidget() bisDisabled = true; //Setting ShopWidgetText back to hidden ShopDialogWidget->SetVisibility(ESlateVisibility::Hidden); + if (ShopDialogWidget->IsVisible()) + { + return; + } + else + { + UE_LOG(LogTemp, Display, TEXT("You cant open this widget when this widget is open")); + } UE_LOG(LogTemp, Display, TEXT("setting isDisabled to true")); if (Property == nullptr) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index 798c680..76af4db 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -61,6 +61,7 @@ public: UPROPERTY() bool bDisableShopDialMove = false; + UFUNCTION(BlueprintCallable, Category= "ButtonLeft") virtual void CameraLeftMover(); diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index d646157..bfdfe06 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -101,18 +101,35 @@ void ATempCharacter::LineTraceLogic() if (AInteraction* MyInteractable = Cast(OutHit.GetActor())) { - DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); - MyInteractable->OnInteract(); - UE_LOG(LogTemp, Display, TEXT("OnInteract activated")); - UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); - - // While loop to check bisDisabled var until it changes to true - while (MyInteractable->bisDisabled == false || MyInteractable->bDisableShopDialMove == false) + if (MyInteractable->ShopDialogWidget->IsVisible()) { - if (MyInteractable->bisDisabled == true || MyInteractable->bDisableShopDialMove == true) + UE_LOG(LogTemp, Display, TEXT("ShopKeeper text is visible")); + bShopKeeperText = true; + return; + } + //if there is no text on screen this triggers + else + { + if (MyInteractable->ItemSelectorWidget->IsVisible()) { - InputDisabler(); - break; + return; + } + else + { + DrawDebugLine(GetWorld(), Start, End, FColor::Green, false, 1.0f); + MyInteractable->OnInteract(); + UE_LOG(LogTemp, Display, TEXT("OnInteract activated")); + UE_LOG(LogTemp, Display, TEXT("HIT: %s"), *OutHit.GetActor()->GetName()); + + // While loop to check bisDisabled var until it changes to true + while (MyInteractable->bisDisabled == false || MyInteractable->bDisableShopDialMove == false) + { + if (MyInteractable->bisDisabled == true || MyInteractable->bDisableShopDialMove == true) + { + InputDisabler(); + break; + } + } } } } @@ -122,6 +139,7 @@ void ATempCharacter::LineTraceLogic() void ATempCharacter::InputDisabler() { UE_LOG(LogTemp, Display, TEXT("Disabling playermovement")); + //GetWorld()->GetFirstPlayerController()->InputComponent->RemoveActionBinding("Interact", IE_Pressed); GetWorld()->GetFirstPlayerController()->SetIgnoreLookInput(true); GetWorld()->GetFirstPlayerController()->SetIgnoreMoveInput(true); GetWorld()->GetFirstPlayerController()->bShowMouseCursor = true; @@ -150,6 +168,7 @@ void ATempCharacter::InputEnabler() GetWorld()->GetFirstPlayerController()->bShowMouseCursor = false; GetWorld()->GetFirstPlayerController()->bEnableClickEvents = false; GetWorld()->GetFirstPlayerController()->bEnableMouseOverEvents = false; + //GetWorld()->GetFirstPlayerController()->InputComponent->BindAction("Interact", IE_Pressed, this, &ATempCharacter::KeyPressed); TraceDistance = 300; ThisCamera = Cast(this->FindComponentByClass()); if (ThisCamera == nullptr) diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 9bb3b3f..928b8df 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -75,5 +75,7 @@ public: UFUNCTION(BlueprintCallable, Category= "Items") void BuyItem(); + + bool bShopKeeperText = false; };