diff --git a/indra/newview/llfloaterdirectory.cpp b/indra/newview/llfloaterdirectory.cpp index 9953d5d73..1e05c6629 100644 --- a/indra/newview/llfloaterdirectory.cpp +++ b/indra/newview/llfloaterdirectory.cpp @@ -66,6 +66,12 @@ #include "lluictrlfactory.h" #include "hippogridmanager.h" +#include "llenvmanager.h" +#include "llnotificationsutil.h" +#include "llviewerregion.h" +#include "llwindow.h" + +const char* market_panel = "market_panel"; class LLPanelDirMarket : public LLPanelDirFind { @@ -81,13 +87,82 @@ public: /*virtual*/ void navigateToDefaultPage() { - if (mWebBrowser) mWebBrowser->navigateTo(getString("default_search_page")); + if (mWebBrowser && !mMarketplaceURL.empty()) mWebBrowser->navigateTo(mMarketplaceURL); + } + + /*virtual*/ BOOL postBuild() + { + if (gHippoGridManager->getConnectedGrid()->isSecondLife()) + mMarketplaceURL = getString("default_search_page"); + else + getChild("reset_btn")->setCommitCallback(boost::bind(&LLPanelDirMarket::navigateToDefaultPage, this)); + return LLPanelDirFind::postBuild(); + } + + void handleRegionChange(LLTabContainer* container) + { + if (LLViewerRegion* region = gAgent.getRegion()) + if (region->getFeaturesReceived()) + setMarketplaceURL(container); + else + region->setFeaturesReceivedCallback(boost::bind(&LLPanelDirMarket::setMarketplaceURL, this, container)); + } + + void setMarketplaceURL(LLTabContainer* container) + { + if (LLViewerRegion* region = gAgent.getRegion()) + { + LLSD info; + region->getSimulatorFeatures(info); + if (info.has("MarketplaceURL")) + { + std::string url = info["MarketplaceURL"].asString(); + if (mMarketplaceURL == url) return; + + if (mMarketplaceURL.empty()) + { + container->addTabPanel(this, getLabel()); + mMarketplaceURL = url; + navigateToDefaultPage(); + } + else + { + LLNotificationsUtil::add("MarketplaceURLChanged", LLSD(), LLSD(), + boost::bind(&LLPanelDirMarket::onConfirmChangeMarketplaceURL, this, boost::bind(LLNotification::getSelectedOption, _1, _2), url)); + } + } + else if (!mMarketplaceURL.empty()) + { + if (gFloaterView->getParentFloater(this)->getVisible()) // Notify the user that they're no longer on the region with the marketplace when search is open + { + LLNotificationsUtil::add("MarketplaceURLGone"); + } + else // Search is not in use, remove the marketplace + { + mMarketplaceURL = ""; + container->removeTabPanel(this); + } + } + } + } + + void onConfirmChangeMarketplaceURL(const S32 option, const std::string& url) + { + if (option == 1) return; //no + else //yes + { + mMarketplaceURL = url; + if (option == 2) navigateToDefaultPage(); + } } static void* create(void* data) { - return new LLPanelDirMarket("market_panel", static_cast(data)); + return new LLPanelDirMarket(market_panel, static_cast(data)); } + +private: + std::string mMarketplaceURL; }; LLFloaterDirectory* LLFloaterDirectory::sInstance = NULL; @@ -128,13 +203,12 @@ LLFloaterDirectory::LLFloaterDirectory(const std::string& name) factory_map["land_sales_panel"] = LLCallbackMap(createLand, this); factory_map["people_panel"] = LLCallbackMap(createPeople, this); factory_map["groups_panel"] = LLCallbackMap(createGroups, this); + factory_map[market_panel] = LLCallbackMap(LLPanelDirMarket::create, this); if (enableWebSearch) { // web search and showcase only for SecondLife factory_map["find_all_panel"] = LLCallbackMap(createFindAll, this); factory_map["showcase_panel"] = LLCallbackMap(createShowcase, this); - if (!enableClassicAllSearch) - factory_map["market_panel"] = LLCallbackMap(LLPanelDirMarket::create, this); } if (enableClassicAllSearch) @@ -169,7 +243,15 @@ LLFloaterDirectory::LLFloaterDirectory(const std::string& name) mPanelAvatarp->selectTab(0); } - getChild("Directory Tabs")->setCommitCallback(boost::bind(&LLFloaterDirectory::onTabChanged,_2)); + LLTabContainer* container = getChild("Directory Tabs"); + if (enableClassicAllSearch) + { + LLPanelDirMarket* marketp = static_cast(container->getPanelByName(market_panel)); + container->removeTabPanel(marketp); // Until we get a MarketPlace URL, tab is removed. + marketp->handleRegionChange(container); + LLEnvManagerNew::instance().setRegionChangeCallback(boost::bind(&LLPanelDirMarket::handleRegionChange, marketp, container)); + } + container->setCommitCallback(boost::bind(&LLFloaterDirectory::onTabChanged,_2)); } LLFloaterDirectory::~LLFloaterDirectory() diff --git a/indra/newview/skins/default/xui/en-us/floater_directory2.xml b/indra/newview/skins/default/xui/en-us/floater_directory2.xml index 823205e69..c02793fe7 100644 --- a/indra/newview/skins/default/xui/en-us/floater_directory2.xml +++ b/indra/newview/skins/default/xui/en-us/floater_directory2.xml @@ -625,6 +625,17 @@ To buy direct, visit the land and click on the place name in the title bar. font="SansSerifSmall" h_pad="0" halign="left" height="16" left="4" mouse_opaque="true" name="result_text" v_pad="0" width="328" /> + +