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 name="ChangeListManager">
<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$/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$/Source/DialogueSystemEditor/DialogueSystemEditor.Build.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Source/DialogueSystemEditor/DialogueSystemEditor.Build.cs" 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/DialogueSystem/DialogueEdge.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/DialogueSystem/DialogueEdge.h" 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/DialogueSystem/DialogueTree.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/DialogueSystem/DialogueTree.cpp" 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/BountySystem/BountyDirector.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/BountySystem/BountyDirector.cpp" 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/Characters/BountyHunterCharacter.h" beforeDir="false" afterPath="$PROJECT_DIR$/Source/EndlessVendetta/Characters/BountyHunterCharacter.h" 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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -28,10 +31,10 @@
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectColorInfo"><![CDATA[{
"customColor": "",
"associatedIndex": 7
}]]></component>
<component name="ProjectColorInfo">{
&quot;customColor&quot;: &quot;&quot;,
&quot;associatedIndex&quot;: 7
}</component>
<component name="ProjectId" id="2bp7o8dmlHZgRsYmVepgy7lbmpM" />
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
@ -42,7 +45,7 @@
"C++ Project.EndlessVendetta.executor": "Run",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "TempBuildSetup",
"git-widget-placeholder": "PauseMenu",
"ignore.virus.scanning.warn.message": "true",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
@ -131,6 +134,7 @@
<option name="presentableId" value="Default" />
<updated>1706900339638</updated>
<workItem from="1706900342753" duration="2652000" />
<workItem from="1706972179014" duration="2867000" />
</task>
<servers />
</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()
{
if (PlayerChar->Money < FavourCost) return;
PlayerChar->Money -= FavourCost;
Favours++;
PC_Display->UpdateFavourCount(Favours);
// if (PlayerChar->Money < FavourCost) return;
// PlayerChar->Money -= FavourCost;
// Favours++;
// PC_Display->UpdateFavourCount(Favours);
}
// ----------- PC Display ---------------

View File

@ -3,6 +3,7 @@
#include "BountyHunterCharacter.h"
#include "Kismet/GameplayStatics.h"
#include "EnhancedInputComponent.h"
void ABountyHunterCharacter::SpawnMainBounty()
{
@ -52,8 +53,34 @@ void ABountyHunterCharacter::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)
{
Super::Tick(DeltaTime);
}

View File

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

View File

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

View File

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

View File

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