summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authordolphin <dolphin@lindenlab.com>2013-01-29 13:58:13 -0800
committerdolphin <dolphin@lindenlab.com>2013-01-29 13:58:13 -0800
commit596522c7e5a9bff53a56db90597c7bcbcdbf1537 (patch)
treed478670d9cfe29a000de6a56cbc7dbc8ba312e28 /indra/newview
parent3e8bc28c88f16c1b8bba496704ec3a6156a25e1d (diff)
Added a combox to the script editor to select an experience.
Selected experience is sent with the script when saved. The list of experiences is currently populated with the avatar's current experience, if any.
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llpreviewscript.cpp105
-rw-r--r--indra/newview/llpreviewscript.h13
-rw-r--r--indra/newview/skins/default/xui/en/panel_script_ed.xml9
3 files changed, 115 insertions, 12 deletions
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index 9c25e69db0..98abd2c9dd 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"
@@ -370,12 +371,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");
@@ -385,6 +395,10 @@ BOOL LLScriptEdCore::postBuild()
childSetAction("Edit_btn", boost::bind(&LLScriptEdCore::openInExternalEditor, this));
initMenu();
+
+
+
+ requestExperiences();
std::vector<std::string> funcs;
@@ -1187,6 +1201,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["experiences"];
+ LLSD::array_const_iterator it = experiences.beginArray();
+ for( /**/ ; it != experiences.endArray(); ++it)
+ {
+ LLUUID public_key = it->asUUID();
+
+ LLExperienceCache::get(public_key, LLExperienceCache::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("GetExperiences");
+ 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::PUBLIC_KEY))
+ {
+ return value[LLExperienceCache::PUBLIC_KEY].asUUID();
+ }
+ return LLUUID::null;
+}
+
+
+
+
+
/// ---------------------------------------------------------------------------
/// LLScriptEdContainer
/// ---------------------------------------------------------------------------
@@ -2142,8 +2236,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)
{
@@ -2151,11 +2245,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;
@@ -2163,6 +2253,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));
}
diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h
index 7563cecd9d..27252d17a1 100644
--- a/indra/newview/llpreviewscript.h
+++ b/indra/newview/llpreviewscript.h
@@ -106,6 +106,9 @@ public:
static bool enableLoadFromFileMenu(void* userdata);
virtual bool hasAccelerators() const { return true; }
+ void addExperienceInfo( const LLSD& experience );
+ void clearExperiences();
+ LLUUID getSelectedExperience()const;
private:
void onBtnHelp();
@@ -120,6 +123,9 @@ private:
void enableSave(BOOL b) {mEnableSave = b;}
+ void requestExperiences();
+ void experienceChanged();
+
protected:
void deleteBridges();
void setHelpPage(const std::string& help_string);
@@ -135,6 +141,7 @@ private:
void (*mSearchReplaceCallback) (void* userdata);
void* mUserdata;
LLComboBox *mFunctions;
+ LLComboBox *mExperiences;
BOOL mForceClose;
LLPanel* mCodePanel;
LLScrollListCtrl* mErrorList;
@@ -237,11 +244,7 @@ private:
virtual void loadAsset();
void loadAsset(BOOL is_new);
/*virtual*/ void saveIfNeeded(bool sync = true);
- void uploadAssetViaCaps(const std::string& url,
- const std::string& filename,
- const LLUUID& task_id,
- const LLUUID& item_id,
- BOOL is_running);
+ void 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);
void uploadAssetLegacy(const std::string& filename,
LLViewerObject* object,
const LLTransactionID& tid,
diff --git a/indra/newview/skins/default/xui/en/panel_script_ed.xml b/indra/newview/skins/default/xui/en/panel_script_ed.xml
index 765b07ed8b..7e4ac1d7fb 100644
--- a/indra/newview/skins/default/xui/en/panel_script_ed.xml
+++ b/indra/newview/skins/default/xui/en/panel_script_ed.xml
@@ -204,4 +204,13 @@
right="400"
name="Edit_btn"
width="81" />
+ <combo_box
+ follows="right|bottom"
+ height="23"
+ label="Experience..."
+ layout="topleft"
+ name="Experiences..."
+ width="196"
+ right="487"
+ top_pad="5" />
</panel>