summaryrefslogtreecommitdiff
path: root/src/touchmanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-05 20:47:16 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-05 20:48:08 +0300
commitbef65b44075a5c918821f1360804ff5f9f2a32ed (patch)
tree9cdbdf2e2b4abd8b102adb02c673aad9c22a886a /src/touchmanager.cpp
parenteb37dba283cab99816c5d227ad3744a8bb19d2c2 (diff)
downloadplus-bef65b44075a5c918821f1360804ff5f9f2a32ed.tar.gz
plus-bef65b44075a5c918821f1360804ff5f9f2a32ed.tar.bz2
plus-bef65b44075a5c918821f1360804ff5f9f2a32ed.tar.xz
plus-bef65b44075a5c918821f1360804ff5f9f2a32ed.zip
add attack and cancel on screen buttons.
Diffstat (limited to 'src/touchmanager.cpp')
-rw-r--r--src/touchmanager.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index 79acaafb1..3b8c6e21b 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -37,6 +37,7 @@ extern int openGLMode;
TouchManager::TouchManager() :
mKeyboard(nullptr),
mPad(nullptr),
+ mAttack(nullptr),
mVertexes(new ImageCollection),
mRedraw(true)
{
@@ -52,18 +53,22 @@ TouchManager::~TouchManager()
void TouchManager::init()
{
#ifdef ANDROID
- loadTouchItem(&mKeyboard, "keyboard_icon.xml", false,
+ loadTouchItem(&mKeyboard, "keyboard_icon.xml", NORMAL,
nullptr, nullptr, &showKeyboard, nullptr);
#endif
if (config.getBoolValue("showScreenJoystick"))
{
- loadTouchItem(&mPad, "dpad.xml", true,
+ loadTouchItem(&mPad, "dpad.xml", LEFT,
&padEvents, &padClick, &padUp, &padOut);
+ loadTouchItem(&mAttack, "dpad_attack.xml", RIGHT,
+ nullptr, &attackClick, &attackUp, &attackOut);
+ loadTouchItem(&mCancel, "dpad_cancel.xml", RIGHT,
+ nullptr, &cancelClick, &cancelUp, &cancelOut);
}
}
-void TouchManager::loadTouchItem(TouchItem **item, std::string name, bool type,
+void TouchManager::loadTouchItem(TouchItem **item, std::string name, int type,
TouchFuncPtr fAll, TouchFuncPtr fPressed,
TouchFuncPtr fReleased, TouchFuncPtr fOut)
{
@@ -79,11 +84,23 @@ void TouchManager::loadTouchItem(TouchItem **item, std::string name, bool type,
if (image)
{
image->incRef();
- const int x = skin->getOption("x", 10);
- const int y = type ? (mainGraphics->mHeight - image->mBounds.h) / 2
- + skin->getOption("y", 10) : skin->getOption("y", 10);
+ int x = skin->getOption("x", 10);
+ int y = skin->getOption("y", 10);
const int pad = skin->getPadding();
const int pad2 = 2 * pad;
+ switch (type)
+ {
+ case LEFT:
+ y += (mainGraphics->mHeight - image->mBounds.h) / 2;
+ break;
+ case RIGHT:
+ x = mainGraphics->mWidth - image->mBounds.w - pad2 - x;
+ y = mainGraphics->mHeight - image->mBounds.h - pad2 - y;
+ break;
+ case NORMAL:
+ default:
+ break;
+ }
*item = new TouchItem(gcn::Rectangle(x, y,
image->getWidth() + pad2, image->getHeight() + pad2),
image, x + pad, y + pad, fAll, fPressed, fReleased, fOut);