martin #25
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
Content/GameBP/UI/Settings/WB_NavigateSimpleEnvironments.uasset
Normal file
BIN
Content/GameBP/UI/Settings/WB_NavigateSimpleEnvironments.uasset
Normal file
Binary file not shown.
BIN
Content/GameBP/UI/Settings/WB_SelectGoalMenu.uasset
Normal file
BIN
Content/GameBP/UI/Settings/WB_SelectGoalMenu.uasset
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2,4 +2,199 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "UI/Settings/SelectGoalUserWidget.h"
|
#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<FName> RowNames = AllGoalListDataTable->GetRowNames();
|
||||||
|
for (const FName& RowName : RowNames)
|
||||||
|
{
|
||||||
|
FAllGoalListData* AllGoalListData = AllGoalListDataTable->FindRow<FAllGoalListData>(RowName, ContextString);
|
||||||
|
if (AllGoalListData)
|
||||||
|
{
|
||||||
|
if (AllGoalListData->bIsActive)
|
||||||
|
{
|
||||||
|
UEnum* GoalTypeEnum = StaticEnum<EGoalType>();
|
||||||
|
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<FName> RowNames = AllGoalListDataTable->GetRowNames();
|
||||||
|
for (const FName& RowName : RowNames)
|
||||||
|
{
|
||||||
|
FAllGoalListData* AllGoalListData = AllGoalListDataTable->FindRow<FAllGoalListData>(RowName, ContextString);
|
||||||
|
if (AllGoalListData)
|
||||||
|
{
|
||||||
|
if (AllGoalListData->bIsActive)
|
||||||
|
{
|
||||||
|
UEnum* GoalTypeEnum = StaticEnum<EGoalType>();
|
||||||
|
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<UUserWidget>(this, AllGoalListData->Widget);
|
||||||
|
if (CreatedUserWidget)
|
||||||
|
{
|
||||||
|
if (GetSizeBox())
|
||||||
|
{
|
||||||
|
GetSizeBox()->AddChild(CreatedUserWidget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (CreatedUserWidget)
|
||||||
|
{
|
||||||
|
CreatedUserWidget->RemoveFromParent();
|
||||||
|
CreatedUserWidget = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DoSendDetail(AllGoalListData->Example);
|
||||||
|
|
||||||
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||||
|
if (GameInstance)
|
||||||
|
{
|
||||||
|
GameInstance->bIsChanged = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
NavigateSimpleEnvironments = Cast<UPathfindingSelectorUserWidget>(CreatedUserWidget);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (CreatedUserWidget)
|
||||||
|
{
|
||||||
|
CreatedUserWidget->RemoveFromParent();
|
||||||
|
CreatedUserWidget = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void USelectGoalUserWidget::DoCloseWindow()
|
||||||
|
{
|
||||||
|
if (GetComboBoxString())
|
||||||
|
{
|
||||||
|
GetComboBoxString()->SetSelectedIndex(bInitAddOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||||
|
if (GameInstance)
|
||||||
|
{
|
||||||
|
if (GameInstance->GameUserWidget)
|
||||||
|
{
|
||||||
|
GameInstance->GameUserWidget->bIsGoalMenuVis = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void USelectGoalUserWidget::DoAutoConfirm()
|
||||||
|
{
|
||||||
|
if (GetComboBoxString())
|
||||||
|
{
|
||||||
|
if (GetComboBoxString()->GetSelectedIndex() != 0)
|
||||||
|
{
|
||||||
|
auto UISubsystem = GetGameInstance()->GetSubsystem<UUISubsystem>();
|
||||||
|
if (UISubsystem)
|
||||||
|
{
|
||||||
|
UISubsystem->OnEndTracing.Broadcast();
|
||||||
|
}
|
||||||
|
|
||||||
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||||
|
if (GameInstance)
|
||||||
|
{
|
||||||
|
GameInstance->UpdateTargetSelector();
|
||||||
|
GameInstance->TempTask = FGoalsTaskData();
|
||||||
|
}
|
||||||
|
|
||||||
|
GetComboBoxString()->SetSelectedIndex(bInitAddOption);
|
||||||
|
|
||||||
|
DoCloseWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void USelectGoalUserWidget::DoAddGoalAndStopTracing()
|
||||||
|
{
|
||||||
|
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(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<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||||
|
if (GameInstance)
|
||||||
|
{
|
||||||
|
GameInstance->TempTask = FGoalsTaskData();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NavigateSimpleEnvironments)
|
||||||
|
{
|
||||||
|
NavigateSimpleEnvironments->BPClickSelectObjectBtn();
|
||||||
|
}
|
||||||
|
}
|
@ -14,4 +14,7 @@ class LUCKYWORLDV2_API UPathfindingSelectorUserWidget : public UUserWidget
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
||||||
|
void BPClickSelectObjectBtn();
|
||||||
};
|
};
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
#include "Blueprint/UserWidget.h"
|
#include "Blueprint/UserWidget.h"
|
||||||
#include "SelectGoalUserWidget.generated.h"
|
#include "SelectGoalUserWidget.generated.h"
|
||||||
|
|
||||||
|
class UComboBoxString;
|
||||||
|
class UPathfindingSelectorUserWidget;
|
||||||
|
class USizeBox;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -14,7 +17,49 @@ class LUCKYWORLDV2_API USelectGoalUserWidget : public UUserWidget
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void NativeConstruct() override;
|
||||||
|
|
||||||
public:
|
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();
|
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();
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user