diff --git a/Content/GameBP/Datatable/DT_AllGoalListData.uasset b/Content/GameBP/Datatable/DT_AllGoalListData.uasset index dd005c4e..0e650fcb 100644 Binary files a/Content/GameBP/Datatable/DT_AllGoalListData.uasset and b/Content/GameBP/Datatable/DT_AllGoalListData.uasset differ diff --git a/Content/luckyBot/Luckywidget/menu/WB_AllRandom.uasset b/Content/GameBP/UI/Settings/WB_AllRandom.uasset similarity index 89% rename from Content/luckyBot/Luckywidget/menu/WB_AllRandom.uasset rename to Content/GameBP/UI/Settings/WB_AllRandom.uasset index ebd1eb8d..f9f52493 100644 Binary files a/Content/luckyBot/Luckywidget/menu/WB_AllRandom.uasset and b/Content/GameBP/UI/Settings/WB_AllRandom.uasset differ diff --git a/Content/GameBP/UI/Settings/WB_CaptureSettings.uasset b/Content/GameBP/UI/Settings/WB_CaptureSettings.uasset index 1897b885..74ae203e 100644 Binary files a/Content/GameBP/UI/Settings/WB_CaptureSettings.uasset and b/Content/GameBP/UI/Settings/WB_CaptureSettings.uasset differ diff --git a/Content/GameBP/UI/Settings/WB_NavigateSimpleEnvironments.uasset b/Content/GameBP/UI/Settings/WB_NavigateSimpleEnvironments.uasset new file mode 100644 index 00000000..f201151d Binary files /dev/null and b/Content/GameBP/UI/Settings/WB_NavigateSimpleEnvironments.uasset differ diff --git a/Content/GameBP/UI/Settings/WB_SelectGoalMenu.uasset b/Content/GameBP/UI/Settings/WB_SelectGoalMenu.uasset new file mode 100644 index 00000000..df9a00ed Binary files /dev/null and b/Content/GameBP/UI/Settings/WB_SelectGoalMenu.uasset differ diff --git a/Content/luckyBot/Luckywidget/menu/WB_ListViewTaskPeopleObject.uasset b/Content/GameBP/UI/Settings/WB_TaskListView.uasset similarity index 72% rename from Content/luckyBot/Luckywidget/menu/WB_ListViewTaskPeopleObject.uasset rename to Content/GameBP/UI/Settings/WB_TaskListView.uasset index bf8f21bc..a56a6ec5 100644 Binary files a/Content/luckyBot/Luckywidget/menu/WB_ListViewTaskPeopleObject.uasset and b/Content/GameBP/UI/Settings/WB_TaskListView.uasset differ diff --git a/Content/GameBP/UI/WB_GameWidget.uasset b/Content/GameBP/UI/WB_GameWidget.uasset index 5811fc84..a0b2755d 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_NavigateSimpleEnvironments.uasset b/Content/luckyBot/Luckywidget/ChildItems/WB_NavigateSimpleEnvironments.uasset deleted file mode 100644 index e82920a1..00000000 Binary files a/Content/luckyBot/Luckywidget/ChildItems/WB_NavigateSimpleEnvironments.uasset and /dev/null differ diff --git a/Content/luckyBot/Luckywidget/menu/WB_SelectGoalMenu.uasset b/Content/luckyBot/Luckywidget/menu/WB_SelectGoalMenu.uasset deleted file mode 100644 index 77b8f2d9..00000000 Binary files a/Content/luckyBot/Luckywidget/menu/WB_SelectGoalMenu.uasset and /dev/null differ diff --git a/Source/LuckyWorldV2/Private/UI/Settings/SelectGoalUserWidget.cpp b/Source/LuckyWorldV2/Private/UI/Settings/SelectGoalUserWidget.cpp index 405a6645..271b3d41 100644 --- a/Source/LuckyWorldV2/Private/UI/Settings/SelectGoalUserWidget.cpp +++ b/Source/LuckyWorldV2/Private/UI/Settings/SelectGoalUserWidget.cpp @@ -2,4 +2,199 @@ #include "UI/Settings/SelectGoalUserWidget.h" +#include "SharedDef.h" +#include "Components/ComboBoxString.h" +#include "Components/SizeBox.h" +#include "Core/LuckyRobotsGameInstance.h" +#include "UI/Settings/PathfindingSelectorUserWidget.h" +#include "UI/GameUserWidget.h" +#include "Subsystem/UISubsystem.h" +void USelectGoalUserWidget::NativeConstruct() +{ + Super::NativeConstruct(); + + bInitAddOption = false; + + if (GetComboBoxString()) + { + if (AllGoalListDataTable) + { + FString ContextString; + TArray RowNames = AllGoalListDataTable->GetRowNames(); + for (const FName& RowName : RowNames) + { + FAllGoalListData* AllGoalListData = AllGoalListDataTable->FindRow(RowName, ContextString); + if (AllGoalListData) + { + if (AllGoalListData->bIsActive) + { + UEnum* GoalTypeEnum = StaticEnum(); + FString GoalTypeString = GoalTypeEnum->GetDisplayNameTextByIndex(int(AllGoalListData->GoalType)).ToString(); + GetComboBoxString()->AddOption(GoalTypeString); + bInitAddOption = true; + break; + } + } + } + } + + GetComboBoxString()->SetSelectedIndex(bInitAddOption); + } +} + +void USelectGoalUserWidget::DoSelectionChanged(const FString& SelectedItem) +{ + if (GetComboBoxString()) + { + if (GetComboBoxString()->GetSelectedIndex() != 0) + { + if (AllGoalListDataTable) + { + FString ContextString; + TArray RowNames = AllGoalListDataTable->GetRowNames(); + for (const FName& RowName : RowNames) + { + FAllGoalListData* AllGoalListData = AllGoalListDataTable->FindRow(RowName, ContextString); + if (AllGoalListData) + { + if (AllGoalListData->bIsActive) + { + UEnum* GoalTypeEnum = StaticEnum(); + FString GoalTypeString = GoalTypeEnum->GetDisplayNameTextByIndex(int(AllGoalListData->GoalType)).ToString(); + if (GoalTypeString == SelectedItem) + { + if (AllGoalListData->Widget) + { + if (!CreatedUserWidget || (CreatedUserWidget && CreatedUserWidget->GetClass() != AllGoalListData->Widget)) + { + if (CreatedUserWidget) + { + CreatedUserWidget->RemoveFromParent(); + CreatedUserWidget = nullptr; + } + + CreatedUserWidget = CreateWidget(this, AllGoalListData->Widget); + if (CreatedUserWidget) + { + if (GetSizeBox()) + { + GetSizeBox()->AddChild(CreatedUserWidget); + } + } + } + } + else + { + if (CreatedUserWidget) + { + CreatedUserWidget->RemoveFromParent(); + CreatedUserWidget = nullptr; + } + } + + DoSendDetail(AllGoalListData->Example); + + ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); + if (GameInstance) + { + GameInstance->bIsChanged = false; + } + + NavigateSimpleEnvironments = Cast(CreatedUserWidget); + + break; + } + } + } + } + } + } + else + { + if (CreatedUserWidget) + { + CreatedUserWidget->RemoveFromParent(); + CreatedUserWidget = nullptr; + } + } + } +} + +void USelectGoalUserWidget::DoCloseWindow() +{ + if (GetComboBoxString()) + { + GetComboBoxString()->SetSelectedIndex(bInitAddOption); + } + + ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); + if (GameInstance) + { + if (GameInstance->GameUserWidget) + { + GameInstance->GameUserWidget->bIsGoalMenuVis = false; + } + } +} + +void USelectGoalUserWidget::DoAutoConfirm() +{ + if (GetComboBoxString()) + { + if (GetComboBoxString()->GetSelectedIndex() != 0) + { + auto UISubsystem = GetGameInstance()->GetSubsystem(); + if (UISubsystem) + { + UISubsystem->OnEndTracing.Broadcast(); + } + + ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); + if (GameInstance) + { + GameInstance->UpdateTargetSelector(); + GameInstance->TempTask = FGoalsTaskData(); + } + + GetComboBoxString()->SetSelectedIndex(bInitAddOption); + + DoCloseWindow(); + } + } +} + +void USelectGoalUserWidget::DoAddGoalAndStopTracing() +{ + ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); + if (GameInstance) + { + if (GameInstance->bIsChanged) + { + if (GetComboBoxString()) + { + if (GetComboBoxString()->GetSelectedIndex() != 0) + { + DoSaveGoalsBTNClick(); + + GetWorld()->GetTimerManager().ClearTimer(DelayAddGoalTimerHandle); + GetWorld()->GetTimerManager().SetTimer(DelayAddGoalTimerHandle, this, &USelectGoalUserWidget::DelayAddGoal, 0.2f, false); + } + } + } + } +} + +void USelectGoalUserWidget::DelayAddGoal() +{ + ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); + if (GameInstance) + { + GameInstance->TempTask = FGoalsTaskData(); + } + + if (NavigateSimpleEnvironments) + { + NavigateSimpleEnvironments->BPClickSelectObjectBtn(); + } +} \ No newline at end of file diff --git a/Source/LuckyWorldV2/Public/UI/Settings/PathfindingSelectorUserWidget.h b/Source/LuckyWorldV2/Public/UI/Settings/PathfindingSelectorUserWidget.h index f70fa615..ef5bd3e3 100644 --- a/Source/LuckyWorldV2/Public/UI/Settings/PathfindingSelectorUserWidget.h +++ b/Source/LuckyWorldV2/Public/UI/Settings/PathfindingSelectorUserWidget.h @@ -14,4 +14,7 @@ class LUCKYWORLDV2_API UPathfindingSelectorUserWidget : public UUserWidget { GENERATED_BODY() +public: + UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + void BPClickSelectObjectBtn(); }; diff --git a/Source/LuckyWorldV2/Public/UI/Settings/SelectGoalUserWidget.h b/Source/LuckyWorldV2/Public/UI/Settings/SelectGoalUserWidget.h index bb92685e..9f15c6d5 100644 --- a/Source/LuckyWorldV2/Public/UI/Settings/SelectGoalUserWidget.h +++ b/Source/LuckyWorldV2/Public/UI/Settings/SelectGoalUserWidget.h @@ -6,6 +6,9 @@ #include "Blueprint/UserWidget.h" #include "SelectGoalUserWidget.generated.h" +class UComboBoxString; +class UPathfindingSelectorUserWidget; +class USizeBox; /** * */ @@ -14,7 +17,49 @@ class LUCKYWORLDV2_API USelectGoalUserWidget : public UUserWidget { GENERATED_BODY() +protected: + virtual void NativeConstruct() override; + public: - UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config") + UDataTable* AllGoalListDataTable; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + UPathfindingSelectorUserWidget* NavigateSimpleEnvironments; + + UPROPERTY(EditAnywhere, BlueprintReadWrite) + UUserWidget* CreatedUserWidget; + +public: + FTimerHandle DelayAddGoalTimerHandle; + +public: + UPROPERTY(EditAnywhere, BlueprintReadWrite) + bool bInitAddOption; +public: + UFUNCTION(BlueprintCallable) + void DoSelectionChanged(const FString& SelectedItem); + + UFUNCTION(BlueprintCallable) + void DoCloseWindow(); + + UFUNCTION(BlueprintCallable) void DoAutoConfirm(); + + UFUNCTION(BlueprintCallable) + void DoAddGoalAndStopTracing(); + + void DelayAddGoal(); +public: + UFUNCTION(BlueprintPure, BlueprintImplementableEvent) + UComboBoxString* GetComboBoxString(); + + UFUNCTION(BlueprintPure, BlueprintImplementableEvent) + USizeBox* GetSizeBox(); + + UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + void DoSendDetail(const FString& Explanationn); + + UFUNCTION(BlueprintCallable, BlueprintImplementableEvent) + void DoSaveGoalsBTNClick(); };