mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Allow for rich presence to be set on game join
better title: Allow for rich presence to be set through BloxstrapRPC on immediate game join
This commit is contained in:
parent
871bf2f9b1
commit
b22d72a1b8
@ -9,6 +9,7 @@ namespace Bloxstrap.Integrations
|
||||
|
||||
private DiscordRPC.RichPresence? _currentPresence;
|
||||
private DiscordRPC.RichPresence? _currentPresenceCopy;
|
||||
private Message? _stashedRPCMessage;
|
||||
|
||||
private bool _visible = true;
|
||||
private long _currentUniverseId;
|
||||
@ -55,6 +56,13 @@ namespace Bloxstrap.Integrations
|
||||
|
||||
if (_currentPresence is null || _currentPresenceCopy is null)
|
||||
{
|
||||
if (_activityWatcher.ActivityInGame)
|
||||
{
|
||||
App.Logger.WriteLine(LOG_IDENT, "Presence is not yet set, but is currently in game, stashing presence set request");
|
||||
_stashedRPCMessage = message;
|
||||
return;
|
||||
}
|
||||
|
||||
App.Logger.WriteLine(LOG_IDENT, "Presence is not set, aborting");
|
||||
return;
|
||||
}
|
||||
@ -173,7 +181,10 @@ namespace Bloxstrap.Integrations
|
||||
if (!_activityWatcher.ActivityInGame)
|
||||
{
|
||||
App.Logger.WriteLine(LOG_IDENT, "Not in game, clearing presence");
|
||||
_currentPresence = _currentPresenceCopy = null;
|
||||
|
||||
_currentPresence = _currentPresenceCopy = null;
|
||||
_stashedRPCMessage = null;
|
||||
|
||||
UpdatePresence();
|
||||
return true;
|
||||
}
|
||||
@ -268,7 +279,16 @@ namespace Bloxstrap.Integrations
|
||||
// this is used for configuration from BloxstrapRPC
|
||||
_currentPresenceCopy = _currentPresence.Clone();
|
||||
|
||||
UpdatePresence();
|
||||
if (_stashedRPCMessage is not null)
|
||||
{
|
||||
App.Logger.WriteLine(LOG_IDENT, "Found stashed RPC message, invoking presence set command now");
|
||||
ProcessRPCMessage(_stashedRPCMessage);
|
||||
_stashedRPCMessage = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdatePresence();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user