From 6a14693826eaf127ebb2e3670ef4bc3a6f6324f5 Mon Sep 17 00:00:00 2001 From: Rafal Swierczek Date: Mon, 30 Oct 2023 18:00:41 +0000 Subject: [PATCH] Implemented UGadgetMenu and it's Functionality --- .../GadgetTutorial/BP_GadgetTutorial.uasset | 4 +- .../GadgetTutorial/WBP_GadgetMenu.uasset | 3 ++ .../Content/Levels/TrainingFacility.umap | 4 +- .../HDRI/HDRI_Epic_Courtyard_Daylight.uasset | 2 +- EndlessVendetta/EndlessVendetta.uproject | 3 +- .../GadgetTutorial/GadgetTutorialStation.cpp | 21 +++++--- .../GadgetTutorial/GadgetTutorialStation.h | 24 +++------ .../UserWidgets/GadgetMenu.cpp | 5 ++ .../EndlessVendetta/UserWidgets/GadgetMenu.h | 50 +++++++++++++++++++ 9 files changed, 85 insertions(+), 31 deletions(-) create mode 100644 EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/WBP_GadgetMenu.uasset create mode 100644 EndlessVendetta/Source/EndlessVendetta/UserWidgets/GadgetMenu.cpp create mode 100644 EndlessVendetta/Source/EndlessVendetta/UserWidgets/GadgetMenu.h diff --git a/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/BP_GadgetTutorial.uasset b/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/BP_GadgetTutorial.uasset index 4763481d..64604dec 100644 --- a/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/BP_GadgetTutorial.uasset +++ b/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/BP_GadgetTutorial.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0ec223a4fa2f994a882c313b35e5f7f2314e2f8a974c0fcb16b0959c4509a8e9 -size 22424 +oid sha256:99736a10befa7b16850c07090ed7d29a0c63d5d4181cacdf73f855190c61c1dd +size 16928 diff --git a/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/WBP_GadgetMenu.uasset b/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/WBP_GadgetMenu.uasset new file mode 100644 index 00000000..69d96971 --- /dev/null +++ b/EndlessVendetta/Content/BountySystem/TutorialFacility/Checkpoints/GadgetTutorial/WBP_GadgetMenu.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:810d2dfb5cf17a33620f773ada8e2d7972ad795139900d78e326fdae5af35239 +size 119297 diff --git a/EndlessVendetta/Content/Levels/TrainingFacility.umap b/EndlessVendetta/Content/Levels/TrainingFacility.umap index d8038530..5e05a85b 100644 --- a/EndlessVendetta/Content/Levels/TrainingFacility.umap +++ b/EndlessVendetta/Content/Levels/TrainingFacility.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:80d409292ad4439737a74a463d528e19c92b5f2673d56712ca2778019a9ad7f6 -size 459303 +oid sha256:46c1dbc7d35d69ea66831390e74563f3dc3dfbdcdc2c09fa0887195d6c231104 +size 460293 diff --git a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset index 866d592f..72280a3b 100644 --- a/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset +++ b/EndlessVendetta/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bb9e2bad3be7351df336b7d68ea591f059abe8dc84cd11bfd10dd3bc41003b15 +oid sha256:d607b449f6cba630df205824ffa12e8dba978263858fcc7a0f6089612f21f28b size 66790690 diff --git a/EndlessVendetta/EndlessVendetta.uproject b/EndlessVendetta/EndlessVendetta.uproject index 1a1190f2..340e263e 100644 --- a/EndlessVendetta/EndlessVendetta.uproject +++ b/EndlessVendetta/EndlessVendetta.uproject @@ -11,7 +11,8 @@ "AdditionalDependencies": [ "Engine", "AIModule", - "CoreUObject" + "CoreUObject", + "UMG" ] } ], diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetTutorial/GadgetTutorialStation.cpp b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetTutorial/GadgetTutorialStation.cpp index 661a1a5f..03742753 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetTutorial/GadgetTutorialStation.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetTutorial/GadgetTutorialStation.cpp @@ -29,19 +29,24 @@ void AGadgetTutorialStation::Tick(float DeltaTime) void AGadgetTutorialStation::Interact() { - // opens up pick gadget widget if (GadgetsArray.IsEmpty()) return; + // Setup Widget so it can be seen and interacted with FInputModeUIOnly InputMode; APlayerController* PlayerController = GetWorld()->GetFirstPlayerController(); - PickGadgetWidget = CreateWidget(GetWorld(), PickGadgetWidgetClass); PickGadgetWidget->AddToViewport(3); - PlayerController->SetInputMode(InputMode); PlayerController->bShowMouseCursor = true; PlayerController->bEnableClickEvents = true; PlayerController->bEnableMouseOverEvents = true; + + // Set up gadget menu's behaviours + GadgetMenu = Cast(PickGadgetWidget); + GadgetMenu->CloseMenuDelegate.AddDynamic(this, &AGadgetTutorialStation::CloseWidget); + GadgetMenu->NextGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::NextGadget); + GadgetMenu->PreviousGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::PreviousGadget); + GadgetMenu->SelectGadgetDelegate.AddDynamic(this, &AGadgetTutorialStation::SelectGadget); } void AGadgetTutorialStation::InteractPrompt() @@ -49,7 +54,7 @@ void AGadgetTutorialStation::InteractPrompt() } -FGadgetInfo AGadgetTutorialStation::NextGadget() +void AGadgetTutorialStation::NextGadget() { FGadgetInfo GadgetInfo; // Either wrap around to the beginning or increment gadget index @@ -58,10 +63,11 @@ FGadgetInfo AGadgetTutorialStation::NextGadget() GadgetInfo.GadgetIcon = GadgetsArray[GadgetIndex]->GetDefaultObject()->GetGadgetIcon(); GadgetInfo.GadgetDesc = GadgetsArray[GadgetIndex]->GetDefaultObject()->GetGadgetDesc(); GadgetInfo.GadgetName = GadgetsArray[GadgetIndex]->GetDefaultObject()->GetGadgetName(); - return GadgetInfo; + + GadgetMenu->UpdateDisplayedGadget(GadgetInfo); } -FGadgetInfo AGadgetTutorialStation::PreviousGadget() +void AGadgetTutorialStation::PreviousGadget() { FGadgetInfo GadgetInfo; // Either wrap around to the end or decrement gadget index @@ -70,7 +76,8 @@ FGadgetInfo AGadgetTutorialStation::PreviousGadget() GadgetInfo.GadgetIcon = GadgetsArray[GadgetIndex]->GetDefaultObject()->GetGadgetIcon(); GadgetInfo.GadgetDesc = GadgetsArray[GadgetIndex]->GetDefaultObject()->GetGadgetDesc(); GadgetInfo.GadgetName = GadgetsArray[GadgetIndex]->GetDefaultObject()->GetGadgetName(); - return GadgetInfo; + + GadgetMenu->UpdateDisplayedGadget(GadgetInfo); } void AGadgetTutorialStation::SelectGadget() diff --git a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetTutorial/GadgetTutorialStation.h b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetTutorial/GadgetTutorialStation.h index 711576f8..95a0ebce 100644 --- a/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetTutorial/GadgetTutorialStation.h +++ b/EndlessVendetta/Source/EndlessVendetta/GadgetSystem/GadgetTutorial/GadgetTutorialStation.h @@ -5,24 +5,10 @@ #include "CoreMinimal.h" #include "EndlessVendetta/GadgetSystem/GadgetBase.h" #include "EndlessVendetta/InteractionInterface.h" +#include "EndlessVendetta/UserWidgets/GadgetMenu.h" #include "GameFramework/Actor.h" #include "GadgetTutorialStation.generated.h" -USTRUCT(BlueprintType) -struct FGadgetInfo -{ - GENERATED_BODY() - - UPROPERTY(BlueprintReadWrite, Category = "Gadget") - UTexture2D* GadgetIcon; - - UPROPERTY(BlueprintReadWrite, Category = "Gadget") - FString GadgetDesc; - - UPROPERTY(BlueprintReadWrite, Category = "Gadget") - FString GadgetName; -}; - UCLASS() class ENDLESSVENDETTA_API AGadgetTutorialStation : public AActor, public IInteractionInterface { @@ -32,12 +18,14 @@ class ENDLESSVENDETTA_API AGadgetTutorialStation : public AActor, public IIntera TArray> GadgetsArray; UPROPERTY(EditDefaultsOnly, Category = "Gadgets") - TSubclassOf PickGadgetWidgetClass; + TSubclassOf PickGadgetWidgetClass; int GadgetIndex = 0; UUserWidget* PickGadgetWidget; + UGadgetMenu* GadgetMenu; + protected: // Called when the game starts or when spawned virtual void BeginPlay() override; @@ -47,10 +35,10 @@ protected: void InteractPrompt() override; UFUNCTION(BlueprintCallable) - FGadgetInfo NextGadget(); + void NextGadget(); UFUNCTION(BlueprintCallable) - FGadgetInfo PreviousGadget(); + void PreviousGadget(); UFUNCTION(BlueprintCallable) void SelectGadget(); diff --git a/EndlessVendetta/Source/EndlessVendetta/UserWidgets/GadgetMenu.cpp b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/GadgetMenu.cpp new file mode 100644 index 00000000..d9db8748 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/GadgetMenu.cpp @@ -0,0 +1,5 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "GadgetMenu.h" + diff --git a/EndlessVendetta/Source/EndlessVendetta/UserWidgets/GadgetMenu.h b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/GadgetMenu.h new file mode 100644 index 00000000..e09b9377 --- /dev/null +++ b/EndlessVendetta/Source/EndlessVendetta/UserWidgets/GadgetMenu.h @@ -0,0 +1,50 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Blueprint/UserWidget.h" +#include "GadgetMenu.generated.h" + +USTRUCT(BlueprintType) +struct FGadgetInfo +{ + GENERATED_BODY() + + UPROPERTY(BlueprintReadWrite, Category = "Gadget") + UTexture2D* GadgetIcon; + + UPROPERTY(BlueprintReadWrite, Category = "Gadget") + FString GadgetDesc; + + UPROPERTY(BlueprintReadWrite, Category = "Gadget") + FString GadgetName; +}; + + +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FCloseMenu); +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FNextGadget); +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FPreviousGadget); +DECLARE_DYNAMIC_MULTICAST_DELEGATE(FSelectGadget); + +UCLASS() +class ENDLESSVENDETTA_API UGadgetMenu : public UUserWidget +{ + GENERATED_BODY() + +public: + UPROPERTY(BlueprintCallable) + FCloseMenu CloseMenuDelegate; + + UPROPERTY(BlueprintCallable) + FCloseMenu NextGadgetDelegate; + + UPROPERTY(BlueprintCallable) + FCloseMenu PreviousGadgetDelegate; + + UPROPERTY(BlueprintCallable) + FCloseMenu SelectGadgetDelegate; + + UFUNCTION(BlueprintImplementableEvent) + void UpdateDisplayedGadget(FGadgetInfo GadgetInfo); +};