Compare commits
No commits in common. "6475e1e18320b5641af043555deba353b1d75972" and "f72780bb003eeec4b0929894110caa06032186a1" have entirely different histories.
6475e1e183
...
f72780bb00
BIN
Content/Levels/Level.umap
(Stored with Git LFS)
BIN
Content/Levels/Level.umap
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MainMenu.umap
(Stored with Git LFS)
BIN
Content/Levels/MainMenu.umap
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MainMenu/BP_MainMenuGameMode.uasset
(Stored with Git LFS)
BIN
Content/Levels/MainMenu/BP_MainMenuGameMode.uasset
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MainMenu/MainMenu.umap
(Stored with Git LFS)
BIN
Content/Levels/MainMenu/MainMenu.umap
(Stored with Git LFS)
Binary file not shown.
BIN
Content/Levels/MainMenu/NS_MainMenu.uasset
(Stored with Git LFS)
BIN
Content/Levels/MainMenu/NS_MainMenu.uasset
(Stored with Git LFS)
Binary file not shown.
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.
@ -1,67 +0,0 @@
|
|||||||
// Louis Hobbs | 2024-2025
|
|
||||||
|
|
||||||
|
|
||||||
#include "MainMenuWidget.h"
|
|
||||||
|
|
||||||
#include "Blueprint/WidgetBlueprintLibrary.h"
|
|
||||||
#include "Components/Button.h"
|
|
||||||
#include "Kismet/GameplayStatics.h"
|
|
||||||
|
|
||||||
void UMainMenuWidget::NativeConstruct()
|
|
||||||
{
|
|
||||||
Super::NativeConstruct();
|
|
||||||
|
|
||||||
if (NewGameButton)
|
|
||||||
{
|
|
||||||
NewGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuWidget::NewGameButtonOnClicked);
|
|
||||||
NewGameButton->OnClicked.AddUniqueDynamic(this, &UMainMenuWidget::PlayClickedSound);
|
|
||||||
|
|
||||||
NewGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuWidget::PlayHoveredSound);
|
|
||||||
NewGameButton->OnHovered.AddUniqueDynamic(this, &UMainMenuWidget::NewGameTextBlockHoveredDelegate);
|
|
||||||
|
|
||||||
NewGameButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuWidget::NewGameTextBlockUnhoveredDelegate);
|
|
||||||
NewGameButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuWidget::PlayUnhoveredSound);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (QuitButton)
|
|
||||||
{
|
|
||||||
QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuWidget::QuitButtonOnClicked);
|
|
||||||
QuitButton->OnClicked.AddUniqueDynamic(this, &UMainMenuWidget::PlayClickedSound);
|
|
||||||
|
|
||||||
QuitButton->OnHovered.AddUniqueDynamic(this, &UMainMenuWidget::PlayHoveredSound);
|
|
||||||
QuitButton->OnHovered.AddUniqueDynamic(this, &UMainMenuWidget::QuitTextBlockHoveredDelegate);
|
|
||||||
|
|
||||||
QuitButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuWidget::QuitTextBlockUnhoveredDelegate);
|
|
||||||
QuitButton->OnUnhovered.AddUniqueDynamic(this, &UMainMenuWidget::PlayUnhoveredSound);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
|
|
||||||
{
|
|
||||||
UWidgetBlueprintLibrary::SetInputMode_UIOnlyEx(PlayerController, this, EMouseLockMode::LockAlways);
|
|
||||||
PlayerController->bShowMouseCursor = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UMainMenuWidget::NewGameButtonOnClicked()
|
|
||||||
{
|
|
||||||
if (!NewGameLevel.IsNull())
|
|
||||||
{
|
|
||||||
UGameplayStatics::OpenLevelBySoftObjectPtr(GetWorld(), NewGameLevel);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (APlayerController* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0))
|
|
||||||
{
|
|
||||||
PlayerController->bShowMouseCursor = false;
|
|
||||||
UWidgetBlueprintLibrary::SetInputMode_GameOnly(PlayerController);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetIsFocusable(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UMainMenuWidget::QuitButtonOnClicked()
|
|
||||||
{
|
|
||||||
// TODO: Add platform specific Exit requests
|
|
||||||
// This is not a bit deal for the moment as we are only building for windows
|
|
||||||
// For some reason the generic version does not work the same as FWindowsPlatformMisc
|
|
||||||
FWindowsPlatformMisc::RequestExit(false);
|
|
||||||
}
|
|
@ -1,64 +0,0 @@
|
|||||||
// Louis Hobbs | 2024-2025
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "VampireInteractiveWidget.h"
|
|
||||||
#include "MainMenuWidget.generated.h"
|
|
||||||
|
|
||||||
class UButton;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class VAMPIRES_API UMainMenuWidget : public UVampireInteractiveWidget
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
// TODO: Add options menu
|
|
||||||
|
|
||||||
public:
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
|
||||||
TObjectPtr<UButton> NewGameButton;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
|
||||||
TObjectPtr<UTextBlock> NewGameTextBlock;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
|
||||||
TObjectPtr<UButton> QuitButton;
|
|
||||||
|
|
||||||
UPROPERTY(BlueprintReadWrite, meta = (BindWidget))
|
|
||||||
TObjectPtr<UTextBlock> QuitTextBlock;
|
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
TSubclassOf<class UUserWidget> NewGameMenuWidget;
|
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
TSoftObjectPtr<UWorld> NewGameLevel;
|
|
||||||
|
|
||||||
private:
|
|
||||||
UPROPERTY()
|
|
||||||
TObjectPtr<UUserWidget> currentNewGameWidget;
|
|
||||||
|
|
||||||
public:
|
|
||||||
virtual void NativeConstruct() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
UFUNCTION()
|
|
||||||
void NewGameButtonOnClicked();
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void QuitButtonOnClicked();
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void NewGameTextBlockHoveredDelegate() { SetTextBlockHovered(NewGameTextBlock); }
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void NewGameTextBlockUnhoveredDelegate() { SetTextBlockUnhovered(NewGameTextBlock); }
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void QuitTextBlockHoveredDelegate() { SetTextBlockHovered(QuitTextBlock); }
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void QuitTextBlockUnhoveredDelegate() { SetTextBlockUnhovered(QuitTextBlock); }
|
|
||||||
};
|
|
@ -1,58 +0,0 @@
|
|||||||
// Louis Hobbs | 2024-2025
|
|
||||||
|
|
||||||
|
|
||||||
#include "VampireInteractiveWidget.h"
|
|
||||||
|
|
||||||
#include "Components/TextBlock.h"
|
|
||||||
#include "GameFramework/GameUserSettings.h"
|
|
||||||
#include "Kismet/GameplayStatics.h"
|
|
||||||
|
|
||||||
void UVampireInteractiveWidget::SetReturnScreen(UUserWidget* userWidget)
|
|
||||||
{
|
|
||||||
if (userWidget)
|
|
||||||
{
|
|
||||||
PreviousScreen = userWidget;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UVampireInteractiveWidget::PlayHoveredSound()
|
|
||||||
{
|
|
||||||
if (ButtonHoveredSound)
|
|
||||||
{
|
|
||||||
UGameplayStatics::PlaySound2D(GetWorld(), ButtonHoveredSound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UVampireInteractiveWidget::SetTextBlockHovered(UTextBlock* TextBlock)
|
|
||||||
{
|
|
||||||
TextBlock->SetColorAndOpacity(FSlateColor(ButtonHoveredTextColor));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UVampireInteractiveWidget::SetTextBlockUnhovered(UTextBlock* TextBlock)
|
|
||||||
{
|
|
||||||
TextBlock->SetColorAndOpacity(FSlateColor(ButtonUnhoveredTextColor));
|
|
||||||
}
|
|
||||||
|
|
||||||
void UVampireInteractiveWidget::PlayUnhoveredSound()
|
|
||||||
{
|
|
||||||
if (ButtonUnhoveredSound)
|
|
||||||
{
|
|
||||||
UGameplayStatics::PlaySound2D(GetWorld(), ButtonUnhoveredSound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UVampireInteractiveWidget::PlayClickedSound()
|
|
||||||
{
|
|
||||||
if (ButtonClickedSound)
|
|
||||||
{
|
|
||||||
UGameplayStatics::PlaySound2D(GetWorld(), ButtonClickedSound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void UVampireInteractiveWidget::ReturnToPreviousScreen()
|
|
||||||
{
|
|
||||||
GEngine->GameUserSettings->ApplySettings(false);
|
|
||||||
|
|
||||||
this->RemoveFromParent();
|
|
||||||
PreviousScreen->AddToViewport();
|
|
||||||
}
|
|
@ -1,62 +0,0 @@
|
|||||||
// Louis Hobbs | 2024-2025
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
|
||||||
#include "Blueprint/UserWidget.h"
|
|
||||||
#include "VampireInteractiveWidget.generated.h"
|
|
||||||
|
|
||||||
class UTextBlock;
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
UCLASS()
|
|
||||||
class VAMPIRES_API UVampireInteractiveWidget : public UUserWidget
|
|
||||||
{
|
|
||||||
GENERATED_BODY()
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
TObjectPtr<USoundBase> ButtonHoveredSound;
|
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
FLinearColor ButtonHoveredTextColor = {0, 1, 0, 1};
|
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
FLinearColor ButtonUnhoveredTextColor = {1, 1, 1, 1};
|
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
TObjectPtr<USoundBase> ButtonUnhoveredSound;
|
|
||||||
|
|
||||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite)
|
|
||||||
TObjectPtr<USoundBase> ButtonClickedSound;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
UPROPERTY()
|
|
||||||
TObjectPtr<UUserWidget> PreviousScreen;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void SetReturnScreen(UUserWidget* userWidget);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
UFUNCTION()
|
|
||||||
void PlayHoveredSound();
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void SetTextBlockHovered(UTextBlock* TextBlock);
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void SetTextBlockUnhovered(UTextBlock* TextBlock);
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void PlayUnhoveredSound();
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void PlayClickedSound();
|
|
||||||
|
|
||||||
UFUNCTION()
|
|
||||||
void ReturnToPreviousScreen();
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user