diff --git a/Content/GameBP/UI/Settings/WB_AllRandom.uasset b/Content/GameBP/UI/Settings/WB_AllRandom.uasset index f9f52493..411f9f76 100644 Binary files a/Content/GameBP/UI/Settings/WB_AllRandom.uasset and b/Content/GameBP/UI/Settings/WB_AllRandom.uasset differ diff --git a/Content/GameBP/UI/Settings/WB_NavigateSimpleEnvironments.uasset b/Content/GameBP/UI/Settings/WB_NavigateSimpleEnvironments.uasset index f201151d..c1107286 100644 Binary files a/Content/GameBP/UI/Settings/WB_NavigateSimpleEnvironments.uasset and b/Content/GameBP/UI/Settings/WB_NavigateSimpleEnvironments.uasset differ diff --git a/Content/GameBP/UI/WB_GameWidget.uasset b/Content/GameBP/UI/WB_GameWidget.uasset index a0b2755d..36a93fae 100644 Binary files a/Content/GameBP/UI/WB_GameWidget.uasset and b/Content/GameBP/UI/WB_GameWidget.uasset differ diff --git a/Content/luckyBot/Luckywidget/ChildItems/WB_ObjectsListCheckbox.uasset b/Content/luckyBot/Luckywidget/ChildItems/WB_ObjectsListCheckbox.uasset index 0669ca82..a7db3059 100644 Binary files a/Content/luckyBot/Luckywidget/ChildItems/WB_ObjectsListCheckbox.uasset and b/Content/luckyBot/Luckywidget/ChildItems/WB_ObjectsListCheckbox.uasset differ diff --git a/Source/LuckyWorldV2/Private/Core/LuckyRobotsGameInstance.cpp b/Source/LuckyWorldV2/Private/Core/LuckyRobotsGameInstance.cpp index 7d9f527b..ebc40ce3 100644 --- a/Source/LuckyWorldV2/Private/Core/LuckyRobotsGameInstance.cpp +++ b/Source/LuckyWorldV2/Private/Core/LuckyRobotsGameInstance.cpp @@ -13,6 +13,18 @@ #include "Subsystems/SubsystemBlueprintLibrary.h" #include "Gameplay/TargetSelector.h" #include "UI/Settings/CaptureSettingsUserWidget.h" +#include "Subsystem/UISubsystem.h" + +void ULuckyRobotsGameInstance::Init() +{ + Super::Init(); + + auto UISubsystem = GetSubsystem(); + if (UISubsystem) + { + UISubsystem->OnAllRandomMenuStateChanged.AddDynamic(this, &ULuckyRobotsGameInstance::DoAllRandomMenuStateChanged); + } +} void ULuckyRobotsGameInstance::DoSendMessage(const FString& SendValue) { @@ -416,6 +428,11 @@ void ULuckyRobotsGameInstance::UpdateTargetSelector() } } +void ULuckyRobotsGameInstance::DoAllRandomMenuStateChanged(bool open) +{ + bIsRandomPannel = open; +} + void ULuckyRobotsGameInstance::SetCurrentFolderName(const FString& FolderName) { CurrentCaptureSettingsData.FolderName = FText::FromString(FolderName); diff --git a/Source/LuckyWorldV2/Private/UI/Settings/AllRandomUserWidget.cpp b/Source/LuckyWorldV2/Private/UI/Settings/AllRandomUserWidget.cpp index 468c72a6..68cf67b8 100644 --- a/Source/LuckyWorldV2/Private/UI/Settings/AllRandomUserWidget.cpp +++ b/Source/LuckyWorldV2/Private/UI/Settings/AllRandomUserWidget.cpp @@ -2,4 +2,63 @@ #include "UI/Settings/AllRandomUserWidget.h" +#include "Subsystem/UISubsystem.h" +#include "Components/WrapBox.h" +#include "Core/LuckyRobotsGameInstance.h" +#include "UI/Settings/ObjectsListUserWidget.h" +void UAllRandomUserWidget::NativeConstruct() +{ + Super::NativeConstruct(); + + SetVisibility(ESlateVisibility::Hidden); + + auto UISubsystem = GetGameInstance()->GetSubsystem(); + if (UISubsystem) + { + UISubsystem->OnAllRandomMenuStateChanged.AddDynamic(this, &UAllRandomUserWidget::DoAllRandomMenuStateChanged); + } + + DoUpdateItemList(EItemCategory::Furniture); +} + +void UAllRandomUserWidget::DoAllRandomMenuStateChanged(bool open) +{ + if (open) + { + DoOpen(); + SetVisibility(ESlateVisibility::Visible); + } + else + { + SetVisibility(ESlateVisibility::Hidden); + } +} + +void UAllRandomUserWidget::DoUpdateItemList(EItemCategory ItemCategory) +{ + if (GetWrapBox() && ObjectsListUserWidgetClass) + { + GetWrapBox()->ClearChildren(); + + ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); + if (GameInstance) + { + TArray SelectableItemList = GameInstance->GetSelectableItemList(ItemCategory); + for (auto SelectableItem : SelectableItemList) + { + UObjectsListUserWidget* ObjectsListUserWidget = CreateWidget(this, ObjectsListUserWidgetClass); + if (ObjectsListUserWidget) + { + ObjectsListUserWidget->SelectableItemData = SelectableItem; + GetWrapBox()->AddChild(ObjectsListUserWidget); + } + } + } + } +} + +void UAllRandomUserWidget::DoOpen() +{ + DoUpdateItemList(EItemCategory::Furniture); +} \ No newline at end of file diff --git a/Source/LuckyWorldV2/Private/UI/Settings/CaptureSettingsUserWidget.cpp b/Source/LuckyWorldV2/Private/UI/Settings/CaptureSettingsUserWidget.cpp index 7eee5892..47480012 100644 --- a/Source/LuckyWorldV2/Private/UI/Settings/CaptureSettingsUserWidget.cpp +++ b/Source/LuckyWorldV2/Private/UI/Settings/CaptureSettingsUserWidget.cpp @@ -84,13 +84,10 @@ void UCaptureSettingsUserWidget::ToggleRandomPannel() ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); if (GameInstance) { - GameInstance->bIsRandomPannel = !GameInstance->bIsRandomPannel; - if (GameInstance->bIsRandomPannel) + auto UISubsystem = GetGameInstance()->GetSubsystem(); + if (UISubsystem) { - if (GameInstance->GameUserWidget && GameInstance->GameUserWidget->GetAllRandomUserWidget()) - { - GameInstance->GameUserWidget->GetAllRandomUserWidget()->DoOpen(); - } + UISubsystem->OnAllRandomMenuStateChanged.Broadcast(!GameInstance->bIsRandomPannel); } } } diff --git a/Source/LuckyWorldV2/Private/UI/Settings/ObjectsListUserWidget.cpp b/Source/LuckyWorldV2/Private/UI/Settings/ObjectsListUserWidget.cpp new file mode 100644 index 00000000..12798d17 --- /dev/null +++ b/Source/LuckyWorldV2/Private/UI/Settings/ObjectsListUserWidget.cpp @@ -0,0 +1,5 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "UI/Settings/ObjectsListUserWidget.h" + diff --git a/Source/LuckyWorldV2/Private/UI/Settings/PathfindingSelectorUserWidget.cpp b/Source/LuckyWorldV2/Private/UI/Settings/PathfindingSelectorUserWidget.cpp index 262d7ba8..93c04d97 100644 --- a/Source/LuckyWorldV2/Private/UI/Settings/PathfindingSelectorUserWidget.cpp +++ b/Source/LuckyWorldV2/Private/UI/Settings/PathfindingSelectorUserWidget.cpp @@ -2,4 +2,63 @@ #include "UI/Settings/PathfindingSelectorUserWidget.h" +#include "Gameplay/TargetSelector.h" +#include "Core/LuckyRobotsGameInstance.h" +#include "Subsystem/UISubsystem.h" +#include "UI/Settings/SelectGoalUserWidget.h" +void UPathfindingSelectorUserWidget::ClickSelectObjectBtn() +{ + if (CreatedTargetSelector) + { + CreatedTargetSelector->Destroy(); + CreatedTargetSelector = nullptr; + } + + ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); + if (GameInstance) + { + FTransform SpawnPoint; + CreatedTargetSelector = GetWorld()->SpawnActorDeferred(GameInstance->TargetSelectorClass, SpawnPoint, nullptr, nullptr, + ESpawnActorCollisionHandlingMethod::AlwaysSpawn); + if (CreatedTargetSelector) + { + CreatedTargetSelector->FinishSpawning(SpawnPoint); + } + } + + auto UISubsystem = GetGameInstance()->GetSubsystem(); + if (UISubsystem) + { + UISubsystem->OnStartTracing.Broadcast(); + } +} + +void UPathfindingSelectorUserWidget::AddGoal() +{ + if (CreatedTargetSelector) + { + ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); + if (GameInstance) + { + FGoalsTaskData addTempTask; + addTempTask.GoalType = EGoalType::NavigateSimpleEnvironments; + addTempTask.TargetLocation = CreatedTargetSelector->GetActorTransform(); + GameInstance->TempTask = addTempTask; + GameInstance->bIsChanged = true; + } + + auto UISubsystem = GetGameInstance()->GetSubsystem(); + if (UISubsystem) + { + UISubsystem->OnEndTracing.Broadcast(); + } + + if (OwnerSelectGoalUserWidget) + { + OwnerSelectGoalUserWidget->DoAddGoalAndStopTracing(); + } + + CreatedTargetSelector->bIsTracing = false; + } +} \ No newline at end of file diff --git a/Source/LuckyWorldV2/Private/UI/Settings/SelectGoalUserWidget.cpp b/Source/LuckyWorldV2/Private/UI/Settings/SelectGoalUserWidget.cpp index 271b3d41..9d86ff3c 100644 --- a/Source/LuckyWorldV2/Private/UI/Settings/SelectGoalUserWidget.cpp +++ b/Source/LuckyWorldV2/Private/UI/Settings/SelectGoalUserWidget.cpp @@ -195,6 +195,6 @@ void USelectGoalUserWidget::DelayAddGoal() if (NavigateSimpleEnvironments) { - NavigateSimpleEnvironments->BPClickSelectObjectBtn(); + NavigateSimpleEnvironments->ClickSelectObjectBtn(); } } \ No newline at end of file diff --git a/Source/LuckyWorldV2/Public/Core/LuckyRobotsGameInstance.h b/Source/LuckyWorldV2/Public/Core/LuckyRobotsGameInstance.h index 5c1b62cd..9d38795a 100644 --- a/Source/LuckyWorldV2/Public/Core/LuckyRobotsGameInstance.h +++ b/Source/LuckyWorldV2/Public/Core/LuckyRobotsGameInstance.h @@ -20,6 +20,9 @@ class LUCKYWORLDV2_API ULuckyRobotsGameInstance : public UGameInstance { GENERATED_BODY() +public: + virtual void Init(); + public: UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config") UDataTable* RobotDataDataTable; @@ -210,6 +213,9 @@ public: UFUNCTION(BlueprintCallable) void UpdateTargetSelector(); + UFUNCTION(BlueprintCallable) + void DoAllRandomMenuStateChanged(bool open); + public: UFUNCTION(BlueprintCallable) void SetCurrentFolderName(const FString& FolderName); diff --git a/Source/LuckyWorldV2/Public/Subsystem/UISubsystem.h b/Source/LuckyWorldV2/Public/Subsystem/UISubsystem.h index 0a535378..276ee971 100644 --- a/Source/LuckyWorldV2/Public/Subsystem/UISubsystem.h +++ b/Source/LuckyWorldV2/Public/Subsystem/UISubsystem.h @@ -14,6 +14,7 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnStopCapture); DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnReset); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnOpenMenuStateChanged, bool, Open); +DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAllRandomMenuStateChanged, bool, Open); /** * */ @@ -40,4 +41,7 @@ public: UPROPERTY(BlueprintCallable, BlueprintAssignable) FOnOpenMenuStateChanged OnOpenMenuStateChanged; + + UPROPERTY(BlueprintCallable, BlueprintAssignable) + FOnAllRandomMenuStateChanged OnAllRandomMenuStateChanged; }; diff --git a/Source/LuckyWorldV2/Public/UI/Settings/AllRandomUserWidget.h b/Source/LuckyWorldV2/Public/UI/Settings/AllRandomUserWidget.h index 1eab1417..969bd62a 100644 --- a/Source/LuckyWorldV2/Public/UI/Settings/AllRandomUserWidget.h +++ b/Source/LuckyWorldV2/Public/UI/Settings/AllRandomUserWidget.h @@ -6,6 +6,8 @@ #include "Blueprint/UserWidget.h" #include "AllRandomUserWidget.generated.h" +class UWrapBox; +class UObjectsListUserWidget; /** * */ @@ -13,8 +15,25 @@ UCLASS() class LUCKYWORLDV2_API UAllRandomUserWidget : public UUserWidget { GENERATED_BODY() - + +protected: + virtual void NativeConstruct() override; + public: - UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config") + TSubclassOf ObjectsListUserWidgetClass; + +public: + UFUNCTION(BlueprintCallable) + void DoAllRandomMenuStateChanged(bool open); + + UFUNCTION(BlueprintCallable) + void DoUpdateItemList(EItemCategory ItemCategory); + + UFUNCTION(BlueprintCallable) void DoOpen(); + +public: + UFUNCTION(BlueprintPure, BlueprintImplementableEvent) + UWrapBox* GetWrapBox(); }; diff --git a/Source/LuckyWorldV2/Public/UI/Settings/ObjectsListUserWidget.h b/Source/LuckyWorldV2/Public/UI/Settings/ObjectsListUserWidget.h new file mode 100644 index 00000000..242c50a0 --- /dev/null +++ b/Source/LuckyWorldV2/Public/UI/Settings/ObjectsListUserWidget.h @@ -0,0 +1,21 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Blueprint/UserWidget.h" +#include "SharedDef.h" +#include "ObjectsListUserWidget.generated.h" + +/** + * + */ +UCLASS() +class LUCKYWORLDV2_API UObjectsListUserWidget : public UUserWidget +{ + GENERATED_BODY() + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite) + FSelectableItemData SelectableItemData; +}; diff --git a/Source/LuckyWorldV2/Public/UI/Settings/PathfindingSelectorUserWidget.h b/Source/LuckyWorldV2/Public/UI/Settings/PathfindingSelectorUserWidget.h index ef5bd3e3..22cdf334 100644 --- a/Source/LuckyWorldV2/Public/UI/Settings/PathfindingSelectorUserWidget.h +++ b/Source/LuckyWorldV2/Public/UI/Settings/PathfindingSelectorUserWidget.h @@ -6,6 +6,8 @@ #include "Blueprint/UserWidget.h" #include "PathfindingSelectorUserWidget.generated.h" +class ATargetSelector; +class USelectGoalUserWidget; /** * */ @@ -15,6 +17,16 @@ class LUCKYWORLDV2_API UPathfindingSelectorUserWidget : public UUserWidget GENERATED_BODY() public: - UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) - void BPClickSelectObjectBtn(); + UPROPERTY(EditAnywhere, BlueprintReadWrite) + ATargetSelector* CreatedTargetSelector; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + USelectGoalUserWidget* OwnerSelectGoalUserWidget; + +public: + UFUNCTION(BlueprintCallable) + void ClickSelectObjectBtn(); + + UFUNCTION(BlueprintCallable) + void AddGoal(); };