diff options
author | brad kittenbrink <brad@lindenlab.com> | 2009-08-04 15:34:34 -0700 |
---|---|---|
committer | brad kittenbrink <brad@lindenlab.com> | 2009-08-04 15:34:34 -0700 |
commit | 33cc363a6813bf6c1268fa85747d1d403e00f8e5 (patch) | |
tree | d30696b245c4b5eb70575582d0dd9ddc4b20e5c7 /indra/newview/llfloaterbuycurrency.cpp | |
parent | dc62495da6e5c153c0df57fdbce6b0f40c0208f2 (diff) | |
parent | 89434ef6e64462041368ab26e049011fc84ae1e3 (diff) |
Merged in latest viewer-2.0.0-3 up through svn r129410. LLFloaterTOS needs some post-merge cleanup.
Diffstat (limited to 'indra/newview/llfloaterbuycurrency.cpp')
-rw-r--r-- | indra/newview/llfloaterbuycurrency.cpp | 98 |
1 files changed, 32 insertions, 66 deletions
diff --git a/indra/newview/llfloaterbuycurrency.cpp b/indra/newview/llfloaterbuycurrency.cpp index 4274650f2c..0107cb6fe2 100644 --- a/indra/newview/llfloaterbuycurrency.cpp +++ b/indra/newview/llfloaterbuycurrency.cpp @@ -37,6 +37,7 @@ // viewer includes #include "llcurrencyuimanager.h" #include "llfloater.h" +#include "llfloaterreg.h" #include "llstatusbar.h" #include "lltextbox.h" #include "llviewchildren.h" @@ -53,12 +54,7 @@ class LLFloaterBuyCurrencyUI : public LLFloater { public: - static LLFloaterBuyCurrencyUI* soleInstance(bool createIfNeeded); - -private: - static LLFloaterBuyCurrencyUI* sInstance; - - LLFloaterBuyCurrencyUI(); + LLFloaterBuyCurrencyUI(const LLSD& key); virtual ~LLFloaterBuyCurrencyUI(); @@ -81,30 +77,17 @@ public: virtual void draw(); virtual BOOL canClose(); - static void onClickBuy(void* data); - static void onClickCancel(void* data); - static void onClickErrorWeb(void* data); + void onClickBuy(); + void onClickCancel(); + void onClickErrorWeb(); }; - -// static -LLFloaterBuyCurrencyUI* LLFloaterBuyCurrencyUI::sInstance = NULL; - -// static -LLFloaterBuyCurrencyUI* LLFloaterBuyCurrencyUI::soleInstance(bool createIfNeeded) +LLFloater* LLFloaterBuyCurrency::buildFloater(const LLSD& key) { - if (!sInstance && createIfNeeded) - { - sInstance = new LLFloaterBuyCurrencyUI(); - - LLUICtrlFactory::getInstance()->buildFloater(sInstance, "floater_buy_currency.xml"); - sInstance->center(); - } - - return sInstance; + LLFloaterBuyCurrencyUI* floater = new LLFloaterBuyCurrencyUI(key); + return floater; } - #if LL_WINDOWS // passing 'this' during construction generates a warning. The callee // only uses the pointer to hold a reference to 'this' which is @@ -112,8 +95,8 @@ LLFloaterBuyCurrencyUI* LLFloaterBuyCurrencyUI::soleInstance(bool createIfNeeded // warning so that we can compile without generating a warning. #pragma warning(disable : 4355) #endif -LLFloaterBuyCurrencyUI::LLFloaterBuyCurrencyUI() -: LLFloater(), +LLFloaterBuyCurrencyUI::LLFloaterBuyCurrencyUI(const LLSD& key) +: LLFloater(key), mChildren(*this), mManager(*this) { @@ -121,10 +104,6 @@ LLFloaterBuyCurrencyUI::LLFloaterBuyCurrencyUI() LLFloaterBuyCurrencyUI::~LLFloaterBuyCurrencyUI() { - if (sInstance == this) - { - sInstance = NULL; - } } @@ -156,11 +135,14 @@ BOOL LLFloaterBuyCurrencyUI::postBuild() { mManager.prepare(); - childSetAction("buy_btn", onClickBuy, this); - childSetAction("cancel_btn", onClickCancel, this); - childSetAction("error_web", onClickErrorWeb, this); - + getChild<LLUICtrl>("buy_btn")->setCommitCallback( boost::bind(&LLFloaterBuyCurrencyUI::onClickBuy, this)); + getChild<LLUICtrl>("cancel_btn")->setCommitCallback( boost::bind(&LLFloaterBuyCurrencyUI::onClickCancel, this)); + getChild<LLUICtrl>("error_web")->setCommitCallback( boost::bind(&LLFloaterBuyCurrencyUI::onClickErrorWeb, this)); + + center(); + updateUI(); + return TRUE; } @@ -312,57 +294,41 @@ void LLFloaterBuyCurrencyUI::updateUI() } } -// static -void LLFloaterBuyCurrencyUI::onClickBuy(void* data) +void LLFloaterBuyCurrencyUI::onClickBuy() { - LLFloaterBuyCurrencyUI* self = LLFloaterBuyCurrencyUI::soleInstance(false); - if (self) - { - self->mManager.buy(self->getString("buy_currency")); - self->updateUI(); - // JC: updateUI() doesn't get called again until progress is made - // with transaction processing, so the "Purchase" button would be - // left enabled for some time. Pre-emptively disable. - self->childSetEnabled("buy_btn", false); - } + mManager.buy(getString("buy_currency")); + updateUI(); + // JC: updateUI() doesn't get called again until progress is made + // with transaction processing, so the "Purchase" button would be + // left enabled for some time. Pre-emptively disable. + childSetEnabled("buy_btn", false); } -// static -void LLFloaterBuyCurrencyUI::onClickCancel(void* data) +void LLFloaterBuyCurrencyUI::onClickCancel() { - LLFloaterBuyCurrencyUI* self = LLFloaterBuyCurrencyUI::soleInstance(false); - if (self) - { - self->closeFloater(); - } + closeFloater(); } -// static -void LLFloaterBuyCurrencyUI::onClickErrorWeb(void* data) +void LLFloaterBuyCurrencyUI::onClickErrorWeb() { - LLFloaterBuyCurrencyUI* self = LLFloaterBuyCurrencyUI::soleInstance(false); - if (self) - { - LLWeb::loadURLExternal(self->mManager.errorURI()); - self->closeFloater(); - } + LLWeb::loadURLExternal(mManager.errorURI()); + closeFloater(); } // static void LLFloaterBuyCurrency::buyCurrency() { - LLFloaterBuyCurrencyUI* ui = LLFloaterBuyCurrencyUI::soleInstance(true); + LLFloaterBuyCurrencyUI* ui = LLFloaterReg::showTypedInstance<LLFloaterBuyCurrencyUI>("buy_currency"); ui->noTarget(); ui->updateUI(); - ui->openFloater(); } +// static void LLFloaterBuyCurrency::buyCurrency(const std::string& name, S32 price) { - LLFloaterBuyCurrencyUI* ui = LLFloaterBuyCurrencyUI::soleInstance(true); + LLFloaterBuyCurrencyUI* ui = LLFloaterReg::showTypedInstance<LLFloaterBuyCurrencyUI>("buy_currency"); ui->target(name, price); ui->updateUI(); - ui->openFloater(); } |