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