Compare commits
No commits in common. "bb6ad4b9f7777ba0b294e81855d84bb0b62e9636" and "49fab1bf38eda731f23a5683d03fce5b12dc0031" have entirely different histories.
bb6ad4b9f7
...
49fab1bf38
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)
BIN
Content/Widgets/Options/BP_OptionsMenuWidget.uasset
(Stored with Git LFS)
Binary file not shown.
@ -59,26 +59,12 @@ float UHealthComponent::GetCurrentHealth()
|
||||
|
||||
void UHealthComponent::SetCurrentHealth(float Value)
|
||||
{
|
||||
CurrentHealth = Value;
|
||||
|
||||
if (Value > MaxHealth)
|
||||
if (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()
|
||||
@ -89,10 +75,8 @@ void UHealthComponent::ResetHealth()
|
||||
|
||||
void UHealthComponent::RecoverHealth(float value)
|
||||
{
|
||||
if (value > 0)
|
||||
{
|
||||
// TODO: We might want to add some extra checking here
|
||||
IncrementHealth(value);
|
||||
}
|
||||
}
|
||||
|
||||
bool UHealthComponent::GetIsDead()
|
||||
|
@ -47,7 +47,6 @@ protected:
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
float CurrentHealth;
|
||||
|
||||
private:
|
||||
bool IsDead = false;
|
||||
|
||||
bool CanDamage = true;
|
||||
|
@ -15,7 +15,7 @@ void UGameOverWidget::NativeConstruct()
|
||||
|
||||
if (ReturnButton)
|
||||
{
|
||||
ReturnButton->OnClicked.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnClicked);
|
||||
ReturnButton->OnClicked.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonClicked);
|
||||
ReturnButton->OnClicked.AddUniqueDynamic(this, &UGameOverWidget::PlayClickedSound);
|
||||
|
||||
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)));
|
||||
}
|
||||
|
||||
void UGameOverWidget::ReturnButtonOnClicked()
|
||||
void UGameOverWidget::ReturnButtonClicked()
|
||||
{
|
||||
if (UVampireGameInstance* GameInstance = Cast<UVampireGameInstance>(GetGameInstance()))
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ public:
|
||||
|
||||
private:
|
||||
UFUNCTION()
|
||||
void ReturnButtonOnClicked();
|
||||
void ReturnButtonClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void ReturnTextBlockHoveredDelegate() { SetTextBlockHovered(ReturnBlock); }
|
||||
|
@ -24,18 +24,6 @@ void UMainMenuWidget::NativeConstruct()
|
||||
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)
|
||||
{
|
||||
QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuWidget::QuitButtonOnClicked);
|
||||
@ -73,22 +61,6 @@ 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()
|
||||
{
|
||||
// TODO: Add platform specific Exit requests
|
||||
|
@ -15,33 +15,30 @@ class VAMPIRES_API UMainMenuWidget : public UVampireInteractiveWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// TODO: Add options menu
|
||||
|
||||
protected:
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
TObjectPtr<UButton> NewGameButton;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
TObjectPtr<UTextBlock> NewGameTextBlock;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UButton> OptionsButton;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UTextBlock> OptionsTextBlock;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
TObjectPtr<UButton> QuitButton;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
||||
TObjectPtr<UTextBlock> QuitTextBlock;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Widget Settings | New Game")
|
||||
TSubclassOf<UUserWidget> NewGameMenuWidget;
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | New Game")
|
||||
TSubclassOf<class UUserWidget> NewGameMenuWidget;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Widget Settings | New Game")
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | New Game")
|
||||
TSoftObjectPtr<UWorld> NewGameLevel;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, Category = "Widget Settings | Options")
|
||||
TSubclassOf<UUserWidget> OptionsMenuWidget;
|
||||
private:
|
||||
UPROPERTY()
|
||||
TObjectPtr<UUserWidget> CurrentNewGameWidget;
|
||||
|
||||
public:
|
||||
virtual void NativeConstruct() override;
|
||||
@ -50,9 +47,6 @@ private:
|
||||
UFUNCTION()
|
||||
void NewGameButtonOnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void OptionsButtonOnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void QuitButtonOnClicked();
|
||||
|
||||
@ -62,12 +56,6 @@ private:
|
||||
UFUNCTION()
|
||||
void NewGameTextBlockUnhoveredDelegate() { SetTextBlockUnhovered(NewGameTextBlock); }
|
||||
|
||||
UFUNCTION()
|
||||
void OptionsTextBlockHoveredDelegate() { SetTextBlockHovered(OptionsTextBlock); }
|
||||
|
||||
UFUNCTION()
|
||||
void OptionsTextBlockUnhoveredDelegate() { SetTextBlockUnhovered(OptionsTextBlock); }
|
||||
|
||||
UFUNCTION()
|
||||
void QuitTextBlockHoveredDelegate() { SetTextBlockHovered(QuitTextBlock); }
|
||||
|
||||
|
@ -1,69 +0,0 @@
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
// 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