diff --git a/Content/DedicatedServers/API/ListFleets/WBP_ListFleetsBox.uasset b/Content/DedicatedServers/API/ListFleets/WBP_ListFleetsBox.uasset index 74b040da..44c6596d 100644 Binary files a/Content/DedicatedServers/API/ListFleets/WBP_ListFleetsBox.uasset and b/Content/DedicatedServers/API/ListFleets/WBP_ListFleetsBox.uasset differ diff --git a/Content/DedicatedServers/APITest/UI/WBP_APITestOverlay.uasset b/Content/DedicatedServers/APITest/UI/WBP_APITestOverlay.uasset index 3ac1c121..54cc2bc5 100644 Binary files a/Content/DedicatedServers/APITest/UI/WBP_APITestOverlay.uasset and b/Content/DedicatedServers/APITest/UI/WBP_APITestOverlay.uasset differ diff --git a/Source/DedicatedServers/Private/UI/APITest/APITestOverlay.cpp b/Source/DedicatedServers/Private/UI/APITest/APITestOverlay.cpp index 084cfadb..15c0115c 100644 --- a/Source/DedicatedServers/Private/UI/APITest/APITestOverlay.cpp +++ b/Source/DedicatedServers/Private/UI/APITest/APITestOverlay.cpp @@ -3,9 +3,14 @@ #include "UI/APITest/APITestOverlay.h" +#include "Blueprint/WidgetLayoutLibrary.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/APITest/APITestManager.h" +#include "UI/HTTP/HTTPRequestTypes.h" void UAPITestOverlay::NativeConstruct() { @@ -17,7 +22,6 @@ void UAPITestOverlay::NativeConstruct() check(ListFleetsBox) check(ListFleetsBox->Button_ListFleets) ListFleetsBox->Button_ListFleets->OnClicked.AddDynamic(this, &UAPITestOverlay::ListFleetsButtonClicked); - } void UAPITestOverlay::ListFleetsButtonClicked() @@ -30,13 +34,26 @@ void UAPITestOverlay::ListFleetsButtonClicked() 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) { - + for (const FString& FleetId : ListFleetsResponse.FleetIds) + { + UFleetId* FleetIdWidget = CreateWidget(this, FleetIdWidgetClass); + FleetIdWidget->TextBlock_FleetId->SetText(FText::FromString(FleetId)); + ListFleetsBox->ScrollBox_ListFleets->AddChild(FleetIdWidget); + } } else { - + UFleetId* FleetIdWidget = CreateWidget(this, FleetIdWidgetClass); + FleetIdWidget->TextBlock_FleetId->SetText(FText::FromString("Something went wrong!")); + ListFleetsBox->ScrollBox_ListFleets->AddChild(FleetIdWidget); } ListFleetsBox->Button_ListFleets->SetIsEnabled(true); } diff --git a/Source/DedicatedServers/Public/UI/APITest/APITestOverlay.h b/Source/DedicatedServers/Public/UI/APITest/APITestOverlay.h index e5eada62..46386b6c 100644 --- a/Source/DedicatedServers/Public/UI/APITest/APITestOverlay.h +++ b/Source/DedicatedServers/Public/UI/APITest/APITestOverlay.h @@ -9,6 +9,8 @@ class UListFleetsBox; class UAPITestManager; struct FDSListFleetsResponse; +class UFleetId; + /** * */ @@ -22,6 +24,9 @@ public: UPROPERTY(EditDefaultsOnly) TSubclassOf APITestManagerClass; + UPROPERTY(EditDefaultsOnly) + TSubclassOf FleetIdWidgetClass; + protected: virtual void NativeConstruct() override;