summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterbuyland.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterbuyland.cpp')
-rw-r--r--indra/newview/llfloaterbuyland.cpp284
1 files changed, 115 insertions, 169 deletions
diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp
index 29506e21d5..7075719299 100644
--- a/indra/newview/llfloaterbuyland.cpp
+++ b/indra/newview/llfloaterbuyland.cpp
@@ -43,6 +43,7 @@
#include "llconfirmationmanager.h"
#include "llcurrencyuimanager.h"
#include "llfloater.h"
+#include "llfloaterreg.h"
#include "llfloatertools.h"
#include "llframetimer.h"
#include "lliconctrl.h"
@@ -75,10 +76,22 @@ const F64 CURRENCY_ESTIMATE_FREQUENCY = 0.5;
class LLFloaterBuyLandUI
: public LLFloater
{
-private:
- LLFloaterBuyLandUI();
+public:
+ LLFloaterBuyLandUI(const LLSD& key);
virtual ~LLFloaterBuyLandUI();
-
+
+private:
+ class SelectionObserver : public LLParcelObserver
+ {
+ public:
+ SelectionObserver(LLFloaterBuyLandUI* floater) : mFloater(floater) {}
+ virtual void changed();
+ private:
+ LLFloaterBuyLandUI* mFloater;
+ };
+
+private:
+ SelectionObserver mParcelSelectionObserver;
LLViewerRegion* mRegion;
LLParcelSelectionHandle mParcel;
bool mIsClaim;
@@ -144,11 +157,7 @@ private:
LLViewerParcelMgr::ParcelBuyInfo* mParcelBuyInfo;
- static LLFloaterBuyLandUI* sInstance;
-
public:
- static LLFloaterBuyLandUI* soleInstance(bool createIfNeeded);
-
void setForGroup(bool is_for_group);
void setParcel(LLViewerRegion* region, LLParcelSelectionHandle parcel);
@@ -156,10 +165,10 @@ public:
void updateParcelInfo();
void updateCovenantInfo();
static void onChangeAgreeCovenant(LLUICtrl* ctrl, void* user_data);
- void updateCovenantText(const std::string& string, const LLUUID &asset_id);
- void updateEstateName(const std::string& name);
- void updateLastModified(const std::string& text);
- void updateEstateOwnerName(const std::string& name);
+ void updateFloaterCovenantText(const std::string& string, const LLUUID &asset_id);
+ void updateFloaterEstateName(const std::string& name);
+ void updateFloaterLastModified(const std::string& text);
+ void updateFloaterEstateOwnerName(const std::string& name);
void updateWebSiteInfo();
void finishWebSiteInfo();
@@ -171,7 +180,7 @@ public:
void refreshUI();
- void startTransaction(TransactionType type, LLXMLRPCValue params);
+ void startTransaction(TransactionType type, const LLXMLRPCValue& params);
bool checkTransaction();
void tellUserError(const std::string& message, const std::string& uri);
@@ -181,27 +190,21 @@ public:
void startBuyPreConfirm();
void startBuyPostConfirm(const std::string& password);
- static void onClickBuy(void* data);
- static void onClickCancel(void* data);
- static void onClickErrorWeb(void* data);
+ void onClickBuy();
+ void onClickCancel();
+ void onClickErrorWeb();
virtual void draw();
virtual BOOL canClose();
- virtual void onClose(bool app_quitting);
- /*virtual*/ void setMinimized(BOOL b);
+
+ void onVisibilityChange ( const LLSD& new_visibility );
-private:
- class SelectionObserver : public LLParcelObserver
- {
- public:
- virtual void changed();
- };
};
static void cacheNameUpdateRefreshesBuyLand(const LLUUID&,
- const std::string&, const std::string&, BOOL, void* data)
+ const std::string&, const std::string&, BOOL)
{
- LLFloaterBuyLandUI* ui = LLFloaterBuyLandUI::soleInstance(false);
+ LLFloaterBuyLandUI* ui = LLFloaterReg::findTypedInstance<LLFloaterBuyLandUI>("buy_land");
if (ui)
{
ui->updateNames();
@@ -218,101 +221,64 @@ void LLFloaterBuyLand::buyLand(
return;
}
- LLFloaterBuyLandUI* ui = LLFloaterBuyLandUI::soleInstance(true);
- ui->setForGroup(is_for_group);
- ui->setParcel(region, parcel);
- ui->open(); /*Flawfinder: ignore*/
+ LLFloaterBuyLandUI* ui = LLFloaterReg::showTypedInstance<LLFloaterBuyLandUI>("buy_land");
+ if (ui)
+ {
+ ui->setForGroup(is_for_group);
+ ui->setParcel(region, parcel);
+ }
}
// static
void LLFloaterBuyLand::updateCovenantText(const std::string& string, const LLUUID &asset_id)
{
- LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE);
+ LLFloaterBuyLandUI* floater = LLFloaterReg::findTypedInstance<LLFloaterBuyLandUI>("buy_land");
if (floater)
{
- floater->updateCovenantText(string, asset_id);
+ floater->updateFloaterCovenantText(string, asset_id);
}
}
// static
void LLFloaterBuyLand::updateEstateName(const std::string& name)
{
- LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE);
+ LLFloaterBuyLandUI* floater = LLFloaterReg::findTypedInstance<LLFloaterBuyLandUI>("buy_land");
if (floater)
{
- floater->updateEstateName(name);
+ floater->updateFloaterEstateName(name);
}
}
// static
void LLFloaterBuyLand::updateLastModified(const std::string& text)
{
- LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE);
+ LLFloaterBuyLandUI* floater = LLFloaterReg::findTypedInstance<LLFloaterBuyLandUI>("buy_land");
if (floater)
{
- floater->updateLastModified(text);
+ floater->updateFloaterLastModified(text);
}
}
// static
void LLFloaterBuyLand::updateEstateOwnerName(const std::string& name)
{
- LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE);
+ LLFloaterBuyLandUI* floater = LLFloaterReg::findTypedInstance<LLFloaterBuyLandUI>("buy_land");
if (floater)
{
- floater->updateEstateOwnerName(name);
+ floater->updateFloaterEstateOwnerName(name);
}
}
// static
-BOOL LLFloaterBuyLand::isOpen()
+LLFloater* LLFloaterBuyLand::buildFloater(const LLSD& key)
{
- LLFloaterBuyLandUI* floater = LLFloaterBuyLandUI::soleInstance(FALSE);
- if (floater)
- {
- return floater->getVisible();
- }
- return FALSE;
-}
-
-// static
-LLFloaterBuyLandUI* LLFloaterBuyLandUI::sInstance = NULL;
-
-// static
-LLFloaterBuyLandUI* LLFloaterBuyLandUI::soleInstance(bool createIfNeeded)
-{
-#if !LL_RELEASE_FOR_DOWNLOAD
- if (createIfNeeded)
- {
- delete sInstance;
- sInstance = NULL;
- }
-#endif
- if (!sInstance && createIfNeeded)
- {
- sInstance = new LLFloaterBuyLandUI();
-
- LLUICtrlFactory::getInstance()->buildFloater(sInstance, "floater_buy_land.xml");
- sInstance->center();
-
- static bool observingCacheName = false;
- if (!observingCacheName)
- {
- gCacheName->addObserver(cacheNameUpdateRefreshesBuyLand);
- observingCacheName = true;
- }
-
- static SelectionObserver* parcelSelectionObserver = NULL;
- if (!parcelSelectionObserver)
- {
- parcelSelectionObserver = new SelectionObserver;
- LLViewerParcelMgr::getInstance()->addObserver(parcelSelectionObserver);
- }
- }
-
- return sInstance;
+ LLFloaterBuyLandUI* floater = new LLFloaterBuyLandUI(key);
+ return floater;
}
+//----------------------------------------------------------------------------
+// LLFloaterBuyLandUI
+//----------------------------------------------------------------------------
#if LL_WINDOWS
// passing 'this' during construction generates a warning. The callee
@@ -321,42 +287,45 @@ LLFloaterBuyLandUI* LLFloaterBuyLandUI::soleInstance(bool createIfNeeded)
// warning so that we can compile without generating a warning.
#pragma warning(disable : 4355)
#endif
-LLFloaterBuyLandUI::LLFloaterBuyLandUI()
-: LLFloater(std::string("Buy Land")),
+LLFloaterBuyLandUI::LLFloaterBuyLandUI(const LLSD& key)
+: LLFloater(LLSD()),
+ mParcelSelectionObserver(this),
mParcel(0),
mBought(false),
mParcelValid(false), mSiteValid(false),
mChildren(*this), mCurrency(*this), mTransaction(0),
mParcelBuyInfo(0)
{
+ static bool observingCacheName = false;
+ if (!observingCacheName)
+ {
+ gCacheName->addObserver(&cacheNameUpdateRefreshesBuyLand);
+ observingCacheName = true;
+ }
+
+ LLViewerParcelMgr::getInstance()->addObserver(&mParcelSelectionObserver);
+
+// LLUICtrlFactory::getInstance()->buildFloater(sInstance, "floater_buy_land.xml");
}
LLFloaterBuyLandUI::~LLFloaterBuyLandUI()
{
- delete mTransaction;
-
+ LLViewerParcelMgr::getInstance()->removeObserver(&mParcelSelectionObserver);
LLViewerParcelMgr::getInstance()->deleteParcelBuy(mParcelBuyInfo);
- if (sInstance == this)
- {
- sInstance = NULL;
- }
+ delete mTransaction;
}
void LLFloaterBuyLandUI::SelectionObserver::changed()
{
- LLFloaterBuyLandUI* ui = LLFloaterBuyLandUI::soleInstance(false);
- if (ui)
+ if (LLViewerParcelMgr::getInstance()->selectionEmpty())
{
- if (LLViewerParcelMgr::getInstance()->selectionEmpty())
- {
- ui->close();
- }
- else {
- ui->setParcel(
- LLViewerParcelMgr::getInstance()->getSelectionRegion(),
- LLViewerParcelMgr::getInstance()->getParcelSelection());
- }
+ mFloater->closeFloater();
+ }
+ else
+ {
+ mFloater->setParcel(LLViewerParcelMgr::getInstance()->getSelectionRegion(),
+ LLViewerParcelMgr::getInstance()->getParcelSelection());
}
}
@@ -566,8 +535,7 @@ void LLFloaterBuyLandUI::updateCovenantInfo()
{
check->set(false);
check->setEnabled(true);
- check->setCallbackUserData(this);
- check->setCommitCallback(onChangeAgreeCovenant);
+ check->setCommitCallback(onChangeAgreeCovenant, this);
}
LLTextBox* box = getChild<LLTextBox>("covenant_text");
@@ -595,51 +563,44 @@ void LLFloaterBuyLandUI::onChangeAgreeCovenant(LLUICtrl* ctrl, void* user_data)
}
}
-void LLFloaterBuyLandUI::updateCovenantText(const std::string &string, const LLUUID& asset_id)
+void LLFloaterBuyLandUI::updateFloaterCovenantText(const std::string &string, const LLUUID& asset_id)
{
LLViewerTextEditor* editor = getChild<LLViewerTextEditor>("covenant_editor");
- if (editor)
- {
- editor->setHandleEditKeysDirectly(FALSE);
- editor->setText(string);
+ editor->setText(string);
- LLCheckBoxCtrl* check = getChild<LLCheckBoxCtrl>("agree_covenant");
- LLTextBox* box = getChild<LLTextBox>("covenant_text");
- if(check && box)
- {
- if (asset_id.isNull())
- {
- check->set(true);
- check->setEnabled(false);
- refreshUI();
+ LLCheckBoxCtrl* check = getChild<LLCheckBoxCtrl>("agree_covenant");
+ LLTextBox* box = getChild<LLTextBox>("covenant_text");
+ if (asset_id.isNull())
+ {
+ check->set(true);
+ check->setEnabled(false);
+ refreshUI();
- // remove the line stating that you must agree
- box->setVisible(FALSE);
- }
- else
- {
- check->setEnabled(true);
+ // remove the line stating that you must agree
+ box->setVisible(FALSE);
+ }
+ else
+ {
+ check->setEnabled(true);
- // remove the line stating that you must agree
- box->setVisible(TRUE);
- }
- }
+ // remove the line stating that you must agree
+ box->setVisible(TRUE);
}
}
-void LLFloaterBuyLandUI::updateEstateName(const std::string& name)
+void LLFloaterBuyLandUI::updateFloaterEstateName(const std::string& name)
{
LLTextBox* box = getChild<LLTextBox>("estate_name_text");
if (box) box->setText(name);
}
-void LLFloaterBuyLandUI::updateLastModified(const std::string& text)
+void LLFloaterBuyLandUI::updateFloaterLastModified(const std::string& text)
{
LLTextBox* editor = getChild<LLTextBox>("covenant_timestamp_text");
if (editor) editor->setText(text);
}
-void LLFloaterBuyLandUI::updateEstateOwnerName(const std::string& name)
+void LLFloaterBuyLandUI::updateFloaterEstateOwnerName(const std::string& name)
{
LLTextBox* box = getChild<LLTextBox>("estate_owner_text");
if (box) box->setText(name);
@@ -836,8 +797,7 @@ void LLFloaterBuyLandUI::updateNames()
}
-void LLFloaterBuyLandUI::startTransaction(TransactionType type,
- LLXMLRPCValue params)
+void LLFloaterBuyLandUI::startTransaction(TransactionType type, const LLXMLRPCValue& params)
{
delete mTransaction;
mTransaction = NULL;
@@ -918,11 +878,15 @@ void LLFloaterBuyLandUI::tellUserError(
// virtual
BOOL LLFloaterBuyLandUI::postBuild()
{
+ mVisibleSignal.connect(boost::bind(&LLFloaterBuyLandUI::onVisibilityChange, this, _2));
+
mCurrency.prepare();
- childSetAction("buy_btn", onClickBuy, this);
- childSetAction("cancel_btn", onClickCancel, this);
- childSetAction("error_web", onClickErrorWeb, this);
+ getChild<LLUICtrl>("buy_btn")->setCommitCallback( boost::bind(&LLFloaterBuyLandUI::onClickBuy, this));
+ getChild<LLUICtrl>("cancel_btn")->setCommitCallback( boost::bind(&LLFloaterBuyLandUI::onClickCancel, this));
+ getChild<LLUICtrl>("error_web")->setCommitCallback( boost::bind(&LLFloaterBuyLandUI::onClickErrorWeb, this));
+
+ center();
return TRUE;
}
@@ -963,7 +927,7 @@ void LLFloaterBuyLandUI::draw()
if (mBought)
{
- close();
+ closeFloater();
}
else if (needsUpdate)
{
@@ -988,24 +952,14 @@ BOOL LLFloaterBuyLandUI::canClose()
return can_close;
}
-// virtual
-void LLFloaterBuyLandUI::setMinimized(BOOL minimize)
+void LLFloaterBuyLandUI::onVisibilityChange ( const LLSD& new_visibility )
{
- bool restored = (isMinimized() && !minimize);
- LLFloater::setMinimized(minimize);
- if (restored)
+ if (new_visibility.asBoolean())
{
refreshUI();
}
}
-void LLFloaterBuyLandUI::onClose(bool app_quitting)
-{
- LLFloater::onClose(app_quitting);
- destroy();
-}
-
-
void LLFloaterBuyLandUI::refreshUI()
{
// section zero: title area
@@ -1155,7 +1109,7 @@ void LLFloaterBuyLandUI::refreshUI()
if (mIsForGroup)
{
LLStringUtil::format_map_t string_args;
- string_args["[GROUP]"] = std::string(gAgent.mGroupName);
+ string_args["[GROUP]"] = std::string(gAgent.getGroupName());
message += getString("insufficient_land_credits", string_args);
@@ -1169,7 +1123,7 @@ void LLFloaterBuyLandUI::refreshUI()
if (!mParcelValid)
{
- message += "(no parcel selected)";
+ message += getString("no_parcel_selected");
}
else if (mParcelBillableArea == mParcelActualArea)
{
@@ -1225,12 +1179,10 @@ void LLFloaterBuyLandUI::refreshUI()
? LLViewChildren::BADGE_NOTE
: LLViewChildren::BADGE_OK);
- childSetText("purchase_action",
- llformat(
- "Pay L$ %d to %s for this land",
- mParcelPrice,
- mParcelSellerName.c_str()
- ));
+ LLStringUtil::format_map_t string_args;
+ string_args["[AMOUNT]"] = llformat("%d", mParcelPrice);
+ string_args["[SELLER]"] = mParcelSellerName;
+ childSetText("purchase_action", getString("pay_to_for_land", string_args));
childSetVisible("purchase_action", mParcelValid);
std::string reasonString;
@@ -1357,26 +1309,20 @@ void LLFloaterBuyLandUI::startBuyPostConfirm(const std::string& password)
}
-// static
-void LLFloaterBuyLandUI::onClickBuy(void* data)
+void LLFloaterBuyLandUI::onClickBuy()
{
- LLFloaterBuyLandUI* self = (LLFloaterBuyLandUI*)data;
- self->startBuyPreConfirm();
+ startBuyPreConfirm();
}
-// static
-void LLFloaterBuyLandUI::onClickCancel(void* data)
+void LLFloaterBuyLandUI::onClickCancel()
{
- LLFloaterBuyLandUI* self = (LLFloaterBuyLandUI*)data;
- self->close();
+ closeFloater();
}
-// static
-void LLFloaterBuyLandUI::onClickErrorWeb(void* data)
+void LLFloaterBuyLandUI::onClickErrorWeb()
{
- LLFloaterBuyLandUI* self = (LLFloaterBuyLandUI*)data;
- LLWeb::loadURLExternal(self->mCannotBuyURI);
- self->close();
+ LLWeb::loadURLExternal(mCannotBuyURI);
+ closeFloater();
}