Add game overlay UI utilities to IOnlinePlatform

This commit is contained in:
2026-08-12 05:50:56 +02:00
parent fcdc541e9a
commit 98ced280e0
3 changed files with 70 additions and 3 deletions
+65
View File
@@ -204,6 +204,47 @@ API_STRUCT(Namespace="FlaxEngine.Online") struct FLAXENGINE_API OnlineLeaderboar
API_FIELD() int32 Score;
};
/// <summary>
/// Online platform game overlay dialog types.
/// </summary>
API_ENUM(Namespace="FlaxEngine.Online") enum class OnlineOverlayDialog
{
/// <summary>
/// Displays the user login page.
/// </summary>
Login = 0,
/// <summary>
/// Displays the uweb browser.
/// </summary>
Website,
/// <summary>
/// Displays the user profile page.
/// </summary>
Profile,
/// <summary>
/// Displays the page with achievements list.
/// </summary>
Achievements,
/// <summary>
/// Displays the page with stats list.
/// </summary>
Stats,
/// <summary>
/// Displays the page with friends list.
/// </summary>
Friends,
/// <summary>
/// Displays the page with text chat.
/// </summary>
Chat,
};
/// <summary>
/// Interface for online platform providers for communicating with various multiplayer services such as player info, achievements, game lobby or in-game store.
/// </summary>
@@ -416,4 +457,28 @@ public:
/// <param name="localUser">The local user (null if use default one).</param>
/// <returns>True if failed, otherwise false.</returns>
API_FUNCTION() virtual bool SetSaveGame(const StringView& name, const Span<byte>& data, User* localUser = nullptr) = 0;
public:
/// <summary>
/// Opens the game store overlay to a specific place. Avaliability depends on the platform and store.
/// </summary>
/// <param name="dialog">The dialog to display.</param>
/// <returns>True if failed, otherwise false.</returns>
API_FUNCTION() virtual bool OpenOverlay(OnlineOverlayDialog dialog) = 0;
/// <summary>
/// Opens the game store overlay to a specific place for a given website URL. Avaliability depends on the platform and store.
/// </summary>
/// <param name="url">The URL of the website to open. Full address with protocol type is required, e.g. https://www.flaxengine.com/.</param>
/// <param name="dialog">The dialog to display.</param>
/// <returns>True if failed, otherwise false.</returns>
API_FUNCTION() virtual bool OpenOverlayUrl(const StringView& url, OnlineOverlayDialog dialog = OnlineOverlayDialog::Website) = 0;
/// <summary>
/// Opens the game store overlay to a specific place for a given user. Avaliability depends on the platform and store.
/// </summary>
/// <param name="user">The user to show Profile/Achievements/Stats pages of.</param>
/// <param name="dialog">The dialog to display.</param>
/// <returns>True if failed, otherwise false.</returns>
API_FUNCTION() virtual bool OpenOverlayUser(const OnlineUser& user, OnlineOverlayDialog dialog = OnlineOverlayDialog::Profile) = 0;
};
+4 -2
View File
@@ -343,12 +343,12 @@ void GDKPlatform::SignInSilently()
}
}
void GDKPlatform::SignInWithUI()
void GDKPlatform::SignInWithUI(bool allowGuests)
{
auto ab = new XAsyncBlock();
ab->queue = TaskQueue;
ab->callback = AddUserComplete;
HRESULT result = XUserAddAsync(XUserAddOptions::AllowGuests, ab);
HRESULT result = XUserAddAsync(allowGuests ? XUserAddOptions::AllowGuests : XUserAddOptions::None, ab);
if (FAILED(result))
{
GDK_LOG(result, "XUserAddAsync");
@@ -552,6 +552,8 @@ bool GDKPlatform::CanOpenUrl(const StringView& url)
void GDKPlatform::OpenUrl(const StringView& url)
{
if (Users.IsEmpty())
return;
const StringAsANSI<> urlANSI(url.Get(), url.Length());
XLaunchUri(Users[0]->UserHandle, urlANSI.Get());
}
+1 -1
View File
@@ -43,7 +43,7 @@ public:
// Signs in user without showing UI. If user is not signed in, it will fail and return false. Use SignInWithUI to show UI and let user sign in.
API_FUNCTION() static void SignInSilently();
// Signs in user with showing UI. If user is already signed in, it will succeed and return true. If user is not signed in, it will show UI and let user sign in.
API_FUNCTION() static void SignInWithUI();
API_FUNCTION() static void SignInWithUI(bool allowGuests = true);
// Searches for a user with a specific local ID.
static User* FindUser(const struct XUserLocalId& id);