diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-08-15 15:47:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-08-15 15:47:09 +0300 |
commit | 243628a5d2d12a02708b14b0cbac1498bdcec844 (patch) | |
tree | 3a34c6e02d26595120f4576b0c7b943da2696fb7 /src | |
parent | 178af146d00873e632802dcbdbc77dcb9198d6b1 (diff) | |
download | manaplus-243628a5d2d12a02708b14b0cbac1498bdcec844.tar.gz manaplus-243628a5d2d12a02708b14b0cbac1498bdcec844.tar.bz2 manaplus-243628a5d2d12a02708b14b0cbac1498bdcec844.tar.xz manaplus-243628a5d2d12a02708b14b0cbac1498bdcec844.zip |
Add button in status window to copy player stats to chat.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/statuswindow.cpp | 34 | ||||
-rw-r--r-- | src/gui/statuswindow.h | 7 |
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; |