summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-05-22 19:33:33 +0300
committerAndrei Karas <akaras@inbox.ru>2011-05-22 19:34:10 +0300
commit8fb121ec3791bfe3e4d4b1003fcc3397d0b0ea19 (patch)
tree08d6f69f2d65be1874d233c24d6f3355fb01f283 /src/gui
parent668306a14e6ecfc6ce9b283b10f9f59cdab788a0 (diff)
downloadplus-8fb121ec3791bfe3e4d4b1003fcc3397d0b0ea19.tar.gz
plus-8fb121ec3791bfe3e4d4b1003fcc3397d0b0ea19.tar.bz2
plus-8fb121ec3791bfe3e4d4b1003fcc3397d0b0ea19.tar.xz
plus-8fb121ec3791bfe3e4d4b1003fcc3397d0b0ea19.zip
Add option to secure trades. Enabled by default.
If client detect problems, it cancel trade.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/setup_players.cpp20
-rw-r--r--src/gui/setup_players.h3
-rw-r--r--src/gui/tradewindow.cpp14
3 files changed, 33 insertions, 4 deletions
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 0b870ccd5..0290c24d5 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -229,6 +229,7 @@ public:
#define ACTION_SHOW_LEVEL "show level"
#define ACTION_TARGET_DEAD "target dead"
#define ACTION_SHOW_OWN_NAME "show own name"
+#define ACTION_SECURE_TRADES "secure trades"
Setup_Players::Setup_Players():
mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)),
@@ -249,7 +250,8 @@ Setup_Players::Setup_Players():
mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender)),
mShowLevel(config.getBoolValue("showlevel")),
mShowOwnName(config.getBoolValue("showownname")),
- mTargetDead(config.getBoolValue("targetDeadPlayers"))
+ mTargetDead(config.getBoolValue("targetDeadPlayers")),
+ mSecureTrades(config.getBoolValue("securetrades"))
{
setName(_("Players"));
@@ -311,6 +313,10 @@ Setup_Players::Setup_Players():
mTargetDeadCheckBox->setActionEventId(ACTION_TARGET_DEAD);
mTargetDeadCheckBox->addActionListener(this);
+ mSecureTradesCheckBox = new CheckBox(_("Secure trades"), mSecureTrades);
+ mSecureTradesCheckBox->setActionEventId(ACTION_SECURE_TRADES);
+ mSecureTradesCheckBox->addActionListener(this);
+
reset();
// Do the layout
@@ -326,8 +332,9 @@ Setup_Players::Setup_Players():
place(1, 5, mOldButton, 1);
place(3, 5, ignore_action_label);
place(3, 6, mIgnoreActionChoicesBox, 2).setPadding(2);
- place(3, 7, mDefaultTrading);
- place(3, 8, mDefaultWhisper);
+ place(3, 7, mDefaultTrading, 2);
+ place(3, 8, mDefaultWhisper, 2);
+ place(3, 9, mSecureTradesCheckBox, 2);
place(0, 9, mWhisperTabCheckBox, 4).setPadding(4);
place(0, 10, mTargetDeadCheckBox, 4).setPadding(4);
@@ -381,6 +388,7 @@ void Setup_Players::apply()
config.setValue("showownname", mShowOwnName);
config.setValue("targetDeadPlayers", mTargetDead);
config.setValue("showgender", mShowGender);
+ config.setValue("securetrades", mSecureTrades);
if (actorSpriteManager)
actorSpriteManager->updatePlayerNames();
@@ -401,6 +409,8 @@ void Setup_Players::cancel()
mShowOwnNameCheckBox->setSelected(mShowOwnName);
mTargetDead = config.getBoolValue("targetDeadPlayers");
mTargetDeadCheckBox->setSelected(mTargetDead);
+ mSecureTrades = config.getBoolValue("securetrades");
+ mSecureTradesCheckBox->setSelected(mSecureTrades);
}
void Setup_Players::action(const gcn::ActionEvent &event)
@@ -464,6 +474,10 @@ void Setup_Players::action(const gcn::ActionEvent &event)
{
mTargetDead = mTargetDeadCheckBox->isSelected();
}
+ else if (event.getId() == ACTION_SECURE_TRADES)
+ {
+ mSecureTrades = mSecureTradesCheckBox->isSelected();
+ }
}
diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h
index 8a82d57d1..64561ed91 100644
--- a/src/gui/setup_players.h
+++ b/src/gui/setup_players.h
@@ -91,6 +91,9 @@ private:
bool mTargetDead;
gcn::CheckBox *mTargetDeadCheckBox;
+
+ bool mSecureTrades;
+ gcn::CheckBox *mSecureTradesCheckBox;
};
#endif
diff --git a/src/gui/tradewindow.cpp b/src/gui/tradewindow.cpp
index 58ac9c592..25c478c21 100644
--- a/src/gui/tradewindow.cpp
+++ b/src/gui/tradewindow.cpp
@@ -22,6 +22,7 @@
#include "gui/tradewindow.h"
+#include "configuration.h"
#include "inventory.h"
#include "item.h"
#include "localplayer.h"
@@ -144,7 +145,16 @@ void TradeWindow::setMoney(int amount)
{
if (amount < 0 || amount < mGotMaxMoney)
{
- mMoneyLabel->setForegroundColor(Theme::getThemeColor(Theme::WARNING));
+ if (config.getBoolValue("securetrades"))
+ {
+ close();
+ return;
+ }
+ else
+ {
+ mMoneyLabel->setForegroundColor(Theme::getThemeColor(
+ Theme::WARNING));
+ }
}
else
{
@@ -217,6 +227,7 @@ void TradeWindow::reset()
mAddButton->setEnabled(true);
mMoneyChangeButton->setEnabled(true);
mGotMoney = 0;
+ mGotMaxMoney = 0;
setStatus(PREPARING);
}
@@ -386,6 +397,7 @@ void TradeWindow::clear()
mAutoMoney = 0;
mAutoAddAmount = 0;
mGotMoney = 0;
+ mGotMaxMoney = 0;
mMoneyLabel->setForegroundColor(Theme::getThemeColor(Theme::TEXT));
}