Support SimulatorFeature MarketplaceURL for Marketplace Search tab on non-SL grids.

This commit is contained in:
Lirusaito
2013-02-24 10:54:46 -05:00
parent c6aa1bb3ea
commit 2ad9476961
4 changed files with 133 additions and 5 deletions

View File

@@ -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<LLUICtrl>("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<LLFloaterDirectory*>(data));
return new LLPanelDirMarket(market_panel, static_cast<LLFloaterDirectory*>(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<LLTabContainer>("Directory Tabs")->setCommitCallback(boost::bind(&LLFloaterDirectory::onTabChanged,_2));
LLTabContainer* container = getChild<LLTabContainer>("Directory Tabs");
if (enableClassicAllSearch)
{
LLPanelDirMarket* marketp = static_cast<LLPanelDirMarket*>(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()

View File

@@ -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" />
</panel>
<panel bottom="-549" follows="all" height="533" label="Marketplace" left="1" mouse_opaque="false" name="market_panel" width="778">
<button bottom="-30" follows="top|left" height="25" label="" left="10" name="back_btn" width="25" image_overlay="go-previous-4.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" left_delta="27" name="forward_btn" width="25" image_overlay="go-next-4.png" />
<button bottom_delta="0" follows="top|left" height="25" label="" left_delta="27" name="reload_btn" width="25" image_overlay="view-refresh-5.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" tooltip="reset" left_delta="27" name="reset_btn" width="25" image_overlay="go-home-4.png"/>
<web_browser name="market_browser" bottom="25" follows="all" left="10" right="-10" top="-40"/>
<text bottom="5" follows="bottom|left" left="10" height="16" name="status_text"/>
<string name="loading_text">Loading...</string>
<string name="done_text">Done</string>
<string name="redirect_404_url">http://www.singularityviewer.org/404</string>
</panel>
</tab_container>
<panel bottom="-560" follows="right|top" height="470" left="340"
name="classified_details_panel" width="440" />

View File

@@ -746,6 +746,17 @@ To buy direct, visit the land and click on the place name in the title bar.
bottom_delta="-20" drop_shadow_visible="true" follows="left|bottom"
font="SansSerifSmall" h_pad="0" halign="left" height="16" left="4"
mouse_opaque="true" name="result_text" v_pad="0" width="328" />
</panel>
<panel bottom="-549" follows="all" height="533" label="Marketplace" left="1" mouse_opaque="false" name="market_panel" width="778">
<button bottom="-30" follows="top|left" height="25" label="" left="10" name="back_btn" width="25" image_overlay="go-previous-4.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" left_delta="27" name="forward_btn" width="25" image_overlay="go-next-4.png" />
<button bottom_delta="0" follows="top|left" height="25" label="" left_delta="27" name="reload_btn" width="25" image_overlay="view-refresh-5.png"/>
<button bottom_delta="0" follows="top|left" height="25" label="" tooltip="reset" left_delta="27" name="reset_btn" width="25" image_overlay="go-home-4.png"/>
<web_browser name="market_browser" bottom="25" follows="all" left="10" right="-10" top="-40"/>
<text bottom="5" follows="bottom|left" left="10" height="16" name="status_text"/>
<string name="loading_text">Loading...</string>
<string name="done_text">Done</string>
<string name="redirect_404_url">http://www.singularityviewer.org/404</string>
</panel>
</tab_container>
<panel bottom="-560" follows="right|top" height="470" left="340"

View File

@@ -392,6 +392,30 @@ Initialization with the Marketplace failed because of a system or network error.
yestext="OK"/>
</notification>
<notification
icon="alertmodal.tga"
name="MarketplaceURLChanged"
type="alertmodal">
The region you have entered has a different marketplace page, would you like to change the marketplace's default page?
Furthermore, would you like your marketplace browser to be reset to this region's page now?
<usetemplate
name="yesnocancelbuttons"
notext="No"
canceltext="Reset"
yestext="Yes"/>
</notification>
<notification
icon="notify.tga"
name="MarketplaceURLGone"
type="notify">
There is no marketplace on the region you've moved to.
<usetemplate
ignoretext="MarketplaceURL is empty on region change"
name="okignore"
yestext="OK"/>
</notification>
<notification
icon="alertmodal.tga"