Skip to main content

Guide

1. Player Profile

player_profile_overview

Player Profile provides player-associated information, containing basic information and custom information. PGOS Overlay encapsulates the PGOS SDK Profile Data and provides a full range of out-of-the-box features, including:

PGOS Overlay also provides relevant APIs that allow you to easily fetch and implement these contents in your own code.

1.1 Get Profile Info of the Current Player

1.1.1 Blueprint

GetSelfPlayerInfo in Blueprint

1.1.2 C++

UPgosSelfPlayerInfo* SelfPlayerInfo = UPgosBlueprintFunctionLibrary::GetSelfPlayerInfo()

1.1.3 Methods & Properties

UCLASS(BlueprintType)
class PGOSWEAVER_API UPgosSelfPlayerInfo : public UObject
{
...

/**
* Called after any info field being changed
*/
UPROPERTY(BlueprintReadWrite, BlueprintAssignable, Category="PGOS Overlay")
FDelegateInfoUpdated InfoUpdated;

/**
* Get player name for displaying on UI
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PGOS Overlay")
const FString& GetDisplayName() const;

/**
* Get the underlying raw ID of the Player
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PGOS Overlay")
const FString& GetPlayerId() const;

/**
* Get the name of the avatar image
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PGOS Overlay")
const FString& GetAvatarName() const;

/**
* Get the sprite object the current avatar name referring
*/
UFUNCTION(BlueprintCallable, BlueprintPure, Category="PGOS Overlay")
UPaperSprite* GetAvatarSprite() const;

...

1.2 Basic Info of Player

PGOS Overlay provides the default behavior of setting player's name and avatar image.

1.2.1 Player Name

change_player_name

In both blueprint and C++, you could change your player name by calling UPgosSelfPlayerInfo::MakeSetNameRequest(...):

set_player_name_in_blueprint

// in C++

UPgosSelfPlayerInfo* SelfPlayerInfo = UPgosBlueprintFunctionLibrary::GetSelfPlayerInfo();
const FString& NewName = ...;
SelfPlayerInfo->MakeSetNameRequest(NewName);

1.2.2 Avatar Image

Players can modify their avatar in their player profile menu.

avatar_image_picker

In both blueprint and C++, you could change your player avatar image by calling UPgosSelfPlayerInfo::MakeSetAvatarRequest(...):

set_avatar_image_in_blueprint

// in C++

UPgosSelfPlayerInfo* SelfPlayerInfo = UPgosBlueprintFunctionLibrary::GetSelfPlayerInfo();
const FString& NewAvatarImageName = ...;
SelfPlayerInfo->MakeSetAvatarRequest(NewAvatarImageName);

1.2.3 Avatar Recource

Note: The method of changing the configuration will be deprecated, please use Avatar Resource Customization to provide resource.

Developers can customize the list of all available avatars by modifying the All Avatar Images in the PgosStyleSheetAsset'/PgosWeaver/Styles/PgosStyleSheet.PgosStyleSheet' configuration.

player_profile_change_avatar_image_assets

1.2.4 Avatar Frame

Players can modify their avatar frame in their player profile menu.

Developers can directly call and modify the avatar frame in Blueprint and C++:

    UPgosSelfPlayerInfo* SelfPlayerInfo = UPgosBlueprintFunctionLibrary::GetSelfPlayerInfo();
const FString& NewAvatarFrameName = ...;
SelfPlayerInfo->MakeSetAvatarFrameRequest(NewAvatarFrameName);

player_profile_change_avatar_frame_menu

player_profile_change_avatar_frame_picker

1.2.5 Avatar Frame Resources

Note: The method of changing the configuration will be deprecated, please use Avatar Resource Customization to provide resource.

Developers can customize the list of all available avatar frames by modifying the All Avatar Frames in the PgosStyleSheetAsset'/PgosWeaver/Styles/PgosStyleSheet.PgosStyleSheet' configuration.

player_profile_change_avatar_frame_assets

1.2.6 Avatar Resource Customization

Through the IPgosGameDataExchange interface, you can display the desired list of avatars/avatar frames in the selected interface.

Define a class which implements interface IPgosGameDataExchange, and override specific methods to implement the custom behaviour. Below chart is the list of methods to override:

MethodBehaviour
OnGetAvatarImageNamesGets all names available for AvatarImage
OnGetAvatarFrameNamesGets all names available for AvatarFrame
OnGetAvatarImageAssetGets the image object immediately for AvatarImage with a specific name
OnGetAvatarImageAssetProxyGets the image object asynchronously for AvatarImage with a specific name
OnGetAvatarFrameAssetGets the image object immediately for AvatarImage with a specific name
OnGetAvatarFrameAssetProxyGets the image object asynchronously for AvatarFrame with a specific name

Typical use case: Firstly, Implete the defination:

UCLASS()
class UYourResourceProviderClass : public UObject, public IPgosGameDataExchange
{
GENERATED_BODY()
public:

//
virtual FPgosEventReply OnGetAvatarImageNames_Implementation(TArray<FString>& OutNames) override
{
// fill out the `OutNames` array with all names you want to use for avatar images
OutNames.Add(TEXT("AvatarImageName_1"));
OutNames.Add(TEXT("AvatarImageName_2"));
...

return UPgosBlueprintFunctionLibrary::Handled();
}

virtual FPgosEventReply OnGetAvatarFrameAsset(const FString& AvatarImageName, UObject*& OutObject) override
{
if (AvatarImageName == TEXT("AvatarImageName_1"))
{
OutObject = SpriteObject or TextureObject;
return UPgosBlueprintFunctionLibrary::Handled();
}

return UPgosBlueprintFunctionLibrary::Unhandled();
}
};

Register the instance defined above to PGOS Overlay:

UYourResourceProviderClass* YourResourceProvider = NewObject<UYourResourceProviderClass>(this);

UPgosGameDataManager* GameDataManager = UPgosBlueprintFunctionLibrary::GetOverlayGameDataManager();
GameDataManager->AddGameDataExchange(YourResourceProvider);

1.2.7 Avatar/Avatar Frame Unlock Status and Description

PGOS Overlay v0.1.2 adds unlock status and description to the avatar/avatar frame. Developers can specify whether an avatar/avatar frame is in the unlock status and whether to display the specified description.

Note: A locked avatar/avatar frame cannot be selected as the current avatar/avatar frame.

Locked status

To specify the avatar/avatar frame unlock status and description, you shall first define an implemented IPgosGameDataExchange API type. This API is used to exchange necessary data between the game and Overlay.

There are four API methods relevant to avatars/avatar frames:

    UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
bool IPgosGameDataExchange::OnGetAvatarImageState(const FString& AvatarImageName, bool& OutIsLocked);

UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
bool IPgosGameDataExchange::OnGetAvatarFrameState(const FString& AvatarFrameName, bool& OutIsLocked);

Implement this method to indicate whether an avatar/avatar frame has been unlocked. The value returned by this method indicates whether the current API instance can confirm the unlock status of the current avatar/avatar frame. If this method returns "true", the parameter OutIsLocked specifies the unlock status (true: locked, false: unlocked). If the return value is false, the method will continue querying other IPgosGameDataExchange instances. If all API instances return false, the avatar/avatar frame is treated as if unlocked.

    /**
* fill out data for avatar image,
* return true if data are properly updated. the manager will stop iterating remaining exchange interface objects
*/
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
bool IPgosGameDataExchange::OnGetAvatarImageInfo(const FString& AvatarImageName, UPgosMapDataObject* DataObject);

/**
* fill out data for avatar frame,
* return true if data are properly updated. the manager will stop iterating remaining exchange interface objects
*/
UFUNCTION(BlueprintNativeEvent, BlueprintCallable)
bool IPgosGameDataExchange::OnGetAvatarFrameInfo(const FString& AvatarFrameName, UPgosMapDataObject* DataObject);

Implement this method to provide avatar/avatar frame description information. The value returned by this method indicates whether the current API instance can provide the description information of the avatar/avatar frame. If this method returns "true", this means the data has been filled. If the return value is false, the method will continue querying other IPgosGameDataExchange instances. If all API instances return false, the avatar/avatar frame is treated as it has no description information.

UPgosMapDataObject is a dictionary data structure similar to TMap. The description information can provide both brief and title key-value pairs, or either one. You can use AddStringEntry or AddTextEntry to add this data.

Data filling

Finally, to make the IPgosGameDataExchange API work, its instance shall be added to the UPgosGameDataManager.

add_game_data_exchange

1.3 Player Profile Content View

The Player Profile is extensible with IPgosPlayerProcessor.

One of these methods will be called in different situation such as showing the Player Profile or closing it:

NameDescription
OnShowPgosPlayerProfileStatistics
(
const FString& PlayerId,
UPgosMapDataObject* MapDataObject
)
Fill out data in this callback for the Player Profile widgets with databinding support.
NOTE: This feature is unfinished.
OnShowPgosPlayerProfileExtensible
(
const FString& PlayerId,
UVerticalBox* Container
)
Add UserWidget to the Content View.
OnClosePgosPlayerProfile
(
const FString& PlayerId
)
Invoked when a Player Profile is closed.

1.3.1 Example of Customized Player Profile

Add a class which implements IPgosPlayerProcessor.

// Header
#pragma once
#include "PgosPlayerProcessor.h"
#include "PGOSDemoPlayerProfileCallbacks.generated.h"

UCLASS()
class UMyPlayerProfileProcessor : public UObject, public IPgosPlayerProcessor
{
GENERATED_BODY()
public:

virtual void OnShowPgosPlayerProfileExtensible_Implementation(const FString& PlayerId, UVerticalBox* Container) override;
};

// Source
void UMyPlayerProfileProcessor::OnShowPgosPlayerProfileExtensible_Implementation(const FString& PlayerId, UVerticalBox* Container)
{
UMyUserWidget* MyUserWidget = CreateMyUserWidget();

// Get the player info from the game via PlayerId
// ...
// Setup MyUserWidget with the player info
// ...

// Add MyUserWidget to the container
UVerticalBoxSlot* VerticalBoxSlot = Container->AddChildToVerticalBox(MyUserWidget);
VerticalBoxSlot->SetHorizontalAlignment(HAlign_Fill);
VerticalBoxSlot->SetVerticalAlignment(VAlign_Fill);
}

Once you have implemented IPgosPlayerProcessor, use the UPgosBlueprintLibrary::SetPlayerProcessor() method to set an instance of this type as player profile processor.


void UPGOSDemoGameInstance::Init()
{
Super::Init();

// ...

UMyPlayerProfileProcessor* Processor = NewObject<UMyPlayerProfileProcessor>(this);
UPgosBlueprintFunctionLibrary::SetPlayerProcessor(Processor);
}