summaryrefslogtreecommitdiff
path: root/indra/newview/llpaneloutfitedit.cpp
diff options
context:
space:
mode:
authorAndrew Polunin <apolunin@productengine.com>2010-06-15 21:52:15 +0300
committerAndrew Polunin <apolunin@productengine.com>2010-06-15 21:52:15 +0300
commite460985ddf0d427aba268c8746efd4fad2419c8d (patch)
tree05e40d010c514b658a3fb000a8fa354b081b4b24 /indra/newview/llpaneloutfitedit.cpp
parent33c3064639d95b75e41a4d83b14620e74802d4f7 (diff)
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
Diffstat (limited to 'indra/newview/llpaneloutfitedit.cpp')
-rw-r--r--indra/newview/llpaneloutfitedit.cpp102
1 files changed, 102 insertions, 0 deletions
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<LLPanelOutfitEdit> 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<LLCOFWearables>("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<LLPanel*> 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<LLPanelDummyClothingListItem*>(item))
+ {
+ type = dummy_item->getWearableType();
+ }
+ else if (LLPanelInventoryListItemBase* real_item = dynamic_cast<LLPanelInventoryListItemBase*>(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();