From 95523616b89dadd697eb6cfa3a466feadc1e1208 Mon Sep 17 00:00:00 2001 From: dolphin Date: Wed, 26 Feb 2014 13:55:32 -0800 Subject: Updated purchase UI for experiences. --- indra/newview/llfloaterregioninfo.cpp | 58 +++++++++++++++++++++- indra/newview/llfloaterregioninfo.h | 7 ++- indra/newview/llviewerregion.cpp | 1 + .../default/xui/en/panel_region_experiences.xml | 39 +++++++++++++-- 4 files changed, 99 insertions(+), 6 deletions(-) diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index b7f66a2c0b..43f0ba10a1 100755 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -96,6 +96,7 @@ #include #include "llfloaterexperiencepicker.h" #include "llexperiencecache.h" +#include "llpanelexperiences.h" const S32 TERRAIN_TEXTURE_COUNT = 4; const S32 CORNER_COUNT = 4; @@ -3482,13 +3483,20 @@ BOOL LLPanelRegionExperiences::postBuild() mAllowed = setupList("panel_allowed"); mTrusted = setupList("panel_trusted"); mBlocked = setupList("panel_blocked"); + mOwned = LLPanelExperiences::create("owned"); + LLPanel* pOwned = findChild("panel_owned"); + pOwned->addChild(mOwned); + mOwned->setShape(pOwned->getRect()); return LLPanelRegionInfo::postBuild(); } LLPanelExperienceListEditor* LLPanelRegionExperiences::setupList( const char* control_name ) { LLPanelExperienceListEditor* child = findChild(control_name); - child->getChild("text_name")->setText(getString(control_name)); + if(child) + { + child->getChild("text_name")->setText(getString(control_name)); + } return child; } @@ -3552,6 +3560,23 @@ void LLPanelRegionExperiences::infoCallback(LLHandle h { floater->processResponse(content); } + +} + + +void LLPanelRegionExperiences::ownedCallback( LLHandle handle, const LLSD& content ) +{ + if(handle.isDead()) + return; + + LLPanelRegionExperiences* floater = handle.get(); + if (floater && content.has("experience_ids")) + { + const LLSD& ids = content["experience_ids"]; + floater->getChild("btn_buy")->setEnabled(ids.beginArray() == ids.endArray()); + + floater->setOwnedExperiences(content["experience_ids"]); + } } @@ -3587,7 +3612,18 @@ bool LLPanelRegionExperiences::refreshFromRegion(LLViewerRegion* region) mTrusted->setReadonly(!allow_modify); mTrusted->addFilter(boost::bind(&LLPanelRegionExperiences::FilterExisting, this, _1)); - std::string url = region->getCapability("RegionExperiences"); + std::string url = region->getCapability("AgentExperiences"); + mOwned->getParent()->setVisible(!url.empty() && region && region->canManageEstate()); + + if(!url.empty()) + { + LLHTTPClient::get(url, new LLRegionExperienceResponder(boost::bind(&LLPanelRegionExperiences::ownedCallback, + getDerivedHandle(), _1))); + + getChild("btn_buy")->setCommitCallback(boost::bind(&LLPanelRegionExperiences::sendPurchaseRequest, this)); + } + + url = region->getCapability("RegionExperiences"); if (!url.empty()) { LLHTTPClient::get(url, new LLRegionExperienceResponder(boost::bind(&LLPanelRegionExperiences::infoCallback, @@ -3631,3 +3667,21 @@ void LLPanelRegionExperiences::listChanged() { onChangeAnything(); } + +void LLPanelRegionExperiences::setOwnedExperiences( const LLSD& experiences ) +{ + mOwned->setExperienceList(experiences); +} + +void LLPanelRegionExperiences::sendPurchaseRequest() const +{ + LLViewerRegion* region = gAgent.getRegion(); + std::string url = region->getCapability("AgentExperiences"); + if(!url.empty()) + { + LLSD content; + + LLHTTPClient::post(url, content, new LLRegionExperienceResponder(boost::bind(&LLPanelRegionExperiences::ownedCallback, + getDerivedHandle(), _1))); + } +} diff --git a/indra/newview/llfloaterregioninfo.h b/indra/newview/llfloaterregioninfo.h index ccd42f9764..066a5c5da9 100755 --- a/indra/newview/llfloaterregioninfo.h +++ b/indra/newview/llfloaterregioninfo.h @@ -61,6 +61,7 @@ class LLPanelRegionTerrainInfo; class LLPanelEstateInfo; class LLPanelEstateCovenant; class LLPanelExperienceListEditor; +class LLPanelExperiences; class LLEventTimer; class LLEnvironmentSettings; @@ -461,10 +462,12 @@ public: virtual BOOL sendUpdate(); static void infoCallback(LLHandle handle, const LLSD& content); - void listChanged(); bool refreshFromRegion(LLViewerRegion* region); + void sendPurchaseRequest()const; private: + static void ownedCallback(LLHandle handle, const LLSD& content); + void setOwnedExperiences(const LLSD& experiences); void processResponse( const LLSD& content ); boost::signals2::connection processResponse( LLPanelExperienceListEditor* panel, boost::signals2::connection& connection, const LLSD& content); void refreshRegionExperiences(); @@ -473,6 +476,8 @@ private: static LLSD addIds( LLPanelExperienceListEditor* panel ); bool FilterExisting(const LLSD& experience ); + + LLPanelExperiences* mOwned; LLPanelExperienceListEditor* mTrusted; boost::signals2::connection mTrustedConnection; LLPanelExperienceListEditor* mAllowed; diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index 454f83f713..28fa93c442 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -1601,6 +1601,7 @@ void LLViewerRegionImpl::buildCapabilityNames(LLSD& capabilityNames) capabilityNames.append("GetDisplayNames"); capabilityNames.append("GetExperiences"); + capabilityNames.append("AgentExperiences"); capabilityNames.append("FindExperienceByName"); capabilityNames.append("GetExperienceInfo"); capabilityNames.append("GetAdminExperiences"); diff --git a/indra/newview/skins/default/xui/en/panel_region_experiences.xml b/indra/newview/skins/default/xui/en/panel_region_experiences.xml index f4d38c0e08..ee908348a3 100644 --- a/indra/newview/skins/default/xui/en/panel_region_experiences.xml +++ b/indra/newview/skins/default/xui/en/panel_region_experiences.xml @@ -1,7 +1,7 @@ + + +