summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-27 22:16:21 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-27 22:18:46 +0300
commite64f2320f68c762b6822a5b616d5f3d4906c94f0 (patch)
treede597a1e14d9716cbaf0b7ca81a6cef3da06f9e7 /src/gui
parent64af3e6133b0f545cf1ad7ff565ee9e74e0d65b7 (diff)
downloadplus-e64f2320f68c762b6822a5b616d5f3d4906c94f0.tar.gz
plus-e64f2320f68c762b6822a5b616d5f3d4906c94f0.tar.bz2
plus-e64f2320f68c762b6822a5b616d5f3d4906c94f0.tar.xz
plus-e64f2320f68c762b6822a5b616d5f3d4906c94f0.zip
Improve tradewindow.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/tradewindow.cpp32
-rw-r--r--src/gui/tradewindow.h7
2 files changed, 15 insertions, 24 deletions
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index 88dac7d55..2e5d026b2 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -89,8 +89,6 @@ TradeWindow::TradeWindow():
mOkOther(false),
mOkMe(false)
{
- logger->log1("TradeWindow::TradeWindow nick");
-
setWindowName("Trade");
setResizable(true);
setCloseButton(true);
@@ -182,7 +180,7 @@ void TradeWindow::setMoney(const int amount)
mGotMoney = amount;
// TRANSLATORS: trade window money label
mMoneyLabel->setCaption(strprintf(_("You get %s"),
- Units::formatCurrency(amount).c_str()));
+ Units::formatCurrency(amount).c_str()));
mMoneyLabel->adjustSize();
}
@@ -208,31 +206,24 @@ void TradeWindow::addItem2(const int id, const bool own, const int quantity,
void TradeWindow::changeQuantity(const int index, const bool own,
const int quantity) const
{
+ Item *item;
if (own)
- {
- if (mMyInventory->getItem(index))
- mMyInventory->getItem(index)->setQuantity(quantity);
- }
+ item = mMyInventory->getItem(index);
else
- {
- if (mPartnerInventory->getItem(index))
- mPartnerInventory->getItem(index)->setQuantity(quantity);
- }
+ item = mPartnerInventory->getItem(index);
+ if (item)
+ item->setQuantity(quantity);
}
void TradeWindow::increaseQuantity(const int index, const bool own,
const int quantity) const
{
+ Item *item;
if (own)
- {
- if (mMyInventory->getItem(index))
- mMyInventory->getItem(index)->increaseQuantity(quantity);
- }
+ item = mMyInventory->getItem(index);
else
- {
- if (mPartnerInventory->getItem(index))
- mPartnerInventory->getItem(index)->increaseQuantity(quantity);
- }
+ item = mPartnerInventory->getItem(index);
+ item->increaseQuantity(quantity);
}
void TradeWindow::reset()
@@ -363,7 +354,6 @@ void TradeWindow::action(const gcn::ActionEvent &event)
setVisible(false);
reset();
PlayerInfo::setTrading(false);
-
Net::getTradeHandler()->cancel();
}
else if (eventId == "ok")
@@ -436,7 +426,7 @@ void TradeWindow::addAutoMoney(const std::string &nick, const int money)
mAutoMoney = money;
}
-void TradeWindow::initTrade(std::string nick)
+void TradeWindow::initTrade(const std::string &nick)
{
if (!player_node)
return;
diff --git a/src/gui/tradewindow.h b/src/gui/tradewindow.h
index ebf0cf6b2..eb5a2369b 100644
--- a/src/gui/tradewindow.h
+++ b/src/gui/tradewindow.h
@@ -92,7 +92,8 @@ class TradeWindow final : public Window,
/**
* Increase quantity of an item.
*/
- void increaseQuantity(int index, bool own, int quantity) const;
+ void increaseQuantity(const int index, const bool own,
+ const int quantity) const;
/**
* Player received ok message from server
@@ -120,7 +121,7 @@ class TradeWindow final : public Window,
* Closes the Trade Window, as well as telling the server that the
* window has been closed.
*/
- void close();
+ void close() override;
/**
* Clear auto trade items.
@@ -135,7 +136,7 @@ class TradeWindow final : public Window,
void addAutoMoney(const std::string &nick, const int money);
- void initTrade(std::string nick);
+ void initTrade(const std::string &nick);
std::string getAutoTradeNick() const A_WARN_UNUSED
{ return mAutoAddToNick; }