summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterexperiences.cpp
diff options
context:
space:
mode:
authordolphin <dolphin@lindenlab.com>2013-10-03 12:59:44 -0700
committerdolphin <dolphin@lindenlab.com>2013-10-03 12:59:44 -0700
commite510fa3ee064ce03a48852fdea26be781e8fa8b6 (patch)
tree82b418df40a937cc8668380d2c80edf4501009f2 /indra/newview/llfloaterexperiences.cpp
parentaed3cbce26a9e1e7ec70a43146fd405f3162f9d7 (diff)
First pass at functional experience list floater
Diffstat (limited to 'indra/newview/llfloaterexperiences.cpp')
-rw-r--r--indra/newview/llfloaterexperiences.cpp126
1 files changed, 126 insertions, 0 deletions
diff --git a/indra/newview/llfloaterexperiences.cpp b/indra/newview/llfloaterexperiences.cpp
index b862b41bba..398ced2632 100644
--- a/indra/newview/llfloaterexperiences.cpp
+++ b/indra/newview/llfloaterexperiences.cpp
@@ -2,13 +2,139 @@
#include "llpanelexperiences.h"
#include "llfloaterexperiences.h"
+#include "llagent.h"
+#include "llfloaterregioninfo.h"
+#include "lltabcontainer.h"
+#include "lltrans.h"
+#include "llexperiencecache.h"
+
+
+class LLExperienceListResponder : public LLHTTPClient::Responder
+{
+public:
+ typedef std::map<std::string, std::string> NameMap;
+ LLExperienceListResponder(const LLHandle<LLFloaterExperiences>& parent, NameMap& nameMap):mParent(parent)
+ {
+ mNameMap.swap(nameMap);
+ }
+
+ LLHandle<LLFloaterExperiences> mParent;
+ NameMap mNameMap;
+
+ virtual void result(const LLSD& content)
+ {
+ if(mParent.isDead())
+ return;
+
+ LLFloaterExperiences* parent=mParent.get();
+
+ LLTabContainer* tabs = parent->getChild<LLTabContainer>("xp_tabs");
+
+ NameMap::iterator it = mNameMap.begin();
+ while(it != mNameMap.end())
+ {
+ if(content.has(it->first))
+ {
+ LLPanelExperiences* tab = (LLPanelExperiences*)tabs->getPanelByName(it->second);
+ if(tab)
+ {
+ const LLSD& ids = content[it->first];
+ tab->setExperienceList(ids);
+ parent->clearFromRecent(ids);
+ }
+ }
+ ++it;
+ }
+ }
+};
+
+
LLFloaterExperiences::LLFloaterExperiences(const LLSD& data)
:LLFloater(data)
{
}
+void LLFloaterExperiences::addTab(const std::string& name, bool select)
+{
+ getChild<LLTabContainer>("xp_tabs")->addTabPanel(LLTabContainer::TabPanelParams().
+ panel(LLPanelExperiences::create(name)).
+ label(LLTrans::getString(name)).
+ select_tab(select));
+}
+
BOOL LLFloaterExperiences::postBuild()
{
+ addTab("Allowed_Experiences_Tab", true);
+ addTab("Blocked_Experiences_Tab", false);
+ addTab("Admin_Experiences_Tab", false);
+ addTab("Contrib_Experiences_Tab", false);
+ addTab("Recent_Experiences_Tab", false);
+
+ setupRecentTabs();
+
+ LLViewerRegion* region = gAgent.getRegion();
+
+ if (region)
+ {
+ LLExperienceListResponder::NameMap nameMap;
+ std::string lookup_url=region->getCapability("GetExperiences");
+ if(!lookup_url.empty())
+ {
+ nameMap["experiences"]="Allowed_Experiences_Tab";
+ nameMap["blocked"]="Blocked_Experiences_Tab";
+ LLHTTPClient::get(lookup_url, new LLExperienceListResponder(getDerivedHandle<LLFloaterExperiences>(), nameMap));
+ }
+
+ lookup_url = region->getCapability("GetAdminExperiences");
+ if(!lookup_url.empty())
+ {
+ nameMap["experience_ids"]="Admin_Experiences_Tab";
+ LLHTTPClient::get(lookup_url, new LLExperienceListResponder(getDerivedHandle<LLFloaterExperiences>(), nameMap));
+ }
+
+ lookup_url = region->getCapability("GetAdminExperiences");
+ if(!lookup_url.empty())
+ {
+ nameMap["experience_ids"]="Contrib_Experiences_Tab";
+ LLHTTPClient::get(lookup_url, new LLExperienceListResponder(getDerivedHandle<LLFloaterExperiences>(), nameMap));
+ }
+ }
return TRUE;
}
+
+void LLFloaterExperiences::clearFromRecent(const LLSD& ids)
+{
+ LLTabContainer* tabs = getChild<LLTabContainer>("xp_tabs");
+
+ LLPanelExperiences* tab = (LLPanelExperiences*)tabs->getPanelByName("Recent_Experiences_Tab");
+ if(!tab)
+ return;
+
+ tab->removeExperiences(ids);
+}
+
+void LLFloaterExperiences::setupRecentTabs()
+{
+ LLTabContainer* tabs = getChild<LLTabContainer>("xp_tabs");
+
+ LLPanelExperiences* tab = (LLPanelExperiences*)tabs->getPanelByName("Recent_Experiences_Tab");
+ if(!tab)
+ return;
+
+ LLSD recent;
+
+ const LLExperienceCache::cache_t& experiences = LLExperienceCache::getCached();
+
+ LLExperienceCache::cache_t::const_iterator it = experiences.begin();
+ while( it != experiences.end() )
+ {
+ if(!it->second.has(LLExperienceCache::MISSING))
+ {
+ recent.append(it->first);
+ }
+ ++it;
+ }
+
+ tab->setExperienceList(recent);
+}