diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llexperienceassociationresponder.cpp | 43 | ||||
-rw-r--r-- | indra/newview/llexperienceassociationresponder.h | 7 | ||||
-rwxr-xr-x | indra/newview/llpreviewscript.cpp | 28 | ||||
-rwxr-xr-x | indra/newview/llpreviewscript.h | 4 | ||||
-rwxr-xr-x | indra/newview/llsidepaneliteminfo.cpp | 35 | ||||
-rwxr-xr-x | indra/newview/llsidepaneliteminfo.h | 2 | ||||
-rwxr-xr-x | indra/newview/skins/default/xui/en/sidepanel_item_info.xml | 14 |
7 files changed, 85 insertions, 48 deletions
diff --git a/indra/newview/llexperienceassociationresponder.cpp b/indra/newview/llexperienceassociationresponder.cpp index 69451bc054..33ada4906d 100644 --- a/indra/newview/llexperienceassociationresponder.cpp +++ b/indra/newview/llexperienceassociationresponder.cpp @@ -1,6 +1,8 @@ /** * @file llexperienceassociationresponder.cpp - * @brief llexperienceassociationresponder implementation + * @brief llexperienceassociationresponder implementation. This class combines + * a lookup for a script association and an experience details request. The first + * is always async, but the second may be cached locally. * * $LicenseInfo:firstyear=2013&license=viewerlgpl$ * Second Life Viewer Source Code @@ -27,12 +29,38 @@ #include "llviewerprecompiledheaders.h" #include "llexperienceassociationresponder.h" #include "llexperiencecache.h" +#include "llviewerregion.h" +#include "llagent.h" ExperienceAssociationResponder::ExperienceAssociationResponder(ExperienceAssociationResponder::callback_t callback):mCallback(callback) { ref(); } +void ExperienceAssociationResponder::fetchAssociatedExperience( const LLUUID& object_id, const LLUUID& item_id, callback_t callback ) +{ + LLSD request; + request["object-id"]=object_id; + request["item-id"]=item_id; + fetchAssociatedExperience(request, callback); +} + +void ExperienceAssociationResponder::fetchAssociatedExperience(LLSD& request, callback_t callback) +{ + LLViewerRegion* region = gAgent.getRegion(); + if (region) + { + std::string lookup_url=region->getCapability("GetMetadata"); + if(!lookup_url.empty()) + { + LLSD fields; + fields.append("experience"); + request["fields"] = fields; + LLHTTPClient::post(lookup_url, request, new ExperienceAssociationResponder(callback)); + } + } +} + void ExperienceAssociationResponder::error( U32 status, const std::string& reason ) { LLSD msg; @@ -52,22 +80,11 @@ void ExperienceAssociationResponder::result( const LLSD& content ) msg["message"]="no experience"; msg["error"]=-1; sendResult(msg); - LL_ERRS("ExperienceAssociation") << "Associated experience missing" << LL_ENDL; + return; } LLExperienceCache::get(content["experience"].asUUID(), boost::bind(&ExperienceAssociationResponder::sendResult, this, _1)); - /* LLLiveLSLEditor* scriptCore = LLFloaterReg::findTypedInstance<LLLiveLSLEditor>("preview_scriptedit", mParent); - - if(!scriptCore) - return; - - LLUUID id; - if(content.has("experience")) - { - id=content["experience"].asUUID(); - } - scriptCore->setAssociatedExperience(id);*/ } void ExperienceAssociationResponder::sendResult( const LLSD& experience ) diff --git a/indra/newview/llexperienceassociationresponder.h b/indra/newview/llexperienceassociationresponder.h index aa0c51abb5..8ff62a3dbc 100644 --- a/indra/newview/llexperienceassociationresponder.h +++ b/indra/newview/llexperienceassociationresponder.h @@ -40,10 +40,15 @@ public: typedef boost::function<void(const LLSD& experience)> callback_t; ExperienceAssociationResponder(callback_t callback); + virtual void result(const LLSD& content); virtual void error(U32 status, const std::string& reason); -private: + static void fetchAssociatedExperience(const LLUUID& object_it, const LLUUID& item_id, callback_t callback); + +private: + static void fetchAssociatedExperience(LLSD& request, callback_t callback); + void sendResult(const LLSD& experience); callback_t mCallback; diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp index 09152ac060..f5a6ec3dd3 100755 --- a/indra/newview/llpreviewscript.cpp +++ b/indra/newview/llpreviewscript.cpp @@ -1966,8 +1966,8 @@ void LLLiveLSLEditor::loadAsset() || gAgent.isGodlike())) { mItem = new LLViewerInventoryItem(item); - //llinfos << "asset id " << mItem->getAssetUUID() << llendl; } + ExperienceAssociationResponder::fetchAssociatedExperience(item->getParentUUID(), item->getUUID(), boost::bind(&LLLiveLSLEditor::setAssociatedExperience, getDerivedHandle<LLLiveLSLEditor>(), _1)); if(!gAgent.isGodlike() && (item @@ -2069,9 +2069,6 @@ void LLLiveLSLEditor::onLoadComplete(LLVFS *vfs, const LLUUID& asset_id, if(instance ) { - instance->fetchAssociatedExperience(asset_id); - - if( LL_ERR_NOERR == status ) { instance->loadScriptText(vfs, asset_id, type); @@ -2518,29 +2515,6 @@ 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; - - ExperienceAssociationResponder::callback_t f = boost::bind(&LLLiveLSLEditor::setAssociatedExperience, getDerivedHandle<LLLiveLSLEditor>(), _1); - LLHTTPClient::post(lookup_url, request, new ExperienceAssociationResponder(f)); - - //test me pls - } - } -} - - BOOL LLLiveLSLEditor::canClose() { return (mScriptEd->canClose()); diff --git a/indra/newview/llpreviewscript.h b/indra/newview/llpreviewscript.h index bd594cdb9d..faeb4a5b8a 100755 --- a/indra/newview/llpreviewscript.h +++ b/indra/newview/llpreviewscript.h @@ -234,9 +234,7 @@ public: static void setAssociatedExperience( LLHandle<LLLiveLSLEditor> editor, const LLSD& experience ); static void onToggleExperience(LLUICtrl *ui, void* userdata); - - void fetchAssociatedExperience(const LLUUID& asset_id); - + void addExperienceInfo( const LLSD& experience, BOOL enabled ); void setExperienceIds(const LLSD& experience_ids); void buildExperienceList(); diff --git a/indra/newview/llsidepaneliteminfo.cpp b/indra/newview/llsidepaneliteminfo.cpp index 92c2863ffd..040c4ee72d 100755 --- a/indra/newview/llsidepaneliteminfo.cpp +++ b/indra/newview/llsidepaneliteminfo.cpp @@ -43,6 +43,8 @@ #include "llviewercontrol.h" #include "llviewerinventory.h" #include "llviewerobjectlist.h" +#include "llexperiencecache.h" +#include "llexperienceassociationresponder.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -316,6 +318,15 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) is_obj_modify = object->permOwnerModify(); } + if(item->getInventoryType() == LLInventoryType::IT_LSL) + { + getChildView("LabelItemExperienceTitle")->setVisible(TRUE); + LLTextBox* tb = getChild<LLTextBox>("LabelItemExperience"); + tb->setText(getString("loading_experience")); + tb->setVisible(TRUE); + ExperienceAssociationResponder::fetchAssociatedExperience(item->getParentUUID(), item->getUUID(), boost::bind(&LLSidepanelItemInfo::setAssociatedExperience, getDerivedHandle<LLSidepanelItemInfo>(), _1)); + } + ////////////////////// // ITEM NAME & DESC // ////////////////////// @@ -666,6 +677,30 @@ void LLSidepanelItemInfo::refreshFromItem(LLViewerInventoryItem* item) } } + +void LLSidepanelItemInfo::setAssociatedExperience( LLHandle<LLSidepanelItemInfo> hInfo, const LLSD& experience ) +{ + LLSidepanelItemInfo* info = hInfo.get(); + if(info) + { + LLUUID id; + if(experience.has(LLExperienceCache::EXPERIENCE_ID) && experience.has(LLExperienceCache::NAME)) + { + id=experience[LLExperienceCache::EXPERIENCE_ID].asUUID(); + } + LLTextBox* xpName = info->getChild<LLTextBox>("LabelItemExperience"); + if(id.isNull()) + { + xpName->setText(info->getString("no_experience")); + } + else + { + xpName->setText(experience[LLExperienceCache::NAME].asString()); + } + } +} + + void LLSidepanelItemInfo::startObjectInventoryObserver() { if (!mObjectInventoryObserver) diff --git a/indra/newview/llsidepaneliteminfo.h b/indra/newview/llsidepaneliteminfo.h index 12aaca923e..2e24e58a2a 100755 --- a/indra/newview/llsidepaneliteminfo.h +++ b/indra/newview/llsidepaneliteminfo.h @@ -67,6 +67,8 @@ protected: void refreshFromItem(LLViewerInventoryItem* item); private: + static void setAssociatedExperience( LLHandle<LLSidepanelItemInfo> hInfo, const LLSD& experience ); + void startObjectInventoryObserver(); void stopObjectInventoryObserver(); diff --git a/indra/newview/skins/default/xui/en/sidepanel_item_info.xml b/indra/newview/skins/default/xui/en/sidepanel_item_info.xml index c9c19f6d57..f1f8843a9d 100755 --- a/indra/newview/skins/default/xui/en/sidepanel_item_info.xml +++ b/indra/newview/skins/default/xui/en/sidepanel_item_info.xml @@ -12,6 +12,10 @@ (none) </panel.string> <panel.string + name="loading_experience"> + (loading) + </panel.string> + <panel.string name="unknown"> (unknown) </panel.string> @@ -434,7 +438,8 @@ left="5" name="LabelItemExperienceTitle" top_pad="10" - width="78"> + width="78" + visible="false"> Experience: </text> <text @@ -446,10 +451,11 @@ left_delta="78" name="LabelItemExperience" top_delta="0" - width="210" - >(loading)</text> + width="210" + visible="false" + ></text> </panel> - + </scroll_container> <panel height="30" |