summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitty Barnett <develop@catznip.com>2024-08-31 01:33:27 +0200
committerKitty Barnett <develop@catznip.com>2024-08-31 22:16:46 +0200
commitc820bb2929a37fb222ce0d7368d699e81f5edc00 (patch)
tree30f4f17db0b39738ba23b68c3d20b7f5afa0fe4f
parente92a06d68114c933599da12d75221504ebac77e0 (diff)
Minimal code needed to add RLVa with an on/off toggle
-rw-r--r--indra/newview/CMakeLists.txt7
-rw-r--r--indra/newview/app_settings/settings.xml11
-rw-r--r--indra/newview/llappviewer.cpp8
-rw-r--r--indra/newview/llstartup.cpp3
-rw-r--r--indra/newview/rlvactions.cpp15
-rw-r--r--indra/newview/rlvactions.h19
-rw-r--r--indra/newview/rlvcommon.cpp40
-rw-r--r--indra/newview/rlvcommon.h16
-rw-r--r--indra/newview/rlvdefines.h51
-rw-r--r--indra/newview/rlvhandler.cpp40
-rw-r--r--indra/newview/rlvhandler.h25
-rw-r--r--indra/newview/skins/default/xui/en/strings.xml1
12 files changed, 236 insertions, 0 deletions
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index 7a9f3a46b5..70a9f09e1f 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -726,6 +726,9 @@ set(viewer_SOURCE_FILES
llxmlrpctransaction.cpp
noise.cpp
pipeline.cpp
+ rlvactions.cpp
+ rlvcommon.cpp
+ rlvhandler.cpp
)
set(VIEWER_BINARY_NAME "secondlife-bin" CACHE STRING
@@ -1386,6 +1389,10 @@ set(viewer_HEADER_FILES
llxmlrpctransaction.h
noise.h
pipeline.h
+ rlvdefines.h
+ rlvactions.h
+ rlvcommon.h
+ rlvhandler.h
roles_constants.h
VertexCache.h
VorbisFramework.h
diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index ec06582d90..48e0878383 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -9843,6 +9843,17 @@
<key>Value</key>
<string>https://feedback.secondlife.com/</string>
</map>
+ <key>RestrainedLove</key>
+ <map>
+ <key>Comment</key>
+ <string>Toggles RLVa features (requires restart)</string>
+ <key>Persist</key>
+ <integer>1</integer>
+ <key>Type</key>
+ <string>Boolean</string>
+ <key>Value</key>
+ <boolean>1</boolean>
+ </map>
<key>RevokePermsOnStopAnimation</key>
<map>
<key>Comment</key>
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index afa701c5f2..6a2498c57a 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -250,6 +250,10 @@ using namespace LL;
#include "llcoproceduremanager.h"
#include "llviewereventrecorder.h"
+#include "rlvactions.h"
+#include "rlvcommon.h"
+#include "rlvhandler.h"
+
// *FIX: These extern globals should be cleaned up.
// The globals either represent state/config/resource-storage of either
// this app, or another 'component' of the viewer. App globals should be
@@ -1710,6 +1714,9 @@ bool LLAppViewer::cleanup()
//ditch LLVOAvatarSelf instance
gAgentAvatarp = NULL;
+ // Sanity check to catch cases where someone forgot to do an RlvActions::isRlvEnabled() check
+ LL_ERRS_IF(!RlvHandler::isEnabled() && RlvHandler::instanceExists()) << "RLV handler instance exists even though RLVa is disabled" << LL_ENDL;
+
LLNotifications::instance().clear();
// workaround for DEV-35406 crash on shutdown
@@ -3333,6 +3340,7 @@ LLSD LLAppViewer::getViewerInfo() const
}
#endif
+ info["RLV_VERSION"] = RlvActions::isRlvEnabled() ? RlvStrings::getVersionAbout() : "(disabled)";
info["OPENGL_VERSION"] = ll_safe_string((const char*)(glGetString(GL_VERSION)));
// Settings
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index b32b80331a..3b027df460 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -205,6 +205,7 @@
#include "threadpool.h"
#include "llperfstats.h"
+#include "rlvhandler.h"
#if LL_WINDOWS
#include "lldxhardware.h"
@@ -876,6 +877,8 @@ bool idle_startup()
return false;
}
+ RlvHandler::setEnabled(gSavedSettings.get<bool>(Rlv::Settings::Main));
+
// reset the values that could have come in from a slurl
// DEV-42215: Make sure they're not empty -- gUserCredential
// might already have been set from gSavedSettings, and it's too bad
diff --git a/indra/newview/rlvactions.cpp b/indra/newview/rlvactions.cpp
new file mode 100644
index 0000000000..1988c99ecf
--- /dev/null
+++ b/indra/newview/rlvactions.cpp
@@ -0,0 +1,15 @@
+#include "llviewerprecompiledheaders.h"
+
+#include "rlvactions.h"
+#include "rlvhandler.h"
+
+// ============================================================================
+// Helper functions
+//
+
+bool RlvActions::isRlvEnabled()
+{
+ return RlvHandler::isEnabled();
+}
+
+// ============================================================================
diff --git a/indra/newview/rlvactions.h b/indra/newview/rlvactions.h
new file mode 100644
index 0000000000..ac4fc73339
--- /dev/null
+++ b/indra/newview/rlvactions.h
@@ -0,0 +1,19 @@
+#pragma once
+
+// ============================================================================
+// RlvActions - developer-friendly non-RLVa code facing class, use in lieu of RlvHandler whenever possible
+//
+
+class RlvActions
+{
+ // ================
+ // Helper functions
+ // ================
+public:
+ /*
+ * Convenience function to check if RLVa is enabled without having to include rlvhandler.h
+ */
+ static bool isRlvEnabled();
+};
+
+// ============================================================================
diff --git a/indra/newview/rlvcommon.cpp b/indra/newview/rlvcommon.cpp
new file mode 100644
index 0000000000..f641d56a85
--- /dev/null
+++ b/indra/newview/rlvcommon.cpp
@@ -0,0 +1,40 @@
+#include "llviewerprecompiledheaders.h"
+#include "llversioninfo.h"
+
+#include "rlvdefines.h"
+#include "rlvcommon.h"
+
+using namespace Rlv;
+
+// ============================================================================
+// RlvStrings
+//
+
+std::string RlvStrings::getVersion(bool wants_legacy)
+{
+ return llformat("%s viewer v%d.%d.%d (RLVa %d.%d.%d)",
+ !wants_legacy ? "RestrainedLove" : "RestrainedLife",
+ SpecVersion::Major, SpecVersion::Minor, SpecVersion::Patch,
+ ImplVersion::Major, ImplVersion::Minor, ImplVersion::Patch);
+}
+
+std::string RlvStrings::getVersionAbout()
+{
+ return llformat("RLV v%d.%d.%d / RLVa v%d.%d.%d.%d",
+ SpecVersion::Major, SpecVersion::Minor, SpecVersion::Patch,
+ ImplVersion::Major, ImplVersion::Minor, ImplVersion::Patch, LLVersionInfo::instance().getBuild());
+}
+
+std::string RlvStrings::getVersionNum()
+{
+ return llformat("%d%02d%02d%02d",
+ SpecVersion::Major, SpecVersion::Minor, SpecVersion::Patch, SpecVersion::Build);
+}
+
+std::string RlvStrings::getVersionImplNum()
+{
+ return llformat("%d%02d%02d%02d",
+ ImplVersion::Major, ImplVersion::Minor, ImplVersion::Patch, ImplVersion::ImplId);
+}
+
+// ============================================================================
diff --git a/indra/newview/rlvcommon.h b/indra/newview/rlvcommon.h
new file mode 100644
index 0000000000..288d48e373
--- /dev/null
+++ b/indra/newview/rlvcommon.h
@@ -0,0 +1,16 @@
+#pragma once
+
+// ============================================================================
+// RlvStrings
+//
+
+class RlvStrings
+{
+public:
+ static std::string getVersion(bool wants_legacy);
+ static std::string getVersionAbout();
+ static std::string getVersionImplNum();
+ static std::string getVersionNum();
+};
+
+// ============================================================================
diff --git a/indra/newview/rlvdefines.h b/indra/newview/rlvdefines.h
new file mode 100644
index 0000000000..dc1e58f47c
--- /dev/null
+++ b/indra/newview/rlvdefines.h
@@ -0,0 +1,51 @@
+#pragma once
+
+// ============================================================================
+// Defines
+//
+
+namespace Rlv
+{
+ // Version of the specification we report
+ struct SpecVersion {
+ static constexpr S32 Major = 4;
+ static constexpr S32 Minor = 0;
+ static constexpr S32 Patch = 0;
+ static constexpr S32 Build = 0;
+ };
+
+ // RLVa implementation version
+ struct ImplVersion {
+ static constexpr S32 Major = 3;
+ static constexpr S32 Minor = 0;
+ static constexpr S32 Patch = 0;
+ static constexpr S32 ImplId = 2; /* Official viewer */
+ };
+}
+
+// Defining these makes it easier if we ever need to change our tag
+#define RLV_WARNS LL_WARNS("RLV")
+#define RLV_INFOS LL_INFOS("RLV")
+#define RLV_DEBUGS LL_DEBUGS("RLV")
+#define RLV_ENDL LL_ENDL
+
+// ============================================================================
+// Settings
+//
+
+namespace Rlv
+{
+ namespace Settings
+ {
+ constexpr char Main[] = "RestrainedLove";
+ constexpr char Debug[] = "RestrainedLoveDebug";
+
+ constexpr char DebugHideUnsetDup[] = "RLVaDebugHideUnsetDuplicate";
+ constexpr char EnableIMQuery[] = "RLVaEnableIMQuery";
+ constexpr char EnableTempAttach[] = "RLVaEnableTemporaryAttachments";
+ constexpr char TopLevelMenu[] = "RLVaTopLevelMenu";
+ };
+
+};
+
+// ============================================================================
diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp
new file mode 100644
index 0000000000..3315ed1999
--- /dev/null
+++ b/indra/newview/rlvhandler.cpp
@@ -0,0 +1,40 @@
+#include "llviewerprecompiledheaders.h"
+#include "llappviewer.h"
+#include "llstartup.h"
+
+#include "rlvdefines.h"
+#include "rlvcommon.h"
+#include "rlvhandler.h"
+
+using namespace Rlv;
+
+// ============================================================================
+// Static variable initialization
+//
+
+bool RlvHandler::mIsEnabled = false;
+
+// ============================================================================
+// Initialization helper functions
+//
+
+bool RlvHandler::canEnable()
+{
+ return LLStartUp::getStartupState() <= STATE_LOGIN_CLEANUP;
+}
+
+bool RlvHandler::setEnabled(bool enable)
+{
+ if (mIsEnabled == enable)
+ return enable;
+
+ if (enable && canEnable())
+ {
+ RLV_INFOS << "Enabling Restrained Love API support - " << RlvStrings::getVersionAbout() << RLV_ENDL;
+ mIsEnabled = true;
+ }
+
+ return mIsEnabled;
+}
+
+// ============================================================================
diff --git a/indra/newview/rlvhandler.h b/indra/newview/rlvhandler.h
new file mode 100644
index 0000000000..0d4cbe98fb
--- /dev/null
+++ b/indra/newview/rlvhandler.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "llsingleton.h"
+
+#include "rlvdefines.h"
+
+// ============================================================================
+// RlvHandler class
+//
+
+class RlvHandler : public LLSingleton<RlvHandler>
+{
+ LLSINGLETON_EMPTY_CTOR(RlvHandler);
+
+public:
+ // Initialization (deliberately static so they can safely be called in tight loops)
+ static bool canEnable();
+ static bool isEnabled() { return mIsEnabled; }
+ static bool setEnabled(bool enable);
+
+private:
+ static bool mIsEnabled;
+};
+
+// ============================================================================
diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml
index 2d04b3e0fe..a270bc473d 100644
--- a/indra/newview/skins/default/xui/en/strings.xml
+++ b/indra/newview/skins/default/xui/en/strings.xml
@@ -60,6 +60,7 @@ Disk cache: [DISK_CACHE_INFO]
HiDPI display mode: [HIDPI]
</string>
<string name="AboutLibs">
+RestrainedLove API: [RLV_VERSION]
J2C Decoder Version: [J2C_VERSION]
Audio Driver Version: [AUDIO_DRIVER_VERSION]
[LIBCEF_VERSION]