Final Widget cleanup for now

This commit is contained in:
baz 2025-09-09 23:01:16 +01:00
parent 7e940e33fd
commit 6ec8588020
6 changed files with 7 additions and 103 deletions

BIN
Content/Levels/MainMenu/MainMenu.umap (Stored with Git LFS)

Binary file not shown.

View File

@ -6,6 +6,7 @@
#include "VampireInteractiveWidget.h"
#include "LevelUpWidget.generated.h"
class UCustomButton;
class UUpgradeButtonWidget;
class UScrollBox;
class UUpgradeButtonDataObject;

View File

@ -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)

View File

@ -6,6 +6,7 @@
#include "VampireInteractiveWidget.h"
#include "OptionsMenuWidget.generated.h"
class UTextBlock;
class UCustomSlider;
class UCustomComboBoxString;
class USlider;

View File

@ -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();
}

View File

@ -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();
};