From b9d87ee07bcbc3b2152ad64934dacaa485a227ae Mon Sep 17 00:00:00 2001 From: MH261677 Date: Sat, 21 Jan 2023 14:19:49 +0000 Subject: [PATCH 01/11] Updated Unreal version to 5.1 --- Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset | 4 ++-- Content/Levels/MerchantPrototype.umap | 4 ++-- the_twilight_abyss.uproject | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset index cb0fa3a..f580e91 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5aba7e76546797d974d8c1fbb2f989416f27912dbd289acc8c16a5bc5b25eefd -size 70965 +oid sha256:a7a22deed0ed1e3d3a13f3e5bd3747798c9d116232832bb92aae43d321216ba7 +size 70616 diff --git a/Content/Levels/MerchantPrototype.umap b/Content/Levels/MerchantPrototype.umap index 7daa7d9..d648c7a 100644 --- a/Content/Levels/MerchantPrototype.umap +++ b/Content/Levels/MerchantPrototype.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ffba42fc8f6527bb83238b65ee72d5d2de2589f1d1bc825c23c5d86fc732889 -size 27144 +oid sha256:ebb8b1c4142831775542c0bcb3400dc138a3360ffe820dd74cd460af4b914a53 +size 26504 diff --git a/the_twilight_abyss.uproject b/the_twilight_abyss.uproject index 4f33989..73e857f 100644 --- a/the_twilight_abyss.uproject +++ b/the_twilight_abyss.uproject @@ -1,6 +1,6 @@ { "FileVersion": 3, - "EngineAssociation": "5.0", + "EngineAssociation": "5.1", "Category": "", "Description": "", "Modules": [ From 3f4cdf5bfacd66111589a0b57b3343457d1f9e65 Mon Sep 17 00:00:00 2001 From: MARCEL HARA Date: Mon, 23 Jan 2023 16:14:15 +0000 Subject: [PATCH 02/11] Updated Interaction.cpp Optimized some functions and variables by storing them in beginplay --- Content/Levels/MerchantPrototype.umap | 4 ++-- .../MerchantInteraction/Interaction.cpp | 23 ++++++++----------- .../MerchantInteraction/Interaction.h | 18 ++++++++++++--- .../PlayerTemp/TempCharacter.h | 2 ++ 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Content/Levels/MerchantPrototype.umap b/Content/Levels/MerchantPrototype.umap index d648c7a..da545bd 100644 --- a/Content/Levels/MerchantPrototype.umap +++ b/Content/Levels/MerchantPrototype.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ebb8b1c4142831775542c0bcb3400dc138a3360ffe820dd74cd460af4b914a53 -size 26504 +oid sha256:5efb970894cb114a37a45fac46558718d0fa4bfed2b9900eebd2a752fc71d021 +size 26607 diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index 192d23c..f8a95f4 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -22,7 +22,10 @@ AInteraction::AInteraction() void AInteraction::BeginPlay() { Super::BeginPlay(); - + TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); + MainCamera = Cast(TempCharacter->FindComponentByClass()); + TargetHealingLocation = HealingItem->GetActorLocation(); + TargetBuffLocation = BuffItem->GetActorLocation(); } // Called every frame @@ -80,8 +83,6 @@ void AInteraction::RemoveWidget() void AInteraction::CameraLeftMover() { UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed")); - TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); - MainCamera = Cast(TempCharacter->FindComponentByClass()); if (TempCharacter == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); @@ -90,16 +91,15 @@ void AInteraction::CameraLeftMover() else { UE_LOG(LogTemp, Display, TEXT("Character Found in interaction.cpp")); - if (MainCamera == nullptr) + if (MainCamera == nullptr || HealingItem == nullptr) { UE_LOG(LogTemp, Display, TEXT("Camera not found in Interaction.cpp")); return; } else { - FVector TargetLocation = FVector(5700,-1270,4040); - FVector CameraLocation = MainCamera->GetComponentLocation(); - FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetLocation); + CameraLocation = MainCamera->GetComponentLocation(); + FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetHealingLocation); MainCamera->SetWorldRotation(CameraRotation); MainCamera->SetFieldOfView(40); } @@ -109,8 +109,6 @@ void AInteraction::CameraLeftMover() void AInteraction::CameraRightMover() { UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed")); - TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); - MainCamera = Cast(TempCharacter->FindComponentByClass()); if (TempCharacter == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); @@ -119,16 +117,15 @@ void AInteraction::CameraRightMover() else { UE_LOG(LogTemp, Display, TEXT("Character Found in interaction.cpp")); - if (MainCamera == nullptr) + if (MainCamera == nullptr || BuffItem == nullptr) { UE_LOG(LogTemp, Display, TEXT("Camera not found in Interaction.cpp")); return; } else { - FVector TargetLocation = FVector(5260, -840, 4070); - FVector CameraLocation = MainCamera->GetComponentLocation(); - FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetLocation); + CameraLocation = MainCamera->GetComponentLocation(); + FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetBuffLocation); MainCamera->SetWorldRotation(CameraRotation); MainCamera->SetFieldOfView(40); } diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index fb771a9..09e9478 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -24,10 +24,10 @@ public: // Called every frame virtual void Tick(float DeltaTime) override; - UPROPERTY(EditAnywhere) + UPROPERTY(EditAnywhere, Category= "Widgets") TSubclassOf ShopDialog; - UPROPERTY(EditAnywhere) + UPROPERTY(EditAnywhere, Category= "Widgets") TSubclassOf ItemSelector; virtual void OnInteract(); @@ -40,7 +40,7 @@ public: UPROPERTY() UUserWidget* ItemSelectorWidget; - UPROPERTY(EditAnywhere) + UPROPERTY(EditAnywhere, Category= "Widgets") float WaitTimer = 8.0f; UPROPERTY() @@ -60,5 +60,17 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player") ACharacter* TempCharacter; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") + AActor* HealingItem; + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") + AActor* BuffItem; + +private: + + FVector TargetHealingLocation; + FVector TargetBuffLocation; + FVector CameraLocation; }; diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 052239c..51c6394 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -43,6 +43,8 @@ public: void InputDisabler(); void LineTraceLogic(); + + UPROPERTY(BlueprintReadWrite, EditAnywhere, Category= "Health") float Health; From c58d5d559248613552d0d52a0d22e443a0635fd5 Mon Sep 17 00:00:00 2001 From: MARCEL HARA Date: Mon, 23 Jan 2023 17:41:30 +0000 Subject: [PATCH 03/11] Updated BP_OPENDIAL Added a custom function which gets triggered in the Interaction.cpp --- Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset | 4 ++-- .../Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset index f580e91..dc438bc 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a7a22deed0ed1e3d3a13f3e5bd3747798c9d116232832bb92aae43d321216ba7 -size 70616 +oid sha256:f4e2e52de4ba0356ffd218c3f18d45903c162a857fb635aa19bd314977af161e +size 68688 diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset index 0c71209..53b7f18 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:22b2132cd76cdc49d851a897a8295bac996dd4b048ee16722f3747a0b0a0fd42 -size 68094 +oid sha256:b4e6415a58a3ef112e7b2a99f67fe5a422f483ef40fa3bf749fea08ea1589e24 +size 67237 From ddc2ef526dedffc5eba951285ed185efd00d7a46 Mon Sep 17 00:00:00 2001 From: MARCEL HARA Date: Mon, 23 Jan 2023 17:41:55 +0000 Subject: [PATCH 04/11] Updated Interaction.cpp Optimized more code by caching more widgets and instead of creating new widgets I am just toggling them on and off. --- .../MerchantInteraction/Interaction.cpp | 32 +++++++++++++++---- .../MerchantInteraction/Interaction.h | 3 ++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index f8a95f4..89e3eef 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -22,10 +22,27 @@ AInteraction::AInteraction() void AInteraction::BeginPlay() { Super::BeginPlay(); + + //Character refs TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); MainCamera = Cast(TempCharacter->FindComponentByClass()); + + //Item refs + TargetHealingLocation = HealingItem->GetActorLocation(); TargetBuffLocation = BuffItem->GetActorLocation(); + + // Dialog refs + + ShopDialogWidget = CreateWidget(GetWorld(), ShopDialog); + ShopDialogWidget->SetVisibility(ESlateVisibility::Hidden); + ShopDialogWidget->AddToViewport(); + + //Item Selector refs + ItemSelectorWidget = CreateWidget(GetWorld(), ItemSelector); + ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); + ItemSelectorWidget->AddToViewport(); + Property = ItemSelectorWidget->GetClass()->FindPropertyByName("publicActor"); } // Called every frame @@ -38,14 +55,17 @@ void AInteraction::Tick(float DeltaTime) void AInteraction::OnInteract() { bDisableShopDialMove = true; - ShopDialogWidget = CreateWidget(GetWorld(), ShopDialog); if (ShopDialogWidget == nullptr) { + UE_LOG(LogTemp, Display, TEXT("ShopDialogWidget is null")); return; } else { - ShopDialogWidget->AddToViewport(0); + //Shop Widget to visible + ShopDialogWidget->SetVisibility(ESlateVisibility::Visible); + //Call a custom event in a blueprint called "PlayText" + ShopDialogWidget->CallFunctionByNameWithArguments(TEXT("PlayText"), *GLog, nullptr, true); } //handles the widget disappearing from the viewport FTimerHandle WidgetTimer; @@ -56,10 +76,10 @@ void AInteraction::OnInteract() void AInteraction::RemoveWidget() { bisDisabled = true; - ShopDialogWidget->RemoveFromViewport(); + //Setting ShopWidgetText back to hidden + ShopDialogWidget->SetVisibility(ESlateVisibility::Hidden); UE_LOG(LogTemp, Display, TEXT("setting isDisabled to true")); - ItemSelectorWidget = CreateWidget(GetWorld(), ItemSelector); - FProperty* Property = ItemSelectorWidget->GetClass()->FindPropertyByName("publicActor"); + if (Property == nullptr) { UE_LOG(LogTemp, Error, TEXT("Property not found")); @@ -75,7 +95,7 @@ void AInteraction::RemoveWidget() } else { - ItemSelectorWidget->AddToViewport(0); + ItemSelectorWidget->SetVisibility(ESlateVisibility::Visible); bisDisabled = false; } } diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index 09e9478..8b9e5a7 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -66,11 +66,14 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") AActor* BuffItem; + private: FVector TargetHealingLocation; FVector TargetBuffLocation; FVector CameraLocation; + + FProperty* Property; }; From 2f22ec811f893d4e405dd6d1c2ac62726ce84be0 Mon Sep 17 00:00:00 2001 From: MARCEL HARA Date: Thu, 26 Jan 2023 17:41:51 +0000 Subject: [PATCH 05/11] Updated Merchant_UI Removed things being removed from parent and transferred it from code to fix many bugs, Also fixed text being instantly displayed once you talk to the merchant again --- Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset | 4 ++-- .../Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset | 4 ++-- Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset | 4 ++-- Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset | 4 ++-- Content/Levels/MerchantPrototype.umap | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset index dc438bc..239df23 100644 --- a/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset +++ b/Content/Blueprints/Merchant/Merchant_UI/BP_OPENDIAL.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f4e2e52de4ba0356ffd218c3f18d45903c162a857fb635aa19bd314977af161e -size 68688 +oid sha256:dd57bdf81793aa6f3b76784e3be306fef5ca81c5e2fa7065a29abadd420c4e0b +size 75420 diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset index 53b7f18..f4f9818 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:b4e6415a58a3ef112e7b2a99f67fe5a422f483ef40fa3bf749fea08ea1589e24 -size 67237 +oid sha256:42aa0e6d25904de056d4d64509aa7c804155c5b3a212ada658ca10dcb63f3e32 +size 55403 diff --git a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyBuff.uasset index 3d3b44f..7eecebb 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:8cc4e9151595d71a12c6f44c47b8f62ebb2687944cc124a6927fb8cddcf6a1fc -size 51431 +oid sha256:abe53946825159c2220acd237c3cc7360478b63836d52e3cbe000876e43eb5d5 +size 63822 diff --git a/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset b/Content/Blueprints/Merchant/Merchant_UI/WBP_BuyHealing.uasset index 5420305..8e7650a 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:4f15b92c944a3038b636058b7f8fb3a6573a2ec271c3a6a1670bb5b9541c9d7c -size 52018 +oid sha256:936f77df55a4f4c1baca361f8ca9384f1af821ab6c0e8c9b016a3ede25c9f8d1 +size 63821 diff --git a/Content/Levels/MerchantPrototype.umap b/Content/Levels/MerchantPrototype.umap index da545bd..ea85903 100644 --- a/Content/Levels/MerchantPrototype.umap +++ b/Content/Levels/MerchantPrototype.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5efb970894cb114a37a45fac46558718d0fa4bfed2b9900eebd2a752fc71d021 -size 26607 +oid sha256:838c48c134383d4b1db178233640e11ef2c4bcd49102f53648cf621dd1dcbf8a +size 27100 From 6faa177f962175d15c851fc27e05f03f3a85dbbd Mon Sep 17 00:00:00 2001 From: MARCEL HARA Date: Thu, 26 Jan 2023 17:43:07 +0000 Subject: [PATCH 06/11] Updated Interaction.cpp Referenced the two buy confirms screen so I can just hide them and cache them upon the start of the game to optimize and fix many bugs such as being able to stack the buy screens. --- .../MerchantInteraction/Interaction.cpp | 46 ++++++++++++++++++- .../MerchantInteraction/Interaction.h | 22 +++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index 89e3eef..a029e95 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -42,7 +42,21 @@ void AInteraction::BeginPlay() ItemSelectorWidget = CreateWidget(GetWorld(), ItemSelector); ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); ItemSelectorWidget->AddToViewport(); + //We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self Property = ItemSelectorWidget->GetClass()->FindPropertyByName("publicActor"); + + //Confirm Buy refs + BuyBuffTextWidget = CreateWidget(GetWorld(), BuyBuffText); + BuyBuffTextWidget->SetVisibility(ESlateVisibility::Hidden); + BuyBuffTextWidget->AddToViewport(); + //We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self + BuyBuffProperty = BuyBuffTextWidget->GetClass()->FindPropertyByName("publicActor"); + + BuyHealingTextWidget = CreateWidget(GetWorld(), BuyHealingText); + BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden); + BuyHealingTextWidget->AddToViewport(); + //We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self + BuyHealingProperty = BuyHealingTextWidget->GetClass()->FindPropertyByName("publicActor"); } // Called every frame @@ -83,6 +97,7 @@ void AInteraction::RemoveWidget() if (Property == nullptr) { UE_LOG(LogTemp, Error, TEXT("Property not found")); + return; } else { @@ -103,7 +118,7 @@ void AInteraction::RemoveWidget() void AInteraction::CameraLeftMover() { UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed")); - if (TempCharacter == nullptr) + if (TempCharacter == nullptr || BuyHealingProperty == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); return; @@ -118,10 +133,14 @@ void AInteraction::CameraLeftMover() } else { + FObjectPropertyBase* ObjectProperty = static_cast(BuyHealingProperty); + ObjectProperty->SetObjectPropertyValue(ObjectProperty->ContainerPtrToValuePtr(BuyHealingTextWidget), this); + CameraLocation = MainCamera->GetComponentLocation(); FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetHealingLocation); MainCamera->SetWorldRotation(CameraRotation); MainCamera->SetFieldOfView(40); + BuyHealingTextWidget->SetVisibility(ESlateVisibility::Visible); } } } @@ -129,7 +148,7 @@ void AInteraction::CameraLeftMover() void AInteraction::CameraRightMover() { UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed")); - if (TempCharacter == nullptr) + if (TempCharacter == nullptr || BuyBuffProperty == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); return; @@ -144,10 +163,33 @@ void AInteraction::CameraRightMover() } else { + FObjectPropertyBase* ObjectProperty = static_cast(BuyBuffProperty); + ObjectProperty->SetObjectPropertyValue(ObjectProperty->ContainerPtrToValuePtr(BuyBuffTextWidget), this); + CameraLocation = MainCamera->GetComponentLocation(); FRotator CameraRotation = UKismetMathLibrary::FindLookAtRotation(CameraLocation, TargetBuffLocation); MainCamera->SetWorldRotation(CameraRotation); MainCamera->SetFieldOfView(40); + BuyBuffTextWidget->SetVisibility(ESlateVisibility::Visible); } } } + +void AInteraction::CancelPurchase() +{ + BuyBuffTextWidget->SetVisibility(ESlateVisibility::Hidden); + BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden); +} + +void AInteraction::HealingPurchase() +{ + +} + +void AInteraction::BuffPurchase() +{ + +} + + + diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index 8b9e5a7..72b0afb 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -30,6 +30,12 @@ public: UPROPERTY(EditAnywhere, Category= "Widgets") TSubclassOf ItemSelector; + UPROPERTY(EditAnywhere, Category = "Widgets") + TSubclassOf BuyBuffText; + + UPROPERTY(EditAnywhere, Category = "Widgets") + TSubclassOf BuyHealingText; + virtual void OnInteract(); virtual void RemoveWidget(); @@ -39,6 +45,12 @@ public: UPROPERTY() UUserWidget* ItemSelectorWidget; + + UPROPERTY() + UUserWidget* BuyBuffTextWidget; + + UPROPERTY() + UUserWidget* BuyHealingTextWidget; UPROPERTY(EditAnywhere, Category= "Widgets") float WaitTimer = 8.0f; @@ -67,6 +79,14 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") AActor* BuffItem; + UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") + virtual void CancelPurchase(); + + UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") + virtual void HealingPurchase(); + + UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") + virtual void BuffPurchase(); private: @@ -75,5 +95,7 @@ private: FVector CameraLocation; FProperty* Property; + FProperty* BuyBuffProperty; + FProperty* BuyHealingProperty; }; From 810b4b1680dc024a1a56861eafa792b7ad3a5ecf Mon Sep 17 00:00:00 2001 From: MARCEL HARA Date: Thu, 26 Jan 2023 18:12:24 +0000 Subject: [PATCH 07/11] TemporarilyBroken TempCharacter.cpp Attempted to fix the close button currently it crashes. --- Content/Blueprints/Combat_UI/CombatCharacter.uasset | 4 ++-- .../Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset | 4 ++-- Content/Blueprints/Player/BP_MyTempCharacter.uasset | 4 ++-- Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp | 2 +- Source/the_twilight_abyss/PlayerTemp/TempCharacter.h | 6 ++++++ 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index 95ef963..af30af7 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:465dda65f6f573e5b213f73e85bf00219e3bbcc762d215532bb138add6695028 -size 82954 +oid sha256:fe3a4ab394636a9f640bfd6b48f1124b36aa73681728412f0aa58ad4d604cb8e +size 79935 diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset index f4f9818..3659a77 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:42aa0e6d25904de056d4d64509aa7c804155c5b3a212ada658ca10dcb63f3e32 -size 55403 +oid sha256:1e9ac1ff7478dfef5edd2254f1241a9b10b7b79d228f1c7fa962c0579a7b2183 +size 53418 diff --git a/Content/Blueprints/Player/BP_MyTempCharacter.uasset b/Content/Blueprints/Player/BP_MyTempCharacter.uasset index 3cd68ed..a5cecf1 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:48787fb18ad9d51b32e5b837c8c1605b11d1b60014c75f2efa1ab910d621415b -size 56881 +oid sha256:443a43ffede70052c0fb3aa89ba6b5ed76bbe89ac6526cead6d574165d0e1c36 +size 54865 diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index 50029de..da1d08c 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -161,7 +161,7 @@ void ATempCharacter::InputEnabler() ThisCamera->SetWorldLocation(OriginalCameraLocation); ThisCamera->SetWorldRotation(OriginalCameraRotation); ThisCamera->FieldOfView = OriginalCameraFOV; - + ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); //ulog the originalcameralocation value UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); } diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 51c6394..5333280 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -32,6 +32,12 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true")) class UInventoryComponent* Inventory; //Using the InventoryComponent class + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ItemSelector") + UUserWidget* ItemSelectorWidget; + + UPROPERTY(EditAnywhere, Category = "Widgets") + TSubclassOf ItemSelector; + // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; From d658c636276c1545698bc96c877fe5af9a4bbebd Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Mon, 30 Jan 2023 17:20:22 +0000 Subject: [PATCH 08/11] Updated WBP_ShopSelector Got rid of it casting from tempcharacter but instead it casts from interaction which then activates a function in interaction which activates a different function in tempcharacter --- Content/Blueprints/Combat_UI/CombatCharacter.uasset | 4 ++-- .../Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset | 4 ++-- Content/Blueprints/Player/BP_MyTempCharacter.uasset | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Content/Blueprints/Combat_UI/CombatCharacter.uasset b/Content/Blueprints/Combat_UI/CombatCharacter.uasset index af30af7..840bc9a 100644 --- a/Content/Blueprints/Combat_UI/CombatCharacter.uasset +++ b/Content/Blueprints/Combat_UI/CombatCharacter.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fe3a4ab394636a9f640bfd6b48f1124b36aa73681728412f0aa58ad4d604cb8e -size 79935 +oid sha256:39f35733eb5d9cd8382249210d2fd0ac1c18511e9202db00a69a5fe8d0c9ce36 +size 79155 diff --git a/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset b/Content/Blueprints/Merchant/Merchant_UI/BP_ShopSelector.uasset index 3659a77..0c1f862 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:1e9ac1ff7478dfef5edd2254f1241a9b10b7b79d228f1c7fa962c0579a7b2183 -size 53418 +oid sha256:0fe126443f981aa1875e8efe299d76c4f0f570aff93f9313cc9503bb811365a5 +size 51324 diff --git a/Content/Blueprints/Player/BP_MyTempCharacter.uasset b/Content/Blueprints/Player/BP_MyTempCharacter.uasset index a5cecf1..f1f038b 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:443a43ffede70052c0fb3aa89ba6b5ed76bbe89ac6526cead6d574165d0e1c36 -size 54865 +oid sha256:be58819ba52b5638a31c272d4b3d2b93cfd6c75d2ad1717183b971c1c9d78234 +size 54639 From 11e6393726c461ec605526efd817512972024fa2 Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Mon, 30 Jan 2023 17:21:10 +0000 Subject: [PATCH 09/11] Updated Interaction,TempCharacter.cpp Removed the code from TempCharacter from last commit and created a new function Inside of Interaction that activates the TempCharacter.cpp InputEnabler() --- .../MerchantInteraction/Interaction.cpp | 30 +++++++++++-------- .../MerchantInteraction/Interaction.h | 12 ++++---- .../PlayerTemp/TempCharacter.cpp | 1 - .../PlayerTemp/TempCharacter.h | 7 ++--- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index a029e95..cfd111a 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -9,6 +9,7 @@ #include "GameFramework/Character.h" #include "Components/WidgetComponent.h" #include "Kismet/KismetMathLibrary.h" +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" // Sets default values @@ -24,9 +25,8 @@ void AInteraction::BeginPlay() Super::BeginPlay(); //Character refs - TempCharacter = GetWorld()->GetFirstPlayerController()->GetCharacter(); - MainCamera = Cast(TempCharacter->FindComponentByClass()); - + TempCharacterRef = Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()); + MainCamera = Cast(TempCharacterRef->FindComponentByClass()); //Item refs TargetHealingLocation = HealingItem->GetActorLocation(); @@ -57,6 +57,7 @@ void AInteraction::BeginPlay() BuyHealingTextWidget->AddToViewport(); //We are getting the property of interaction since we need a reference for when we cast in BP and we need the reference to be self BuyHealingProperty = BuyHealingTextWidget->GetClass()->FindPropertyByName("publicActor"); + } // Called every frame @@ -118,7 +119,7 @@ void AInteraction::RemoveWidget() void AInteraction::CameraLeftMover() { UE_LOG(LogTemp, Display, TEXT("Button Left is being pressed")); - if (TempCharacter == nullptr || BuyHealingProperty == nullptr) + if (TempCharacterRef == nullptr || BuyHealingProperty == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); return; @@ -148,7 +149,7 @@ void AInteraction::CameraLeftMover() void AInteraction::CameraRightMover() { UE_LOG(LogTemp, Display, TEXT("Button Right is being pressed")); - if (TempCharacter == nullptr || BuyBuffProperty == nullptr) + if (TempCharacterRef == nullptr || BuyBuffProperty == nullptr) { UE_LOG(LogTemp, Display, TEXT("Character not found in Interaction.cpp")); return; @@ -181,15 +182,20 @@ void AInteraction::CancelPurchase() BuyHealingTextWidget->SetVisibility(ESlateVisibility::Hidden); } -void AInteraction::HealingPurchase() +void AInteraction::ExitScreen() { - -} - -void AInteraction::BuffPurchase() -{ - + if (TempCharacterRef == nullptr) + { + UE_LOG(LogTemp, Display, TEXT("TempCharacterRef in Interaction.cpp not found")); + return; + } + else + { + TempCharacterRef->InputEnabler(); + ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); + } } + diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h index 72b0afb..798c680 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.h +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.h @@ -5,6 +5,7 @@ #include "CoreMinimal.h" #include "Camera/CameraComponent.h" #include "GameFramework/Actor.h" +#include "the_twilight_abyss/PlayerTemp/TempCharacter.h" #include "Interaction.generated.h" UCLASS() @@ -70,9 +71,6 @@ public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Camera") UCameraComponent* MainCamera; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Player") - ACharacter* TempCharacter; - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Items") AActor* HealingItem; @@ -83,10 +81,10 @@ public: virtual void CancelPurchase(); UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") - virtual void HealingPurchase(); - - UFUNCTION(BlueprintCallable, Category = "ConfirmButtons") - virtual void BuffPurchase(); + virtual void ExitScreen(); + + UPROPERTY(EditAnywhere, Category = "Player") + ATempCharacter* TempCharacterRef; private: diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp index da1d08c..d646157 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.cpp @@ -161,7 +161,6 @@ void ATempCharacter::InputEnabler() ThisCamera->SetWorldLocation(OriginalCameraLocation); ThisCamera->SetWorldRotation(OriginalCameraRotation); ThisCamera->FieldOfView = OriginalCameraFOV; - ItemSelectorWidget->SetVisibility(ESlateVisibility::Hidden); //ulog the originalcameralocation value UE_LOG(LogTemp, Display, TEXT("Original Camera Location: %s"), *OriginalCameraLocation.ToString()); } diff --git a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h index 5333280..9bb3b3f 100644 --- a/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h +++ b/Source/the_twilight_abyss/PlayerTemp/TempCharacter.h @@ -31,12 +31,9 @@ public: UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Inventory, meta = (AllowPrivateAccess = "true")) class UInventoryComponent* Inventory; //Using the InventoryComponent class - - UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "ItemSelector") + + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Widgets") UUserWidget* ItemSelectorWidget; - - UPROPERTY(EditAnywhere, Category = "Widgets") - TSubclassOf ItemSelector; // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; From 63e44f47e8aae8f232928aeea9bccca302d473cc Mon Sep 17 00:00:00 2001 From: Marcel Hara Date: Mon, 30 Jan 2023 17:23:19 +0000 Subject: [PATCH 10/11] Changed Interaction.cpp comment change Changed the ref comment --- Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp index cfd111a..f8589fd 100644 --- a/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp +++ b/Source/the_twilight_abyss/MerchantInteraction/Interaction.cpp @@ -24,7 +24,7 @@ void AInteraction::BeginPlay() { Super::BeginPlay(); - //Character refs + //Character & Camera refs TempCharacterRef = Cast(GetWorld()->GetFirstPlayerController()->GetCharacter()); MainCamera = Cast(TempCharacterRef->FindComponentByClass()); //Item refs From f33c43689bf905bc720fb4342e34efc2d5b5f434 Mon Sep 17 00:00:00 2001 From: MH261677 Date: Mon, 30 Jan 2023 21:07:36 +0000 Subject: [PATCH 11/11] 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; };