summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2024-05-02 16:58:37 +0300
committerGitHub <noreply@github.com>2024-05-02 16:58:37 +0300
commit51e86a0eff4e919075b32c498305add577450111 (patch)
tree4334ec60cadf7aefddf8266c21731b38592aa583
parent6d860672ec3e05660844a40c56b8644130a1f6b6 (diff)
parentf9a2748b542d05d153fa591a8c452162d9402828 (diff)
Merge pull request #1352 from secondlife/lua-change-debug-setting
Allow changing debug settings via Lua script
-rw-r--r--indra/llxml/llcontrol.cpp4
-rw-r--r--indra/llxml/llcontrol.h4
-rw-r--r--indra/newview/llfloatersettingsdebug.cpp20
-rw-r--r--indra/newview/llfloatersettingsdebug.h4
-rw-r--r--indra/newview/llviewercontrollistener.cpp7
-rw-r--r--indra/newview/scripts/lua/LLDebugSettings.lua24
-rw-r--r--indra/newview/skins/default/xui/en/floater_settings_debug.xml18
7 files changed, 69 insertions, 12 deletions
diff --git a/indra/llxml/llcontrol.cpp b/indra/llxml/llcontrol.cpp
index 2960ecf829..a2178ed77d 100644
--- a/indra/llxml/llcontrol.cpp
+++ b/indra/llxml/llcontrol.cpp
@@ -730,7 +730,7 @@ void LLControlGroup::setLLSD(const std::string& name, const LLSD& val)
set(name, val);
}
-void LLControlGroup::setUntypedValue(const std::string& name, const LLSD& val)
+void LLControlGroup::setUntypedValue(const std::string& name, const LLSD& val, bool saved_value)
{
if (name.empty())
{
@@ -741,7 +741,7 @@ void LLControlGroup::setUntypedValue(const std::string& name, const LLSD& val)
if (control)
{
- control->setValue(val);
+ control->setValue(val, saved_value);
}
else
{
diff --git a/indra/llxml/llcontrol.h b/indra/llxml/llcontrol.h
index 0839c02c50..5a8d688892 100644
--- a/indra/llxml/llcontrol.h
+++ b/indra/llxml/llcontrol.h
@@ -143,7 +143,7 @@ public:
LLSD getDefault() const { return mValues.front(); }
LLSD getSaveValue() const;
- void set(const LLSD& val) { setValue(val); }
+ void set(const LLSD& val, bool saved_value = true) { setValue(val, saved_value); }
void setValue(const LLSD& value, bool saved_value = TRUE);
void setDefaultValue(const LLSD& value);
void setPersist(ePersist);
@@ -278,7 +278,7 @@ public:
void setLLSD(const std::string& name, const LLSD& val);
// type agnostic setter that takes LLSD
- void setUntypedValue(const std::string& name, const LLSD& val);
+ void setUntypedValue(const std::string& name, const LLSD& val, bool saved_value = true);
// generic setter
template<typename T> void set(const std::string& name, const T& val)
diff --git a/indra/newview/llfloatersettingsdebug.cpp b/indra/newview/llfloatersettingsdebug.cpp
index 3c7f341613..e1df6a4b1f 100644
--- a/indra/newview/llfloatersettingsdebug.cpp
+++ b/indra/newview/llfloatersettingsdebug.cpp
@@ -34,6 +34,7 @@
#include "llcolorswatch.h"
#include "llviewercontrol.h"
#include "lltexteditor.h"
+#include "llclipboard.h"
LLFloaterSettingsDebug::LLFloaterSettingsDebug(const LLSD& key)
@@ -52,6 +53,8 @@ BOOL LLFloaterSettingsDebug::postBuild()
enableResizeCtrls(true, false, true);
mComment = getChild<LLTextEditor>("comment_text");
+ mSettingName = getChild<LLTextBox>("setting_name_txt");
+ mCopyBtn = getChild<LLButton>("copy_btn");
getChild<LLFilterEditor>("filter_input")->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::setSearchFilter, this, _2));
@@ -59,6 +62,8 @@ BOOL LLFloaterSettingsDebug::postBuild()
mSettingList->setCommitOnSelectionChange(TRUE);
mSettingList->setCommitCallback(boost::bind(&LLFloaterSettingsDebug::onSettingSelect, this));
+ mCopyBtn->setCommitCallback([this](LLUICtrl *ctrl, const LLSD &param) { onClickCopy(); });
+
updateList();
gSavedSettings.getControl("DebugSettingsHideDefault")->getCommitSignal()->connect(boost::bind(&LLFloaterSettingsDebug::updateList, this, false));
@@ -203,9 +208,10 @@ void LLFloaterSettingsDebug::updateControl(LLControlVariable* controlp)
//hide combo box only for non booleans, otherwise this will result in the combo box closing every frame
getChildView("boolean_combo")->setVisible( type == TYPE_BOOLEAN);
getChildView("default_btn")->setVisible(true);
- getChildView("setting_name_txt")->setVisible(true);
- getChild<LLTextBox>("setting_name_txt")->setText(controlp->getName());
- getChild<LLTextBox>("setting_name_txt")->setToolTip(controlp->getName());
+ mSettingName->setVisible(true);
+ mSettingName->setText(controlp->getName());
+ mSettingName->setToolTip(controlp->getName());
+ mCopyBtn->setVisible(true);
mComment->setVisible(true);
std::string old_text = mComment->getText();
@@ -632,7 +638,13 @@ void LLFloaterSettingsDebug::hideUIControls()
getChildView("val_text")->setVisible(false);
getChildView("default_btn")->setVisible(false);
getChildView("boolean_combo")->setVisible(false);
- getChildView("setting_name_txt")->setVisible(false);
+ mSettingName->setVisible(false);
+ mCopyBtn->setVisible(false);
mComment->setVisible(false);
}
+void LLFloaterSettingsDebug::onClickCopy()
+{
+ std::string setting_name = mSettingName->getText();
+ LLClipboard::instance().copyToClipboard(utf8str_to_wstring(setting_name), 0, setting_name.size());
+}
diff --git a/indra/newview/llfloatersettingsdebug.h b/indra/newview/llfloatersettingsdebug.h
index 888eaadcbd..6ff3e344b4 100644
--- a/indra/newview/llfloatersettingsdebug.h
+++ b/indra/newview/llfloatersettingsdebug.h
@@ -31,6 +31,7 @@
#include "llfloater.h"
class LLScrollListCtrl;
+class LLTextBox;
class LLFloaterSettingsDebug
: public LLFloater
@@ -46,6 +47,7 @@ public:
void onCommitSettings();
void onClickDefault();
+ void onClickCopy();
bool matchesSearchFilter(std::string setting_name);
bool isSettingHidden(LLControlVariable* control);
@@ -67,6 +69,8 @@ private:
protected:
class LLTextEditor* mComment;
+ LLTextBox* mSettingName;
+ LLButton* mCopyBtn;
std::string mSearchFilter;
};
diff --git a/indra/newview/llviewercontrollistener.cpp b/indra/newview/llviewercontrollistener.cpp
index 8820f9ec56..16c4084a77 100644
--- a/indra/newview/llviewercontrollistener.cpp
+++ b/indra/newview/llviewercontrollistener.cpp
@@ -141,7 +141,8 @@ void LLViewerControlListener::set(LLSD const & request)
if (request.has("value"))
{
- info.control->setValue(request["value"]);
+ LL_WARNS("LLViewerControlListener") << "Changing debug setting " << std::quoted(info.key) << " to " << request["value"] << LL_ENDL;
+ info.control->setValue(request["value"], false);
}
else
{
@@ -158,7 +159,9 @@ void LLViewerControlListener::toggle(LLSD const & request)
if (info.control->isType(TYPE_BOOLEAN))
{
- info.control->set(! info.control->get().asBoolean());
+ bool value = !info.control->get().asBoolean();
+ LL_WARNS("LLViewerControlListener") << "Toggling debug setting " << std::quoted(info.key) << " to " << value << LL_ENDL;
+ info.control->set(value, false);
}
else
{
diff --git a/indra/newview/scripts/lua/LLDebugSettings.lua b/indra/newview/scripts/lua/LLDebugSettings.lua
new file mode 100644
index 0000000000..c809dfff91
--- /dev/null
+++ b/indra/newview/scripts/lua/LLDebugSettings.lua
@@ -0,0 +1,24 @@
+leap = require 'leap'
+
+function check_response(res)
+ if res.error then
+ error(res.error)
+ end
+ return res
+end
+
+local LLDebugSettings = {}
+
+function LLDebugSettings.set(name, value)
+ check_response(leap.request('LLViewerControl', {op='set', group='Global', key=name, value=value}))
+end
+
+function LLDebugSettings.toggle(name)
+ check_response(leap.request('LLViewerControl', {op='toggle', group='Global', key=name}))
+end
+
+function LLDebugSettings.get(name)
+ return check_response(leap.request('LLViewerControl', {op='get', group='Global', key=name}))['value']
+end
+
+return LLDebugSettings
diff --git a/indra/newview/skins/default/xui/en/floater_settings_debug.xml b/indra/newview/skins/default/xui/en/floater_settings_debug.xml
index a93be6a18d..6fd8f2b255 100644
--- a/indra/newview/skins/default/xui/en/floater_settings_debug.xml
+++ b/indra/newview/skins/default/xui/en/floater_settings_debug.xml
@@ -43,6 +43,20 @@
label="Setting"
name="setting" />
</scroll_list>
+ <button
+ follows="right|bottom"
+ layout="topleft"
+ image_hover_unselected="Toolbar_Middle_Over"
+ image_overlay="Icon_Copy"
+ image_selected="Toolbar_Middle_Selected"
+ image_unselected="Toolbar_Middle_Off"
+ name="copy_btn"
+ tool_tip="Copy to clipboard"
+ top_delta="8"
+ left_pad="10"
+ visible="false"
+ height="20"
+ width="20" />
<text
type="string"
length="1"
@@ -51,8 +65,7 @@
layout="topleft"
name="setting_name_txt"
font="SansSerifSmallBold"
- top_delta="8"
- left_pad="10"
+ left_pad="4"
visible="false"
use_ellipses="true"
text_color="White"
@@ -67,6 +80,7 @@
name="comment_text"
follows="left|top"
width="240"
+ left="320"
top_delta="20"
word_wrap="true" />
<radio_group