Setup Pause Menu Input

This commit is contained in:
Rafal Swierczek 2024-02-03 16:00:11 +00:00
parent f0f04e1928
commit 162d9c85a4
12 changed files with 87 additions and 31 deletions

View File

@ -8,14 +8,17 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="dfa3053d-1d51-4dad-9270-4c17e086f627" name="Changes" comment=""> <list default="true" id="dfa3053d-1d51-4dad-9270-4c17e086f627" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.EndlessVendetta/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FirstPerson/Blueprints/BP_FirstPersonCharacter.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/FirstPerson/Input/IMC_Default.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/FirstPerson/Input/IMC_Default.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" beforeDir="false" afterPath="$PROJECT_DIR$/Content/Levels/MainMenuLevel.umap" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/HDRI/HDRI_Epic_Courtyard_Daylight.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/DialogueSystemEditor/DialogueSystemEditor.Build.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Source/DialogueSystemEditor/DialogueSystemEditor.Build.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Content/StarterContent/Particles/P_Ambient_Dust.uasset" beforeDir="false" afterPath="$PROJECT_DIR$/Content/StarterContent/Particles/P_Ambient_Dust.uasset" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta.Target.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta.Target.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyDirector.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyDirector.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/DialogueSystem/DialogueEdge.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/DialogueSystem/DialogueEdge.h" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/DialogueSystem/DialogueRootNode.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/DialogueSystem/DialogueRootNode.h" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/DialogueSystem/DialogueTree.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/DialogueSystem/DialogueTree.cpp" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.cpp" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/EndlessVendettaCharacter.h" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -28,10 +31,10 @@
<component name="MarkdownSettingsMigration"> <component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" /> <option name="stateVersion" value="1" />
</component> </component>
<component name="ProjectColorInfo"><![CDATA[{ <component name="ProjectColorInfo">{
"customColor": "", &quot;customColor&quot;: &quot;&quot;,
"associatedIndex": 7 &quot;associatedIndex&quot;: 7
}]]></component> }</component>
<component name="ProjectId" id="2bp7o8dmlHZgRsYmVepgy7lbmpM" /> <component name="ProjectId" id="2bp7o8dmlHZgRsYmVepgy7lbmpM" />
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
@ -42,7 +45,7 @@
"C++ Project.EndlessVendetta.executor": "Run", "C++ Project.EndlessVendetta.executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true", "RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true", "RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "TempBuildSetup", "git-widget-placeholder": "PauseMenu",
"ignore.virus.scanning.warn.message": "true", "ignore.virus.scanning.warn.message": "true",
"node.js.detected.package.eslint": "true", "node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true", "node.js.detected.package.tslint": "true",
@ -131,6 +134,7 @@
<option name="presentableId" value="Default" /> <option name="presentableId" value="Default" />
<updated>1706900339638</updated> <updated>1706900339638</updated>
<workItem from="1706900342753" duration="2652000" /> <workItem from="1706900342753" duration="2652000" />
<workItem from="1706972179014" duration="2867000" />
</task> </task>
<servers /> <servers />
</component> </component>

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -188,10 +188,10 @@ void ABountyDirector::BuyEnemyRadio()
void ABountyDirector::BuyFavours() void ABountyDirector::BuyFavours()
{ {
if (PlayerChar->Money < FavourCost) return; // if (PlayerChar->Money < FavourCost) return;
PlayerChar->Money -= FavourCost; // PlayerChar->Money -= FavourCost;
Favours++; // Favours++;
PC_Display->UpdateFavourCount(Favours); // PC_Display->UpdateFavourCount(Favours);
} }
// ----------- PC Display --------------- // ----------- PC Display ---------------

View File

@ -3,6 +3,7 @@
#include "BountyHunterCharacter.h" #include "BountyHunterCharacter.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "EnhancedInputComponent.h"
void ABountyHunterCharacter::SpawnMainBounty() void ABountyHunterCharacter::SpawnMainBounty()
{ {
@ -52,8 +53,34 @@ void ABountyHunterCharacter::BeginPlay()
Super::BeginPlay(); Super::BeginPlay();
} }
void ABountyHunterCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent))
{
EnhancedInputComponent->BindAction(PauseMenuAction, ETriggerEvent::Started, this, &ABountyHunterCharacter::TogglePauseMenu);
}
UE_LOG(LogTemp, Warning, TEXT("Setup player input on bounty hunter character"));
Super::SetupPlayerInputComponent(PlayerInputComponent);
}
void ABountyHunterCharacter::TogglePauseMenu()
{
bool bOpenNewPauseMenu = !IsValid(PauseMenu);
FInputModeUIOnly UIOnly;
FInputModeGameOnly GameOnly;
APlayerController* PC = Cast<APlayerController>(GetController());
InPauseMenu = bOpenNewPauseMenu;
PC->SetIgnoreMoveInput(bOpenNewPauseMenu);
PC->SetIgnoreLookInput(bOpenNewPauseMenu);
PC->SetShowMouseCursor(bOpenNewPauseMenu);
PauseMenu = bOpenNewPauseMenu ? CreateWidget<UPauseMenuClass>(GetWorld(), PauseMenuWidgetClass) : nullptr;
if (bOpenNewPauseMenu) PauseMenu->AddToViewport(50);
}
void ABountyHunterCharacter::Tick(float DeltaTime) void ABountyHunterCharacter::Tick(float DeltaTime)
{ {
Super::Tick(DeltaTime); Super::Tick(DeltaTime);
} }

View File

@ -7,6 +7,7 @@
#include "EndlessVendetta/EVGameInstance.h" #include "EndlessVendetta/EVGameInstance.h"
#include "EndlessVendetta/MainSaveGameClass.h" #include "EndlessVendetta/MainSaveGameClass.h"
#include "EndlessVendetta/BountySystem/MainBountyClass.h" #include "EndlessVendetta/BountySystem/MainBountyClass.h"
#include "EndlessVendetta/PauseMenu/PauseMenuClass.h"
#include "BountyHunterCharacter.generated.h" #include "BountyHunterCharacter.generated.h"
/** /**
@ -32,6 +33,14 @@ class ENDLESSVENDETTA_API ABountyHunterCharacter : public AEndlessVendettaCharac
UPROPERTY(EditDefaultsOnly, Category = "Bounty Hunter") UPROPERTY(EditDefaultsOnly, Category = "Bounty Hunter")
FString OpenWorldLevelName = "ControlTutorialLevel"; FString OpenWorldLevelName = "ControlTutorialLevel";
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
UInputAction* PauseMenuAction;
UPROPERTY(EditDefaultsOnly, Category = PauseMenu)
TSubclassOf<UPauseMenuClass> PauseMenuWidgetClass;
UPauseMenuClass* PauseMenu;
protected: protected:
@ -52,6 +61,11 @@ protected:
// Called When Player Spawns // Called When Player Spawns
virtual void BeginPlay() override; virtual void BeginPlay() override;
// Overridden to Setup up Pause Menu Inputs
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
void TogglePauseMenu();
// Called every frame // Called every frame
virtual void Tick(float DeltaTime) override; virtual void Tick(float DeltaTime) override;
public: public:

View File

@ -70,6 +70,7 @@ void AMyVICharacterBase::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& O
void AMyVICharacterBase::Jump() void AMyVICharacterBase::Jump()
{ {
if (PlayerOnShip || InPauseMenu) return;
// If missing critical components then jump and exit // If missing critical components then jump and exit
if (!VaultComponent || !GetCharacterMovement()) if (!VaultComponent || !GetCharacterMovement())
{ {

View File

@ -216,10 +216,12 @@ void AEndlessVendettaCharacter::SetupPlayerInputComponent(class UInputComponent*
//Interacting //Interacting
EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Interact); EnhancedInputComponent->BindAction(InteractAction, ETriggerEvent::Started, this, &AEndlessVendettaCharacter::Interact);
} }
UE_LOG(LogTemp, Warning, TEXT("Setup player input on EV character"));
} }
void AEndlessVendettaCharacter::Interact() void AEndlessVendettaCharacter::Interact()
{ {
if (InPauseMenu) return;
if (bIsInDialogue) if (bIsInDialogue)
{ {
Cast<UAC_PlayerDialogueInterpreter>(GetComponentByClass(UAC_PlayerDialogueInterpreter::StaticClass()))->NextDialogue(); Cast<UAC_PlayerDialogueInterpreter>(GetComponentByClass(UAC_PlayerDialogueInterpreter::StaticClass()))->NextDialogue();
@ -257,7 +259,7 @@ void AEndlessVendettaCharacter::Interact()
void AEndlessVendettaCharacter::SetCrouch() void AEndlessVendettaCharacter::SetCrouch()
{ {
if (PlayerOnShip) return; if (PlayerOnShip || InPauseMenu) return;
Crouch(); Crouch();
} }
@ -301,7 +303,7 @@ float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEve
void AEndlessVendettaCharacter::ToggleRecon() void AEndlessVendettaCharacter::ToggleRecon()
{ {
if (PlayerOnShip) return; if (PlayerOnShip || InPauseMenu) return;
if (!GadgetManager->IsValidReconGadget()) return; if (!GadgetManager->IsValidReconGadget()) return;
if (IsValid(PrimaryWeapon)) EquipPrimary(); if (IsValid(PrimaryWeapon)) EquipPrimary();
@ -324,7 +326,7 @@ void AEndlessVendettaCharacter::ToggleRecon()
void AEndlessVendettaCharacter::ToggleCombat() void AEndlessVendettaCharacter::ToggleCombat()
{ {
if (PlayerOnShip) return; if (PlayerOnShip || InPauseMenu) return;
if (!GadgetManager->IsValidCombatGadget()) return; if (!GadgetManager->IsValidCombatGadget()) return;
if (IsValid(PrimaryWeapon)) EquipPrimary(); if (IsValid(PrimaryWeapon)) EquipPrimary();
@ -349,7 +351,7 @@ void AEndlessVendettaCharacter::ToggleCombat()
//When 1 is pressed it calls EquipPrimary //When 1 is pressed it calls EquipPrimary
void AEndlessVendettaCharacter::EquipPrimary() void AEndlessVendettaCharacter::EquipPrimary()
{ {
if (PlayerOnShip) return; if (PlayerOnShip || InPauseMenu) return;
if (!IsValid(PrimaryWeaponClass)) return; if (!IsValid(PrimaryWeaponClass)) return;
FActorSpawnParameters spawnParams; FActorSpawnParameters spawnParams;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
@ -421,7 +423,7 @@ void AEndlessVendettaCharacter::EquipPrimary()
void AEndlessVendettaCharacter::EquipSecondary() void AEndlessVendettaCharacter::EquipSecondary()
{ {
if (!IsValid(SecondaryWeaponClass)) return; if (!IsValid(SecondaryWeaponClass)) return;
if (PlayerOnShip) return; if (PlayerOnShip || InPauseMenu) return;
FActorSpawnParameters spawnParams; FActorSpawnParameters spawnParams;
spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; spawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true); FAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);
@ -518,6 +520,7 @@ void AEndlessVendettaCharacter::WeaponSwitcher(AActor* Outhit)
//Calls the fire function in the baseWeaponClass //Calls the fire function in the baseWeaponClass
void AEndlessVendettaCharacter::FireCaller() void AEndlessVendettaCharacter::FireCaller()
{ {
if (InPauseMenu) return;
if (IsValid(PrimaryWeapon) && !bIsReloading) if (IsValid(PrimaryWeapon) && !bIsReloading)
{ {
PrimaryWeapon->Fire(); PrimaryWeapon->Fire();
@ -542,6 +545,7 @@ void AEndlessVendettaCharacter::StopFire()
void AEndlessVendettaCharacter::GunRightClick() void AEndlessVendettaCharacter::GunRightClick()
{ {
if (InPauseMenu) return;
if (IsValid(PrimaryWeapon) && !bIsScoped) if (IsValid(PrimaryWeapon) && !bIsScoped)
{ {
bIsScoped = true; bIsScoped = true;
@ -578,6 +582,7 @@ void AEndlessVendettaCharacter::StopGunRightClick()
void AEndlessVendettaCharacter::GunReload() void AEndlessVendettaCharacter::GunReload()
{ {
if (InPauseMenu) return;
if (IsValid(PrimaryWeapon)) if (IsValid(PrimaryWeapon))
{ {
PrimaryWeapon->ReloadTimer(); PrimaryWeapon->ReloadTimer();
@ -617,6 +622,7 @@ void AEndlessVendettaCharacter::Move(const FInputActionValue& Value)
void AEndlessVendettaCharacter::Sprint() void AEndlessVendettaCharacter::Sprint()
{ {
if (InPauseMenu) return;
bIsPlayerSprinting = true; bIsPlayerSprinting = true;
if (bIsPlayerSprinting) if (bIsPlayerSprinting)
{ {

View File

@ -133,6 +133,8 @@ protected:
virtual void BeginPlay() override; virtual void BeginPlay() override;
virtual void Tick(float DeltaTime) override; virtual void Tick(float DeltaTime) override;
bool InPauseMenu = false;
UPROPERTY(EditDefaultsOnly, Category = "Gadget") UPROPERTY(EditDefaultsOnly, Category = "Gadget")
TSubclassOf<AGadgetManager> GadgetManagerClass; TSubclassOf<AGadgetManager> GadgetManagerClass;
@ -145,7 +147,6 @@ protected:
void PlayFadeScreen(); void PlayFadeScreen();
public: public:
int Money = 2000;
AGadgetManager* GadgetManager; AGadgetManager* GadgetManager;
bool bIsReloading = false; bool bIsReloading = false;
@ -269,11 +270,11 @@ public:
// Space Ship // Space Ship
private: private:
bool PlayerOnShip = false;
UPROPERTY(EditDefaultsOnly, Category = "Space Ship") UPROPERTY(EditDefaultsOnly, Category = "Space Ship")
TSubclassOf<ASpaceShip> SpaceShipClass; TSubclassOf<ASpaceShip> SpaceShipClass;
ASpaceShip* SpaceShip; ASpaceShip* SpaceShip;
protected:
bool PlayerOnShip = false;
public: public:
void ExitShip(FTransform ExitLoc); void ExitShip(FTransform ExitLoc);
void EnterShip(FTransform TakeoffLoc); void EnterShip(FTransform TakeoffLoc);