summaryrefslogtreecommitdiff
path: root/indra/newview/llpreviewscript.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llpreviewscript.cpp')
-rwxr-xr-xindra/newview/llpreviewscript.cpp179
1 files changed, 170 insertions, 9 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 968a912ea2..bba0f1330c 100755
--- 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,125 @@ 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));
+ }
+ }
+};
+
+class ExperienceAssociationResponder : public LLHTTPClient::Responder
+{
+public:
+ ExperienceAssociationResponder(const LLUUID& parent):mParent(parent)
+ {
+ }
+
+ LLUUID mParent;
+
+ virtual void result(const LLSD& content)
+ {
+
+ LLLiveLSLEditor* scriptCore = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", mParent);
+
+ if(!scriptCore || !content.has("experience"))
+ return;
+
+ scriptCore->setAssociatedExperience(content["experience"].asUUID());
+ }
+
+ virtual void error(U32 status, const std::string& reason)
+ {
+ llinfos << "Failed to look up associated script: " << status << ": " << reason << llendl;
+ }
+
+};
+
+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[LLExperienceCache::EXPERIENCE_ID].asUUID());
+ if(mAssociatedExperience == experience[LLExperienceCache::EXPERIENCE_ID].asUUID())
+ {
+ setAssociatedExperience(mAssociatedExperience);
+ }
+}
+
+void LLScriptEdCore::clearExperiences()
+{
+ mExperiences->removeall();
+ mExperiences->add("No Experience", LLUUID::null);
+}
+
+LLUUID LLScriptEdCore::getSelectedExperience()const
+{
+ return mExperiences->getSelectedValue().asUUID();
+}
+
+void LLScriptEdCore::setAssociatedExperience( const LLUUID& experience_id )
+{
+ mAssociatedExperience = experience_id;
+ if(experience_id.notNull())
+ {
+ if(!mExperiences->setSelectedByValue(mAssociatedExperience, TRUE))
+ {
+ mExperiences->setSelectedByValue(LLUUID::null, TRUE);
+ }
+ }
+}
+
+
+
+
+
+
/// ---------------------------------------------------------------------------
/// LLScriptEdContainer
/// ---------------------------------------------------------------------------
@@ -1860,7 +1993,7 @@ void LLLiveLSLEditor::loadAsset()
LLHost host(object->getRegion()->getIP(),
object->getRegion()->getPort());
gMessageSystem->sendReliable(host);
- */
+ */
}
}
else
@@ -1893,11 +2026,15 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id,
lldebugs << "LLLiveLSLEditor::onLoadComplete: got uuid " << asset_id
<< llendl;
LLUUID* xored_id = (LLUUID*)user_data;
-
+
+
LLLiveLSLEditor* instance = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", *xored_id);
if(instance )
{
+ instance->fetchAssociatedExperience(asset_id);
+
+
if( LL_ERR_NOERR == status )
{
instance->loadScriptText(vfs, asset_id, type);
@@ -2146,8 +2283,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 +2292,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 +2300,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));
}
@@ -2347,6 +2481,25 @@ void LLLiveLSLEditor::onSaveBytecodeComplete(const LLUUID& asset_uuid, void* use
delete data;
}
+void LLLiveLSLEditor::fetchAssociatedExperience(const LLUUID& asset_id)
+{
+ LLViewerRegion* region = gAgent.getRegion();
+ if (region)
+ {
+ std::string lookup_url=region->getCapability("GetMetadata");
+ if(!lookup_url.empty())
+ {
+ LLSD request;
+ request["asset-id"]=asset_id;
+ LLSD fields;
+ fields.append("experience");
+ request["fields"] = fields;
+ LLHTTPClient::post(lookup_url, request, new ExperienceAssociationResponder(getKey()));
+ }
+ }
+}
+
+
BOOL LLLiveLSLEditor::canClose()
{
return (mScriptEd->canClose());
@@ -2418,3 +2571,11 @@ BOOL LLLiveLSLEditor::monoChecked() const
}
return FALSE;
}
+
+void LLLiveLSLEditor::setAssociatedExperience( const LLUUID& experience_id )
+{
+ if(mScriptEd)
+ {
+ mScriptEd->setAssociatedExperience(experience_id);
+ }
+}