summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterbuycurrency.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterbuycurrency.cpp')
-rw-r--r--indra/newview/llfloaterbuycurrency.cpp98
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();
}