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.cpp105
1 files changed, 98 insertions, 7 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 968a912ea2..f39a5ffd62 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -86,6 +86,7 @@
#include "lltrans.h"
#include "llviewercontrol.h"
#include "llappviewer.h"
+#include "llexperiencecache.h"
const std::string HELLO_LSL =
"default\n"
@@ -374,12 +375,21 @@ LLScriptEdCore::~LLScriptEdCore()
delete mLiveFile;
}
+void LLScriptEdCore::experienceChanged()
+{
+ enableSave(TRUE);
+ getChildView("Save_btn")->setEnabled(true);
+}
+
BOOL LLScriptEdCore::postBuild()
{
mErrorList = getChild<LLScrollListCtrl>("lsl errors");
mFunctions = getChild<LLComboBox>( "Insert...");
+ mExperiences = getChild<LLComboBox>("Experiences...");
+ mExperiences->setCommitCallback(boost::bind(&LLScriptEdCore::experienceChanged, this));
+
childSetCommitCallback("Insert...", &LLScriptEdCore::onBtnInsertFunction, this);
mEditor = getChild<LLViewerTextEditor>("Script Editor");
@@ -389,6 +399,10 @@ BOOL LLScriptEdCore::postBuild()
childSetAction("Edit_btn", boost::bind(&LLScriptEdCore::openInExternalEditor, this));
initMenu();
+
+
+
+ requestExperiences();
std::vector<std::string> funcs;
@@ -1191,6 +1205,86 @@ bool LLScriptEdCore::enableLoadFromFileMenu(void* userdata)
return (self && self->mEditor) ? self->mEditor->canLoadOrSaveToFile() : FALSE;
}
+
+void AddExperienceResult(LLHandle<LLScriptEdCore> panel, const LLSD& experience)
+{
+ LLScriptEdCore* scriptCore = panel.get();
+ if(scriptCore)
+ {
+ scriptCore->addExperienceInfo(experience);
+ }
+}
+
+
+class ExperienceResponder : public LLHTTPClient::Responder
+{
+public:
+ ExperienceResponder(const LLHandle<LLScriptEdCore>& parent):mParent(parent)
+ {
+ }
+
+ LLHandle<LLScriptEdCore> mParent;
+
+ virtual void result(const LLSD& content)
+ {
+ LLScriptEdCore* scriptCore = mParent.get();
+ if(!scriptCore)
+ return;
+
+ scriptCore->clearExperiences();
+
+ LLSD experiences = content["experience_ids"];
+ LLSD::array_const_iterator it = experiences.beginArray();
+ for( /**/ ; it != experiences.endArray(); ++it)
+ {
+ LLUUID public_key = it->asUUID();
+
+ LLExperienceCache::get(public_key, boost::bind(AddExperienceResult, mParent, _1));
+ }
+ }
+};
+
+void LLScriptEdCore::requestExperiences()
+{
+ mExperiences->setEnabled(FALSE);
+
+ LLViewerRegion* region = gAgent.getRegion();
+ if (region)
+ {
+ std::string lookup_url=region->getCapability("GetCreatorExperiences");
+ if(!lookup_url.empty())
+ {
+ LLHTTPClient::get(lookup_url, new ExperienceResponder(getDerivedHandle<LLScriptEdCore>()));
+ }
+ }
+}
+
+void LLScriptEdCore::addExperienceInfo( const LLSD& experience )
+{
+ mExperiences->setEnabled(TRUE);
+ mExperiences->add(experience[LLExperienceCache::NAME], experience);
+}
+
+void LLScriptEdCore::clearExperiences()
+{
+ mExperiences->removeall();
+ mExperiences->add("No Experience");
+}
+
+LLUUID LLScriptEdCore::getSelectedExperience()const
+{
+ LLSD value = mExperiences->getSelectedValue();
+ if(value.has(LLExperienceCache::EXPERIENCE_ID))
+ {
+ return value[LLExperienceCache::EXPERIENCE_ID].asUUID();
+ }
+ return LLUUID::null;
+}
+
+
+
+
+
/// ---------------------------------------------------------------------------
/// LLScriptEdContainer
/// ---------------------------------------------------------------------------
@@ -2146,8 +2240,8 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
mPendingUploads++;
BOOL is_running = getChild<LLCheckBoxCtrl>( "running")->get();
if (!url.empty())
- {
- uploadAssetViaCaps(url, filename, mObjectUUID, mItemUUID, is_running);
+ {
+ uploadAssetViaCaps(url, filename, mObjectUUID, mItemUUID, is_running, mScriptEd->getSelectedExperience());
}
else if (gAssetStorage)
{
@@ -2155,11 +2249,7 @@ void LLLiveLSLEditor::saveIfNeeded(bool sync /*= true*/)
}
}
-void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url,
- const std::string& filename,
- const LLUUID& task_id,
- const LLUUID& item_id,
- BOOL is_running)
+void LLLiveLSLEditor::uploadAssetViaCaps( const std::string& url, const std::string& filename, const LLUUID& task_id, const LLUUID& item_id, BOOL is_running, const LLUUID& experience_public_id )
{
llinfos << "Update Task Inventory via capability " << url << llendl;
LLSD body;
@@ -2167,6 +2257,7 @@ void LLLiveLSLEditor::uploadAssetViaCaps(const std::string& url,
body["item_id"] = item_id;
body["is_script_running"] = is_running;
body["target"] = monoChecked() ? "mono" : "lsl2";
+ body["experience"] = experience_public_id;
LLHTTPClient::post(url, body,
new LLUpdateTaskInventoryResponder(body, filename, LLAssetType::AT_LSL_TEXT));
}