summaryrefslogtreecommitdiff
path: root/src/gui/statuswindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-08-15 15:47:09 +0300
committerAndrei Karas <akaras@inbox.ru>2011-08-15 15:47:09 +0300
commit243628a5d2d12a02708b14b0cbac1498bdcec844 (patch)
tree3a34c6e02d26595120f4576b0c7b943da2696fb7 /src/gui/statuswindow.cpp
parent178af146d00873e632802dcbdbc77dcb9198d6b1 (diff)
downloadplus-243628a5d2d12a02708b14b0cbac1498bdcec844.tar.gz
plus-243628a5d2d12a02708b14b0cbac1498bdcec844.tar.bz2
plus-243628a5d2d12a02708b14b0cbac1498bdcec844.tar.xz
plus-243628a5d2d12a02708b14b0cbac1498bdcec844.zip
Add button in status window to copy player stats to chat.
Diffstat (limited to 'src/gui/statuswindow.cpp')
-rw-r--r--src/gui/statuswindow.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/gui/statuswindow.cpp b/src/gui/statuswindow.cpp
index b96720341..fcc324730 100644
--- a/src/gui/statuswindow.cpp
+++ b/src/gui/statuswindow.cpp
@@ -22,6 +22,7 @@
#include "gui/statuswindow.h"
+#include "chatwindow.h"
#include "configuration.h"
#include "event.h"
#include "equipment.h"
@@ -71,6 +72,14 @@ class AttrDisplay : public Container
virtual Type getType()
{ return UNKNOWN; }
+ std::string getValue()
+ {
+ if (!mValue)
+ return "-";
+ else
+ return mValue->getCaption();
+ }
+
protected:
AttrDisplay(int id, const std::string &name);
@@ -228,6 +237,10 @@ StatusWindow::StatusWindow():
mCharacterPointsLabel = new Label("C");
place(0, 6, mCharacterPointsLabel, 5);
+ mCopyButton = new Button(_("Copy to chat"), "copy", this);
+
+ place(0, 5, mCopyButton);
+
if (Net::getPlayerHandler()->canCorrectAttributes())
{
mCorrectionPointsLabel = new Label("C");
@@ -890,6 +903,27 @@ void StatusWindow::updateStatusBar(ProgressBar *bar, bool percent A_UNUSED)
}
}
+void StatusWindow::action(const gcn::ActionEvent &event)
+{
+ if (!chatWindow)
+ return;
+
+ if (event.getId() == "copy")
+ {
+ Attrs::iterator it = mAttrs.begin();
+ Attrs::iterator it_end = mAttrs.end();
+ std::string str;
+ while (it != it_end)
+ {
+ ChangeDisplay *attr = dynamic_cast<ChangeDisplay*>((*it).second);
+ if (attr)
+ str += attr->getValue() + " ";
+ ++ it;
+ }
+ chatWindow->addInputText(str);
+ }
+}
+
AttrDisplay::AttrDisplay(int id, const std::string &name):
mId(id),
mName(name)