From 6ec858802064f19f4c5f81ea26d8f179f178a966 Mon Sep 17 00:00:00 2001 From: baz Date: Tue, 9 Sep 2025 23:01:16 +0100 Subject: [PATCH] Final Widget cleanup for now --- Content/Levels/MainMenu/MainMenu.umap | 4 +- Source/vampires/Widgets/LevelUpWidget.h | 1 + Source/vampires/Widgets/MainMenuWidget.cpp | 2 + Source/vampires/Widgets/OptionsMenuWidget.h | 1 + .../Widgets/VampireInteractiveWidget.cpp | 53 ------------------- .../Widgets/VampireInteractiveWidget.h | 49 +---------------- 6 files changed, 7 insertions(+), 103 deletions(-) diff --git a/Content/Levels/MainMenu/MainMenu.umap b/Content/Levels/MainMenu/MainMenu.umap index a1a548d..334055c 100644 --- a/Content/Levels/MainMenu/MainMenu.umap +++ b/Content/Levels/MainMenu/MainMenu.umap @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f21dfcd7746b81d5b250a1d014c6b9911e50b337eb80955b24e6618da8142beb -size 49092 +oid sha256:316363d009a2a89e0fa65fe2893020e741e90cd7fb90f20bb99f81e2c4633266 +size 49023 diff --git a/Source/vampires/Widgets/LevelUpWidget.h b/Source/vampires/Widgets/LevelUpWidget.h index fe75ee8..3f0b510 100644 --- a/Source/vampires/Widgets/LevelUpWidget.h +++ b/Source/vampires/Widgets/LevelUpWidget.h @@ -6,6 +6,7 @@ #include "VampireInteractiveWidget.h" #include "LevelUpWidget.generated.h" +class UCustomButton; class UUpgradeButtonWidget; class UScrollBox; class UUpgradeButtonDataObject; diff --git a/Source/vampires/Widgets/MainMenuWidget.cpp b/Source/vampires/Widgets/MainMenuWidget.cpp index 06efb19..940a765 100644 --- a/Source/vampires/Widgets/MainMenuWidget.cpp +++ b/Source/vampires/Widgets/MainMenuWidget.cpp @@ -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) diff --git a/Source/vampires/Widgets/OptionsMenuWidget.h b/Source/vampires/Widgets/OptionsMenuWidget.h index b0d1394..fb6913e 100644 --- a/Source/vampires/Widgets/OptionsMenuWidget.h +++ b/Source/vampires/Widgets/OptionsMenuWidget.h @@ -6,6 +6,7 @@ #include "VampireInteractiveWidget.h" #include "OptionsMenuWidget.generated.h" +class UTextBlock; class UCustomSlider; class UCustomComboBoxString; class USlider; diff --git a/Source/vampires/Widgets/VampireInteractiveWidget.cpp b/Source/vampires/Widgets/VampireInteractiveWidget.cpp index 2263db5..87208ef 100644 --- a/Source/vampires/Widgets/VampireInteractiveWidget.cpp +++ b/Source/vampires/Widgets/VampireInteractiveWidget.cpp @@ -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(); -} diff --git a/Source/vampires/Widgets/VampireInteractiveWidget.h b/Source/vampires/Widgets/VampireInteractiveWidget.h index 12497df..6e07b71 100644 --- a/Source/vampires/Widgets/VampireInteractiveWidget.h +++ b/Source/vampires/Widgets/VampireInteractiveWidget.h @@ -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 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 ButtonUnhoveredSound; - - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings | Sound") - TObjectPtr ButtonClickedSound; - - UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Widget Settings") - TArray> InteractableButtons; - - TObjectPtr CurrentFocus; - UPROPERTY() - TObjectPtr PreviousScreen; + TObjectPtr 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(); };