diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-04-22 18:45:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-04-22 18:45:55 +0300 |
commit | 9128a4b2466259956a56fbc953e1be050faad319 (patch) | |
tree | 3cbc3d2d1c059004c2ae7aabcdf7fc5c9e62ddcd /src | |
parent | d32d2c9b6555201aeda94e657357803f2f9a9a70 (diff) | |
download | mv-9128a4b2466259956a56fbc953e1be050faad319.tar.gz mv-9128a4b2466259956a56fbc953e1be050faad319.tar.bz2 mv-9128a4b2466259956a56fbc953e1be050faad319.tar.xz mv-9128a4b2466259956a56fbc953e1be050faad319.zip |
Improve keyboard handling in create character dialog.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/charcreatedialog.cpp | 20 | ||||
-rw-r--r-- | src/gui/charcreatedialog.h | 7 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/gui/charcreatedialog.cpp b/src/gui/charcreatedialog.cpp index 864ddf0b6..db6916a62 100644 --- a/src/gui/charcreatedialog.cpp +++ b/src/gui/charcreatedialog.cpp @@ -24,6 +24,8 @@ #include "client.h" #include "game.h" +#include "keydata.h" +#include "keyevent.h" #include "localplayer.h" #include "main.h" #include "units.h" @@ -230,6 +232,8 @@ CharCreateDialog::CharCreateDialog(CharSelectDialog *parent, int slot): updateRace(); updatePlayer(); + + addKeyListener(this); } CharCreateDialog::~CharCreateDialog() @@ -548,3 +552,19 @@ void CharCreateDialog::updatePlayer() mPlayer->setAction(actions[mAction]); } } + +void CharCreateDialog::keyPressed(gcn::KeyEvent &keyEvent) +{ + int actionId = static_cast<KeyEvent*>(&keyEvent)->getActionId(); + switch (actionId) + { + case Input::KEY_GUI_CANCEL: + keyEvent.consume(); + action(gcn::ActionEvent(mCancelButton, + mCancelButton->getActionEventId())); + break; + + default: + break; + } +} diff --git a/src/gui/charcreatedialog.h b/src/gui/charcreatedialog.h index 15fdf7466..408297adc 100644 --- a/src/gui/charcreatedialog.h +++ b/src/gui/charcreatedialog.h @@ -31,6 +31,7 @@ #include "gui/widgets/window.h" #include <guichan/actionlistener.hpp> +#include <guichan/keylistener.hpp> class LocalPlayer; class PlayerBox; @@ -41,7 +42,9 @@ class TextField; * * \ingroup Interface */ -class CharCreateDialog : public Window, public gcn::ActionListener +class CharCreateDialog : public Window, + public gcn::ActionListener, + public gcn::KeyListener { public: /** @@ -71,6 +74,8 @@ class CharCreateDialog : public Window, public gcn::ActionListener void updatePlayer(); + void keyPressed(gcn::KeyEvent &keyEvent); + private: int getDistributedPoints() const; |