summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/newview/app_settings/settings.xml11
-rw-r--r--indra/newview/llappviewer.cpp32
-rw-r--r--indra/newview/llappviewer.h1
-rw-r--r--indra/newview/llfloaterpreference.cpp8
-rw-r--r--indra/newview/llstartup.cpp3
-rw-r--r--indra/newview/skins/default/xui/en/panel_preferences_privacy.xml1
6 files changed, 56 insertions, 0 deletions
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index a2e0a8dbbe..bb7211514d 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -1172,6 +1172,17 @@
<key>Value</key>
<integer>0</integer>
</map>
+ <key>ShowDiscordActivityState</key>
+ <map>
+ <key>Comment</key>
+ <string>When set, show location on Discord Rich Presence</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <integer>0</integer>
+ </map>
<key>EnableDiskCacheDebugInfo</key>
<map>
<key>Comment</key>
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
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index 8ff07accbe..79db515970 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -253,6 +253,7 @@ public:
#ifdef LL_DISCORD
static void initDiscordSocial();
static void handleDiscordSocial(bool enable);
+ static void updateDiscordActivity();
#endif
protected:
diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp
index 136683296f..c6e839c5de 100644
--- a/indra/newview/llfloaterpreference.cpp
+++ b/indra/newview/llfloaterpreference.cpp
@@ -238,10 +238,17 @@ void handleAppearanceCameraMovementChanged(const LLSD& newvalue)
}
#ifdef LL_DISCORD
+
void handleDiscordSocial(const LLSD& newvalue)
{
LLAppViewer::handleDiscordSocial(newvalue.asBoolean());
}
+
+void handleDiscordActivityState(const LLSD& newvalue)
+{
+ LLAppViewer::updateDiscordActivity();
+}
+
#endif
void fractionFromDecimal(F32 decimal_val, S32& numerator, S32& denominator)
@@ -375,6 +382,7 @@ LLFloaterPreference::LLFloaterPreference(const LLSD& key)
mCommitCallbackRegistrar.add("UpdateFilter", boost::bind(&LLFloaterPreference::onUpdateFilterTerm, this, false)); // <FS:ND/> Hook up for filtering
#ifdef LL_DISCORD
gSavedSettings.getControl("EnableDiscord")->getCommitSignal()->connect(boost::bind(&handleDiscordSocial, _2));
+ gSavedSettings.getControl("ShowDiscordActivityState")->getCommitSignal()->connect(boost::bind(&handleDiscordActivityState, _2));
#endif
}
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 8d010553a0..2f40beb9c4 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -2082,6 +2082,9 @@ bool idle_startup()
// We have a region, and just did a big inventory download.
// We can estimate the user's connection speed, and set their
// max bandwidth accordingly. JC
+#ifdef LL_DISCORD
+ LLAppViewer::updateDiscordActivity();
+#endif
if (gSavedSettings.getBOOL("FirstLoginThisInstall"))
{
// This is actually a pessimistic computation, because TCP may not have enough
diff --git a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml
index 8d78618a21..86bc23d699 100644
--- a/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml
+++ b/indra/newview/skins/default/xui/en/panel_preferences_privacy.xml
@@ -150,6 +150,7 @@
<check_box
enabled_control="EnableDiscord"
+ control_name="ShowDiscordActivityState"
height="16"
enabled="false"
label="Show location"