Skip to content

Commit a5f62a3

Browse files
add Friends.setRichPresence (#12)
* add Friends.setRichPresence * Improve rich presence and add a small doc --------- Co-authored-by: Yuxiao Mao <yuxiao.mao@outlook.com>
1 parent 240cfc1 commit a5f62a3

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

native/friends.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,20 @@ HL_PRIM void HL_NAME(activate_overlay_store)( int appid, int flag ) {
6060
SteamFriends()->ActivateGameOverlayToStore((AppId_t)appid,(EOverlayToStoreFlag)flag);
6161
}
6262

63+
HL_PRIM bool HL_NAME(set_rich_presence)( vbyte *pchKey, vbyte *pchValue ) {
64+
return SteamFriends()->SetRichPresence((char*)pchKey, (char*)pchValue);
65+
}
66+
67+
HL_PRIM void HL_NAME(clear_rich_presence)() {
68+
SteamFriends()->ClearRichPresence();
69+
}
70+
6371
DEFINE_PRIM(_BYTES, get_user_name, _UID);
6472
DEFINE_PRIM(_BYTES, get_user_avatar, _UID _I32 _REF(_I32) _REF(_I32));
6573
DEFINE_PRIM(_BOOL, request_user_information, _UID _BOOL);
6674
DEFINE_PRIM(_ARR, get_friends, _I32);
6775
DEFINE_PRIM(_BOOL, has_friend, _UID _I32);
6876
DEFINE_PRIM(_VOID, activate_overlay_user, _BYTES _UID);
6977
DEFINE_PRIM(_VOID, activate_overlay_store, _I32 _I32);
70-
78+
DEFINE_PRIM(_BOOL, set_rich_presence, _BYTES _BYTES);
79+
DEFINE_PRIM(_VOID, clear_rich_presence, _NO_ARG);

steam/Friends.hx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,22 @@ class Friends {
9292
public static function activateOverlay( overlay : OverlayKind, ?uid : UID ) {
9393
activate_overlay_user( overlay == None ? null : @:privateAccess overlay.toString().toUtf8(), uid);
9494
}
95-
95+
9696
public static function activateOverlayStore( appId : Int, flags : OverlayToStoreFlag ) : Void {}
9797

98+
/**
99+
Key `steam_display` requires localized token as value, see https://partner.steamgames.com/doc/api/ISteamFriends#richpresencelocalization
100+
Set `value` to empty or null to remove the key.
101+
**/
102+
public static function setRichPresence( key : String, value : Null<String> ) : Bool {
103+
return @:privateAccess set_rich_presence(key.toUtf8(), value == null ? null : value.toUtf8());
104+
}
105+
106+
public static function clearRichPresence() : Void {}
107+
98108
static function get_friends( flags : FriendFlags ) : hl.NativeArray<UID> { return null; }
99109
static function has_friend( uid : UID, flags : FriendFlags ) : Bool { return false; }
100110
static function activate_overlay_user( overlay : hl.Bytes, uid : UID ) : Void {}
111+
static function set_rich_presence( pchKey : hl.Bytes, pchValue : hl.Bytes ) : Bool { return false; }
101112

102-
}
113+
}

0 commit comments

Comments
 (0)