diff --git a/Config/DefaultInput.ini b/Config/DefaultInput.ini index 4f7902d..223f2ab 100644 --- a/Config/DefaultInput.ini +++ b/Config/DefaultInput.ini @@ -85,6 +85,8 @@ DoubleClickTime=0.200000 +ActionMappings=(ActionName="Fire",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=LeftMouseButton) +ActionMappings=(ActionName="Reload",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=R) +ActionMappings=(ActionName="ThrowGrenade",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=G) ++ActionMappings=(ActionName="Quit",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Escape) ++ActionMappings=(ActionName="Quit",bShift=False,bCtrl=False,bAlt=False,bCmd=False,Key=Q) +AxisMappings=(AxisName="MoveForward",Scale=1.000000,Key=W) +AxisMappings=(AxisName="MoveForward",Scale=-1.000000,Key=S) +AxisMappings=(AxisName="MoveRight",Scale=1.000000,Key=D) diff --git a/Content/Blueprints/PlayerController/BP_BlasterPlayerController.uasset b/Content/Blueprints/PlayerController/BP_BlasterPlayerController.uasset index a18dfb2..f2b6af4 100644 Binary files a/Content/Blueprints/PlayerController/BP_BlasterPlayerController.uasset and b/Content/Blueprints/PlayerController/BP_BlasterPlayerController.uasset differ diff --git a/Source/Blaster/HUD/ReturnToMainMenu.cpp b/Source/Blaster/HUD/ReturnToMainMenu.cpp index 415ab5e..74b65c1 100644 --- a/Source/Blaster/HUD/ReturnToMainMenu.cpp +++ b/Source/Blaster/HUD/ReturnToMainMenu.cpp @@ -24,7 +24,7 @@ void UReturnToMainMenu::MenuSetup() } } - if (ReturnButton) + if (ReturnButton && !ReturnButton->OnClicked.IsBound()) { ReturnButton->OnClicked.AddDynamic(this, &UReturnToMainMenu::ReturnButtonClicked); } @@ -63,6 +63,14 @@ void UReturnToMainMenu::MenuTearDown() PlayerController->SetShowMouseCursor(false); } } + if (ReturnButton && ReturnButton->OnClicked.IsBound()) + { + ReturnButton->OnClicked.RemoveDynamic(this, &UReturnToMainMenu::ReturnButtonClicked); + } + if (MultiplayerSessionsSubsystem && MultiplayerSessionsSubsystem->MultiplayerOnDestroySessionComplete.IsBound()) + { + MultiplayerSessionsSubsystem->MultiplayerOnDestroySessionComplete.RemoveDynamic(this, &UReturnToMainMenu::OnDestroySessionComplete); + } } void UReturnToMainMenu::ReturnButtonClicked() diff --git a/Source/Blaster/PlayerController/BlasterPlayerController.cpp b/Source/Blaster/PlayerController/BlasterPlayerController.cpp index 6549fb3..de0bf5c 100644 --- a/Source/Blaster/PlayerController/BlasterPlayerController.cpp +++ b/Source/Blaster/PlayerController/BlasterPlayerController.cpp @@ -11,6 +11,7 @@ #include "Blaster/HUD/BlasterHUD.h" #include "Blaster/HUD/CharacterOverlay.h" #include "Blaster/HUD/DebugWidget.h" +#include "Blaster/HUD/ReturnToMainMenu.h" #include "Blaster/PlayerState/BlasterPlayerState.h" #include "Components/ProgressBar.h" #include "Components/TextBlock.h" @@ -27,6 +28,15 @@ void ABlasterPlayerController::BeginPlay() ServerCheckMatchState(); } +void ABlasterPlayerController::SetupInputComponent() +{ + Super::SetupInputComponent(); + + if (InputComponent == nullptr) return; + + InputComponent->BindAction("Quit", IE_Pressed, this, &ABlasterPlayerController::ShowReturnToMainMenu); +} + void ABlasterPlayerController::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); @@ -70,7 +80,6 @@ void ABlasterPlayerController::CheckPing(float DeltaTime) PlayerState = PlayerState == nullptr ? GetPlayerState() : PlayerState; if (PlayerState) { - UE_LOG(LogTemp, Warning, TEXT("Ping: %f"), PlayerState->GetPingInMilliseconds()); if (PlayerState->GetPingInMilliseconds() > HighPingThreshold) { HighPingWarning(); @@ -468,6 +477,28 @@ void ABlasterPlayerController::StopHighPingWarning() } } +void ABlasterPlayerController::ShowReturnToMainMenu() +{ + if (ReturnToMainMenuWidget == nullptr) return; + + if (ReturnToMainMenu == nullptr) + { + ReturnToMainMenu = CreateWidget(this, ReturnToMainMenuWidget); + } + if (ReturnToMainMenu) + { + bReturnToMainMenuOpen = !bReturnToMainMenuOpen; + if (bReturnToMainMenuOpen) + { + ReturnToMainMenu->MenuSetup(); + } + else + { + ReturnToMainMenu->MenuTearDown(); + } + } +} + void ABlasterPlayerController::ServerRequestServerTime_Implementation(float TimeOfClientRequest) { float ServerTimeOfReceipt = GetWorld()->GetTimeSeconds(); diff --git a/Source/Blaster/PlayerController/BlasterPlayerController.h b/Source/Blaster/PlayerController/BlasterPlayerController.h index df5911c..8aceb84 100644 --- a/Source/Blaster/PlayerController/BlasterPlayerController.h +++ b/Source/Blaster/PlayerController/BlasterPlayerController.h @@ -52,7 +52,7 @@ public: FHighPingDelegate HighPingDelegate; protected: - + virtual void SetupInputComponent() override; virtual void BeginPlay() override; void CheckTimeSync(float DeltaTime); void HandleMatchHasStarted(); @@ -85,14 +85,26 @@ protected: void HighPingWarning(); void StopHighPingWarning(); -private: + void ShowReturnToMainMenu(); + +private: UPROPERTY() class UDebugWidget* DebugWidget; UPROPERTY() class ABlasterHUD* BlasterHUD; + // Return to main menu + + UPROPERTY(EditAnywhere, Category = HUD) + TSubclassOf ReturnToMainMenuWidget; + + UPROPERTY() + class UReturnToMainMenu* ReturnToMainMenu; + + bool bReturnToMainMenuOpen = false; + UPROPERTY() class ABlasterGameMode* BlasterGameMode;