summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llcurrencyuimanager.cpp121
-rw-r--r--indra/newview/llcurrencyuimanager.h9
-rw-r--r--indra/newview/llfloaterbuyland.cpp16
-rw-r--r--indra/newview/skins/default/xui/en/floater_buy_land.xml8
4 files changed, 116 insertions, 38 deletions
diff --git a/indra/newview/llcurrencyuimanager.cpp b/indra/newview/llcurrencyuimanager.cpp
index c4bfd71999..319cbf8209 100644
--- a/indra/newview/llcurrencyuimanager.cpp
+++ b/indra/newview/llcurrencyuimanager.cpp
@@ -76,8 +76,15 @@ public:
bool mUserEnteredCurrencyBuy;
// from website
- bool mSiteCurrencyEstimated;
- S32 mSiteCurrencyEstimatedCost;
+
+ // pre-viewer 2.0, the server returned estimates as an
+ // integer US cents value, e.g., "1000" for $10.00
+ // post-viewer 2.0, the server may also return estimates
+ // as a string with currency embedded, e.g., "10.00 Euros"
+ bool mUSDCurrencyEstimated;
+ S32 mUSDCurrencyEstimatedCost;
+ bool mLocalCurrencyEstimated;
+ std::string mLocalCurrencyEstimatedCost;
std::string mSiteConfirm;
bool mBought;
@@ -101,6 +108,10 @@ public:
void startCurrencyBuy(const std::string& password);
void finishCurrencyBuy();
+
+ void clearEstimate();
+ bool hasEstimate() const;
+ std::string getLocalEstimate() const;
void startTransaction(TransactionType type,
const char* method, LLXMLRPCValue params);
@@ -126,12 +137,11 @@ LLCurrencyUIManager::Impl::Impl(LLPanel& dialog)
mError(false),
mUserCurrencyBuy(2000), // note, this is a default, real value set in llfloaterbuycurrency.cpp
mUserEnteredCurrencyBuy(false),
- mSiteCurrencyEstimated(false),
- mSiteCurrencyEstimatedCost(0),
mBought(false),
mTransactionType(TransactionNone), mTransaction(0),
mCurrencyChanged(false)
{
+ clearEstimate();
}
LLCurrencyUIManager::Impl::~Impl()
@@ -141,14 +151,13 @@ LLCurrencyUIManager::Impl::~Impl()
void LLCurrencyUIManager::Impl::updateCurrencyInfo()
{
- mSiteCurrencyEstimated = false;
- mSiteCurrencyEstimatedCost = 0;
+ clearEstimate();
mBought = false;
mCurrencyChanged = false;
if (mUserCurrencyBuy == 0)
{
- mSiteCurrencyEstimated = true;
+ mLocalCurrencyEstimated = true;
return;
}
@@ -185,9 +194,21 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo()
}
LLXMLRPCValue currency = result["currency"];
- mSiteCurrencyEstimated = true;
- mSiteCurrencyEstimatedCost = currency["estimatedCost"].asInt();
-
+
+ // old XML-RPC server: estimatedCost = value in US cents
+ mUSDCurrencyEstimated = currency["estimatedCost"].isValid();
+ if (mUSDCurrencyEstimated)
+ {
+ mUSDCurrencyEstimatedCost = currency["estimatedCost"].asInt();
+ }
+
+ // newer XML-RPC server: estimatedLocalCost = local currency string
+ mLocalCurrencyEstimated = currency["estimatedLocalCost"].isValid();
+ if (mLocalCurrencyEstimated)
+ {
+ mLocalCurrencyEstimatedCost = currency["estimatedLocalCost"].asString();
+ }
+
S32 newCurrencyBuy = currency["currencyBuy"].asInt();
if (newCurrencyBuy != mUserCurrencyBuy)
{
@@ -200,17 +221,20 @@ void LLCurrencyUIManager::Impl::finishCurrencyInfo()
void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password)
{
- mSiteCurrencyEstimated = false;
- mSiteCurrencyEstimatedCost = 0;
- mCurrencyChanged = false;
-
LLXMLRPCValue keywordArgs = LLXMLRPCValue::createStruct();
keywordArgs.appendString("agentId", gAgent.getID().asString());
keywordArgs.appendString(
"secureSessionId",
gAgent.getSecureSessionID().asString());
keywordArgs.appendInt("currencyBuy", mUserCurrencyBuy);
- keywordArgs.appendInt("estimatedCost", mSiteCurrencyEstimatedCost);
+ if (mUSDCurrencyEstimated)
+ {
+ keywordArgs.appendInt("estimatedCost", mUSDCurrencyEstimatedCost);
+ }
+ if (mLocalCurrencyEstimated)
+ {
+ keywordArgs.appendString("estimatedLocalCost", mLocalCurrencyEstimatedCost);
+ }
keywordArgs.appendString("confirm", mSiteConfirm);
if (!password.empty())
{
@@ -226,6 +250,9 @@ void LLCurrencyUIManager::Impl::startCurrencyBuy(const std::string& password)
params.append(keywordArgs);
startTransaction(TransactionBuy, "buyCurrency", params);
+
+ clearEstimate();
+ mCurrencyChanged = false;
}
void LLCurrencyUIManager::Impl::finishCurrencyBuy()
@@ -270,6 +297,34 @@ void LLCurrencyUIManager::Impl::startTransaction(TransactionType type,
clearError();
}
+void LLCurrencyUIManager::Impl::clearEstimate()
+{
+ mUSDCurrencyEstimated = false;
+ mUSDCurrencyEstimatedCost = 0;
+ mLocalCurrencyEstimated = false;
+ mLocalCurrencyEstimatedCost = "0";
+}
+
+bool LLCurrencyUIManager::Impl::hasEstimate() const
+{
+ return (mUSDCurrencyEstimated || mLocalCurrencyEstimated);
+}
+
+std::string LLCurrencyUIManager::Impl::getLocalEstimate() const
+{
+ if (mLocalCurrencyEstimated)
+ {
+ // we have the new-style local currency string
+ return mLocalCurrencyEstimatedCost;
+ }
+ if (mUSDCurrencyEstimated)
+ {
+ // we have the old-style USD-specific value
+ return "US$ " + llformat("%#.2f", mUSDCurrencyEstimatedCost / 100.0);
+ }
+ return "";
+}
+
bool LLCurrencyUIManager::Impl::checkTransaction()
{
if (!mTransaction)
@@ -342,8 +397,8 @@ void LLCurrencyUIManager::Impl::currencyKey(S32 value)
mUserCurrencyBuy = value;
- if (mSiteCurrencyEstimated) {
- mSiteCurrencyEstimated = false;
+ if (hasEstimate()) {
+ clearEstimate();
//cannot just simply refresh the whole UI, as the edit field will
// get reset and the cursor will change...
@@ -406,8 +461,8 @@ void LLCurrencyUIManager::Impl::updateUI()
}
}
- mPanel.childSetTextArg("currency_est", "[LOCALAMOUNT]", "US$ " + llformat("%#.2f", mSiteCurrencyEstimatedCost / 100.0));
- mPanel.childSetVisible("currency_est", mSiteCurrencyEstimated && mUserCurrencyBuy > 0);
+ mPanel.childSetTextArg("currency_est", "[LOCALAMOUNT]", getLocalEstimate());
+ mPanel.childSetVisible("currency_est", hasEstimate() && mUserCurrencyBuy > 0);
if (mPanel.childIsEnabled("buy_btn")
||mPanel.childIsVisible("currency_est")
@@ -448,18 +503,32 @@ void LLCurrencyUIManager::setZeroMessage(const std::string& message)
impl.mZeroMessage = message;
}
-void LLCurrencyUIManager::setEstimate(int amount)
+void LLCurrencyUIManager::setUSDEstimate(int amount)
+{
+ impl.mUSDCurrencyEstimatedCost = amount;
+ impl.mUSDCurrencyEstimated = true;
+ impl.updateUI();
+
+ impl.mCurrencyChanged = false;
+}
+
+int LLCurrencyUIManager::getUSDEstimate()
+{
+ return impl.mUSDCurrencyEstimated ? impl.mUSDCurrencyEstimatedCost : 0;
+}
+
+void LLCurrencyUIManager::setLocalEstimate(const std::string &amount)
{
- impl.mSiteCurrencyEstimatedCost = amount;
- impl.mSiteCurrencyEstimated = true;
+ impl.mLocalCurrencyEstimatedCost = amount;
+ impl.mLocalCurrencyEstimated = true;
impl.updateUI();
impl.mCurrencyChanged = false;
}
-int LLCurrencyUIManager::getEstimate()
+std::string LLCurrencyUIManager::getLocalEstimate() const
{
- return impl.mSiteCurrencyEstimated ? impl.mSiteCurrencyEstimatedCost : 0;
+ return impl.getLocalEstimate();
}
void LLCurrencyUIManager::prepare()
@@ -490,7 +559,7 @@ void LLCurrencyUIManager::buy(const std::string& buy_msg)
LLUIString msg = buy_msg;
msg.setArg("[LINDENS]", llformat("%d", impl.mUserCurrencyBuy));
- msg.setArg("[LOCALAMOUNT]", "US$ " + llformat("%#.2f", impl.mSiteCurrencyEstimatedCost / 100.0));
+ msg.setArg("[LOCALAMOUNT]", getLocalEstimate());
LLConfirmationManager::confirm(impl.mSiteConfirm,
msg,
impl,
@@ -511,7 +580,7 @@ bool LLCurrencyUIManager::canCancel()
bool LLCurrencyUIManager::canBuy()
{
return impl.mTransactionType == Impl::TransactionNone
- && impl.mSiteCurrencyEstimated
+ && impl.hasEstimate()
&& impl.mUserCurrencyBuy > 0;
}
diff --git a/indra/newview/llcurrencyuimanager.h b/indra/newview/llcurrencyuimanager.h
index 93427aed7f..dfe027098d 100644
--- a/indra/newview/llcurrencyuimanager.h
+++ b/indra/newview/llcurrencyuimanager.h
@@ -57,11 +57,16 @@ public:
void setZeroMessage(const std::string& message);
// sets the gray message to show when zero
- void setEstimate(int);
- int getEstimate();
+ void setUSDEstimate(int); // deprecated in 2.0
+ int getUSDEstimate(); // deprecated in 2.0
// the amount in US$ * 100 (in otherwords, in cents)
// use set when you get this information from elsewhere
+ void setLocalEstimate(const std::string &local_est);
+ std::string getLocalEstimate() const;
+ // the estimated cost in the user's local currency
+ // for example, "US$ 10.00" or "10.00 Euros"
+
void prepare();
// call once after dialog is built, from postBuild()
void updateUI(bool show = true);
diff --git a/indra/newview/llfloaterbuyland.cpp b/indra/newview/llfloaterbuyland.cpp
index 36f0315790..467796b4a3 100644
--- a/indra/newview/llfloaterbuyland.cpp
+++ b/indra/newview/llfloaterbuyland.cpp
@@ -685,7 +685,14 @@ void LLFloaterBuyLandUI::finishWebSiteInfo()
mSiteLandUseAction = landUse["action"].asString();
LLXMLRPCValue currency = result["currency"];
- mCurrency.setEstimate(currency["estimatedCost"].asInt());
+ if (currency["estimatedCost"].isValid())
+ {
+ mCurrency.setUSDEstimate(currency["estimatedCost"].asInt());
+ }
+ if (currency["estimatedLocalCost"].isValid())
+ {
+ mCurrency.setLocalEstimate(currency["estimatedLocalCost"].asString());
+ }
mSiteConfirm = result["confirm"].asString();
}
@@ -733,7 +740,8 @@ void LLFloaterBuyLandUI::runWebSitePrep(const std::string& password)
keywordArgs.appendInt("billableArea",
mIsForGroup ? 0 : mParcelBillableArea);
keywordArgs.appendInt("currencyBuy", mCurrency.getAmount());
- keywordArgs.appendInt("estimatedCost", mCurrency.getEstimate());
+ keywordArgs.appendInt("estimatedCost", mCurrency.getUSDEstimate());
+ keywordArgs.appendString("estimatedLocalCost", mCurrency.getLocalEstimate());
keywordArgs.appendString("confirm", mSiteConfirm);
if (!password.empty())
{
@@ -1217,7 +1225,7 @@ void LLFloaterBuyLandUI::refreshUI()
childSetText("currency_reason", getString("not_enough_lindens", string_args));
- childSetTextArg("currency_est", "[AMOUNT2]", llformat("%#.2f", mCurrency.getEstimate() / 100.0));
+ childSetTextArg("currency_est", "[LOCAL_AMOUNT]", mCurrency.getLocalEstimate());
}
if (willHaveEnough)
@@ -1297,7 +1305,7 @@ void LLFloaterBuyLandUI::startBuyPreConfirm()
{
LLStringUtil::format_map_t string_args;
string_args["[AMOUNT]"] = llformat("%d", mCurrency.getAmount());
- string_args["[AMOUNT2]"] = llformat("%#.2f", mCurrency.getEstimate() / 100.0);
+ string_args["[LOCAL_AMOUNT]"] = mCurrency.getLocalEstimate();
action += getString("buy_for_US", string_args);
}
diff --git a/indra/newview/skins/default/xui/en/floater_buy_land.xml b/indra/newview/skins/default/xui/en/floater_buy_land.xml
index 0f710a8047..6e0c3dfe54 100644
--- a/indra/newview/skins/default/xui/en/floater_buy_land.xml
+++ b/indra/newview/skins/default/xui/en/floater_buy_land.xml
@@ -115,7 +115,7 @@ Try selecting a smaller area.
</floater.string>
<floater.string
name="buy_for_US">
- Buy L$ [AMOUNT] for approx. US$ [AMOUNT2],
+ Buy L$ [AMOUNT] for approx. [LOCAL_AMOUNT],
</floater.string>
<floater.string
name="parcel_meters">
@@ -172,10 +172,6 @@ supports [AMOUNT2] objects
name="no_parcel_selected">
(no parcel selected)
</floater.string>
- <floater.string
- name="buy_currency">
- Buy L$ [LINDENS] for approx. US$ [USD]
- </floater.string>
<text
type="string"
length="1"
@@ -667,7 +663,7 @@ This parcel is 512 m² of land.
name="currency_est"
top="409"
width="178">
- for approx. US$ [AMOUNT2]
+ for approx. [LOCAL_AMOUNT]
</text>
<text
type="string"