From 14f4ff4d3558bfa794d4706d3b02a4a6d831a2fc Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Sun, 21 May 2023 15:19:18 +0100 Subject: [PATCH] Bugfix Focus Issues in Inventory & Able to Open Inventory in Shop Able to consistently open & close the inventory without losing focus on root widget --- .../Blueprints/Game_UI/WBP_ItemDisplay.uasset | 4 +- .../Game_UI/WBP_PlayerInventory.uasset | 4 +- .../Blueprints/Game_UI/WBP_Settings.uasset | 4 +- .../Inventory_UI/WBP_ItemDisplay.uasset | 3 - .../Inventory_UI/WBP_PlayerInventory.uasset | 3 - .../Merchant_UI/BP_ShopSelector.uasset | 4 +- .../Merchant/Merchant_UI/WBP_BuyBuff.uasset | 4 +- .../Merchant_UI/WBP_BuyHealing.uasset | 4 +- .../Player/BP_MyTempCharacter.uasset | 4 +- Content/Blueprints/Quest_UI/Quest_UI.uasset | 4 +- Content/Levels/Build.umap | 2 +- .../BaseItems/Items/EatableItems.cpp | 6 ++ .../MerchantInteraction/Interaction.cpp | 14 +---- .../MerchantInteraction/Interaction.h | 2 +- .../PlayerTemp/TempCharacter.cpp | 56 +++++-------------- .../PlayerTemp/TempCharacter.h | 1 + 16 files changed, 42 insertions(+), 77 deletions(-) delete mode 100644 Content/Blueprints/Inventory_UI/WBP_ItemDisplay.uasset delete mode 100644 Content/Blueprints/Inventory_UI/WBP_PlayerInventory.uasset diff --git a/Content/Blueprints/Game_UI/WBP_ItemDisplay.uasset b/Content/Blueprints/Game_UI/WBP_ItemDisplay.uasset index 6c4f8b6..bf678fe 100644 --- a/Content/Blueprints/Game_UI/WBP_ItemDisplay.uasset +++ b/Content/Blueprints/Game_UI/WBP_ItemDisplay.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eb362d425c7d70fe582c70770546db10ae06edf17897cebb44519235c22324d8 -size 92315 +oid sha256:39325c23d1b84233f230dd4938b9f2cac6ef7d607af2497c4d8d3f8fc977b046 +size 92371 diff --git a/Content/Blueprints/Game_UI/WBP_PlayerInventory.uasset b/Content/Blueprints/Game_UI/WBP_PlayerInventory.uasset index c6e0cca..90ac478 100644 --- a/Content/Blueprints/Game_UI/WBP_PlayerInventory.uasset +++ b/Content/Blueprints/Game_UI/WBP_PlayerInventory.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:69e916f45c76266e666342ce69afd6e311613ad1b11c70107d194291e6c1468c -size 141254 +oid sha256:32639b04b8b52dbd4429e7c4a27afc63eb2c1665db77136dd346a65d2199f5ba +size 108861 diff --git a/Content/Blueprints/Game_UI/WBP_Settings.uasset b/Content/Blueprints/Game_UI/WBP_Settings.uasset index d1849fd..332ff81 100644 --- a/Content/Blueprints/Game_UI/WBP_Settings.uasset +++ b/Content/Blueprints/Game_UI/WBP_Settings.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c2e39579f2872ca8b9d5290cb2c075feed9a80795102a876df5c50592197fe2d -size 99082 +oid sha256:8c79086d1253e810181a6549b2f7878eeb35ae83680f01b85b064fdeafe4eccd +size 59074 diff --git a/Content/Blueprints/Inventory_UI/WBP_ItemDisplay.uasset b/Content/Blueprints/Inventory_UI/WBP_ItemDisplay.uasset deleted file mode 100644 index 6e0581f..0000000 --- a/Content/Blueprints/Inventory_UI/WBP_ItemDisplay.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:037cf94bfad007a231997881349b31fe002219d0c98eae0285022ddee2de6e0f -size 75824 diff --git a/Content/Blueprints/Inventory_UI/WBP_PlayerInventory.uasset b/Content/Blueprints/Inventory_UI/WBP_PlayerInventory.uasset deleted file mode 100644 index 2a91515..0000000 --- a/Content/Blueprints/Inventory_UI/WBP_PlayerInventory.uasset +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:fd6ffc07b98733694c91e0765050ee36312bbf61a6766e7561a2fcfd4cfafeef -size 134102 diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset index 4afc3c8..a9213a7 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0734a14208325596bc3d88d93fe269e3ceee5b10be518af23976a1063f00c7e9 -size 85740 +oid sha256:21b5310291b92a339556433e51aab382a32463c84744fe3be78a1689aed6b5d0 +size 98246 diff --git a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset index 914fd9a..807585e 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:78f9bd03821449914bca7960ae0090fea1cbedd7c9ad184db32eadcd9ca99396 -size 70670 +oid sha256:3a6ccc9ad3d2b4c7b5bbf29f09914b56cffe449b488b2d228314b7ef84d93af2 +size 70482 diff --git a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset index e1a5bd8..5633d03 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:546345d3635e5ee96e6957c4ea50339826cb7c8014d92ce53b8d22fb8f2eb43f -size 70900 +oid sha256:c5e4cd3b1e162052166603df59ef2164cb534f3f76dbe73614ed32557c8f9598 +size 70708 diff --git a/Content/Blueprints/Player/BP_MyTempCharacter.uasset b/Content/Blueprints/Player/BP_MyTempCharacter.uasset index d207cb9..36c4e69 100644 --- a/Content/Blueprints/Player/BP_MyTempCharacter.uasset +++ b/Content/Blueprints/Player/BP_MyTempCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e60e91a99d04a203412eda67fb471e1d62ca177bea62013350c8473657bcc199 -size 210512 +oid sha256:15d53fc6fc0e249454ea466145bbdcbce825066f7fb16df0be2c69391d659456 +size 267370 diff --git a/Content/Blueprints/Quest_UI/Quest_UI.uasset b/Content/Blueprints/Quest_UI/Quest_UI.uasset index d963e74..23d7bd4 100644 --- a/Content/Blueprints/Quest_UI/Quest_UI.uasset +++ b/Content/Blueprints/Quest_UI/Quest_UI.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:282e2ac7fd7d005ad5fc112fb12cef0895aca57c3a740c86781ae73c16442e3a -size 46040 +oid sha256:216f87ffc5cca1b40b515ee11a71ccb4800069981a48c3d7692c9bdc7c5164cd +size 46122 diff --git a/Content/Levels/Build.umap b/Content/Levels/Build.umap index bf5a1da..3b9bb7d 100644 --- a/Content/Levels/Build.umap +++ b/Content/Levels/Build.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a93bf013138aba949a329f024275cdd0707032fcd1719ddfb73e8ae8c64b9c56 +oid sha256:43614caa4e3909c75514f92a5ee79d07dfa862caf06a90a97055f8acda6489aa size 5617248 diff --git a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp index 5056473..c080f54 100644 --- a/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp +++ b/Source/the_twilight_abyss/BaseItems/Items/EatableItems.cpp @@ -24,11 +24,13 @@ void UEatableItems::Use(ATempCharacter* Character) { Character->Health = FMath::Clamp(Character->Health + 20, 0, 100); Character->Inventory->RemoveItem(this); + return; } else if (Character->Health >= 100) { UE_LOG(LogTemp, Display, TEXT("Health is full")); GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("Health is full")); + return; } } @@ -38,6 +40,7 @@ void UEatableItems::Use(ATempCharacter* Character) StatusSystem->AddStatusEffect(NewObject(Character, StrengthBuffStatusEffect)); UE_LOG(LogTemp, Display, TEXT("Damage Buffed")); Character->Inventory->RemoveItem(this); + return; } if (isProbertiumType) @@ -49,6 +52,7 @@ void UEatableItems::Use(ATempCharacter* Character) TurnBaseCombat->ProbertiumResource = FMath::Clamp(TurnBaseCombat->ProbertiumResource + 2, 0, 20); Character->Inventory->RemoveItem(this); } + return; } if (isEisType) @@ -60,6 +64,7 @@ void UEatableItems::Use(ATempCharacter* Character) TurnBaseCombat->EisResource = FMath::Clamp(TurnBaseCombat->EisResource + 2, 0, 20); Character->Inventory->RemoveItem(this); } + return; } if (isAzosType) @@ -71,6 +76,7 @@ void UEatableItems::Use(ATempCharacter* Character) TurnBaseCombat->AzosResource = FMath::Clamp(TurnBaseCombat->AzosResource + 2, 0, 20); Character->Inventory->RemoveItem(this); } + return; } if (isIroquoidType) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index 48c4db6..f743fa6 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -90,18 +90,9 @@ void AInteraction::RemoveWidget() //Character & Camera refs TempCharacterRef = Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()); MainCamera = Cast(TempCharacterRef->FindComponentByClass()); + TempCharacterRef->bShopKeeperText = true; bDisableShopDialMove = true; 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")); Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::Hidden); if (Property == nullptr) @@ -208,9 +199,10 @@ void AInteraction::ExitScreen() } else { - TempCharacterRef->InputEnabler(); ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()->GetComponentByClass(UQuestSystem::StaticClass()))->QuestWidgetInstance->SetVisibility(ESlateVisibility::HitTestInvisible); + TempCharacterRef->bShopKeeperText = false; + TempCharacterRef->InputEnabler(); } } diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index 7481d80..8a5209b 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -45,7 +45,7 @@ public: UPROPERTY() UUserWidget* ShopDialogWidget; - UPROPERTY() + UPROPERTY(BlueprintReadOnly) UUserWidget* ItemSelectorWidget; UPROPERTY() diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index d67f3d0..c24d8ec 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -147,12 +147,12 @@ void ATempCharacter::LineTraceLogic() { return; } - if(OutHit.GetActor()->ActorHasTag(TEXT("Probertium"))) + if (OutHit.GetActor()->ActorHasTag(TEXT("Probertium"))) { AddToInventory(); return; } - if(OutHit.GetActor()->ActorHasTag(TEXT("Iroquid"))) + if (OutHit.GetActor()->ActorHasTag(TEXT("Iroquid"))) { AddToInventory(); return; @@ -184,38 +184,12 @@ void ATempCharacter::LineTraceLogic() } // if the actor hit has the interaction component/script then it will activate the code - if (AInteraction* MyInteractable = Cast(OutHit.GetActor())) + if (const AInteraction* MyInteractable = Cast(OutHit.GetActor())) { if (MyInteractable->ShopDialogWidget->IsVisible()) { 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()) - { - 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; - // } - // } - } } } } @@ -243,19 +217,16 @@ void ATempCharacter::AddToInventory() void ATempCharacter::InputDisabler() { - //Disable Character Movement - if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) - { - PlayerCharacter->DisableInput(GetWorld()->GetFirstPlayerController()); - } //TURNING OFF CROSSHAIR CrossHairWidget->SetVisibility(ESlateVisibility::Hidden); - + //Set to UI Mode Only APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); - PlayerController->SetInputMode(FInputModeUIOnly()); + PlayerController->SetInputMode(FInputModeGameAndUI()); PlayerController->bShowMouseCursor = true; + PlayerController->SetIgnoreMoveInput(true); + PlayerController->SetIgnoreLookInput(true); disableTab = true; if (ThisCamera != nullptr) @@ -269,18 +240,20 @@ void ATempCharacter::InputDisabler() void ATempCharacter::InputEnabler() { - //Enable Character Movement - if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) - { - PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController()); - } //Reset UI Mode APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); PlayerController->SetInputMode(FInputModeGameOnly()); PlayerController->bShowMouseCursor = false; PlayerController->SetIgnoreMoveInput(false); PlayerController->SetIgnoreLookInput(false); + CrossHairWidget->SetVisibility(ESlateVisibility::HitTestInvisible); + //Enable Character Movement + if (ACharacter* PlayerCharacter = Cast(GetWorld()->GetFirstPlayerController()->GetPawn())) + { + PlayerCharacter->EnableInput(GetWorld()->GetFirstPlayerController()); + } + UE_LOG(LogTemp, Display, TEXT("Enabling Inputs")); disableTab = true; TraceDistance = 300; @@ -326,5 +299,4 @@ void ATempCharacter::BuyItem(AActor* Item) TraceDistance = 1000; LineTraceLogic(); } - } diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 33b97bc..f136c58 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -94,6 +94,7 @@ public: UFUNCTION(BlueprintCallable, Category= "Items") void BuyItem(AActor* Item); + UPROPERTY(BlueprintReadOnly) bool bShopKeeperText = false; UPROPERTY(BlueprintReadWrite)