From 4e662792eb8ca2cb63f869dbf52d7884f9f5a2b6 Mon Sep 17 00:00:00 2001 From: GP Garcia Date: Thu, 4 Apr 2024 12:55:42 -0500 Subject: [PATCH] Added new contributor, updated some rich presence stuff --- docs/contribute/contributors.md | 1 + docs/tutorials/common_issues.md | 2 ++ docs/tutorials/rich_presence.md | 55 +++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/docs/contribute/contributors.md b/docs/contribute/contributors.md index 76660601..ccf6b4d2 100644 --- a/docs/contribute/contributors.md +++ b/docs/contribute/contributors.md @@ -100,6 +100,7 @@ Here is a list of all the great contributors, both those who have provided code - Ronan Docherty - RosenX - Shine Right Studio + - Siddhant Chereddy - Thorsten Schleinzer - Wonderful Days Studio - Zeo Löwenhielm diff --git a/docs/tutorials/common_issues.md b/docs/tutorials/common_issues.md index bf588954..df041b15 100644 --- a/docs/tutorials/common_issues.md +++ b/docs/tutorials/common_issues.md @@ -102,6 +102,8 @@ There is no way to bind the enums so they are not present. Rich presence will work fine on all operating systems _except_ Windows. It will occasionally make the value the key on random calls. +[Thankfully, Furcifer shared some code to help with this issue. You can read more about it in the Rich Presence tutorial!](../rich_presence) + ### Getting Lobbies For whatever reason, the get lobby callback would not return a single array like everything else so the callback will send an array of lobbies and the total count. \ No newline at end of file diff --git a/docs/tutorials/rich_presence.md b/docs/tutorials/rich_presence.md index 4ba7791e..89a55212 100644 --- a/docs/tutorials/rich_presence.md +++ b/docs/tutorials/rich_presence.md @@ -67,6 +67,61 @@ Please note this bug *does not exist* in the pre-compiled module versions nor GD This behavior definitely seems to be a GDNative problem so we can't really fix it on our and an issue has been submitted to the Godot GitHub page. +Thankfully, **Furcifer** has shared some code that should help with this! + +```gdscript +var iteration = 0 +var richPresenceKeyValue = [] +var updatingRichPresence = false + +func callNextFrame(methodName, arguments = []): + get_tree().connect("idle_frame", self, methodName, arguments, CONNECT_ONESHOT) + +func updateRichPresence(): + iteration = 0 + richPresenceKeyValue.clear() + + addRichPresence("numwins", String(Game.getNumWins())) + addRichPresence("steam_display", "#status_Ingame") + + if not updatingRichPresence: + updatingRichPresence = true + setPresenceDelayed() + +func addRichPresence(key, value): + richPresenceKeyValue.push_back([key, value]) + Steam.setRichPresence(key, value) + +func setPresenceDelayed(): + var remaining = [] + for tuple in richPresenceKeyValue: + var success = forceSetProperty(tuple[0], tuple[1]) + if not success: + remaining.push_back(tuple) + + richPresenceKeyValue = remaining + + if not richPresenceKeyValue.empty(): + iteration += 1 + recallSetPresenceDelayed() # recalls this function after a frame + else: + updatingRichPresence = false + +func recallSetPresenceDelayed(): + Util.callNextFrame(self, "setPresenceDelayed") + +func forceSetProperty(key : String, value : String) -> bool: + for i in 10: + var setval = Steam.getFriendRichPresence(STEAM_ID, key) + if setval == key: + #print("could not set key ", key, " - iteration: ", iteration, "/",i) + Steam.setRichPresence(key, value) + else: + return true + + return false +``` + {== ## Additional Resources ==}