Compare commits
4 Commits
49fab1bf38
...
bb6ad4b9f7
Author | SHA1 | Date | |
---|---|---|---|
bb6ad4b9f7 | |||
738f4a2b8b | |||
145b497ed4 | |||
d93127a74e |
BIN
Content/Widgets/MainMenu/BP_MainMenuWidget.uasset
(Stored with Git LFS)
BIN
Content/Widgets/MainMenu/BP_MainMenuWidget.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Widgets/Options/BP_OptionsMenuWidget.uasset
(Stored with Git LFS)
Normal file
BIN
Content/Widgets/Options/BP_OptionsMenuWidget.uasset
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -59,12 +59,26 @@ float UHealthComponent::GetCurrentHealth()
|
|||||||
|
|
||||||
void UHealthComponent::SetCurrentHealth(float Value)
|
void UHealthComponent::SetCurrentHealth(float Value)
|
||||||
{
|
{
|
||||||
CurrentHealth = Value;
|
|
||||||
|
|
||||||
if (CurrentHealth > MaxHealth)
|
if (Value > MaxHealth)
|
||||||
{
|
{
|
||||||
CurrentHealth = MaxHealth;
|
CurrentHealth = MaxHealth;
|
||||||
}
|
}
|
||||||
|
else if (Value <= 0.0f)
|
||||||
|
{
|
||||||
|
IsDead = true;
|
||||||
|
OnDeath.Broadcast({GetOwner(), CurrentHealth - Value, nullptr, nullptr, nullptr});
|
||||||
|
CurrentHealth = 0.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Value < CurrentHealth)
|
||||||
|
{
|
||||||
|
OnDamaged.Broadcast({GetOwner(), CurrentHealth - Value, nullptr, nullptr, nullptr});
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentHealth = Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UHealthComponent::ResetHealth()
|
void UHealthComponent::ResetHealth()
|
||||||
@ -75,9 +89,11 @@ void UHealthComponent::ResetHealth()
|
|||||||
|
|
||||||
void UHealthComponent::RecoverHealth(float value)
|
void UHealthComponent::RecoverHealth(float value)
|
||||||
{
|
{
|
||||||
// TODO: We might want to add some extra checking here
|
if (value > 0)
|
||||||
|
{
|
||||||
IncrementHealth(value);
|
IncrementHealth(value);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool UHealthComponent::GetIsDead()
|
bool UHealthComponent::GetIsDead()
|
||||||
{
|
{
|
||||||
|
@ -47,6 +47,7 @@ protected:
|
|||||||
UPROPERTY(VisibleAnywhere)
|
UPROPERTY(VisibleAnywhere)
|
||||||
float CurrentHealth;
|
float CurrentHealth;
|
||||||
|
|
||||||
|
private:
|
||||||
bool IsDead = false;
|
bool IsDead = false;
|
||||||
|
|
||||||
bool CanDamage = true;
|
bool CanDamage = true;
|
||||||
|
@ -15,7 +15,7 @@ void UGameOverWidget::NativeConstruct()
|
|||||||
|
|
||||||
if (ReturnButton)
|
if (ReturnButton)
|
||||||
{
|
{
|
||||||
ReturnButton->OnClicked.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonClicked);
|
ReturnButton->OnClicked.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnClicked);
|
||||||
ReturnButton->OnClicked.AddUniqueDynamic(this, &UGameOverWidget::PlayClickedSound);
|
ReturnButton->OnClicked.AddUniqueDynamic(this, &UGameOverWidget::PlayClickedSound);
|
||||||
|
|
||||||
ReturnButton->OnHovered.AddUniqueDynamic(this, &UGameOverWidget::PlayHoveredSound);
|
ReturnButton->OnHovered.AddUniqueDynamic(this, &UGameOverWidget::PlayHoveredSound);
|
||||||
@ -55,7 +55,7 @@ void UGameOverWidget::SetGameInfo(int Level, float Timer, int Kill, int Gold)
|
|||||||
GoldBlock->SetText(FText::FromString(FString::FromInt(Gold)));
|
GoldBlock->SetText(FText::FromString(FString::FromInt(Gold)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UGameOverWidget::ReturnButtonClicked()
|
void UGameOverWidget::ReturnButtonOnClicked()
|
||||||
{
|
{
|
||||||
if (UVampireGameInstance* GameInstance = Cast<UVampireGameInstance>(GetGameInstance()))
|
if (UVampireGameInstance* GameInstance = Cast<UVampireGameInstance>(GetGameInstance()))
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void ReturnButtonClicked();
|
void ReturnButtonOnClicked();
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void ReturnTextBlockHoveredDelegate() { SetTextBlockHovered(ReturnBlock); }
|
void ReturnTextBlockHoveredDelegate() { SetTextBlockHovered(ReturnBlock); }
|
||||||
|
@ -24,6 +24,18 @@ void UMainMenuWidget::NativeConstruct()
|
|||||||
NewGameButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuWidget::PlayUnhoveredSound);
|
NewGameButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuWidget::PlayUnhoveredSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (OptionsButton)
|
||||||
|
{
|
||||||
|
OptionsButton->OnClicked.AddUniqueDynamic(this, &UMainMenuWidget::OptionsButtonOnClicked);
|
||||||
|
OptionsButton->OnClicked.AddUniqueDynamic(this, &UMainMenuWidget::PlayClickedSound);
|
||||||
|
|
||||||
|
OptionsButton->OnHovered.AddUniqueDynamic(this, &UMainMenuWidget::PlayHoveredSound);
|
||||||
|
OptionsButton->OnHovered.AddUniqueDynamic(this, &UMainMenuWidget::OptionsTextBlockHoveredDelegate);
|
||||||
|
|
||||||
|
OptionsButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuWidget::OptionsTextBlockUnhoveredDelegate);
|
||||||
|
OptionsButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuWidget::PlayUnhoveredSound);
|
||||||
|
}
|
||||||
|
|
||||||
if (QuitButton)
|
if (QuitButton)
|
||||||
{
|
{
|
||||||
QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuWidget::QuitButtonOnClicked);
|
QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuWidget::QuitButtonOnClicked);
|
||||||
@ -61,6 +73,22 @@ void UMainMenuWidget::NewGameButtonOnClicked()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UMainMenuWidget::OptionsButtonOnClicked()
|
||||||
|
{
|
||||||
|
if (OptionsMenuWidget)
|
||||||
|
{
|
||||||
|
RemoveFromParent();
|
||||||
|
|
||||||
|
UUserWidget* OptionWeaponWidget = CreateWidget<UUserWidget, APlayerController*>(
|
||||||
|
UGameplayStatics::GetPlayerController(GetWorld(), 0), OptionsMenuWidget);
|
||||||
|
|
||||||
|
if (OptionWeaponWidget)
|
||||||
|
{
|
||||||
|
OptionWeaponWidget->AddToViewport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UMainMenuWidget::QuitButtonOnClicked()
|
void UMainMenuWidget::QuitButtonOnClicked()
|
||||||
{
|
{
|
||||||
// TODO: Add platform specific Exit requests
|
// TODO: Add platform specific Exit requests
|
||||||
|
@ -15,30 +15,33 @@ class VAMPIRES_API UMainMenuWidget : public UVampireInteractiveWidget
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
// TODO: Add options menu
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
UPROPERTY(meta = (BindWidget))
|
||||||
TObjectPtr<UButton> NewGameButton;
|
TObjectPtr<UButton> NewGameButton;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
UPROPERTY(meta = (BindWidget))
|
||||||
TObjectPtr<UTextBlock> NewGameTextBlock;
|
TObjectPtr<UTextBlock> NewGameTextBlock;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UButton> OptionsButton;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UTextBlock> OptionsTextBlock;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
TObjectPtr<UButton> QuitButton;
|
TObjectPtr<UButton> QuitButton;
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
UPROPERTY(meta = (BindWidget))
|
||||||
TObjectPtr<UTextBlock> QuitTextBlock;
|
TObjectPtr<UTextBlock> QuitTextBlock;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | New Game")
|
UPROPERTY(EditDefaultsOnly, Category = "Widget Settings | New Game")
|
||||||
TSubclassOf<class UUserWidget> NewGameMenuWidget;
|
TSubclassOf<UUserWidget> NewGameMenuWidget;
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | New Game")
|
UPROPERTY(EditDefaultsOnly, Category = "Widget Settings | New Game")
|
||||||
TSoftObjectPtr<UWorld> NewGameLevel;
|
TSoftObjectPtr<UWorld> NewGameLevel;
|
||||||
|
|
||||||
private:
|
UPROPERTY(EditDefaultsOnly, Category = "Widget Settings | Options")
|
||||||
UPROPERTY()
|
TSubclassOf<UUserWidget> OptionsMenuWidget;
|
||||||
TObjectPtr<UUserWidget> CurrentNewGameWidget;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void NativeConstruct() override;
|
virtual void NativeConstruct() override;
|
||||||
@ -47,6 +50,9 @@ private:
|
|||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void NewGameButtonOnClicked();
|
void NewGameButtonOnClicked();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OptionsButtonOnClicked();
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void QuitButtonOnClicked();
|
void QuitButtonOnClicked();
|
||||||
|
|
||||||
@ -56,6 +62,12 @@ private:
|
|||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void NewGameTextBlockUnhoveredDelegate() { SetTextBlockUnhovered(NewGameTextBlock); }
|
void NewGameTextBlockUnhoveredDelegate() { SetTextBlockUnhovered(NewGameTextBlock); }
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OptionsTextBlockHoveredDelegate() { SetTextBlockHovered(OptionsTextBlock); }
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OptionsTextBlockUnhoveredDelegate() { SetTextBlockUnhovered(OptionsTextBlock); }
|
||||||
|
|
||||||
UFUNCTION()
|
UFUNCTION()
|
||||||
void QuitTextBlockHoveredDelegate() { SetTextBlockHovered(QuitTextBlock); }
|
void QuitTextBlockHoveredDelegate() { SetTextBlockHovered(QuitTextBlock); }
|
||||||
|
|
||||||
|
69
Source/vampires/Widgets/OptionsMenuWidget.cpp
Normal file
69
Source/vampires/Widgets/OptionsMenuWidget.cpp
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// Louis Hobbs | 2024-2025
|
||||||
|
|
||||||
|
|
||||||
|
#include "OptionsMenuWidget.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "Components/Button.h"
|
||||||
|
#include "Components/ComboBoxString.h"
|
||||||
|
#include "Kismet/GameplayStatics.h"
|
||||||
|
#include "Kismet/KismetSystemLibrary.h"
|
||||||
|
|
||||||
|
|
||||||
|
void UOptionsMenuWidget::NativeConstruct()
|
||||||
|
{
|
||||||
|
Super::NativeConstruct();
|
||||||
|
|
||||||
|
GenerateResolutionOptions();
|
||||||
|
|
||||||
|
if (ReturnButton)
|
||||||
|
{
|
||||||
|
ReturnButton->OnClicked.AddUniqueDynamic(this, &UOptionsMenuWidget::ReturnButtonOnClicked);
|
||||||
|
ReturnButton->OnClicked.AddUniqueDynamic(this, &UOptionsMenuWidget::PlayClickedSound);
|
||||||
|
|
||||||
|
ReturnButton->OnHovered.AddUniqueDynamic(this, &UOptionsMenuWidget::PlayHoveredSound);
|
||||||
|
ReturnButton->OnHovered.AddUniqueDynamic(this, &UOptionsMenuWidget::ReturnTextBlockHoveredDelegate);
|
||||||
|
|
||||||
|
ReturnButton->OnUnhovered.AddUniqueDynamic(this, &UOptionsMenuWidget::ReturnTextBlockUnhoveredDelegate);
|
||||||
|
ReturnButton->OnUnhovered.AddUniqueDynamic(this, &UOptionsMenuWidget::PlayUnhoveredSound);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UOptionsMenuWidget::GenerateResolutionOptions()
|
||||||
|
{
|
||||||
|
ResolutionComboBox->ClearOptions();
|
||||||
|
|
||||||
|
TArray<FIntPoint> Resolutions;
|
||||||
|
UKismetSystemLibrary::GetSupportedFullscreenResolutions(Resolutions);
|
||||||
|
for (FIntPoint Resolution : Resolutions)
|
||||||
|
{
|
||||||
|
ResolutionComboBox->AddOption(FString::FromInt(Resolution.X) + "x" + FString::FromInt(Resolution.Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
FVector2D Resolution = FVector2D::ZeroVector;
|
||||||
|
GEngine->GameViewport->GetViewportSize(Resolution);
|
||||||
|
FString ResolutionString = FString::FromInt(Resolution.X) + "x" + FString::FromInt(Resolution.Y);
|
||||||
|
if (ResolutionComboBox->FindOptionIndex(ResolutionString) == -1)
|
||||||
|
{
|
||||||
|
ResolutionComboBox->AddOption(ResolutionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
ResolutionComboBox->SetSelectedOption(ResolutionString);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UOptionsMenuWidget::ReturnButtonOnClicked()
|
||||||
|
{
|
||||||
|
if (MainMenuMenuWidget)
|
||||||
|
{
|
||||||
|
RemoveFromParent();
|
||||||
|
|
||||||
|
UUserWidget* SelectWeaponWidget = CreateWidget<UUserWidget, APlayerController*>(
|
||||||
|
UGameplayStatics::GetPlayerController(GetWorld(), 0), MainMenuMenuWidget);
|
||||||
|
|
||||||
|
if (SelectWeaponWidget)
|
||||||
|
{
|
||||||
|
SelectWeaponWidget->AddToViewport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
69
Source/vampires/Widgets/OptionsMenuWidget.h
Normal file
69
Source/vampires/Widgets/OptionsMenuWidget.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
// Louis Hobbs | 2024-2025
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "VampireInteractiveWidget.h"
|
||||||
|
#include "OptionsMenuWidget.generated.h"
|
||||||
|
|
||||||
|
class UComboBoxString;
|
||||||
|
class UComboBox;
|
||||||
|
class UComboBox;
|
||||||
|
class UButton;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class VAMPIRES_API UOptionsMenuWidget : public UVampireInteractiveWidget
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UComboBoxString> ResolutionComboBox;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UTextBlock> ResolutionTextBlock;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UComboBoxString> WindowTypeComboBox;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UComboBoxString> VsyncComboBox;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UComboBoxString> RefreshRateComboBox;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UComboBoxString> DynamicResolutionComboBox;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UButton> ReturnButton;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UTextBlock> ReturnBlock;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UButton> ResetToDefaultsButton;
|
||||||
|
|
||||||
|
UPROPERTY(meta = (BindWidget))
|
||||||
|
TObjectPtr<UTextBlock> ResetToDefaultsBlock;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly, Category = "Widget Settings | New Game")
|
||||||
|
TSubclassOf<UUserWidget> MainMenuMenuWidget;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void NativeConstruct() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void GenerateResolutionOptions();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void ReturnButtonOnClicked();
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void ReturnTextBlockHoveredDelegate() { SetTextBlockHovered(ReturnBlock); }
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void ReturnTextBlockUnhoveredDelegate() { SetTextBlockUnhovered(ReturnBlock); }
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user