Skip to content

Commit

Permalink
Added new contributor, updated some rich presence stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Gramps committed Apr 4, 2024
1 parent 639b8ee commit 4e66279
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/contribute/contributors.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/tutorials/common_issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
55 changes: 55 additions & 0 deletions docs/tutorials/rich_presence.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
==}
Expand Down

0 comments on commit 4e66279

Please sign in to comment.