summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-02-15 11:29:40 +0000
committerJared Adams <jaxad0127@gmail.com>2009-02-15 11:29:40 +0000
commit79e803232438d41cce80467a97e9efde8e6c0c70 (patch)
treef8fd399a13913ccbc6942f6385f9852426f9ebf1 /src/gui
parent0a106989bd16c48525f01cb8515809e74f37a8d8 (diff)
downloadmana-79e803232438d41cce80467a97e9efde8e6c0c70.tar.gz
mana-79e803232438d41cce80467a97e9efde8e6c0c70.tar.bz2
mana-79e803232438d41cce80467a97e9efde8e6c0c70.tar.xz
mana-79e803232438d41cce80467a97e9efde8e6c0c70.zip
Add configurable units system
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/buy.cpp8
-rw-r--r--src/gui/char_select.cpp22
-rw-r--r--src/gui/char_select.h2
-rw-r--r--src/gui/chat.cpp2
-rw-r--r--src/gui/inventorywindow.cpp18
-rw-r--r--src/gui/inventorywindow.h3
-rw-r--r--src/gui/itempopup.cpp6
-rw-r--r--src/gui/sell.cpp11
-rw-r--r--src/gui/status.cpp15
-rw-r--r--src/gui/status.h2
-rw-r--r--src/gui/trade.cpp8
11 files changed, 63 insertions, 34 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 0c8c4d9d..23bf89f5 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -31,6 +31,7 @@
#include "widgets/layout.h"
#include "../npc.h"
+#include "../units.h"
#include "../net/messageout.h"
#include "../net/protocol.h"
@@ -54,7 +55,8 @@ BuyDialog::BuyDialog(Network *network):
mScrollArea = new ScrollArea(mShopItemList);
mSlider = new Slider(1.0);
mQuantityLabel = new gcn::Label("0");
- mMoneyLabel = new gcn::Label(strprintf(_("Price: %d GP / Total: %d GP"), 0, 0));
+ mMoneyLabel = new gcn::Label(strprintf(_("Price: %s / Total: %s"),
+ "", ""));
mIncreaseButton = new Button("+", "+", this);
mDecreaseButton = new Button("-", "-", this);
mBuyButton = new Button(_("Buy"), "buy", this);
@@ -235,5 +237,7 @@ void BuyDialog::updateButtonsAndLabels()
// Update quantity and money labels
mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
mMoneyLabel->setCaption
- (strprintf(_("Price: %d GP / Total: %d GP"), price, mMoney - price));
+ (strprintf(_("Price: %s / Total: %s"),
+ Units::formatCurrency(price).c_str(),
+ Units::formatCurrency(mMoney - price).c_str()));
}
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 8de4f5a7..34174275 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -37,6 +37,7 @@
#include "../game.h"
#include "../localplayer.h"
#include "../main.h"
+#include "../units.h"
#include "../net/charserverhandler.h"
#include "../net/messageout.h"
@@ -85,6 +86,9 @@ CharSelectDialog::CharSelectDialog(Network *network,
Window(_("Select Character")), mNetwork(network),
mCharInfo(charInfo), mGender(gender), mCharSelected(false)
{
+ LocalPlayer *pi = mCharInfo->getEntry();
+ if (pi)
+ mMoney = Units::formatCurrency(pi->mGp);
// Control that shows the Player
mPlayerBox = new PlayerBox;
mPlayerBox->setWidth(74);
@@ -92,7 +96,7 @@ CharSelectDialog::CharSelectDialog(Network *network,
mNameLabel = new gcn::Label(strprintf(_("Name: %s"), ""));
mLevelLabel = new gcn::Label(strprintf(_("Level: %d"), 0));
mJobLevelLabel = new gcn::Label(strprintf(_("Job Level: %d"), 0));
- mMoneyLabel = new gcn::Label(strprintf(_("Money: %d"), 0));
+ mMoneyLabel = new gcn::Label(strprintf(_("Money: %s"), mMoney.c_str()));
const std::string tempString = getFont()->getWidth(_("New")) <
getFont()->getWidth(_("Delete")) ?
@@ -163,10 +167,16 @@ void CharSelectDialog::action(const gcn::ActionEvent &event)
else if (event.getId() == "previous")
{
mCharInfo->prev();
+ LocalPlayer *pi = mCharInfo->getEntry();
+ if (pi)
+ mMoney = Units::formatCurrency(pi->mGp);
}
else if (event.getId() == "next")
{
mCharInfo->next();
+ LocalPlayer *pi = mCharInfo->getEntry();
+ if (pi)
+ mMoney = Units::formatCurrency(pi->mGp);
}
}
@@ -176,10 +186,12 @@ void CharSelectDialog::updatePlayerInfo()
if (pi)
{
- mNameLabel->setCaption(strprintf(_("Name: %s"), pi->getName().c_str()));
+ mNameLabel->setCaption(strprintf(_("Name: %s"),
+ pi->getName().c_str()));
mLevelLabel->setCaption(strprintf(_("Level: %d"), pi->mLevel));
- mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"), pi->mJobLevel));
- mMoneyLabel->setCaption(strprintf(_("Gold: %d"), pi->mGp));
+ mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"),
+ pi->mJobLevel));
+ mMoneyLabel->setCaption(strprintf(_("Money: %s"), mMoney.c_str()));
if (!mCharSelected)
{
mNewDelCharButton->setCaption(_("Delete"));
@@ -191,7 +203,7 @@ void CharSelectDialog::updatePlayerInfo()
mNameLabel->setCaption(strprintf(_("Name: %s"), ""));
mLevelLabel->setCaption(strprintf(_("Level: %d"), 0));
mJobLevelLabel->setCaption(strprintf(_("Job Level: %d"), 0));
- mMoneyLabel->setCaption(strprintf(_("Money: %d"), 0));
+ mMoneyLabel->setCaption(strprintf(_("Money: %s"), 0));
mNewDelCharButton->setCaption(_("New"));
mSelectButton->setEnabled(false);
}
diff --git a/src/gui/char_select.h b/src/gui/char_select.h
index 23de061d..28091a18 100644
--- a/src/gui/char_select.h
+++ b/src/gui/char_select.h
@@ -71,7 +71,7 @@ class CharSelectDialog : public Window, public gcn::ActionListener
gcn::Label *mNameLabel;
gcn::Label *mLevelLabel;
gcn::Label *mJobLevelLabel;
- gcn::Label *mMoneyLabel;
+ gcn::Label *mMoneyLabel; std::string mMoney;
PlayerBox *mPlayerBox;
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 484426dd..21e4f106 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -667,7 +667,7 @@ std::string ChatWindow::const_msg(CHATSKILL act)
msg += _("You cannot do that right now!");
break;
case RFAIL_ZENY:
- msg += _("Seems you need more GP... ;-)");
+ msg += _("Seems you need more money... ;-)");
break;
case RFAIL_WEAPON:
msg += _("You cannot use this skill with that kind of weapon!");
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index af3b29a2..6debf473 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -38,6 +38,7 @@
#include "../inventory.h"
#include "../item.h"
+#include "../units.h"
#include "../resources/iteminfo.h"
@@ -76,8 +77,8 @@ InventoryWindow::InventoryWindow(int invSize):
mInvenScroll = new ScrollArea(mItems);
mInvenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
- mTotalWeight = toString(player_node->mTotalWeight);
- mMaxWeight = toString(player_node->mMaxWeight);
+ mTotalWeight = -1;
+ mMaxWeight = -1;
mUsedSlots = toString(player_node->getInventory()->getNumberOfSlotsUsed());
mSlotsLabel = new gcn::Label(_("Slots: "));
@@ -124,12 +125,12 @@ void InventoryWindow::logic()
// redesign of InventoryWindow and ItemContainer probably.
updateButtons();
- if ((mMaxWeight != toString(player_node->mMaxWeight)) ||
- mTotalWeight != toString(player_node->mTotalWeight) ||
+ if (mMaxWeight != player_node->mMaxWeight ||
+ mTotalWeight != player_node->mTotalWeight ||
mUsedSlots != toString(player_node->getInventory()->getNumberOfSlotsUsed()))
{
- mTotalWeight = toString(player_node->mTotalWeight);
- mMaxWeight = toString(player_node->mMaxWeight);
+ mTotalWeight = player_node->mTotalWeight;
+ mMaxWeight = player_node->mMaxWeight;
mUsedSlots = toString(player_node->getInventory()->getNumberOfSlotsUsed());
// Weight Bar coloration
@@ -154,8 +155,9 @@ void InventoryWindow::logic()
player_node->mMaxWeight);
mSlotsBar->setText(strprintf("%s/%d", mUsedSlots.c_str(), mMaxSlots));
- mWeightBar->setText(strprintf("%sg/%sg", mTotalWeight.c_str(),
- mMaxWeight.c_str()));
+ mWeightBar->setText(strprintf("%s/%s",
+ Units::formatWeight(mTotalWeight).c_str(),
+ Units::formatWeight(mMaxWeight).c_str()));
}
}
diff --git a/src/gui/inventorywindow.h b/src/gui/inventorywindow.h
index 78d30461..6c66b95e 100644
--- a/src/gui/inventorywindow.h
+++ b/src/gui/inventorywindow.h
@@ -78,8 +78,7 @@ class InventoryWindow : public Window, gcn::ActionListener,
std::string mWeight;
std::string mSlots;
std::string mUsedSlots;
- std::string mTotalWeight;
- std::string mMaxWeight;
+ int mTotalWeight, mMaxWeight;
gcn::Button *mUseButton, *mDropButton;
gcn::ScrollArea *mInvenScroll;
diff --git a/src/gui/itempopup.cpp b/src/gui/itempopup.cpp
index 008a41d9..ee28435b 100644
--- a/src/gui/itempopup.cpp
+++ b/src/gui/itempopup.cpp
@@ -32,6 +32,8 @@
#include "widgets/layout.h"
+#include "../units.h"
+
#include "../resources/iteminfo.h"
#include "../utils/gettext.h"
@@ -108,8 +110,8 @@ void ItemPopup::setItem(const ItemInfo &item)
mItemName->setWidth(boldFont->getWidth(item.getName()));
mItemDesc->setTextWrapped(item.getDescription(), 196);
mItemEffect->setTextWrapped(item.getEffect(), 196);
- mItemWeight->setTextWrapped(_("Weight: ") + toString(item.getWeight()) +
- _(" grams"), 196);
+ mItemWeight->setTextWrapped(_("Weight: ") +
+ Units::formatWeight(item.getWeight()), 196);
int minWidth = mItemName->getWidth();
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index e4be7921..a46f3ce6 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -31,6 +31,7 @@
#include "widgets/layout.h"
#include "../npc.h"
+#include "../units.h"
#include "../net/messageout.h"
#include "../net/protocol.h"
@@ -55,8 +56,8 @@ SellDialog::SellDialog(Network *network):
mScrollArea = new ScrollArea(mShopItemList);
mSlider = new Slider(1.0);
mQuantityLabel = new gcn::Label("0");
- mMoneyLabel = new gcn::Label(
- strprintf(_("Price: %d GP / Total: %d GP"), 0, 0));
+ mMoneyLabel = new gcn::Label(strprintf(_("Price: %s / Total: %s"),
+ "", ""));
mIncreaseButton = new Button("+", "+", this);
mDecreaseButton = new Button("-", "-", this);
mSellButton = new Button(_("Sell"), "sell", this);
@@ -249,7 +250,7 @@ void SellDialog::updateButtonsAndLabels()
// Update the quantity and money labels
mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
- mMoneyLabel->setCaption
- (strprintf(_("Price: %d GP / Total: %d GP"),
- income, mPlayerMoney + income));
+ mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
+ Units::formatCurrency(income).c_str(),
+ Units::formatCurrency(mPlayerMoney - income).c_str()));
}
diff --git a/src/gui/status.cpp b/src/gui/status.cpp
index 683a9a41..cb02a57a 100644
--- a/src/gui/status.cpp
+++ b/src/gui/status.cpp
@@ -29,6 +29,7 @@
#include "widgets/layout.h"
#include "../localplayer.h"
+#include "../units.h"
#include "../utils/gettext.h"
#include "../utils/strprintf.h"
@@ -36,7 +37,9 @@
StatusWindow::StatusWindow(LocalPlayer *player):
Window(player->getName()),
- mPlayer(player)
+ mPlayer(player),
+ currency(-1),
+ currencyS("?")
{
setWindowName(_("Status"));
setCloseButton(true);
@@ -49,7 +52,7 @@ StatusWindow::StatusWindow(LocalPlayer *player):
mLvlLabel = new gcn::Label(strprintf(_("Level: %d"), 0));
mJobLvlLabel = new gcn::Label(strprintf(_("Job: %d"), 0));
- mGpLabel = new gcn::Label(strprintf(_("Money: %d GP"), 0));
+ mGpLabel = new gcn::Label(strprintf(_("Money: %s"), ""));
mHpLabel = new gcn::Label(_("HP:"));
mHpBar = new ProgressBar(1.0f, 80, 15, 0, 171, 34);
@@ -171,8 +174,12 @@ void StatusWindow::update()
mJobLvlLabel->setCaption(strprintf(_("Job: %d"), mPlayer->mJobLevel));
mJobLvlLabel->adjustSize();
- mGpLabel->setCaption(strprintf(_("Money: %d GP"), mPlayer->mGp));
- mGpLabel->adjustSize();
+ if (currency != mPlayer->mGp) {
+ currency = mPlayer->mGp;
+ currencyS = strprintf(_("Money: %s"), Units::formatCurrency(currency).c_str());
+ mGpLabel->setCaption(currencyS);
+ mGpLabel->adjustSize();
+ }
mHpBar->setText(toString(mPlayer->mHp) +
"/" + toString(mPlayer->mMaxHp));
diff --git a/src/gui/status.h b/src/gui/status.h
index 00a48f4e..7545d696 100644
--- a/src/gui/status.h
+++ b/src/gui/status.h
@@ -64,7 +64,7 @@ class StatusWindow : public Window, public gcn::ActionListener
* Status Part
*/
gcn::Label *mLvlLabel, *mJobLvlLabel;
- gcn::Label *mGpLabel;
+ gcn::Label *mGpLabel; int currency; std::string currencyS;
gcn::Label *mHpLabel, *mMpLabel, *mXpLabel, *mJobLabel;
ProgressBar *mHpBar, *mMpBar;
ProgressBar *mXpBar, *mJobBar;
diff --git a/src/gui/trade.cpp b/src/gui/trade.cpp
index af30d1fe..9c11afd4 100644
--- a/src/gui/trade.cpp
+++ b/src/gui/trade.cpp
@@ -37,6 +37,7 @@
#include "../inventory.h"
#include "../item.h"
#include "../localplayer.h"
+#include "../units.h"
#include "../net/messageout.h"
#include "../net/protocol.h"
@@ -77,7 +78,7 @@ TradeWindow::TradeWindow(Network *network):
mPartnerScroll = new ScrollArea(mPartnerItemContainer);
- mMoneyLabel = new gcn::Label(strprintf(_("You get %d GP."), 0));
+ mMoneyLabel = new gcn::Label(strprintf(_("You get %s."), ""));
mMoneyLabel2 = new gcn::Label(_("You give:"));
mMoneyField = new TextField;
mMoneyField->setWidth(50);
@@ -119,7 +120,8 @@ void TradeWindow::widgetResized(const gcn::Event &event)
void TradeWindow::addMoney(int amount)
{
- mMoneyLabel->setCaption(strprintf(_("You get %d GP."), amount));
+ mMoneyLabel->setCaption(strprintf(_("You get %s."),
+ Units::formatCurrency(amount).c_str()));
mMoneyLabel->adjustSize();
}
@@ -169,7 +171,7 @@ void TradeWindow::reset()
mOkButton->setEnabled(true);
mOkOther = false;
mOkMe = false;
- mMoneyLabel->setCaption(strprintf(_("You get %d GP."), 0));
+ mMoneyLabel->setCaption(strprintf(_("You get %s."), ""));
mMoneyField->setEnabled(true);
mMoneyField->setText("");
}