diff options
author | Erik Kundiman <erik@megapahit.org> | 2025-07-28 15:13:36 +0800 |
---|---|---|
committer | Erik Kundiman <erik@megapahit.org> | 2025-07-28 15:13:36 +0800 |
commit | 306eb28d78c9aa83669307dc49daacb94f8c8742 (patch) | |
tree | 90062be2796d4fb8aababf11f670f8a2e9224dad /indra/newview/llappviewer.cpp | |
parent | ec86ee28171428824cde4afe88d1165e80633233 (diff) |
Location for Discord Rich Presence Activity State
I was going to use LLAgentUI::buildLocationString but there's no
location format that shows only region and coords without having
to have the parcel name empty, so I copied buildLocationString
implementation in the case of LOCATION_FORMAT_NO_MATURITY but when
the parcel name is empty.
I had to make updateDiscordActivity check agent's ID and the
existence of agent avatar pointer first before trying to set
Activity Details or State, cause I like the "Show location" button
be checkable not only after online when both the ID & pointer will
have existed. I think this way is simpler than programmatically
enabling the "Show location" button after the user is logged in.
I put a trigger to Activity update somewhere after the user is
logged in for now, not yet after a TP.
The elapsed time gets reset whenever Activity is updated for now,
but I'll try to make elapsed time extended instead.
No Party for now, because I couldn't find a way to make a Party
shown without showing its CurrentSize (I could still get away not
showing its MaxSize by setting it to 0), so the State (location)
is shown above the elapsed time, not on the right of it.
I'll try to figure out to get some representative numbers for its
CurrentSize & MaxSize next.
Also no privacy on hiding the username for now, until the UI is
ready.
Diffstat (limited to 'indra/newview/llappviewer.cpp')
-rw-r--r-- | indra/newview/llappviewer.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 030c778990..3d8dfd39e6 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -5980,4 +5980,36 @@ void LLAppViewer::handleDiscordSocial(bool enable) } } +void LLAppViewer::updateDiscordActivity() +{ + discordpp::Activity activity; + activity.SetType(discordpp::ActivityTypes::Playing); + if (gAgentAvatarp) + activity.SetDetails(gAgentAvatarp->getFullname()); + if (gAgent.getID() != LLUUID::null && gSavedSettings.getBOOL("ShowDiscordActivityState")) + { + auto agent_pos_region = gAgent.getPositionAgent(); + S32 pos_x = S32(agent_pos_region.mV[VX] + 0.5f); + S32 pos_y = S32(agent_pos_region.mV[VY] + 0.5f); + S32 pos_z = S32(agent_pos_region.mV[VZ] + 0.5f); + F32 velocity_mag_sq = gAgent.getVelocity().magVecSquared(); + const F32 FLY_CUTOFF = 6.f; + const F32 FLY_CUTOFF_SQ = FLY_CUTOFF * FLY_CUTOFF; + const F32 WALK_CUTOFF = 1.5f; + const F32 WALK_CUTOFF_SQ = WALK_CUTOFF * WALK_CUTOFF; + if (velocity_mag_sq > FLY_CUTOFF_SQ) + { + pos_x -= pos_x % 4; + pos_y -= pos_y % 4; + } + else if (velocity_mag_sq > WALK_CUTOFF_SQ) + { + pos_x -= pos_x % 2; + pos_y -= pos_y % 2; + } + activity.SetState(llformat("%s (%d, %d, %d)", gAgent.getRegion()->getName().c_str(), pos_x, pos_y, pos_z)); + } + gDiscordClient->UpdateRichPresence(activity, [](discordpp::ClientResult) {}); +} + #endif |