martin #25
Binary file not shown.
Binary file not shown.
@ -4,6 +4,11 @@
|
|||||||
#include "UI/Settings/SelectGoalUserWidget.h"
|
#include "UI/Settings/SelectGoalUserWidget.h"
|
||||||
#include "SharedDef.h"
|
#include "SharedDef.h"
|
||||||
#include "Components/ComboBoxString.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()
|
void USelectGoalUserWidget::NativeConstruct()
|
||||||
{
|
{
|
||||||
@ -37,3 +42,159 @@ void USelectGoalUserWidget::NativeConstruct()
|
|||||||
GetComboBoxString()->SetSelectedIndex(bInitAddOption);
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
class UComboBoxString;
|
class UComboBoxString;
|
||||||
class UPathfindingSelectorUserWidget;
|
class UPathfindingSelectorUserWidget;
|
||||||
|
class USizeBox;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -26,14 +27,39 @@ public:
|
|||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
UPathfindingSelectorUserWidget* NavigateSimpleEnvironments;
|
UPathfindingSelectorUserWidget* NavigateSimpleEnvironments;
|
||||||
|
|
||||||
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
|
UUserWidget* CreatedUserWidget;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FTimerHandle DelayAddGoalTimerHandle;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
UPROPERTY(EditAnywhere, BlueprintReadWrite)
|
||||||
bool bInitAddOption;
|
bool bInitAddOption;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
|
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)
|
UFUNCTION(BlueprintPure, BlueprintImplementableEvent)
|
||||||
UComboBoxString* GetComboBoxString();
|
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