Lesson 66 - Displaying Fleet Data
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -3,9 +3,14 @@
|
|||||||
|
|
||||||
#include "UI/APITest/APITestOverlay.h"
|
#include "UI/APITest/APITestOverlay.h"
|
||||||
|
|
||||||
|
#include "Blueprint/WidgetLayoutLibrary.h"
|
||||||
#include "Components/Button.h"
|
#include "Components/Button.h"
|
||||||
|
#include "Components/ScrollBox.h"
|
||||||
|
#include "Components/TextBlock.h"
|
||||||
|
#include "UI/API/ListFleets/FleetId.h"
|
||||||
#include "UI/API/ListFleets/ListFleetsBox.h"
|
#include "UI/API/ListFleets/ListFleetsBox.h"
|
||||||
#include "UI/APITest/APITestManager.h"
|
#include "UI/APITest/APITestManager.h"
|
||||||
|
#include "UI/HTTP/HTTPRequestTypes.h"
|
||||||
|
|
||||||
void UAPITestOverlay::NativeConstruct()
|
void UAPITestOverlay::NativeConstruct()
|
||||||
{
|
{
|
||||||
@@ -17,7 +22,6 @@ void UAPITestOverlay::NativeConstruct()
|
|||||||
check(ListFleetsBox)
|
check(ListFleetsBox)
|
||||||
check(ListFleetsBox->Button_ListFleets)
|
check(ListFleetsBox->Button_ListFleets)
|
||||||
ListFleetsBox->Button_ListFleets->OnClicked.AddDynamic(this, &UAPITestOverlay::ListFleetsButtonClicked);
|
ListFleetsBox->Button_ListFleets->OnClicked.AddDynamic(this, &UAPITestOverlay::ListFleetsButtonClicked);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UAPITestOverlay::ListFleetsButtonClicked()
|
void UAPITestOverlay::ListFleetsButtonClicked()
|
||||||
@@ -30,13 +34,26 @@ void UAPITestOverlay::ListFleetsButtonClicked()
|
|||||||
|
|
||||||
void UAPITestOverlay::OnListFleetsResponseReceived(const FDSListFleetsResponse& ListFleetsResponse, bool bWasSuccessful)
|
void UAPITestOverlay::OnListFleetsResponseReceived(const FDSListFleetsResponse& ListFleetsResponse, bool bWasSuccessful)
|
||||||
{
|
{
|
||||||
|
if (APITestManager->OnListFleetsResponseReceived.IsAlreadyBound(this, &UAPITestOverlay::OnListFleetsResponseReceived))
|
||||||
|
{
|
||||||
|
APITestManager->OnListFleetsResponseReceived.RemoveDynamic(this, &UAPITestOverlay::OnListFleetsResponseReceived);
|
||||||
|
}
|
||||||
|
ListFleetsBox->ScrollBox_ListFleets->ClearChildren();
|
||||||
|
check(FleetIdWidgetClass);
|
||||||
if (bWasSuccessful)
|
if (bWasSuccessful)
|
||||||
{
|
{
|
||||||
|
for (const FString& FleetId : ListFleetsResponse.FleetIds)
|
||||||
|
{
|
||||||
|
UFleetId* FleetIdWidget = CreateWidget<UFleetId>(this, FleetIdWidgetClass);
|
||||||
|
FleetIdWidget->TextBlock_FleetId->SetText(FText::FromString(FleetId));
|
||||||
|
ListFleetsBox->ScrollBox_ListFleets->AddChild(FleetIdWidget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
UFleetId* FleetIdWidget = CreateWidget<UFleetId>(this, FleetIdWidgetClass);
|
||||||
|
FleetIdWidget->TextBlock_FleetId->SetText(FText::FromString("Something went wrong!"));
|
||||||
|
ListFleetsBox->ScrollBox_ListFleets->AddChild(FleetIdWidget);
|
||||||
}
|
}
|
||||||
ListFleetsBox->Button_ListFleets->SetIsEnabled(true);
|
ListFleetsBox->Button_ListFleets->SetIsEnabled(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
class UListFleetsBox;
|
class UListFleetsBox;
|
||||||
class UAPITestManager;
|
class UAPITestManager;
|
||||||
struct FDSListFleetsResponse;
|
struct FDSListFleetsResponse;
|
||||||
|
class UFleetId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@@ -22,6 +24,9 @@ public:
|
|||||||
UPROPERTY(EditDefaultsOnly)
|
UPROPERTY(EditDefaultsOnly)
|
||||||
TSubclassOf<UAPITestManager> APITestManagerClass;
|
TSubclassOf<UAPITestManager> APITestManagerClass;
|
||||||
|
|
||||||
|
UPROPERTY(EditDefaultsOnly)
|
||||||
|
TSubclassOf<UFleetId> FleetIdWidgetClass;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual void NativeConstruct() override;
|
virtual void NativeConstruct() override;
|
||||||
|
|||||||
Reference in New Issue
Block a user