Compare commits
2 Commits
a0a3aaddff
...
6ec8588020
Author | SHA1 | Date | |
---|---|---|---|
6ec8588020 | |||
7e940e33fd |
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,8 +3,7 @@
|
||||
|
||||
#include "GameOverWidget.h"
|
||||
|
||||
#include "Blueprint/WidgetBlueprintLibrary.h"
|
||||
#include "Components/Button.h"
|
||||
#include "CustomButton.h"
|
||||
#include "Components/TextBlock.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "vampires/VampireGameInstance.h"
|
||||
@ -13,12 +12,22 @@ void UGameOverWidget::NativeConstruct()
|
||||
{
|
||||
Super::NativeConstruct();
|
||||
|
||||
SetIsFocusable(false);
|
||||
|
||||
if (ReturnButton)
|
||||
{
|
||||
ReturnButton->OnClicked.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnClicked);
|
||||
ReturnButton->OnHovered.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnHovered);
|
||||
ReturnButton->OnUnhovered.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnUnhovered);
|
||||
ReturnButton->OnFocused.AddUniqueDynamic(this, &UGameOverWidget::ReturnButtonOnFocused);
|
||||
}
|
||||
|
||||
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)
|
||||
@ -52,8 +61,6 @@ 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())
|
||||
@ -69,14 +76,7 @@ void UGameOverWidget::ReturnButtonOnClicked()
|
||||
}
|
||||
}
|
||||
|
||||
void UGameOverWidget::ReturnButtonOnHovered()
|
||||
void UGameOverWidget::ReturnButtonOnFocused(FFocusEvent InFocusEvent)
|
||||
{
|
||||
SetTextBlockHovered(ReturnBlock);
|
||||
PlayHoveredSound();
|
||||
}
|
||||
|
||||
void UGameOverWidget::ReturnButtonOnUnhovered()
|
||||
{
|
||||
SetTextBlockUnhovered(ReturnBlock);
|
||||
PlayUnhoveredSound();
|
||||
SetCurrentFocus(ReturnButton);
|
||||
}
|
||||
|
@ -4,11 +4,10 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "VampireInteractiveWidget.h"
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "GameOverWidget.generated.h"
|
||||
|
||||
class UCustomButton;
|
||||
class UTextBlock;
|
||||
class UButton;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -18,10 +17,7 @@ class VAMPIRES_API UGameOverWidget : public UVampireInteractiveWidget
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(meta=(BindWidget))
|
||||
TObjectPtr<UButton> ReturnButton;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UTextBlock> ReturnBlock;
|
||||
TObjectPtr<UCustomButton> ReturnButton;
|
||||
|
||||
UPROPERTY(meta = (BindWidget))
|
||||
TObjectPtr<UTextBlock> LevelBlock;
|
||||
@ -37,6 +33,8 @@ 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);
|
||||
|
||||
@ -45,8 +43,5 @@ private:
|
||||
void ReturnButtonOnClicked();
|
||||
|
||||
UFUNCTION()
|
||||
void ReturnButtonOnHovered();
|
||||
|
||||
UFUNCTION()
|
||||
void ReturnButtonOnUnhovered();
|
||||
void ReturnButtonOnFocused(FFocusEvent InFocusEvent);
|
||||
};
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "VampireInteractiveWidget.h"
|
||||
#include "LevelUpWidget.generated.h"
|
||||
|
||||
class UCustomButton;
|
||||
class UUpgradeButtonWidget;
|
||||
class UScrollBox;
|
||||
class UUpgradeButtonDataObject;
|
||||
|
@ -37,6 +37,8 @@ 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,6 +6,7 @@
|
||||
#include "VampireInteractiveWidget.h"
|
||||
#include "OptionsMenuWidget.generated.h"
|
||||
|
||||
class UTextBlock;
|
||||
class UCustomSlider;
|
||||
class UCustomComboBoxString;
|
||||
class USlider;
|
||||
|
@ -3,9 +3,6 @@
|
||||
|
||||
#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)
|
||||
@ -20,57 +17,7 @@ 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,9 +6,6 @@
|
||||
#include "Blueprint/UserWidget.h"
|
||||
#include "VampireInteractiveWidget.generated.h"
|
||||
|
||||
class UCustomButton;
|
||||
class UButton;
|
||||
class UTextBlock;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ -17,31 +14,9 @@ class VAMPIRES_API UVampireInteractiveWidget : public UUserWidget
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
// TODO: Remove a lot of this stuff that has now been replaced by UCustomButton
|
||||
|
||||
protected:
|
||||
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;
|
||||
TObjectPtr<UUserWidget> CurrentFocus;
|
||||
|
||||
bool GamepadConnected = false;
|
||||
|
||||
@ -50,28 +25,6 @@ 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