From e460985ddf0d427aba268c8746efd4fad2419c8d Mon Sep 17 00:00:00 2001 From: Andrew Polunin Date: Tue, 15 Jun 2010 21:52:15 +0300 Subject: EXT-7639 FIXED added shop button which reacts according to the ticket description - Added method LLAccordionCtrl::getExpandedTab() which search for the first expanded accordion tab. This method is a bit of hacking, but I discussed it with Vadim Savchuk. - LLAccordionCtrlTab::isExpanded() is made 'const'. This is necessary to call it from getExpandedTab() which is also 'const'. - Added all provided Marketplace URLs (taken from EXT-7257) to the settings.xml. So URLs can be configured without recompilation. - Added method LLCOFWearables::getSelectedItems() which can be used to get ALL selected items (not only one). - Class LLShopURLDispatcher is implemented in the llpaneloutfitedit.cpp. - Added callback LLPanelOutfitEdit::onShopButtonClicked() which calls LLShopURLDispatcher to send user to the correct URL. - Added shop button (shop_btn) widget in panel_outfit_edit.xml. It has invalid icon for now. After review I'm going to reassign the ticket to someone who will provide correct icons. Reviewed by Vadim Savchuk and Mike Antipov at https://codereview.productengine.com/secondlife/r/569/ --HG-- branch : product-engine --- indra/llui/llaccordionctrl.cpp | 18 + indra/llui/llaccordionctrl.h | 7 + indra/llui/llaccordionctrltab.h | 2 +- indra/newview/app_settings/settings.xml | 376 ++++++++++++++++++++- indra/newview/llcofwearables.cpp | 33 ++ indra/newview/llcofwearables.h | 3 + indra/newview/llpaneloutfitedit.cpp | 102 ++++++ indra/newview/llpaneloutfitedit.h | 1 + .../skins/default/xui/en/panel_outfit_edit.xml | 14 +- 9 files changed, 553 insertions(+), 3 deletions(-) (limited to 'indra') diff --git a/indra/llui/llaccordionctrl.cpp b/indra/llui/llaccordionctrl.cpp index fc93793ed8..3a1e9f19fa 100644 --- a/indra/llui/llaccordionctrl.cpp +++ b/indra/llui/llaccordionctrl.cpp @@ -826,6 +826,24 @@ void LLAccordionCtrl::setFilterSubString(const std::string& filter_string) mNoVisibleTabsHelpText->setValue(text); } +const LLAccordionCtrlTab* LLAccordionCtrl::getExpandedTab() const +{ + typedef std::vector::const_iterator tabs_const_iterator; + + const LLAccordionCtrlTab* result = 0; + + for (tabs_const_iterator i = mAccordionTabs.begin(); i != mAccordionTabs.end(); ++i) + { + if ((*i)->isExpanded()) + { + result = *i; + break; + } + } + + return result; +} + S32 LLAccordionCtrl::calcExpandedTabHeight(S32 tab_index /* = 0 */, S32 available_height /* = 0 */) { if(tab_index < 0) diff --git a/indra/llui/llaccordionctrl.h b/indra/llui/llaccordionctrl.h index fc6f2d896c..677b598a32 100644 --- a/indra/llui/llaccordionctrl.h +++ b/indra/llui/llaccordionctrl.h @@ -129,6 +129,13 @@ public: */ void setFilterSubString(const std::string& filter_string); + /** + * This method returns the first expanded accordion tab. + * It is expected to be called for accordion which doesn't allow multiple + * tabs to be expanded. Use with care. + */ + const LLAccordionCtrlTab* getExpandedTab() const; + private: void initNoTabsWidget(const LLTextBox::Params& tb_params); void updateNoTabsHelpTextVisibility(); diff --git a/indra/llui/llaccordionctrltab.h b/indra/llui/llaccordionctrltab.h index 19d4ec0a1c..7bf7eeef8f 100644 --- a/indra/llui/llaccordionctrltab.h +++ b/indra/llui/llaccordionctrltab.h @@ -171,7 +171,7 @@ public: virtual bool addChild(LLView* child, S32 tab_group); - bool isExpanded() { return mDisplayChildren; } + bool isExpanded() const { return mDisplayChildren; } S32 getHeaderHeight(); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 4506ee6e0c..f9a1dfb0dc 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4667,7 +4667,381 @@ String Value https://www.xstreetsl.com/modules.php?name=Marketplace - + + MarketplaceURL_objectFemale + + Comment + URL to the Marketplace Attachments Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/attachments + + MarketplaceURL_objectMale + + Comment + URL to the Marketplace Attachments Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/attachments + + MarketplaceURL_clothingFemale + + Comment + URL to the Marketplace Clothing Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/clothing_female_avatar + + MarketplaceURL_clothingMale + + Comment + URL to the Marketplace Clothing Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/clothing_male_avatar + + MarketplaceURL_bodypartFemale + + Comment + URL to the Marketplace Bodyparts Female + Persist + 0 + Type + String + Value + https://www.xstreetsl.com/modules.php?name=Marketplace + + MarketplaceURL_bodypartMale + + Comment + URL to the Marketplace Bodyparts Male + Persist + 0 + Type + String + Value + https://www.xstreetsl.com/modules.php?name=Marketplace + + MarketplaceURL_glovesMale + + Comment + URL to the Marketplace Gloves Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/gloves_both_women_and_men + + MarketplaceURL_glovesFemale + + Comment + URL to the Marketplace Gloves Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/gloves_both_women_and_men + + MarketplaceURL_jacketFemale + + Comment + URL to the Marketplace Jacket Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/jacket_womens + + MarketplaceURL_jacketMale + + Comment + URL to the Marketplace Jacket Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/jacket_mens + + MarketplaceURL_shirtFemale + + Comment + URL to the Marketplace Shirt Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/shirt_womens + + MarketplaceURL_shirtMale + + Comment + URL to the Marketplace Shirt Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/shirt_mens + + MarketplaceURL_undershirtFemale + + Comment + URL to the Marketplace Undershirt Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/undershirt_womens + + MarketplaceURL_undershirtMale + + Comment + URL to the Marketplace Undershirt Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/undershirt_mens + + MarketplaceURL_skirtFemale + + Comment + URL to the Marketplace Skirt Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/skirts_women + + MarketplaceURL_skirtMale + + Comment + URL to the Marketplace Skirt Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/skirts_women + + MarketplaceURL_pantsFemale + + Comment + URL to the Marketplace Pants Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/pants_women + + MarketplaceURL_pantsMale + + Comment + URL to the Marketplace Pants Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/pants_men + + MarketplaceURL_underpantsFemale + + Comment + URL to the Marketplace Underwear Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/underwear_women + + MarketplaceURL_underpantsMale + + Comment + URL to the Marketplace Underwear Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/underwear_men + + MarketplaceURL_shoesFemale + + Comment + URL to the Marketplace Shoes Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/shoes_women + + MarketplaceURL_shoesMale + + Comment + URL to the Marketplace Shoes Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/shoes_men + + MarketplaceURL_socksFemale + + Comment + URL to the Marketplace Socks Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/socks_women + + MarketplaceURL_socksMale + + Comment + URL to the Marketplace Socks Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/socks_women + + MarketplaceURL_tattooMale + + Comment + URL to the Marketplace Tattoo Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/tattoo_both_women_and_men + + MarketplaceURL_tattooFemale + + Comment + URL to the Marketplace Tattoo Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/tattoo_both_women_and_men + + MarketplaceURL_hairFemale + + Comment + URL to the Marketplace Hair Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/womens_hair + + MarketplaceURL_hairMale + + Comment + URL to the Marketplace Hair Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/mens_hair + + MarketplaceURL_eyesFemale + + Comment + URL to the Marketplace Eyes Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/womens_eyes + + MarketplaceURL_eyesMale + + Comment + URL to the Marketplace Eyes Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/mens_eyes + + MarketplaceURL_shapeFemale + + Comment + URL to the Marketplace Shape Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/womens_shape + + MarketplaceURL_shapeMale + + Comment + URL to the Marketplace Shape Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/mens_shape + + MarketplaceURL_skinFemale + + Comment + URL to the Marketplace Skin Female + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/womens_skin + + MarketplaceURL_skinMale + + Comment + URL to the Marketplace Skins Male + Persist + 0 + Type + String + Value + http://marketplace.secondlife.com/trampoline/viewer21/mens_skin + MaxDragDistance Comment diff --git a/indra/newview/llcofwearables.cpp b/indra/newview/llcofwearables.cpp index 611396b0e5..880d79222b 100644 --- a/indra/newview/llcofwearables.cpp +++ b/indra/newview/llcofwearables.cpp @@ -34,6 +34,8 @@ #include "llcofwearables.h" +#include "llaccordionctrl.h" +#include "llaccordionctrltab.h" #include "llagentdata.h" #include "llagentwearables.h" #include "llappearancemgr.h" @@ -557,6 +559,14 @@ LLPanel* LLCOFWearables::getSelectedItem() return mLastSelectedList->getSelectedItem(); } +void LLCOFWearables::getSelectedItems(std::vector& selected_items) const +{ + if (mLastSelectedList) + { + mLastSelectedList->getSelectedItems(selected_items); + } +} + void LLCOFWearables::clear() { mAttachments->clear(); @@ -564,6 +574,29 @@ void LLCOFWearables::clear() mBodyParts->clear(); } +LLAssetType::EType LLCOFWearables::getExpandedAccordionAssetType() +{ + static std::map type_map; + static LLAccordionCtrl* accordion_ctrl = getChild("cof_wearables_accordion"); + + if (type_map.empty()) + { + type_map["tab_clothing"] = LLAssetType::AT_CLOTHING; + type_map["tab_attachments"] = LLAssetType::AT_OBJECT; + type_map["tab_body_parts"] = LLAssetType::AT_BODYPART; + } + + const LLAccordionCtrlTab* tab = accordion_ctrl->getExpandedTab(); + + if (!tab) + { + llwarns << "No accordion is expanded" << llendl; + return LLAssetType::AT_NONE; + } + + return type_map[tab->getName()]; +} + void LLCOFWearables::onListRightClick(LLUICtrl* ctrl, S32 x, S32 y, LLListContextMenu* menu) { if(menu) diff --git a/indra/newview/llcofwearables.h b/indra/newview/llcofwearables.h index f99f2662e6..62f4cfc692 100644 --- a/indra/newview/llcofwearables.h +++ b/indra/newview/llcofwearables.h @@ -78,10 +78,13 @@ public: bool getSelectedUUIDs(uuid_vec_t& selected_ids); LLPanel* getSelectedItem(); + void getSelectedItems(std::vector& selected_items) const; void refresh(); void clear(); + LLAssetType::EType getExpandedAccordionAssetType(); + LLCOFCallbacks& getCOFCallbacks() { return mCOFCallbacks; } protected: diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index 1454a2f6af..8da7432e0a 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -72,6 +72,8 @@ #include "lltoggleablemenu.h" #include "llwearablelist.h" #include "llwearableitemslist.h" +#include "llwearabletype.h" +#include "llweb.h" static LLRegisterPanelClassWrapper t_outfit_edit("panel_outfit_edit"); @@ -81,6 +83,65 @@ const U64 ALL_ITEMS_MASK = WEARABLE_MASK | ATTACHMENT_MASK; static const std::string REVERT_BTN("revert_btn"); +class LLShopURLDispatcher +{ +public: + std::string resolveURL(LLWearableType::EType wearable_type, ESex sex); + std::string resolveURL(LLAssetType::EType asset_type, ESex sex); +}; + +std::string LLShopURLDispatcher::resolveURL(LLWearableType::EType wearable_type, ESex sex) +{ + const std::string prefix = "MarketplaceURL"; + const std::string sex_str = (sex == SEX_MALE) ? "Male" : "Female"; + const std::string type_str = LLWearableType::getTypeName(wearable_type); + + std::string setting_name = prefix; + + switch (wearable_type) + { + case LLWearableType::WT_ALPHA: + case LLWearableType::WT_NONE: + case LLWearableType::WT_INVALID: // just in case, this shouldn't happen + case LLWearableType::WT_COUNT: // just in case, this shouldn't happen + break; + + default: + setting_name += '_'; + setting_name += type_str; + setting_name += sex_str; + break; + } + + return gSavedSettings.getString(setting_name); +} + +std::string LLShopURLDispatcher::resolveURL(LLAssetType::EType asset_type, ESex sex) +{ + const std::string prefix = "MarketplaceURL"; + const std::string sex_str = (sex == SEX_MALE) ? "Male" : "Female"; + const std::string type_str = LLAssetType::lookup(asset_type); + + std::string setting_name = prefix; + + switch (asset_type) + { + case LLAssetType::AT_CLOTHING: + case LLAssetType::AT_OBJECT: + case LLAssetType::AT_BODYPART: + setting_name += '_'; + setting_name += type_str; + setting_name += sex_str; + break; + + // to suppress warnings + default: + break; + } + + return gSavedSettings.getString(setting_name); +} + class LLPanelOutfitEditGearMenu { public: @@ -262,6 +323,7 @@ BOOL LLPanelOutfitEdit::postBuild() childSetCommitCallback("list_view_btn", boost::bind(&LLPanelOutfitEdit::showWearablesListView, this), NULL); childSetCommitCallback("wearables_gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL); childSetCommitCallback("gear_menu_btn", boost::bind(&LLPanelOutfitEdit::onGearButtonClick, this, _1), NULL); + childSetCommitCallback("shop_btn", boost::bind(&LLPanelOutfitEdit::onShopButtonClicked, this), NULL); mCOFWearables = getChild("cof_wearables_list"); mCOFWearables->setCommitCallback(boost::bind(&LLPanelOutfitEdit::filterWearablesBySelectedItem, this)); @@ -530,6 +592,46 @@ void LLPanelOutfitEdit::onReplaceBodyPartMenuItemClicked(LLUUID selected_item_id } } +void LLPanelOutfitEdit::onShopButtonClicked() +{ + static LLShopURLDispatcher url_resolver; + + std::string url; + std::vector selected_items; + mCOFWearables->getSelectedItems(selected_items); + + ESex sex = gSavedSettings.getU32("AvatarSex") ? SEX_MALE : SEX_FEMALE; + + if (selected_items.size() == 1) + { + LLWearableType::EType type = LLWearableType::WT_NONE; + LLPanel* item = selected_items.front(); + + // LLPanelDummyClothingListItem is lower then LLPanelInventoryListItemBase in hierarchy tree + if (LLPanelDummyClothingListItem* dummy_item = dynamic_cast(item)) + { + type = dummy_item->getWearableType(); + } + else if (LLPanelInventoryListItemBase* real_item = dynamic_cast(item)) + { + type = real_item->getWearableType(); + } + + // WT_INVALID comes for attachments + if (type != LLWearableType::WT_INVALID) + { + url = url_resolver.resolveURL(type, sex); + } + } + + if (url.empty()) + { + url = url_resolver.resolveURL(mCOFWearables->getExpandedAccordionAssetType(), sex); + } + + LLWeb::loadURLExternal(url); +} + void LLPanelOutfitEdit::onRemoveFromOutfitClicked(void) { LLUUID id_to_remove = mCOFWearables->getSelectedUUID(); diff --git a/indra/newview/llpaneloutfitedit.h b/indra/newview/llpaneloutfitedit.h index 56c6c6d680..1705e3043b 100644 --- a/indra/newview/llpaneloutfitedit.h +++ b/indra/newview/llpaneloutfitedit.h @@ -163,6 +163,7 @@ public: void onEditWearableClicked(void); void onAddWearableClicked(void); void onReplaceBodyPartMenuItemClicked(LLUUID selected_item_id); + void onShopButtonClicked(); void displayCurrentOutfit(); void updateCurrentOutfitName(); diff --git a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml index efd1798d44..528850a6ec 100644 --- a/indra/newview/skins/default/xui/en/panel_outfit_edit.xml +++ b/indra/newview/skins/default/xui/en/panel_outfit_edit.xml @@ -375,7 +375,19 @@ It is calculated as border_size + 2*UIResizeBarOverlap layout="topleft" left_pad="1" name="dummy_right_icon" - width="281" /> + width="246" /> +