diff options
author | dolphin <dolphin@lindenlab.com> | 2013-10-03 12:59:44 -0700 |
---|---|---|
committer | dolphin <dolphin@lindenlab.com> | 2013-10-03 12:59:44 -0700 |
commit | e510fa3ee064ce03a48852fdea26be781e8fa8b6 (patch) | |
tree | 82b418df40a937cc8668380d2c80edf4501009f2 | |
parent | aed3cbce26a9e1e7ec70a43146fd405f3162f9d7 (diff) |
First pass at functional experience list floater
-rw-r--r-- | indra/newview/llfloaterexperiences.cpp | 126 | ||||
-rw-r--r-- | indra/newview/llfloaterexperiences.h | 5 | ||||
-rw-r--r-- | indra/newview/llpanelexperiences.cpp | 265 | ||||
-rw-r--r-- | indra/newview/llpanelexperiences.h | 63 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_experiences.xml | 20 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_experiences.xml | 36 | ||||
-rwxr-xr-x | indra/newview/skins/default/xui/en/strings.xml | 5 |
7 files changed, 189 insertions, 331 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); +} diff --git a/indra/newview/llfloaterexperiences.h b/indra/newview/llfloaterexperiences.h index 1e5f216f8d..7d8c4a4be7 100644 --- a/indra/newview/llfloaterexperiences.h +++ b/indra/newview/llfloaterexperiences.h @@ -35,9 +35,14 @@ class LLFloaterExperiences : public: LLFloaterExperiences(const LLSD& data); + void clearFromRecent(const LLSD& ids); protected: /*virtual*/ BOOL postBuild(); + void setupRecentTabs(); + void addTab(const std::string& name, bool select); + + private: }; diff --git a/indra/newview/llpanelexperiences.cpp b/indra/newview/llpanelexperiences.cpp index 617ceef615..0d7cdce6e8 100644 --- a/indra/newview/llpanelexperiences.cpp +++ b/indra/newview/llpanelexperiences.cpp @@ -7,82 +7,18 @@ #include "llagent.h" #include "llpanelexperiences.h" +#include "llslurl.h" static LLRegisterPanelClassWrapper<LLPanelExperiences> register_experiences_panel("experiences_panel"); LLPanelExperiences::LLPanelExperiences( ) - : mExperiencesList(NULL), - mExperiencesAccTab(NULL), - mProfilePanel(NULL), - mPanelExperienceInfo(NULL), - mNoExperiences(false) + : mExperiencesList(NULL) { - -} - -void* LLPanelExperiences::create( void* data ) -{ - return new LLPanelExperiences(); -} - -void ExperienceResult(LLHandle<LLPanelExperiences> panel, const LLSD& experience) -{ - LLPanelExperiences* experiencePanel = panel.get(); - if(experiencePanel) - { - experiencePanel->addExperienceInfo(experience); - } -} - -class LLExperienceListResponder : public LLHTTPClient::Responder -{ -public: - LLExperienceListResponder(const LLHandle<LLPanelExperiences>& parent):mParent(parent) - { - } - - LLHandle<LLPanelExperiences> mParent; - - virtual void result(const LLSD& content) - { - if(mParent.isDead()) - return; - - 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, boost::bind(ExperienceResult, mParent, _1)); - } - } -}; - -void LLPanelExperiences::addExperienceInfo(const LLSD& experience) -{ - LLExperienceItem* item = new LLExperienceItem(); - if(experience.has(LLExperienceCache::NAME)) - { - item->setExperienceName(experience[LLExperienceCache::NAME].asString()); - } - else if(experience.has("error")) - { - item->setExperienceName(experience["error"].asString()); - } - - if(experience.has(LLExperienceCache::DESCRIPTION)) - { - item->setExperienceDescription(experience[LLExperienceCache::DESCRIPTION].asString()); - } - - mExperiencesList->addItem(item); - + buildFromFile("panel_experiences.xml"); } - BOOL LLPanelExperiences::postBuild( void ) { mExperiencesList = getChild<LLFlatListView>("experiences_list"); @@ -91,44 +27,10 @@ BOOL LLPanelExperiences::postBuild( void ) mExperiencesList->setNoItemsCommentText(getString("no_experiences")); } - - LLViewerRegion* region = gAgent.getRegion(); - if (region) - { - std::string lookup_url=region->getCapability("GetExperiences"); - if(!lookup_url.empty()) - { - LLHTTPClient::get(lookup_url, new LLExperienceListResponder(getDerivedHandle<LLPanelExperiences>())); - } - } - - mExperiencesAccTab = getChild<LLAccordionCtrlTab>("tab_experiences"); - mExperiencesAccTab->setDropDownStateChangedCallback(boost::bind(&LLPanelExperiences::onAccordionStateChanged, this, mExperiencesAccTab)); - mExperiencesAccTab->setDisplayChildren(true); - return TRUE; } -void LLPanelExperiences::onOpen( const LLSD& key ) -{ - LLPanel::onOpen(key); -} -void LLPanelExperiences::onClosePanel() -{ - if (mPanelExperienceInfo) - { - onPanelExperienceClose(mPanelExperienceInfo); - } -} - -void LLPanelExperiences::updateData() -{ - if(isDirty()) - { - mNoExperiences = false; - } -} LLExperienceItem* LLPanelExperiences::getSelectedExperienceItem() { @@ -138,165 +40,50 @@ LLExperienceItem* LLPanelExperiences::getSelectedExperienceItem() return dynamic_cast<LLExperienceItem*>(selected_item); } -void LLPanelExperiences::setProfilePanel( LLPanelProfile* profile_panel ) -{ - mProfilePanel = profile_panel; -} - -void LLPanelExperiences::onListCommit( const LLFlatListView* f_list ) -{ - if(f_list == mExperiencesList) - { - mExperiencesList->resetSelection(true); - } - else - { - llwarns << "Unknown list" << llendl; - } - - //updateButtons(); -} - -void LLPanelExperiences::onAccordionStateChanged( const LLAccordionCtrlTab* acc_tab ) -{ - if(!mExperiencesAccTab->getDisplayChildren()) - { - mExperiencesList->resetSelection(true); - } - -} - -void LLPanelExperiences::openExperienceInfo() +void LLPanelExperiences::setExperienceList( const LLSD& experiences ) { - LLSD selected_value = mExperiencesList->getSelectedValue(); - if(selected_value.isUndefined()) - { - return; - } - - LLExperienceItem* experience = (LLExperienceItem*)mExperiencesList->getSelectedItem(); - - createExperienceInfoPanel(); + mExperiencesList->clear(); - LLSD params; - params["experience_name"] = experience->getExperienceName(); - params["experience_desc"] = experience->getExperienceDescription(); + LLSD::array_const_iterator it = experiences.beginArray(); + for( /**/ ; it != experiences.endArray(); ++it) + { + LLUUID public_key = it->asUUID(); + LLExperienceItem* item = new LLExperienceItem(); - getProfilePanel()->openPanel(mPanelExperienceInfo, params); - -} - - -void LLPanelExperiences::createExperienceInfoPanel() -{ - if(!mPanelExperienceInfo) - { - mPanelExperienceInfo = LLPanelExperienceInfo::create(); - mPanelExperienceInfo->setExitCallback(boost::bind(&LLPanelExperiences::onPanelExperienceClose, this, mPanelExperienceInfo)); - mPanelExperienceInfo->setVisible(FALSE); - } + item->init(public_key); + mExperiencesList->addItem(item, public_key); + } } -void LLPanelExperiences::onPanelExperienceClose( LLPanel* panel ) +LLPanelExperiences* LLPanelExperiences::create(const std::string& name) { - getProfilePanel()->closePanel(panel); + LLPanelExperiences* panel= new LLPanelExperiences(); + panel->setName(name); + return panel; } -LLPanelProfile* LLPanelExperiences::getProfilePanel() +void LLPanelExperiences::removeExperiences( const LLSD& ids ) { - llassert_always(NULL != mProfilePanel); - - return mProfilePanel; + LLSD::array_const_iterator it = ids.beginArray(); + for( /**/ ; it != ids.endArray(); ++it) + { + mExperiencesList->removeItemByUUID(it->asUUID()); + } } - - - - - - - - - LLExperienceItem::LLExperienceItem() { - buildFromFile("panel_experience_info.xml"); -} - -void LLExperienceItem::init( LLSD* experience_data ) -{ - if(experience_data) - { - setExperienceDescription(experience_data->has(LLExperienceCache::DESCRIPTION)?(*experience_data)[LLExperienceCache::DESCRIPTION].asString() : std::string()); - setExperienceName(experience_data->has(LLExperienceCache::NAME)?(*experience_data)[LLExperienceCache::NAME].asString() : std::string()); - } -} - -void LLExperienceItem::setExperienceDescription( const std::string& val ) -{ - mExperienceDescription = val; - getChild<LLUICtrl>("experience_desc")->setValue(val); -} - -void LLExperienceItem::setExperienceName( const std::string& val ) -{ - mExperienceName = val; - getChild<LLUICtrl>("experience_name")->setValue(val); + buildFromFile("panel_experience_list_item.xml"); } -BOOL LLExperienceItem::postBuild() +void LLExperienceItem::init( const LLUUID& id) { - return TRUE; + getChild<LLUICtrl>("experience_name")->setValue(LLSLURL("experience", id, "profile").getSLURLString()); } -void LLExperienceItem::update() -{ - -} - -void LLExperienceItem::processProperties( void* data, EAvatarProcessorType type ) -{ - -} LLExperienceItem::~LLExperienceItem() { } - - -void LLPanelExperienceInfo::setExperienceName( const std::string& name ) -{ - getChild<LLUICtrl>("experience_name")->setValue(name); -} - -void LLPanelExperienceInfo::setExperienceDesc( const std::string& desc ) -{ - getChild<LLUICtrl>("experience_desc")->setValue(desc); -} - -void LLPanelExperienceInfo::onOpen( const LLSD& key ) -{ - setExperienceName(key["experience_name"]); - setExperienceDesc(key["experience_desc"]); - - /* - LLAvatarPropertiesProcessor::getInstance()->addObserver( - getAvatarId(), this); - LLAvatarPropertiesProcessor::getInstance()->sendPickInfoRequest( - getAvatarId(), getPickId()); - */ -} - -LLPanelExperienceInfo* LLPanelExperienceInfo::create() -{ - LLPanelExperienceInfo* panel = new LLPanelExperienceInfo(); - panel->buildFromFile("panel_experience_info.xml"); - return panel; -} - -void LLPanelExperienceInfo::setExitCallback( const commit_callback_t& cb ) -{ - getChild<LLButton>("back_btn")->setClickedCallback(cb); -} diff --git a/indra/newview/llpanelexperiences.h b/indra/newview/llpanelexperiences.h index 1fe3f6ae1d..e3c223d9db 100644 --- a/indra/newview/llpanelexperiences.h +++ b/indra/newview/llpanelexperiences.h @@ -34,86 +34,37 @@ class LLExperienceItem; class LLPanelProfile; -class LLPanelExperienceInfo - : public LLPanel -{ -public: - static LLPanelExperienceInfo* create(); - - void onOpen(const LLSD& key); - void setExperienceName( const std::string& name ); - void setExperienceDesc( const std::string& desc ); - - - virtual void setExitCallback(const commit_callback_t& cb); -}; - class LLPanelExperiences - : public LLPanel /*LLPanelProfileTab*/ + : public LLPanel { public: - LLPanelExperiences(); + LLPanelExperiences(); - static void* create(void* data); + static LLPanelExperiences* create(const std::string& name); /*virtual*/ BOOL postBuild(void); - - /*virtual*/ void onOpen(const LLSD& key); - /*virtual*/ void onClosePanel(); - void updateData(); + void setExperienceList(const LLSD& experiences); - LLExperienceItem* getSelectedExperienceItem(); - - void setProfilePanel(LLPanelProfile* profile_panel); - void addExperienceInfo(const LLSD& experience); + LLExperienceItem* getSelectedExperienceItem(); + void removeExperiences( const LLSD& ids ); protected: - void onListCommit(const LLFlatListView* f_list); - void onAccordionStateChanged(const LLAccordionCtrlTab* acc_tab); - - - void openExperienceInfo(); - void createExperienceInfoPanel(); - void onPanelExperienceClose(LLPanel* panel); - LLPanelProfile* getProfilePanel(); private: LLFlatListView* mExperiencesList; - LLAccordionCtrlTab* mExperiencesAccTab; - LLPanelProfile* mProfilePanel; - LLPanelExperienceInfo* mPanelExperienceInfo; - bool mNoExperiences; }; class LLExperienceItem : public LLPanel - //, public LLAvatarPropertiesObserver { public: LLExperienceItem(); ~LLExperienceItem(); - void init(LLSD* experience_data); - /*virtual*/ BOOL postBuild(); - void update(); - - /*virtual*/ void processProperties(void* data, EAvatarProcessorType type); - - void setCreatorID(const LLUUID& val) { mCreatorID = val; } - void setExperienceDescription(const std::string& val); - void setExperienceName(const std::string& val); - - const LLUUID& getCreatorID() const { return mCreatorID; } - const std::string& getExperienceName() const { return mExperienceName; } - const std::string& getExperienceDescription() const { return mExperienceDescription; } - + void init(const LLUUID& experience_id); protected: - LLUUID mCreatorID; - - std::string mExperienceName; - std::string mExperienceDescription; }; #endif // LL_LLPANELEXPERIENCES_H diff --git a/indra/newview/skins/default/xui/en/floater_experiences.xml b/indra/newview/skins/default/xui/en/floater_experiences.xml index 57541c8b35..1258ce26ac 100644 --- a/indra/newview/skins/default/xui/en/floater_experiences.xml +++ b/indra/newview/skins/default/xui/en/floater_experiences.xml @@ -1,11 +1,10 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <floater - positioning="cascading" can_close="true" can_resize="true" height="400" - help_topic="sidebar_experiences" + width="300" min_height="300" min_width="300" layout="topleft" @@ -13,17 +12,16 @@ save_rect="false" single_instance="true" reuse_instance="false" - title="EXPERIENCES" - width="400"> - <panel + bg_opaque_color="0 0.5 0 0.3" + title="EXPERIENCES"> + <tab_container top="3" left="3" layout="topleft" - right="-3" + width="294" follows="all" - height="300" - class="experiences_panel" - filename="panel_experiences.xml" - > - </panel> + height="394" + name="xp_tabs"> + </tab_container> + </floater> diff --git a/indra/newview/skins/default/xui/en/panel_experiences.xml b/indra/newview/skins/default/xui/en/panel_experiences.xml index 47a3005aae..bc78d0813c 100644 --- a/indra/newview/skins/default/xui/en/panel_experiences.xml +++ b/indra/newview/skins/default/xui/en/panel_experiences.xml @@ -4,37 +4,23 @@ layout="topleft" top="3" left="3" - right="-3" - bottom="-3" + width="200" + height="300" label="Experiences" + bg_opaque_color="0 0.5 0 0.3" follows="all"> <string name="no_experiences" value="No experiences."/> - <accordion - fit_parent="true" + <flat_list_view + name="experiences_list" layout="topleft" top="0" - left="3" - right="-3" - bottom="-3" - single_expansion="true" - follows="all"> - <accordion_tab - name="tab_experiences" - layout="topleft" - top="0" - left="0" - right="-3" - title="Experiences" - follows="all"> - <flat_list_view - name="experiences_list" - layout="topleft" - top="0" - left="0" - follows="all"/> - </accordion_tab> - </accordion> + left="0" + width="200" + height="300" + follows="all" + > + </flat_list_view> </panel> diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index fc189b5d62..70c990872e 100755 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3925,6 +3925,11 @@ Try enclosing path to the editor with double quotes. <string name="experience_tools_experience">Experience</string> <string name="ExperienceNameNull">(no experience)</string> <string name="GRID_WIDE">Grid-wide</string> + <string name="Allowed_Experiences_Tab">Allowed</string> + <string name="Blocked_Experiences_Tab">Blocked</string> + <string name="Contrib_Experiences_Tab">Contributor</string> + <string name="Admin_Experiences_Tab">Admin</string> + <string name="Recent_Experiences_Tab">Recent</string> <!-- Conversation log messages --> <string name="logging_calls_disabled_log_empty"> |