Steamworks 文献库
Enhanced Rich Presence

此页面尚不支持您的偏好语言。

本文献页当前不能以您的偏好语言显示,因此下方将显示英文版本。

Overview

With the recent release of the new Steam Friends and Chat client we've enhanced the capabilities of our rich presence system to show more about the games being played. We see a player's rich presence as a way to engage the player's friends in their activity. For example, friends who own the game engage by knowing the right time to join the game or by talking about it with the player, and those who don't own the game may have their interest piqued by coming across a variety of rich presence strings that tell them more about a game that they don't know much about.

Rich Presence is shown in multiple contexts

In this documentation, we’re going to cover two settings you can define to control how your game appears in players’ friends list:
  • Rich Presence String – used for displaying information about player state in your game that their friends may want to know
  • Friend Grouping – used for grouping friends together that are playing together in the game

Game controlled Rich Presence string


Friends can see more information about games at a glance
The system in place is customizable so that your team can determine which information is the most interesting to a player's friends.
Your game will have its own specific data that will be the right information to show with enhanced rich presence. To start you off, though, here are some thoughts to consider:

Multiplayer Games

Depending on the multiplayer game type, information that helps a player's friends know when to jump in can vary. Some games are played in rounds that are determined by time, or by players remaining, and so that information is most useful to display. Other multiplayer games are finished once an objective is met and showing progression towards that goal can be useful. Knowing which game mode or map your player is on can also be useful in helping the player's friends make a decision on how to engage with the player.

Single-player Games

While single-player games are not joined by a player's friends, friend engagement can still occur if the information shown causes the friend to watch the player play, talk to them about strategies, or talk about highlights of playing. Information showing the zone, chapter, or level the player is in, or what the player is currently doing in the game can help achieve these goals.

* To define the string to display in Steam friends list and chat, set the steam_display key/value in SetRichPresence. More information and examples about the API calls at the end of this document.

Examples of data to show if applicable
  • Time remaining
  • Time passed
  • Players still alive
  • Map or Zone name
  • Player level
  • Player Class
  • Game score
  • Difficulty
  • Game mode type
  • Spots open on the server
  • Action being taken (deck building, roster changing, on main menu etc.)
NOTE: Keep in mind that this rich presence string will need to fit on one line, and is shown under a players name in the friends list. If it is too long, the end of the line will be truncated or ellipsized.

Friend Grouping


Along with the additional line of information, the new Friends List is able to display groups of friends who are playing together. Those friends who are in a party, server, or match together will be grouped under the game category with a line connecting them together. The way the grouping is determined will depend on your game and what makes the most sense to show. For example, in Dota 2 there are parties of up to 5 people, so we will show the party that is being played with, not the full team of 5 that is match-made by the game. In Counter-Strike, though, 2 friends may be playing on a server together, but rather than showing the whole server as part of the party, only the mutual friends who are playing together are placed in the same Steam Player Group.

When friends playing together are grouped, others know if there is room for them to join

* To define the grouping of players in the Steam friends list and chat, set the steam_player_group and steam_player_group_size key/values in SetRichPresence.

Steam API & Localization



Below is a code sample to show how simple it is to set this up.

Code Snippet
/*--------------------------- SAMPLE -------------------*/ const char *pchStatus; if ( bWinning && cWinners > 1 ) { pchStatus = "Tied"; } else if ( bWinning ) { pchStatus = "Winning"; } else { pchStatus = "Losing"; } SteamFriends()->SetRichPresence( "gamestatus", pchStatus ); bool bDisplayScoreInRichPresence = true; if ( bDisplayScoreInRichPresence ) { char rgchBuffer[32]; sprintf_safe( rgchBuffer, "%2u", uMyScore ); SteamFriends()->SetRichPresence( "score", rgchBuffer ); } SteamFriends()->SetRichPresence( "steam_display", bDisplayScoreInRichPresence ? "#StatusWithScore" : "#StatusWithoutScore" ); // Sample of grouping friends together when they play together if ( nPartyMemberCount > 1 && strPartyID ) { // If we're in a party of more than one user, and we have a valid PartyID then // inform Steam's Rich Presence system. steamapicontext->SteamFriends()->SetRichPresence( "steam_player_group", strPartyID ); steamapicontext->SteamFriends()->SetRichPresence( "steam_player_group_size", CNumStr( nPartyMemberCount ) ); } else { // Otherwise, clear out whatever information we had there before; we're not in a party. steamapicontext->SteamFriends()->SetRichPresence( "steam_player_group", nullptr ); steamapicontext->SteamFriends()->SetRichPresence( "steam_player_group_size", nullptr ); }

The above code uses localization that includes English tokens like the following:

"lang" { "language" "english" "tokens" { "#StatusWithoutScore" "{#Status_%gamestatus%}" "#StatusWithScore" "{#Status_%gamestatus%}: %SCORE%" "#Status_AtMainMenu" "At the main menu" "#Status_WaitingForMatch" "Waiting for match" "#Status_Winning" "Winning" "#Status_Losing" "Losing" "#Status_Tied" "Tied" } }