Optimizing WB_CaptureSettings

This commit is contained in:
martinluckyrobots 2025-04-11 13:33:10 +08:00
parent 8d20bf761d
commit e670c690ce
7 changed files with 60 additions and 2 deletions

View File

@ -7,7 +7,7 @@
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
#include "Subsystems/SubsystemBlueprintLibrary.h"
#include "VaRestSubsystem.h"
#include <Kismet/GameplayStatics.h>
#include "Kismet/GameplayStatics.h"
void UMainScreenUserWidget::NativeConstruct()
{

View File

@ -2,4 +2,39 @@
#include "UI/Settings/CaptureSettingsUserWidget.h"
#include "Core/LuckyRobotsGameInstance.h"
#include "UI/GameUserWidget.h"
void UCaptureSettingsUserWidget::NativeConstruct()
{
Super::NativeConstruct();
BPRefreshTaskList();
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->OnRandomMeshesUpdated.AddDynamic(this, &UCaptureSettingsUserWidget::BPOnRandomMeshesUpdated);
}
}
void UCaptureSettingsUserWidget::ToggleMenu()
{
bIsOpen = !bIsOpen;
if (bIsOpen)
{
BPLoadSettings();
}
else
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance && GameInstance->GameUserWidget)
{
GameInstance->GameUserWidget->DoAutoConfirm();
}
}
OnOpenMenuStateChanged.Broadcast(bIsOpen);
ToggleMenuDisplay();
}

View File

@ -47,4 +47,7 @@ public:
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void DoRefreshListView();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void DoAutoConfirm();
};

View File

@ -7,6 +7,8 @@
#include "SharedDef.h"
#include "CaptureSettingsUserWidget.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnOpenMenuStateChanged, bool, Open);
/**
*
*/
@ -14,12 +16,30 @@ UCLASS()
class LUCKYROBOTS_API UCaptureSettingsUserWidget : public UUserWidget
{
GENERATED_BODY()
protected:
virtual void NativeConstruct() override;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsOpen;
UPROPERTY(BlueprintCallable, BlueprintAssignable, Category = "Event")
FOnOpenMenuStateChanged OnOpenMenuStateChanged;
public:
UFUNCTION(BlueprintCallable)
void ToggleMenu();
public:
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void BPRefreshTaskList();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void BPOnRandomMeshesUpdated();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void BPLoadSettings();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void ToggleMenuDisplay();
};