From 0a302a8efa9ecb8eb5abcf9fe1fe0c32a965d6a3 Mon Sep 17 00:00:00 2001 From: baz Date: Thu, 23 May 2024 23:27:23 +0100 Subject: [PATCH] Create LoadGameUserWidget --- Source/Nakatomi/UI/LoadGameUserWidget.cpp | 26 ++++++++++++++ Source/Nakatomi/UI/LoadGameUserWidget.h | 41 +++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 Source/Nakatomi/UI/LoadGameUserWidget.cpp create mode 100644 Source/Nakatomi/UI/LoadGameUserWidget.h diff --git a/Source/Nakatomi/UI/LoadGameUserWidget.cpp b/Source/Nakatomi/UI/LoadGameUserWidget.cpp new file mode 100644 index 0000000..9fb71c1 --- /dev/null +++ b/Source/Nakatomi/UI/LoadGameUserWidget.cpp @@ -0,0 +1,26 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "../UI/LoadGameUserWidget.h" + +void ULoadGameUserWidget::NativeConstruct() +{ + Super::NativeConstruct(); + + if (CancelButton) + { + CancelButton->OnClicked.AddUniqueDynamic(this, &ULoadGameUserWidget::CancelButtonOnClicked); + CancelButton->OnClicked.AddUniqueDynamic(this, &ULoadGameUserWidget::PlayClickedSound); + + CancelButton->OnHovered.AddUniqueDynamic(this, &ULoadGameUserWidget::CancelButtonHoveredDelegate); + CancelButton->OnHovered.AddUniqueDynamic(this, &ULoadGameUserWidget::PlayHoveredSound); + + CancelButton->OnUnhovered.AddUniqueDynamic(this, &ULoadGameUserWidget::CancelButtonUnhoveredDelegate); + CancelButton->OnUnhovered.AddUniqueDynamic(this, &ULoadGameUserWidget::PlayUnhoveredSound); + } +} + +void ULoadGameUserWidget::CancelButtonOnClicked() +{ + ReturnToPreviousScreen(); +} diff --git a/Source/Nakatomi/UI/LoadGameUserWidget.h b/Source/Nakatomi/UI/LoadGameUserWidget.h new file mode 100644 index 0000000..63ccd3c --- /dev/null +++ b/Source/Nakatomi/UI/LoadGameUserWidget.h @@ -0,0 +1,41 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "NakatomiInteractiveWidget.h" +#include "Components/Button.h" +#include "Components/ScrollBox.h" +#include "LoadGameUserWidget.generated.h" + +/** + * + */ +UCLASS() +class NAKATOMI_API ULoadGameUserWidget : public UNakatomiInteractiveWidget +{ + GENERATED_BODY() +public: + + UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) + UButton* CancelButton; + + UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) + UTextBlock* CancelButtonTextBlock; + + UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) + UScrollBox* SavedGamesScrollBox; + +public: + virtual void NativeConstruct() override; + +private: + UFUNCTION() + void CancelButtonOnClicked(); + + UFUNCTION() + void CancelButtonHoveredDelegate() { SetTextBlockHovered(CancelButtonTextBlock); } + + UFUNCTION() + void CancelButtonUnhoveredDelegate() { SetTextBlockUnhovered(CancelButtonTextBlock); } +};