diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-11 01:15:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-11 01:15:25 +0300 |
commit | cddb3dd72f0fdf4639270596b3bcc252b3216c3a (patch) | |
tree | 8941d557f9b9fe27c9f8dbb2f4a9ddee26624871 | |
parent | fcd7af5db04ada44f9351ed7c1cac5b19001ace8 (diff) | |
download | manaverse-cddb3dd72f0fdf4639270596b3bcc252b3216c3a.tar.gz manaverse-cddb3dd72f0fdf4639270596b3bcc252b3216c3a.tar.bz2 manaverse-cddb3dd72f0fdf4639270596b3bcc252b3216c3a.tar.xz manaverse-cddb3dd72f0fdf4639270596b3bcc252b3216c3a.zip |
Hide on screen buttons before enter to game and show in game.
-rw-r--r-- | src/game.cpp | 3 | ||||
-rw-r--r-- | src/touchmanager.cpp | 15 | ||||
-rw-r--r-- | src/touchmanager.h | 3 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/game.cpp b/src/game.cpp index f2b88769f..57b855a18 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -42,6 +42,7 @@ #include "playerinfo.h" #include "soundmanager.h" #include "spellshortcut.h" +#include "touchmanager.h" #include "gui/botcheckerwindow.h" #include "gui/debugwindow.h" @@ -377,6 +378,7 @@ Game::Game(): mLowerCounter(0), mPing(0) { + touchManager.setInGame(true); spellManager = new SpellManager; spellShortcut = new SpellShortcut; @@ -438,6 +440,7 @@ Game::Game(): Game::~Game() { + touchManager.setInGame(false); config.write(); serverConfig.write(); diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 2780f186f..af90c65e3 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -43,7 +43,8 @@ TouchManager::TouchManager() : mShowJoystick(false), mShowButtons(false), mButtonsSize(1), - mJoystickSize(1) + mJoystickSize(1), + mInGame(false) { for (int f = 0; f < actionsSize; f ++) mActions[f] = false; @@ -158,7 +159,7 @@ void TouchManager::draw() it != it_end; ++ it) { const TouchItem *const item = *it; - if (item && item->images) + if (item && item->images && (mInGame || item == mKeyboard)) { mainGraphics->calcWindow(mVertexes, item->x, item->y, item->width, item->height, *item->images); @@ -174,7 +175,7 @@ void TouchManager::draw() it != it_end; ++ it) { const TouchItem *const item = *it; - if (item && item->images) + if (item && item->images && (mInGame || item == mKeyboard)) { mainGraphics->drawImageRect(item->x, item->y, item->width, item->height, *item->images); @@ -192,7 +193,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) it != it_end; ++ it) { const TouchItem *const item = *it; - if (!item) + if (!item || (!mInGame && item != mKeyboard)) continue; const gcn::Rectangle &rect = item->rect; if (rect.isPointInRect(x, y)) @@ -393,3 +394,9 @@ void TouchManager::optionChanged(const std::string &value) } } } + +void TouchManager::setInGame(bool b) +{ + mInGame = b; + mRedraw = true; +} diff --git a/src/touchmanager.h b/src/touchmanager.h index e93618fc8..883080514 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -135,6 +135,8 @@ class TouchManager final : public ConfigListener int getPadSize() { return (mJoystickSize + 2) * 50; } + void setInGame(bool b); + private: TouchItem *mKeyboard; TouchItem *mPad; @@ -148,6 +150,7 @@ class TouchManager final : public ConfigListener bool mShowButtons; int mButtonsSize; int mJoystickSize; + bool mInGame; }; extern TouchManager touchManager; |