diff options
Diffstat (limited to 'indra/newview/llviewermenu.cpp')
-rw-r--r-- | indra/newview/llviewermenu.cpp | 70 |
1 files changed, 58 insertions, 12 deletions
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 2687938b35..cd0b3dbd0c 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -350,7 +350,10 @@ class LLMenuParcelObserver : public LLParcelObserver public: LLMenuParcelObserver(); ~LLMenuParcelObserver(); - virtual void changed(); + void changed() override; +private: + LLHandle<LLUICtrl> mLandBuyHandle; + LLHandle<LLUICtrl> mLandBuyPassHandle; }; static LLMenuParcelObserver* gMenuParcelObserver = NULL; @@ -359,6 +362,8 @@ static LLUIListener sUIListener; LLMenuParcelObserver::LLMenuParcelObserver() { + mLandBuyHandle = gMenuLand->getChild<LLMenuItemCallGL>("Land Buy")->getHandle(); + mLandBuyPassHandle = gMenuLand->getChild<LLMenuItemCallGL>("Land Buy Pass")->getHandle(); LLViewerParcelMgr::getInstance()->addObserver(this); } @@ -372,17 +377,16 @@ void LLMenuParcelObserver::changed() LLParcel *parcel = LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(); if (gMenuLand && parcel) { - LLView* child = gMenuLand->findChild<LLView>("Land Buy Pass"); - if (child) + if (!mLandBuyPassHandle.isDead()) { - child->setEnabled(LLPanelLandGeneral::enableBuyPass(NULL) && !(parcel->getOwnerID() == gAgent.getID())); + LLParcel *parcel = LLViewerParcelMgr::getInstance()->getParcelSelection()->getParcel(); + static_cast<LLMenuItemCallGL*>(mLandBuyPassHandle.get())->setEnabled(LLPanelLandGeneral::enableBuyPass(NULL) && !(parcel->getOwnerID() == gAgent.getID())); } - child = gMenuLand->findChild<LLView>("Land Buy"); - if (child) + if (!mLandBuyHandle.isDead()) { bool buyable = enable_buy_land(NULL); - child->setEnabled(buyable); + static_cast<LLMenuItemCallGL*>(mLandBuyHandle.get())->setEnabled(buyable); } } } @@ -402,10 +406,34 @@ void initialize_menus(); // Break up groups of more than 6 items with separators //----------------------------------------------------------------------------- -void set_merchant_SLM_menu() +void set_merchant_SLM_menu(); + +class LLSLMMenuUpdater +{ +public: + LLSLMMenuUpdater(); + ~LLSLMMenuUpdater() = default; + + void setMerchantMenu(); + void checkMerchantStatus(bool force); + +private: + LLHandle<LLView> mMarketplaceListingsItem; +}; + +static LLSLMMenuUpdater* gSLMMenuUpdater = NULL; + +LLSLMMenuUpdater::LLSLMMenuUpdater() +{ + mMarketplaceListingsItem = gMenuHolder->getChild<LLView>("MarketplaceListings")->getHandle(); +} +void LLSLMMenuUpdater::setMerchantMenu() { // All other cases (new merchant, not merchant, migrated merchant): show the new Marketplace Listings menu and enable the tool - gMenuHolder->getChild<LLView>("MarketplaceListings")->setVisible(true); + if(!mMarketplaceListingsItem.isDead()) + { + mMarketplaceListingsItem.get()->setVisible(true); + } LLCommand* command = LLCommandManager::instance().getCommand("marketplacelistings"); gToolBarView->enableCommand(command->id(), true); @@ -422,7 +450,7 @@ void set_merchant_SLM_menu() } } -void check_merchant_status(bool force) +void LLSLMMenuUpdater::checkMerchantStatus(bool force) { if (force) { @@ -430,7 +458,10 @@ void check_merchant_status(bool force) LLMarketplaceData::instance().setSLMStatus(MarketplaceStatusCodes::MARKET_PLACE_NOT_INITIALIZED); } // Hide SLM related menu item - gMenuHolder->getChild<LLView>("MarketplaceListings")->setVisible(false); + if(!mMarketplaceListingsItem.isDead()) + { + mMarketplaceListingsItem.get()->setVisible(false); + } // Also disable the toolbar button for Marketplace Listings LLCommand* command = LLCommandManager::instance().getCommand("marketplacelistings"); @@ -440,6 +471,16 @@ void check_merchant_status(bool force) LLMarketplaceData::instance().initializeSLM(boost::bind(&set_merchant_SLM_menu)); } +void set_merchant_SLM_menu() +{ + if(gSLMMenuUpdater) gSLMMenuUpdater->setMerchantMenu(); +} + +void check_merchant_status(bool force) +{ + if(gSLMMenuUpdater) gSLMMenuUpdater->checkMerchantStatus(force); +} + void init_menus() { // Initialize actions @@ -555,6 +596,8 @@ void init_menus() // Let land based option enable when parcel changes gMenuParcelObserver = new LLMenuParcelObserver(); + gSLMMenuUpdater = new LLSLMMenuUpdater(); + gLoginMenuBarView = LLUICtrlFactory::getInstance()->createFromFile<LLMenuBarGL>("menu_login.xml", gMenuHolder, LLViewerMenuHolderGL::child_registry_t::instance()); gLoginMenuBarView->arrangeAndClear(); LLRect menuBarRect = gLoginMenuBarView->getRect(); @@ -2752,6 +2795,9 @@ class LLAdminOnSaveState: public view_listener_t //----------------------------------------------------------------------------- void cleanup_menus() { + delete gSLMMenuUpdater; + gSLMMenuUpdater = nullptr; + delete gMenuParcelObserver; gMenuParcelObserver = NULL; @@ -2768,7 +2814,7 @@ void cleanup_menus() gMenuAttachmentSelf = NULL; delete gMenuAttachmentOther; - gMenuAttachmentSelf = NULL; + gMenuAttachmentOther = NULL; delete gMenuLand; gMenuLand = NULL; |