summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/statuswindow.cpp34
-rw-r--r--src/gui/statuswindow.h7
2 files changed, 40 insertions, 1 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)
diff --git a/src/gui/statuswindow.h b/src/gui/statuswindow.h
index 74eb2c401..44d052004 100644
--- a/src/gui/statuswindow.h
+++ b/src/gui/statuswindow.h
@@ -48,7 +48,9 @@ class VertContainer;
*
* \ingroup Interface
*/
-class StatusWindow : public Window, public Mana::Listener
+class StatusWindow : public Window,
+ public gcn::ActionListener,
+ public Mana::Listener
{
public:
/**
@@ -77,6 +79,8 @@ class StatusWindow : public Window, public Mana::Listener
void updateProgressBar(ProgressBar *bar, int id,
bool percent = true);
+ void action(const gcn::ActionEvent &event);
+
private:
static std::string translateLetter(char* letters);
@@ -97,6 +101,7 @@ class StatusWindow : public Window, public Mana::Listener
gcn::Label *mCharacterPointsLabel;
gcn::Label *mCorrectionPointsLabel;
+ gcn::Button *mCopyButton;
typedef std::map<int, AttrDisplay*> Attrs;
Attrs mAttrs;