File size: 3,461 Bytes
4331f83 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | // Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Engine/World.h"
#include "GameUIPolicy.generated.h"
#define UE_API COMMONGAME_API
class UCommonLocalPlayer;
class UGameUIManagerSubsystem;
class ULocalPlayer;
class UPrimaryGameLayout;
/**
*
*/
UENUM()
enum class ELocalMultiplayerInteractionMode : uint8
{
// Fullscreen viewport for the primary player only, regardless of the other player's existence
PrimaryOnly,
// Fullscreen viewport for one player, but players can swap control over who's is displayed and who's is dormant
SingleToggle,
// Viewports displayed simultaneously for both players
Simultaneous
};
USTRUCT()
struct FRootViewportLayoutInfo
{
GENERATED_BODY()
public:
UPROPERTY(Transient)
TObjectPtr<ULocalPlayer> LocalPlayer = nullptr;
UPROPERTY(Transient)
TObjectPtr<UPrimaryGameLayout> RootLayout = nullptr;
UPROPERTY(Transient)
bool bAddedToViewport = false;
FRootViewportLayoutInfo() {}
FRootViewportLayoutInfo(ULocalPlayer* InLocalPlayer, UPrimaryGameLayout* InRootLayout, bool bIsInViewport)
: LocalPlayer(InLocalPlayer)
, RootLayout(InRootLayout)
, bAddedToViewport(bIsInViewport)
{}
bool operator==(const ULocalPlayer* OtherLocalPlayer) const { return LocalPlayer == OtherLocalPlayer; }
};
UCLASS(MinimalAPI, Abstract, Blueprintable, Within = GameUIManagerSubsystem)
class UGameUIPolicy : public UObject
{
GENERATED_BODY()
public:
template <typename GameUIPolicyClass = UGameUIPolicy>
static GameUIPolicyClass* GetGameUIPolicyAs(const UObject* WorldContextObject)
{
return Cast<GameUIPolicyClass>(GetGameUIPolicy(WorldContextObject));
}
static UE_API UGameUIPolicy* GetGameUIPolicy(const UObject* WorldContextObject);
public:
UE_API virtual UWorld* GetWorld() const override;
UE_API UGameUIManagerSubsystem* GetOwningUIManager() const;
UE_API UPrimaryGameLayout* GetRootLayout(const UCommonLocalPlayer* LocalPlayer) const;
ELocalMultiplayerInteractionMode GetLocalMultiplayerInteractionMode() const { return LocalMultiplayerInteractionMode; }
UE_API void RequestPrimaryControl(UPrimaryGameLayout* Layout);
protected:
UE_API void AddLayoutToViewport(UCommonLocalPlayer* LocalPlayer, UPrimaryGameLayout* Layout);
UE_API void RemoveLayoutFromViewport(UCommonLocalPlayer* LocalPlayer, UPrimaryGameLayout* Layout);
UE_API virtual void OnRootLayoutAddedToViewport(UCommonLocalPlayer* LocalPlayer, UPrimaryGameLayout* Layout);
UE_API virtual void OnRootLayoutRemovedFromViewport(UCommonLocalPlayer* LocalPlayer, UPrimaryGameLayout* Layout);
UE_API virtual void OnRootLayoutReleased(UCommonLocalPlayer* LocalPlayer, UPrimaryGameLayout* Layout);
UE_API void CreateLayoutWidget(UCommonLocalPlayer* LocalPlayer);
UE_API TSubclassOf<UPrimaryGameLayout> GetLayoutWidgetClass(UCommonLocalPlayer* LocalPlayer);
private:
ELocalMultiplayerInteractionMode LocalMultiplayerInteractionMode = ELocalMultiplayerInteractionMode::PrimaryOnly;
UPROPERTY(EditAnywhere)
TSoftClassPtr<UPrimaryGameLayout> LayoutClass;
UPROPERTY(Transient)
TArray<FRootViewportLayoutInfo> RootViewportLayouts;
private:
UE_API void NotifyPlayerAdded(UCommonLocalPlayer* LocalPlayer);
UE_API void NotifyPlayerRemoved(UCommonLocalPlayer* LocalPlayer);
UE_API void NotifyPlayerDestroyed(UCommonLocalPlayer* LocalPlayer);
friend class UGameUIManagerSubsystem;
};
#undef UE_API
|