diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-19 12:57:33 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-10-19 12:57:33 +0000 |
commit | c3e36e443698b001e98219e48cc97e259ada0a1d (patch) | |
tree | d0224b1d52691eb4b27daaff4d556990bda69e81 /src | |
parent | 4ea68b6102053d591516ff3bc83512c71e2c8ce9 (diff) | |
download | mana-client-c3e36e443698b001e98219e48cc97e259ada0a1d.tar.gz mana-client-c3e36e443698b001e98219e48cc97e259ada0a1d.tar.bz2 mana-client-c3e36e443698b001e98219e48cc97e259ada0a1d.tar.xz mana-client-c3e36e443698b001e98219e48cc97e259ada0a1d.zip |
Marked buy and sell dialog boxes as translatable.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/buy.cpp | 34 | ||||
-rw-r--r-- | src/gui/sell.cpp | 38 |
2 files changed, 39 insertions, 33 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index bbf2102e..7912bf13 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -34,10 +34,11 @@ #include "../npc.h" #include "../net/gameserver/player.h" #include "../resources/itemdb.h" -#include "../utils/tostring.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" BuyDialog::BuyDialog(): - Window("Buy"), + Window(_("Buy")), mMoney(0), mAmountItems(0), mMaxItems(0) { setResizable(true); @@ -51,13 +52,13 @@ BuyDialog::BuyDialog(): mScrollArea = new ScrollArea(mShopItemList); mSlider = new Slider(1.0); mQuantityLabel = new gcn::Label("0"); - mMoneyLabel = new gcn::Label("Price : 0 GP / 0 GP"); + mMoneyLabel = new gcn::Label(strprintf(_("Price: %d GP / Total: %d GP"), 0, 0)); mIncreaseButton = new Button("+", "+", this); mDecreaseButton = new Button("-", "-", this); - mBuyButton = new Button("Buy", "buy", this); - mQuitButton = new Button("Quit", "quit", this); - mItemDescLabel = new gcn::Label("Description:"); - mItemEffectLabel = new gcn::Label("Effect:"); + mBuyButton = new Button(_("Buy"), "buy", this); + mQuitButton = new Button(_("Quit"), "quit", this); + mItemDescLabel = new gcn::Label(strprintf(_("Description: %s"), "")); + mItemEffectLabel = new gcn::Label(strprintf(_("Effect: %s"), "")); mIncreaseButton->setSize(20, 20); mDecreaseButton->setSize(20, 20); @@ -159,7 +160,7 @@ void BuyDialog::action(const gcn::ActionEvent &event) } // TODO: Actually we'd have a bug elsewhere if this check for the number // of items to be bought ever fails, Bertram removed the assertions, is - // there a better way to ensure this fails in an _obivous_ way in C++? + // there a better way to ensure this fails in an _obvious_ way in C++? else if (event.getId() == "buy" && mAmountItems > 0 && mAmountItems <= mMaxItems) { @@ -241,8 +242,10 @@ BuyDialog::updateButtonsAndLabels() { const ItemInfo &info = ItemDB::get(mShopItems->at(selectedItem).id); - mItemDescLabel->setCaption("Description: " + info.getDescription()); - mItemEffectLabel->setCaption("Effect: " + info.getEffect()); + mItemDescLabel->setCaption + (strprintf(_("Description: %s"), info.getDescription().c_str())); + mItemEffectLabel->setCaption + (strprintf(_("Effect: %s"), info.getEffect().c_str())); // Calculate how many the player can afford mMaxItems = mMoney / mShopItems->at(selectedItem).price; @@ -256,8 +259,8 @@ BuyDialog::updateButtonsAndLabels() } else { - mItemDescLabel->setCaption("Description:"); - mItemEffectLabel->setCaption("Effect:"); + mItemDescLabel->setCaption(strprintf(_("Description: %s"), "")); + mItemEffectLabel->setCaption(strprintf(_("Effect: %s"), "")); mMaxItems = 0; mAmountItems = 0; } @@ -269,8 +272,7 @@ BuyDialog::updateButtonsAndLabels() mSlider->setEnabled(mMaxItems > 1); // Update quantity and money labels - mQuantityLabel->setCaption( - toString(mAmountItems) + " / " + toString(mMaxItems)); - mMoneyLabel->setCaption("Price: " + toString(price) + " GP / " - + toString(mMoney - price) + " GP" ); + mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems)); + mMoneyLabel->setCaption + (strprintf(_("Price: %d GP / Total: %d GP"), price, mMoney - price)); } diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 5f1011c1..ff6fa17f 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -38,10 +38,11 @@ #include "../net/gameserver/player.h" #include "../resources/itemdb.h" #include "../resources/iteminfo.h" -#include "../utils/tostring.h" +#include "../utils/gettext.h" +#include "../utils/strprintf.h" SellDialog::SellDialog(): - Window("Sell"), + Window(_("Sell")), mMaxItems(0), mAmountItems(0) { setResizable(true); @@ -55,13 +56,13 @@ SellDialog::SellDialog(): mScrollArea = new ScrollArea(mShopItemList); mSlider = new Slider(1.0); mQuantityLabel = new gcn::Label("0"); - mMoneyLabel = new gcn::Label("Money: 0 GP / Total: 0 GP"); + mMoneyLabel = new gcn::Label(strprintf(_("Price: %d GP / Total: %d GP"), 0, 0)); mIncreaseButton = new Button("+", "+", this); mDecreaseButton = new Button("-", "-", this); - mSellButton = new Button("Sell", "sell", this); - mQuitButton = new Button("Quit", "quit", this); - mItemDescLabel = new gcn::Label("Description:"); - mItemEffectLabel = new gcn::Label("Effect:"); + mSellButton = new Button(_("Sell"), "sell", this); + mQuitButton = new Button(_("Quit"), "quit", this); + mItemDescLabel = new gcn::Label(strprintf(_("Description: %s"), "")); + mItemEffectLabel = new gcn::Label(strprintf(_("Effect: %s"), "")); mIncreaseButton->setSize(20, 20); mDecreaseButton->setSize(20, 20); @@ -249,6 +250,13 @@ SellDialog::updateButtonsAndLabels() if (selectedItem > -1) { + const ItemInfo &info = ItemDB::get(mShopItems->at(selectedItem).id); + + mItemDescLabel->setCaption + (strprintf(_("Description: %s"), info.getDescription().c_str())); + mItemEffectLabel->setCaption + (strprintf(_("Effect: %s"), info.getEffect().c_str())); + mMaxItems = mShopItems->at(selectedItem).quantity; if (mAmountItems > mMaxItems) { @@ -256,17 +264,13 @@ SellDialog::updateButtonsAndLabels() } income = mAmountItems * mShopItems->at(selectedItem).price; - - const ItemInfo &info = ItemDB::get(mShopItems->at(selectedItem).id); - mItemDescLabel->setCaption("Description: " + info.getDescription()); - mItemEffectLabel->setCaption("Effect: " + info.getEffect()); } else { + mItemDescLabel->setCaption(strprintf(_("Description: %s"), "")); + mItemEffectLabel->setCaption(strprintf(_("Effect: %s"), "")); mMaxItems = 0; mAmountItems = 0; - mItemDescLabel->setCaption("Description:"); - mItemEffectLabel->setCaption("Effect:"); } // Update Buttons and slider @@ -276,8 +280,8 @@ SellDialog::updateButtonsAndLabels() mSlider->setEnabled(mMaxItems > 1); // Update the quantity and money labels - mQuantityLabel->setCaption( - toString(mAmountItems) + " / " + toString(mMaxItems)); - mMoneyLabel->setCaption("Money: " + toString(income) + " GP / Total: " - + toString(mPlayerMoney + income) + " GP"); + mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems)); + mMoneyLabel->setCaption + (strprintf(_("Price: %d GP / Total: %d GP"), + income, mPlayerMoney + income)); } |