1. Customized Menu Options
You may add customized menu options for your game in each Overlay
context interface, in addition to the default menu.
❗ Note: Currently only support text menu options.
1.1 API Definitions
class PGOSWEAVER_API IPgosOverlayContextMenuProvider
{
GENERATED_IINTERFACE_BODY()
public:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category="PGOS Overlay")
void OnPlayerInfoContextMenu(UPgosMenu* Menu, UPgosPlayerInfoBase* PlayerInfoObject);
};
1.2 Register a Custom Provider
The instance of the type implements IPgosOverlayContextMenuProvider
needs to be added by using the method AddOverlayContextMenuProvider
to register it to the Overlay
.
void UPgosBlueprintFunctionLibrary::AddOverlayContextMenuProvider(TScriptInterface<IPgosOverlayContextMenuProvider> ContextMenuProvider);
1.3 Remove
Notify Overlay
to remove the added IPgosOverlayContextMenuProvider
when it is no longer needed.
void UPgosBlueprintFunctionLibrary::RemoveOverlayContextMenuProvider(TScriptInterface<IPgosOverlayContextMenuProvider> ContextMenuProvider);
2. Typical Use Cases
2.1 Implement IPgosOverlayContextMenuProvider
interface
Make your class implementing IPgosOverlayContextMenuProvider
interface.
UCLASS()
class UYourMenuProvider : public UObject, public IPgosOverlayContextMenuProvider
{
GENERATED_BODY()
public:
virtual void OnPlayerInfoContextMenu(UPgosMenu* Menu, UPgosPlayerInfoBase* PlayerInfoObject) override
{
if (PlayerInfoObject->IsSelfPlayer())
{
// Add your menu item here
Menu->AddTextMenuNativeEntry(YourMenuEntryText, UPgosTextMenuItem::FDelegateOnNativeClicked::FDelegate::CreateWeakLambda(PlayerInfoObject, [PlayerInfoObject, MenuWeakPtr]
{
UE_LOG(LogTemp, Log, TEXT("Hello"));
UPgosBlueprintLibrary::CloseAllContextualWidgets();
}));
}
}
};
2.2 Register/unregister the context menu provider
UYourMenuProvider* Provider = NewObject<UYourMenuProvider>(this);
UPgosBlueprintFunctionLibrary::AddOverlayContextMenuProvider(Provider);
// unregister if you decide not to customize the context menu
UPgosBlueprintFunctionLibrary::RemoveOverlayContextMenuProvider(Provider);