Compare commits
No commits in common. "6ec858802064f19f4c5f81ea26d8f179f178a966" and "a0a3aaddffb6db906fabfa90af3f74c7c257d780" have entirely different histories.
6ec8588020
...
a0a3aaddff
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/Widgets/GameOver/BP_GameOverWidget.uasset
(Stored with Git LFS)
BIN
Content/Widgets/GameOver/BP_GameOverWidget.uasset
(Stored with Git LFS)
Binary file not shown.
@ -3,7 +3,8 @@
|
||||
|
||||
#include "GameOverWidget.h"
|
||||
|
||||
#include "CustomButton.h"
|
||||
#include "Blueprint/WidgetBlueprintLibrary.h"
|
||||
#include "Components/Button.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "vampires/VampireGameInstance.h"
|
||||
@ -12,22 +13,12 @@ void UGameOverWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
SetIsFocusable(false);
|
||||
|
||||
if (ReturnButton)
|
||||
{
|
||||
ReturnButton->OnClicked.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnClicked);
|
||||
ReturnButton->OnFocused.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnFocused);
|
||||
ReturnButton->OnHovered.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnHovered);
|
||||
ReturnButton->OnUnhovered.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnUnhovered);
|
||||
}
|
||||
|
||||
ReturnButton->SetKeyboardFocus();
|
||||
}
|
||||
|
||||
FReply UGameOverWidget::NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)
|
||||
{
|
||||
CurrentFocus->SetKeyboardFocus();
|
||||
|
||||
return Super::NativeOnMouseButtonUp(InGeometry, InMouseEvent);
|
||||
}
|
||||
|
||||
void UGameOverWidget::SetGameInfo(int Level, float Timer, int Kill, int Gold)
|
||||
@ -61,6 +52,8 @@ void UGameOverWidget::SetGameInfo(int Level, float Timer, int Kill, int Gold)
|
||||
|
||||
void UGameOverWidget::ReturnButtonOnClicked()
|
||||
{
|
||||
PlayClickedSound();
|
||||
|
||||
if (UVampireGameInstance* GameInstance = Cast<UVampireGameInstance>(GetGameInstance()))
|
||||
{
|
||||
if (!GameInstance->MainMenuWorld.IsNull())
|
||||
@ -76,7 +69,14 @@ void UGameOverWidget::ReturnButtonOnClicked()
|
||||
}
|
||||
}
|
||||
|
||||
void UGameOverWidget::ReturnButtonOnFocused(FFocusEvent InFocusEvent)
|
||||
void UGameOverWidget::ReturnButtonOnHovered()
|
||||
{
|
||||
SetCurrentFocus(ReturnButton);
|
||||
SetTextBlockHovered(ReturnBlock);
|
||||
PlayHoveredSound();
|
||||
}
|
||||
|
||||
void UGameOverWidget::ReturnButtonOnUnhovered()
|
||||
{
|
||||
SetTextBlockUnhovered(ReturnBlock);
|
||||
PlayUnhoveredSound();
|
||||
}
|
||||
|
@ -4,10 +4,11 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "VampireInteractiveWidget.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "GameOverWidget.generated.h"
|
||||
|
||||
class UCustomButton;
|
||||
class UTextBlock;
|
||||
class UButton;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -17,7 +18,10 @@ class VAMPIRES_API UGameOverWidget : public UVampireInteractiveWidget
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(meta=(BindWidget))
|
||||
TObjectPtr<UCustomButton> ReturnButton;
|
||||
TObjectPtr<UButton> ReturnButton;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UTextBlock> ReturnBlock;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UTextBlock> LevelBlock;
|
||||
@ -33,8 +37,6 @@ class VAMPIRES_API UGameOverWidget : public UVampireInteractiveWidget
|
||||
|
||||
virtual void NativeConstruct() override;
|
||||
|
||||
virtual FReply NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override;
|
||||
|
||||
public:
|
||||
void SetGameInfo(int Level, float Timer, int Kill, int Gold);
|
||||
|
||||
@ -43,5 +45,8 @@ private:
|
||||
void ReturnButtonOnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void ReturnButtonOnFocused(FFocusEvent InFocusEvent);
|
||||
void ReturnButtonOnHovered();
|
||||
|
||||
UFUNCTION()
|
||||
void ReturnButtonOnUnhovered();
|
||||
};
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "VampireInteractiveWidget.h"
|
||||
#include "LevelUpWidget.generated.h"
|
||||
|
||||
class UCustomButton;
|
||||
class UUpgradeButtonWidget;
|
||||
class UScrollBox;
|
||||
class UUpgradeButtonDataObject;
|
||||
|
@ -37,8 +37,6 @@ void UMainMenuWidget::NativeConstruct()
|
||||
UWidgetBlueprintLibrary::SetInputMode_UIOnlyEx(PlayerController, NewGameButton, EMouseLockMode::LockAlways);
|
||||
PlayerController->bShowMouseCursor = true;
|
||||
}
|
||||
|
||||
NewGameButton->SetKeyboardFocus();
|
||||
}
|
||||
|
||||
FReply UMainMenuWidget::NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent)
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "VampireInteractiveWidget.h"
|
||||
#include "OptionsMenuWidget.generated.h"
|
||||
|
||||
class UTextBlock;
|
||||
class UCustomSlider;
|
||||
class UCustomComboBoxString;
|
||||
class USlider;
|
||||
|
@ -3,6 +3,9 @@
|
||||
|
||||
#include "VampireInteractiveWidget.h"
|
||||
|
||||
#include "Components/TextBlock.h"
|
||||
#include "GameFramework/GameUserSettings.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "vampires/DetectGamepad.h"
|
||||
|
||||
void UVampireInteractiveWidget::NativeTick(const FGeometry& MyGeometry, float InDeltaTime)
|
||||
@ -17,7 +20,57 @@ FReply UVampireInteractiveWidget::NativeOnMouseButtonUp(const FGeometry& InGeome
|
||||
return Super::NativeOnMouseButtonUp(InGeometry, InMouseEvent);
|
||||
}
|
||||
|
||||
void UVampireInteractiveWidget::SetReturnScreen(UUserWidget* UserWidget)
|
||||
{
|
||||
if (UserWidget)
|
||||
{
|
||||
PreviousScreen = UserWidget;
|
||||
}
|
||||
}
|
||||
|
||||
void UVampireInteractiveWidget::SetCurrentFocus(UUserWidget* UserWidget)
|
||||
{
|
||||
CurrentFocus = 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();
|
||||
}
|
||||
|
@ -6,6 +6,9 @@
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "VampireInteractiveWidget.generated.h"
|
||||
|
||||
class UCustomButton;
|
||||
class UButton;
|
||||
class UTextBlock;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -14,10 +17,32 @@ class VAMPIRES_API UVampireInteractiveWidget : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// TODO: Remove a lot of this stuff that has now been replaced by UCustomButton
|
||||
|
||||
protected:
|
||||
UPROPERTY()
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | Sound")
|
||||
TObjectPtr<USoundBase> ButtonHoveredSound;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | Color")
|
||||
FLinearColor ButtonHoveredTextColor = {0, 1, 0, 1};
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | Color")
|
||||
FLinearColor ButtonUnhoveredTextColor = {1, 1, 1, 1};
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | Sound")
|
||||
TObjectPtr<USoundBase> ButtonUnhoveredSound;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | Sound")
|
||||
TObjectPtr<USoundBase> ButtonClickedSound;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings")
|
||||
TArray<TObjectPtr<UButton>> InteractableButtons;
|
||||
|
||||
TObjectPtr<UUserWidget> CurrentFocus;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UUserWidget> PreviousScreen;
|
||||
|
||||
bool GamepadConnected = false;
|
||||
|
||||
virtual void NativeTick(const FGeometry& MyGeometry, float InDeltaTime) override;
|
||||
@ -25,6 +50,28 @@ protected:
|
||||
virtual FReply NativeOnMouseButtonUp(const FGeometry& InGeometry, const FPointerEvent& InMouseEvent) override;
|
||||
|
||||
public:
|
||||
UFUNCTION()
|
||||
void SetReturnScreen(UUserWidget* UserWidget);
|
||||
|
||||
UFUNCTION()
|
||||
void SetCurrentFocus(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