summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rw-r--r--indra/newview/llpreviewscript.cpp101
1 files changed, 95 insertions, 6 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 23c6cc01f5..4207d33afe 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -87,6 +87,9 @@
#include "llexperiencecache.h"
#include "llfloaterexperienceprofile.h"
#include "llviewerassetupload.h"
+#include "lltoggleablemenu.h"
+#include "llmenubutton.h"
+#include "llinventoryfunctions.h"
const std::string HELLO_LSL =
"default\n"
@@ -323,6 +326,38 @@ void LLFloaterScriptSearch::onSearchBoxCommit()
}
/// ---------------------------------------------------------------------------
+
+class LLScriptMovedObserver : public LLInventoryObserver
+{
+ public:
+ LLScriptMovedObserver(LLPreviewLSL *floater) : mPreview(floater) { gInventory.addObserver(this); }
+ virtual ~LLScriptMovedObserver() { gInventory.removeObserver(this); }
+ virtual void changed(U32 mask);
+
+ private:
+ LLPreviewLSL *mPreview;
+};
+
+void LLScriptMovedObserver::changed(U32 mask)
+{
+ const std::set<LLUUID> &mChangedItemIDs = gInventory.getChangedIDs();
+ std::set<LLUUID>::const_iterator it;
+
+ const LLUUID &item_id = mPreview->getScriptID();
+
+ for (it = mChangedItemIDs.begin(); it != mChangedItemIDs.end(); it++)
+ {
+ if (*it == item_id)
+ {
+ if ((mask & (LLInventoryObserver::STRUCTURE)) != 0)
+ {
+ mPreview->setDirty();
+ }
+ }
+ }
+}
+
+/// ---------------------------------------------------------------------------
/// LLScriptEdCore
/// ---------------------------------------------------------------------------
@@ -460,6 +495,13 @@ BOOL LLScriptEdCore::postBuild()
LLSyntaxIdLSL::getInstance()->initialize();
processKeywords();
+ mCommitCallbackRegistrar.add("FontSize.Set", boost::bind(&LLScriptEdCore::onChangeFontSize, this, _2));
+ mEnableCallbackRegistrar.add("FontSize.Check", boost::bind(&LLScriptEdCore::isFontSizeChecked, this, _2));
+
+ LLToggleableMenu *context_menu = LLUICtrlFactory::getInstance()->createFromFile<LLToggleableMenu>(
+ "menu_lsl_font_size.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance());
+ getChild<LLMenuButton>("font_btn")->setMenu(context_menu, LLMenuButton::MP_BOTTOM_LEFT, true);
+
return TRUE;
}
@@ -788,7 +830,7 @@ void LLScriptEdCore::setHelpPage(const std::string& help_string)
LLUIString url_string = gSavedSettings.getString("LSLHelpURL");
- url_string.setArg("[LSL_STRING]", help_string);
+ url_string.setArg("[LSL_STRING]", help_string.empty() ? HELP_LSL_PORTAL_TOPIC : help_string);
addHelpItemToHistory(help_string);
@@ -1288,7 +1330,21 @@ LLUUID LLScriptEdCore::getAssociatedExperience()const
return mAssociatedExperience;
}
-void LLLiveLSLEditor::setExperienceIds( const LLSD& experience_ids )
+void LLScriptEdCore::onChangeFontSize(const LLSD &userdata)
+{
+ const std::string font_name = userdata.asString();
+ gSavedSettings.setString("LSLFontSizeName", font_name);
+}
+
+bool LLScriptEdCore::isFontSizeChecked(const LLSD &userdata)
+{
+ const std::string current_size_name = LLScriptEditor::getScriptFontSize();
+ const std::string size_name = userdata.asString();
+
+ return (size_name == current_size_name);
+}
+
+ void LLLiveLSLEditor::setExperienceIds( const LLSD& experience_ids )
{
mExperienceIds=experience_ids;
updateExperiencePanel();
@@ -1476,7 +1532,21 @@ bool LLScriptEdContainer::onExternalChange(const std::string& filename)
return true;
}
-/// ---------------------------------------------------------------------------
+BOOL LLScriptEdContainer::handleKeyHere(KEY key, MASK mask)
+{
+ if (('A' == key) && (MASK_CONTROL == (mask & MASK_MODIFIERS)))
+ {
+ mScriptEd->selectAll();
+ return TRUE;
+ }
+
+ if (!LLPreview::handleKeyHere(key, mask))
+ {
+ return mScriptEd->handleKeyHere(key, mask);
+ }
+ return TRUE;
+}
+ /// ---------------------------------------------------------------------------
/// LLPreviewLSL
/// ---------------------------------------------------------------------------
@@ -1517,6 +1587,14 @@ LLPreviewLSL::LLPreviewLSL(const LLSD& key )
mPendingUploads(0)
{
mFactoryMap["script panel"] = LLCallbackMap(LLPreviewLSL::createScriptEdPanel, this);
+
+ mItemObserver = new LLScriptMovedObserver(this);
+}
+
+LLPreviewLSL::~LLPreviewLSL()
+{
+ delete mItemObserver;
+ mItemObserver = NULL;
}
// virtual
@@ -1528,10 +1606,14 @@ BOOL LLPreviewLSL::postBuild()
if (item)
{
getChild<LLUICtrl>("desc")->setValue(item->getDescription());
+
+ std::string item_path = get_category_path(item->getParentUUID());
+ getChild<LLUICtrl>("path_txt")->setValue(item_path);
+ getChild<LLUICtrl>("path_txt")->setToolTip(item_path);
}
childSetCommitCallback("desc", LLPreview::onText, this);
getChild<LLLineEditor>("desc")->setPrevalidate(&LLTextValidate::validateASCIIPrintableNoPipe);
-
+
return LLPreview::postBuild();
}
@@ -1543,7 +1625,12 @@ void LLPreviewLSL::draw()
setTitle(LLTrans::getString("ScriptWasDeleted"));
mScriptEd->setItemRemoved(TRUE);
}
-
+ else if (mDirty)
+ {
+ std::string item_path = get_category_path(item->getParentUUID());
+ getChild<LLUICtrl>("path_txt")->setValue(item_path);
+ getChild<LLUICtrl>("path_txt")->setToolTip(item_path);
+ }
LLPreview::draw();
}
// virtual
@@ -1829,7 +1916,8 @@ LLLiveLSLEditor::LLLiveLSLEditor(const LLSD& key) :
mPendingUploads(0),
mIsModifiable(FALSE),
mIsNew(false),
- mIsSaving(FALSE)
+ mIsSaving(FALSE),
+ mObjectName("")
{
mFactoryMap["script ed panel"] = LLCallbackMap(LLLiveLSLEditor::createScriptEdPanel, this);
}
@@ -1966,6 +2054,7 @@ void LLLiveLSLEditor::loadAsset()
}
refreshFromItem();
+ getChild<LLUICtrl>("obj_name")->setValue(mObjectName);
// This is commented out, because we don't completely
// handle script exports yet.
/*