2 Commits

Author SHA1 Message Date
Norman Lansing
898fba8153 Lession 56 - API Test HUD 2026-03-15 09:19:39 -04:00
Norman Lansing
f52a4225c3 Lesson 55 - #if #endif blocks added to DS_GameMode.cpp to prevent gamelift issues in editor mode 2026-03-15 08:58:52 -04:00
10 changed files with 77 additions and 3 deletions

View File

@@ -2,8 +2,8 @@
CommonUI.Debug.CheckGameViewportClientValid=0
[/Script/EngineSettings.GameMapsSettings]
GameDefaultMap=/Game/ThirdPerson/Maps/ThirdPersonMap.ThirdPersonMap
EditorStartupMap=/Game/ThirdPerson/Maps/ThirdPersonMap.ThirdPersonMap
GameDefaultMap=/Game/Maps/StartupMap.StartupMap
EditorStartupMap=/Game/Maps/StartupMap.StartupMap
GlobalDefaultGameMode=/Game/Blueprints/Game/BP_ShooterGameModeBase.BP_ShooterGameModeBase_C
ServerDefaultMap=/Game/ThirdPerson/Maps/ThirdPersonMap.ThirdPersonMap

View File

@@ -21,7 +21,8 @@ public class DedicatedServers : ModuleRules
{
"Slate",
"SlateCore",
"OpenSSL"
"OpenSSL",
"UMG"
});
// Adds in the plugin for GameLiftServerSDK if it is the server build.

View File

@@ -18,6 +18,9 @@ void ADS_GameMode::BeginPlay()
void ADS_GameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage)
{
Super::InitGame(MapName, Options, ErrorMessage);
#if WITH_GAMELIFT
CachedCommandLine = FCommandLine::Get();
const FPortResult PortResult = cmdlineparser::details::GetConfiguredOrDefaultPort(CachedCommandLine, TEXT("port"));;
@@ -39,6 +42,8 @@ void ADS_GameMode::InitGame(const FString& MapName, const FString& Options, FStr
UE_LOGFMT(LogDS_GameMode, Log, "Fleet type: EC2");
// TODO: EC2 configuration
}
#endif
}
FString ADS_GameMode::GetSHA256Hash(const FString& InString)
@@ -320,6 +325,7 @@ void ADS_GameMode::LogAnywhereFleetParameters()
void ADS_GameMode::LogServerParameters(const FServerParameters& InServerParameters)
{
#if WITH_GAMELIFT
UE_LOGFMT(LogDS_GameMode, Log, ">>>> WebSocket URL: {WebSocketUrl}", InServerParameters.m_webSocketUrl);
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Fleet ID: {FleetId}", InServerParameters.m_fleetId);
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Process ID: {ProcessId}", InServerParameters.m_processId);
@@ -345,6 +351,7 @@ void ADS_GameMode::LogServerParameters(const FServerParameters& InServerParamete
{
UE_LOGFMT(LogDS_GameMode, Log, ">>>> Session Token: {SessionToken}", GetValueOrHash(InServerParameters.m_sessionToken));
}
#endif
}
FString ADS_GameMode::GetValueOrHash(const FString& Value)

View File

@@ -0,0 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "UI/API_Test/APITestOverlay.h"

View File

@@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "UI/API_Test/API_TestHUD.h"
#include "UI/API_Test/APITestOverlay.h"
void AAPI_TestHUD::BeginPlay()
{
Super::BeginPlay();
APlayerController* PlayerController = GetOwningPlayerController();
if (IsValid(PlayerController) && APITestOverlayClass)
{
APITestOverlay = CreateWidget<UAPITestOverlay>(PlayerController, APITestOverlayClass);
APITestOverlay->AddToViewport();
}
}

View File

@@ -0,0 +1,16 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "APITestOverlay.generated.h"
/**
*
*/
UCLASS()
class DEDICATEDSERVERS_API UAPITestOverlay : public UUserWidget
{
GENERATED_BODY()
};

View File

@@ -0,0 +1,29 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/HUD.h"
#include "API_TestHUD.generated.h"
class UAPITestOverlay;
/**
*
*/
UCLASS()
class DEDICATEDSERVERS_API AAPI_TestHUD : public AHUD
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly)
TSubclassOf<UAPITestOverlay> APITestOverlayClass;
protected:
virtual void BeginPlay() override;
private:
UPROPERTY()
TObjectPtr<UAPITestOverlay> APITestOverlay;
};