RLVa can now be toggled on/off at the login screen without requiring a viewer restart

--HG--
branch : RLVa
master
Kitty Barnett 2016-11-20 12:44:36 +01:00
parent 351c4f7709
commit d8a64bfa86
6 changed files with 41 additions and 85 deletions

View File

@ -3,14 +3,16 @@
<key>RLVaLoginLastLocation</key>
<map>
<key>Comment</key>
<string>Determines whether the next login will be forced to the last logoff location (set by the viewer)</string>
<string>Determines whether the next login will be forced to the last logoff location (set by RLVa)</string>
<key>Persist</key>
<integer>1</integer>
<key>HideFromEditor</key>
<integer>1</integer>
<key>Type</key>
<string>Boolean</string>
<string>Boolean</string>
<key>Value</key>
<boolean>1</boolean>
</map>
<boolean>1</boolean>
</map>
<key>AvatarHoverOffsetZ</key>
<map>
<key>Comment</key>

View File

@ -187,8 +187,7 @@
#include "llavatariconctrl.h"
#include "llvoicechannel.h"
#include "llpathfindingmanager.h"
// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0a)
// [RLVa:KB] - Checked: RLVa-1.2.0
#include "rlvhandler.h"
// [/RLVa:KB]
@ -376,13 +375,6 @@ bool idle_startup()
std::string lastGPU = gSavedSettings.getString("LastGPUString");
std::string thisGPU = LLFeatureManager::getInstance()->getGPUString();
// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0a) | Modified: RLVa-0.2.1d
if ( (gSavedSettings.controlExists(RLV_SETTING_MAIN)) && (gSavedSettings.getBOOL(RLV_SETTING_MAIN)) )
{
rlv_handler_t::setEnabled(TRUE);
}
// [/RLVa:KB]
if (LLFeatureManager::getInstance()->isSafe())
{
LLNotificationsUtil::add("DisplaySetToSafe");
@ -845,6 +837,13 @@ bool idle_startup()
return FALSE;
}
// [RLVa:KB] - Checked: RLVa-0.2.1
if (gSavedSettings.getBOOL(RLV_SETTING_MAIN))
{
RlvHandler::setEnabled(true);
}
// [/RLVa:KB]
// 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
@ -968,8 +967,8 @@ bool idle_startup()
// their last location, or some URL "-url //sim/x/y[/z]"
// All accounts have both a home and a last location, and we don't support
// more locations than that. Choose the appropriate one. JC
// [RLVa:KB] - Checked: 2010-04-01 (RLVa-1.2.0c) | Modified: RLVa-0.2.1d
if ( (rlv_handler_t::isEnabled()) && (RlvSettings::getLoginLastLocation()) )
// [RLVa:KB] - Checked: RLVa-0.2.1
if ( (RlvHandler::isEnabled()) && (RlvSettings::getLoginLastLocation()) )
{
// Force login at the last location
LLStartUp::setStartSLURL(LLSLURL(LLSLURL::SIM_LOCATION_LAST));
@ -1804,8 +1803,8 @@ bool idle_startup()
LLFloaterReg::getInstance("inventory");
display_startup();
// [RLVa:KB] - Checked: 2010-02-27 (RLVa-1.2.0a) | Added: RLVa-1.1.0f
if (rlv_handler_t::isEnabled())
// [RLVa:KB] - Checked: RLVa-1.1.0
if (RlvHandler::isEnabled())
{
// Regularly process a select subset of retained commands during logon
gIdleCallbacks.addFunction(RlvHandler::onIdleStartup, new LLTimer());

View File

@ -152,17 +152,14 @@ bool RlvSettings::onChangedSettingBOOL(const LLSD& sdValue, bool* pfSetting)
return true;
}
// Checked: 2015-05-25 (RLVa-1.5.0)
void RlvSettings::onChangedSettingMain(const LLSD& sdValue)
{
if (sdValue.asBoolean() != (bool)rlv_handler_t::isEnabled())
{
LLNotificationsUtil::add(
"GenericAlert",
LLSD().with("MESSAGE", llformat(LLTrans::getString("RLVaToggleMessage").c_str(),
(sdValue.asBoolean()) ? LLTrans::getString("RLVaToggleEnabled").c_str()
: LLTrans::getString("RLVaToggleDisabled").c_str())));
}
LLStringUtil::format_map_t args;
args["[STATE]"] = LLTrans::getString( (sdValue.asBoolean()) ? "RLVaToggleEnabled" : "RLVaToggleDisabled");
// As long as RLVa hasn't been enabled but >can< be enabled all toggles are instant (everything else will require a restart)
bool fQuickToggle = (!RlvHandler::isEnabled()) && (RlvHandler::canEnable());
LLNotificationsUtil::add("GenericAlert", LLSD().with("MESSAGE", LLTrans::getString((fQuickToggle) ? "RLVaToggleMessageLogin" : "RLVaToggleMessageRestart", args)));
}
void RlvSettings::initCompatibilityMode(std::string strCompatList)
@ -629,7 +626,7 @@ bool rlvMenuMainToggleVisible(LLUICtrl* pMenuCtrl)
if (pMenuItem)
{
static std::string strLabel = pMenuItem->getLabel();
if (gSavedSettings.getBOOL(RLV_SETTING_MAIN) == rlv_handler_t::isEnabled())
if ((bool)gSavedSettings.getBOOL(RLV_SETTING_MAIN) == rlv_handler_t::isEnabled())
pMenuItem->setLabel(strLabel);
else
pMenuItem->setLabel(strLabel + " " + LLTrans::getString("RLVaPendingRestart"));

View File

@ -64,7 +64,7 @@
// Static variable initialization
//
BOOL RlvHandler::m_fEnabled = FALSE;
bool RlvHandler::m_fEnabled = false;
rlv_handler_t gRlvHandler;
@ -1044,17 +1044,20 @@ bool RlvHandler::redirectChatOrEmote(const std::string& strUTF8Text) const
// Initialization helper functions
//
// Checked: 2010-02-27 (RLVa-1.2.0a) | Modified: RLVa-1.2.0a
BOOL RlvHandler::setEnabled(BOOL fEnable)
bool RlvHandler::canEnable()
{
return LLStartUp::getStartupState() <= STATE_LOGIN_CLEANUP;
}
bool RlvHandler::setEnabled(bool fEnable)
{
// TODO-RLVa: [RLVa-1.2.1] Allow toggling at runtime if we haven't seen any llOwnerSay("@....");
if (m_fEnabled == fEnable)
return fEnable;
if (fEnable)
if ( (fEnable) && (canEnable()) )
{
RLV_INFOS << "Enabling Restrained Love API support - " << RlvStrings::getVersionAbout() << RLV_ENDL;
m_fEnabled = TRUE;
m_fEnabled = true;
// Initialize static classes
RlvSettings::initClass();
@ -1079,51 +1082,6 @@ BOOL RlvHandler::setEnabled(BOOL fEnable)
return m_fEnabled;
}
BOOL RlvHandler::canDisable()
{
return FALSE;
}
void RlvHandler::clearState()
{
/*
// TODO-RLVa: should restore all RLV controlled debug variables to their defaults
// Issue @clear on behalf of every object that has a currently active RLV restriction (even if it's just an exception)
LLUUID idObj; LLViewerObject* pObj; bool fDetachable;
while (m_Objects.size())
{
idObj = m_Objects.begin()->first; // Need a copy since after @clear the data it points to will no longer exist
fDetachable = ((pObj = gObjectList.findObject(idObj)) != NULL) ? isLockedAttachment(pObj, RLV_LOCK_REMOVE) : true;
processCommand(idObj, "clear", false);
if (!fDetachable)
processCommand(idObj, "detachme=force", false);
}
// Sanity check - these should all be empty after we issue @clear on the last object
if ( (!m_Objects.empty()) || !(m_Exceptions.empty()) || (!m_AttachAdd.empty()) || (!m_AttachRem.empty()) )
{
RLV_ERRS << "Object, exception or attachment map not empty after clearing state!" << LL_ENDL;
m_Objects.clear();
m_Exceptions.clear();
m_AttachAdd.clear();
m_AttachRem.clear();
}
// These all need manual clearing
memset(m_LayersAdd, 0, sizeof(S16) * WT_COUNT);
memset(m_LayersRem, 0, sizeof(S16) * WT_COUNT);
memset(m_Behaviours, 0, sizeof(S16) * RLV_BHVR_COUNT);
m_Retained.clear();
clearCommandHandlers(); // <- calls delete on all registered command handlers
// Clear dynamically allocated memory
delete m_pGCTimer;
m_pGCTimer = NULL;
*/
}
// ============================================================================
// Command handlers (RLV_TYPE_ADD and RLV_TYPE_REMOVE)
//

View File

@ -114,11 +114,10 @@ public:
const LLUUID& getCurrentObject() const { return (!m_CurObjectStack.empty()) ? m_CurObjectStack.top() : LLUUID::null; }
// Initialization
static BOOL canDisable();
static BOOL isEnabled() { return m_fEnabled; }
static BOOL setEnabled(BOOL fEnable);
static bool canEnable();
static bool isEnabled() { return m_fEnabled; }
static bool setEnabled(bool fEnable);
protected:
void clearState();
// --------------------------------
@ -202,7 +201,7 @@ protected:
rlv_command_signal_t m_OnCommand;
mutable std::list<RlvExtCommandHandler*> m_CommandHandlers;
static BOOL m_fEnabled; // Use setEnabled() to toggle this
static bool m_fEnabled; // Use setEnabled() to toggle this
bool m_fCanCancelTp; // @accepttp=n and @tpto=force
mutable LLVector3d m_posSitSource; // @standtp=n (mutable because onForceXXX handles are all declared as const)

View File

@ -4102,8 +4102,9 @@ Try enclosing path to the editor with double quotes.
<string name="UserDictionary">[User]</string>
<!-- RLVa -->
<string name="RLVaPendingRestart"> (pending restart)</string>
<string name="RLVaToggleMessage">RestrainedLove Support will be %s after you restart</string>
<string name="RLVaPendingRestart">(pending restart)</string>
<string name="RLVaToggleMessageLogin">RLVa has been [STATE] (no restart required)</string>
<string name="RLVaToggleMessageRestart">RLVa will be [STATE] after you restart</string>
<string name="RLVaToggleEnabled">enabled</string>
<string name="RLVaToggleDisabled">disabled</string>