diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-12-31 02:00:06 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-12-31 02:00:06 +0300 |
commit | f4f8701763eed4c1ab9badf004e4755126b98e9e (patch) | |
tree | f904efec07054d9be7bac7dba4d34b5de8bc49ce /src/touchmanager.cpp | |
parent | 021e567ba44650b0ab63e7f571dc0d622edbcc6d (diff) | |
download | mv-f4f8701763eed4c1ab9badf004e4755126b98e9e.tar.gz mv-f4f8701763eed4c1ab9badf004e4755126b98e9e.tar.bz2 mv-f4f8701763eed4c1ab9badf004e4755126b98e9e.tar.xz mv-f4f8701763eed4c1ab9badf004e4755126b98e9e.zip |
Add option to show/hide onscreen keyboard icon.
Diffstat (limited to 'src/touchmanager.cpp')
-rw-r--r-- | src/touchmanager.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 3dd9e64a9..b78f0264d 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -42,6 +42,7 @@ TouchManager::TouchManager() : mRedraw(true), mShowJoystick(false), mShowButtons(false), + mShowKeyboard(false), mButtonsSize(1), mJoystickSize(1), mShow(false), @@ -68,21 +69,20 @@ void TouchManager::init() { config.addListener("showScreenJoystick", this); config.addListener("showScreenButtons", this); + config.addListener("showScreenKeyboard", this); config.addListener("screenButtonsSize", this); config.addListener("screenJoystickSize", this); mShowJoystick = config.getBoolValue("showScreenJoystick"); mShowButtons = config.getBoolValue("showScreenButtons"); + mShowKeyboard = config.getBoolValue("showScreenKeyboard"); mButtonsSize = config.getIntValue("screenButtonsSize"); mJoystickSize = config.getIntValue("screenJoystickSize"); setHalfJoyPad(getPadSize() / 2); -#ifdef ANDROID - loadTouchItem(&mKeyboard, "keyboard_icon.xml", "", -1, -1, 28, 28, NORMAL, - nullptr, nullptr, &showKeyboard, nullptr); -#endif - + if (mShowKeyboard) + loadKeyboard(); if (mShowJoystick) loadPad(); if (mShowButtons) @@ -172,7 +172,8 @@ void TouchManager::draw() it != it_end; ++ it) { const TouchItem *const item = *it; - if (item && item->images && (mShow || item == mKeyboard)) + if (item && item->images && (mShow || + (item == mKeyboard && mShowKeyboard))) { mainGraphics->calcWindow(mVertexes, item->x, item->y, item->width, item->height, *item->images); @@ -195,7 +196,8 @@ void TouchManager::draw() it != it_end; ++ it) { const TouchItem *const item = *it; - if (item && item->images && (mShow || item == mKeyboard)) + if (item && item->images && (mShow || + (item == mKeyboard && mShowKeyboard))) { mainGraphics->drawImageRect(item->x, item->y, item->width, item->height, *item->images); @@ -220,7 +222,7 @@ bool TouchManager::processEvent(const MouseInput &mouseInput) it != it_end; ++ it) { const TouchItem *const item = *it; - if (!item || (!mShow && item != mKeyboard)) + if (!item || (!mShow && (item != mKeyboard || !mShowKeyboard))) continue; const gcn::Rectangle &rect = item->rect; if (rect.isPointInRect(x, y)) @@ -372,6 +374,12 @@ void TouchManager::loadButtons() } +void TouchManager::loadKeyboard() +{ + loadTouchItem(&mKeyboard, "keyboard_icon.xml", "", -1, -1, 28, 28, NORMAL, + nullptr, nullptr, &showKeyboard, nullptr); +} + void TouchManager::optionChanged(const std::string &value) { if (value == "showScreenJoystick") @@ -401,6 +409,17 @@ void TouchManager::optionChanged(const std::string &value) } mRedraw = true; } + else if (value == "showScreenKeyboard") + { + if (mShowKeyboard == config.getBoolValue("showScreenKeyboard")) + return; + mShowKeyboard = config.getBoolValue("showScreenKeyboard"); + if (mShowKeyboard) + loadKeyboard(); + else + unloadTouchItem(&mKeyboard); + mRedraw = true; + } else if (value == "screenButtonsSize") { if (mButtonsSize == config.getIntValue("screenButtonsSize")) |