Merge all presence methods into one

I'm about to make them interdependent (and it's discord's fault),
so it doesn't really make sense to make them separate at this point
I don't think. And it felt weird anyway.
This commit is contained in:
Bartłomiej Dach 2024-03-25 18:00:42 +01:00
parent e95f29cf4b
commit a398754a27
No known key found for this signature in database
1 changed files with 7 additions and 13 deletions

View File

@ -134,16 +134,14 @@ private void schedulePresenceUpdate()
bool hideIdentifiableInformation = privacyMode.Value == DiscordRichPresenceMode.Limited || status.Value == UserStatus.DoNotDisturb;
updatePresenceStatus(hideIdentifiableInformation);
updatePresenceParty(hideIdentifiableInformation);
updatePresenceAssets();
updatePresence(hideIdentifiableInformation);
client.SetPresence(presence);
}, 200);
}
private void updatePresenceStatus(bool hideIdentifiableInformation)
private void updatePresence(bool hideIdentifiableInformation)
{
// user activity
if (activity.Value != null)
{
presence.State = truncate(activity.Value.GetStatus(hideIdentifiableInformation));
@ -170,10 +168,8 @@ private void updatePresenceStatus(bool hideIdentifiableInformation)
presence.State = "Idle";
presence.Details = string.Empty;
}
}
private void updatePresenceParty(bool hideIdentifiableInformation)
{
// user party
if (!hideIdentifiableInformation && multiplayerClient.Room != null)
{
MultiplayerRoom room = multiplayerClient.Room;
@ -201,11 +197,9 @@ private void updatePresenceParty(bool hideIdentifiableInformation)
presence.Party = null;
presence.Secrets.JoinSecret = null;
}
}
private void updatePresenceAssets()
{
// update user information
// game images:
// large image tooltip
if (privacyMode.Value == DiscordRichPresenceMode.Limited)
presence.Assets.LargeImageText = string.Empty;
else
@ -216,7 +210,7 @@ private void updatePresenceAssets()
presence.Assets.LargeImageText = $"{user.Value.Username}" + (user.Value.Statistics?.GlobalRank > 0 ? $" (rank #{user.Value.Statistics.GlobalRank:N0})" : string.Empty);
}
// update ruleset
// small image
presence.Assets.SmallImageKey = ruleset.Value.IsLegacyRuleset() ? $"mode_{ruleset.Value.OnlineID}" : "mode_custom";
presence.Assets.SmallImageText = ruleset.Value.Name;
}