GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/input/touch/touchmanager.cpp Lines: 61 332 18.4 %
Date: 2017-11-29 Branches: 41 849 4.8 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2012-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "input/touch/touchmanager.h"
22
23
#include "configuration.h"
24
25
#include "gui/gui.h"
26
#include "gui/skin.h"
27
#include "gui/theme.h"
28
29
#include "gui/fonts/font.h"
30
31
#include "input/inputmanager.h"
32
#include "input/mouseinput.h"
33
34
#include "input/touch/touchactions.h"
35
36
#include "utils/delete2.h"
37
#include "utils/foreach.h"
38
39
#include "render/graphics.h"
40
41
#include "render/vertexes/imagecollection.h"
42
43
#include "resources/imagerect.h"
44
45
#include "resources/image/image.h"
46
47
#include "debug.h"
48
49
2
TouchManager touchManager;
50
51
extern RenderType openGLMode;
52
53
2
TouchManager::TouchManager() :
54
    mKeyboard(nullptr),
55
    mPad(nullptr),
56
    mObjects(),
57
    mVertexes(nullptr),
58
    mRedraw(true),
59
    mShowJoystick(false),
60
    mShowButtons(false),
61
    mShowKeyboard(false),
62
    mButtonsSize(1),
63
    mJoystickSize(1),
64
    mButtonsFormat(0),
65
    mWidth(0),
66
    mHeight(0),
67
    mShow(false),
68
    mInGame(false),
69
6
    mTempHideButtons(false)
70
{
71
1338
    for (int f = 0; f < actionsSize; f ++)
72
1336
        mActions[f] = false;
73
50
    for (int f = 0; f < buttonsCount; f ++)
74
24
        mButtons[f] = nullptr;
75
2
}
76
77
6
TouchManager::~TouchManager()
78
{
79
2
    clear();
80
    CHECKLISTENERS
81
2
}
82
83
384
void TouchManager::shutdown() restrict2
84
{
85
384
    config.removeListeners(this);
86
384
}
87
88
152
void TouchManager::init() restrict2
89
{
90
152
    delete mVertexes;
91
152
    mVertexes = new ImageCollection;
92
93

608
    config.addListener("showScreenJoystick", this);
94

608
    config.addListener("showScreenButtons", this);
95

608
    config.addListener("showScreenKeyboard", this);
96

608
    config.addListener("screenButtonsSize", this);
97

608
    config.addListener("screenJoystickSize", this);
98

608
    config.addListener("screenButtonsFormat", this);
99
100

608
    mShowJoystick = config.getBoolValue("showScreenJoystick");
101

608
    mShowButtons = config.getBoolValue("showScreenButtons");
102

608
    mShowKeyboard = config.getBoolValue("showScreenKeyboard");
103

608
    mButtonsSize = config.getIntValue("screenButtonsSize");
104

608
    mJoystickSize = config.getIntValue("screenJoystickSize");
105

608
    mButtonsFormat = config.getIntValue("screenButtonsFormat");
106
107
304
    setHalfJoyPad(getPadSize() / 2);
108
109
152
    if (mShowKeyboard)
110
        loadKeyboard();
111
152
    if (mShowJoystick)
112
        loadPad();
113
152
    if (mShowButtons)
114
        loadButtons();
115
152
    mWidth = mainGraphics->mWidth;
116
152
    mHeight = mainGraphics->mHeight;
117
152
}
118
119
void TouchManager::loadTouchItem(TouchItem **restrict item,
120
                                 const std::string &restrict name,
121
                                 const std::string &restrict imageName,
122
                                 const std::string &restrict text,
123
                                 int x, int y,
124
                                 const int width, const int height,
125
                                 const int type,
126
                                 const std::string &restrict eventPressed,
127
                                 const std::string &restrict eventReleased,
128
                                 const TouchFuncPtr fAll,
129
                                 const TouchFuncPtr fPressed,
130
                                 const TouchFuncPtr fReleased,
131
                                 const TouchFuncPtr fOut) restrict2
132
{
133
    *item = nullptr;
134
    if (theme == nullptr)
135
        return;
136
    ImageRect *images = new ImageRect;
137
    for (int f = 0; f < 9; f ++)
138
        images->grid[f] = nullptr;
139
140
    Image *icon;
141
    if (imageName.empty())
142
        icon = nullptr;
143
    else
144
        icon = Theme::getImageFromThemeXml(imageName, "");
145
146
    Skin *const skin = theme->loadSkinRect(*images, name, "");
147
    if (skin != nullptr)
148
    {
149
        Image *const image = images->grid[0];
150
        if (image != nullptr)
151
        {
152
            if (x == -1)
153
                x = skin->getOption("x", 10);
154
            if (y == -1)
155
                y = skin->getOption("y", 10);
156
            const int pad = skin->getPadding();
157
            const int pad2 = 2 * pad;
158
            const int border = skin->getOption("clickborder");
159
            const int border2 = border * 2;
160
            const int diff = pad - border;
161
            switch (type)
162
            {
163
                case LEFT:
164
                    y += (mainGraphics->mHeight - height) / 2;
165
                    break;
166
                case RIGHT:
167
                    x = mainGraphics->mWidth - width - pad2 - x;
168
                    y = mainGraphics->mHeight - height - pad2 - y;
169
                    break;
170
                case NORMAL:
171
                default:
172
                    break;
173
            }
174
            *item = new TouchItem(text, Rect(x + diff, y + diff,
175
                width + border2, height + border2), type,
176
                eventPressed, eventReleased, images, icon,
177
                x + pad, y + pad, width, height,
178
                fAll, fPressed, fReleased, fOut);
179
            mObjects.push_back(*item);
180
        }
181
        else
182
        {
183
            delete images;
184
        }
185
        theme->unload(skin);
186
    }
187
    else
188
    {
189
        delete images;
190
    }
191
    mRedraw = true;
192
}
193
194
386
void TouchManager::clear() restrict2
195
{
196
2316
    FOR_EACH (TouchItemVectorCIter, it, mObjects)
197
        unload(*it);
198
772
    mObjects.clear();
199
386
    delete2(mVertexes);
200
386
    mRedraw = true;
201
386
}
202
203
132
void TouchManager::draw() restrict2
204
{
205
132
    if (mRedraw)
206
    {
207
132
        mRedraw = false;
208
132
        mVertexes->clear();
209
792
        FOR_EACH (TouchItemVectorCIter, it, mObjects)
210
        {
211
            const TouchItem *const item = *it;
212
            if ((item != nullptr) && (item->images != nullptr) && (mShow ||
213
                (item == mKeyboard && mShowKeyboard)))
214
            {
215
                mainGraphics->calcWindow(mVertexes, item->x, item->y,
216
                    item->width, item->height, *item->images);
217
                const Image *const icon = item->icon;
218
                if (icon != nullptr)
219
                {
220
                    mainGraphics->calcTileCollection(mVertexes, icon,
221
                        item->x + (item->width - icon->mBounds.w) / 2,
222
                        item->y + (item->height - icon->mBounds.h) / 2);
223
                }
224
            }
225
        }
226
132
        mainGraphics->finalize(mVertexes);
227
    }
228
132
    mainGraphics->drawTileCollection(mVertexes);
229
132
    drawText();
230
132
}
231
232
void TouchManager::safeDraw() restrict2
233
{
234
    FOR_EACH (TouchItemVectorCIter, it, mObjects)
235
    {
236
        const TouchItem *const item = *it;
237
        if ((item != nullptr) && (item->images != nullptr) && (mShow ||
238
            (item == mKeyboard && mShowKeyboard)))
239
        {
240
            mainGraphics->drawImageRect(item->x, item->y,
241
                item->width, item->height, *item->images);
242
            const Image *const icon = item->icon;
243
            if (icon != nullptr)
244
            {
245
                mainGraphics->drawImage(icon,
246
                    item->x + (item->width - icon->mBounds.w) / 2,
247
                    item->y + (item->height - icon->mBounds.h) / 2);
248
            }
249
        }
250
    }
251
    drawText();
252
}
253
254
132
void TouchManager::drawText() restrict2
255
{
256
132
    if (gui == nullptr)
257
        return;
258
259
132
    Font *const font = boldFont;
260
132
    const Color &color1 = theme->getColor(ThemeColorId::TEXT, 255);
261
132
    const Color &color2 = theme->getColor(ThemeColorId::TEXT_OUTLINE, 255);
262
263
792
    FOR_EACH (TouchItemVectorCIter, it, mObjects)
264
    {
265
        const TouchItem *const item = *it;
266
        if ((item != nullptr) && mShow && !item->text.empty())
267
        {
268
            const std::string str = item->text;
269
            const int textX = (item->rect.width - font->getWidth(str))
270
                / 2 + item->x;
271
            const int textY = (item->rect.height - font->getHeight())
272
                / 2 + item->y;
273
            font->drawString(mainGraphics,
274
                color1,
275
                color2,
276
                str, textX, textY);
277
        }
278
    }
279
}
280
281
bool TouchManager::processEvent(const MouseInput &mouseInput) restrict2
282
{
283
    const int x = mouseInput.getTouchX();
284
    const int y = mouseInput.getTouchY();
285
286
    FOR_EACH (TouchItemVectorCIter, it, mObjects)
287
    {
288
        const TouchItem *const item = *it;
289
        if (item == nullptr ||
290
            (!mShow && (item != mKeyboard || !mShowKeyboard)))
291
        {
292
            continue;
293
        }
294
        const Rect &rect = item->rect;
295
        if (rect.isPointInRect(x, y))
296
        {
297
            MouseInput event = mouseInput;
298
            event.setX(event.getTouchX() - item->x);
299
            event.setY(event.getTouchY() - item->y);
300
            if (item->funcAll != nullptr)
301
                item->funcAll(event);
302
303
            switch (mouseInput.getType())
304
            {
305
                case MouseEventType::PRESSED:
306
                    if (!item->eventPressed.empty())
307
                        executeAction(item->eventPressed);
308
                    else if (item->funcPressed != nullptr)
309
                        item->funcPressed(event);
310
                    break;
311
                case MouseEventType::RELEASED:
312
                    if (!item->eventReleased.empty())
313
                        executeAction(item->eventReleased);
314
                    else if (item->funcReleased != nullptr)
315
                        item->funcReleased(event);
316
                    break;
317
                default:
318
                case MouseEventType::MOVED:
319
                case MouseEventType::WHEEL_MOVED_DOWN:
320
                case MouseEventType::WHEEL_MOVED_UP:
321
                case MouseEventType::CLICKED:
322
                case MouseEventType::ENTERED:
323
                case MouseEventType::EXITED:
324
                case MouseEventType::DRAGGED:
325
                case MouseEventType::RELEASED2:
326
                    break;
327
            }
328
            return true;
329
        }
330
        else if (item->funcOut != nullptr)
331
        {
332
            item->funcOut(mouseInput);
333
        }
334
    }
335
    return false;
336
}
337
338
4
bool TouchManager::isActionActive(const InputActionT index) restrict2 const
339
{
340
4
    if (CAST_S32(index) < 0 ||
341
        CAST_S32(index) >= actionsSize)
342
    {
343
        return false;
344
    }
345
4
    return mActions[CAST_SIZE(index)];
346
}
347
348
void TouchManager::resize(const int width, const int height) restrict2
349
{
350
    mRedraw = true;
351
    const int maxHeight = mHeight;
352
    const int diffW = width - mWidth;
353
    const int diffH = height - maxHeight;
354
    FOR_EACH (TouchItemVectorCIter, it, mObjects)
355
    {
356
        TouchItem *const item = *it;
357
        if (item == nullptr)
358
            continue;
359
360
        switch (item->type)
361
        {
362
            case LEFT:
363
                if (height != maxHeight)
364
                {
365
                    item->y = (height - item->height) / 2;
366
                    item->rect.y = (height - item->rect.y) / 2;
367
                }
368
                break;
369
            case RIGHT:
370
            {
371
                item->x += diffW;
372
                item->rect.x += diffW;
373
                item->y += diffH;
374
                item->rect.y += diffH;
375
                break;
376
            }
377
            case NORMAL:
378
            default:
379
                break;
380
        }
381
    }
382
    mWidth = mainGraphics->mWidth;
383
    mHeight = mainGraphics->mHeight;
384
}
385
386
void TouchManager::unload(TouchItem *restrict const item)
387
{
388
    if (item != nullptr)
389
    {
390
        if (item->images != nullptr)
391
        {
392
            Theme::unloadRect(*item->images);
393
            delete2(item->images);
394
            if (item->icon != nullptr)
395
            {
396
                item->icon->decRef();
397
                item->icon = nullptr;
398
            }
399
        }
400
        delete item;
401
    }
402
}
403
404
void TouchManager::unloadTouchItem(TouchItem *restrict *unloadItem) restrict2
405
{
406
    FOR_EACH (TouchItemVectorIter, it, mObjects)
407
    {
408
        TouchItem *item = *it;
409
        if ((item != nullptr) && *unloadItem == item)
410
        {
411
            mObjects.erase(it);
412
            unload(item);
413
            return;
414
        }
415
    }
416
}
417
418
void TouchManager::loadPad() restrict2
419
{
420
    const int sz = (mJoystickSize + 2) * 50;
421
    loadTouchItem(&mPad, "dpad.xml", "dpad_image.xml", "", -1, -1, sz, sz,
422
        LEFT, "", "", &padEvents, &padClick, &padUp, &padOut);
423
}
424
425
void TouchManager::loadButtons() restrict2
426
{
427
    const int sz = (mButtonsSize + 1) * 50;
428
    if (theme == nullptr)
429
        return;
430
    Skin *const skin = theme->load("dbutton.xml", "");
431
432
    if (skin != nullptr)
433
    {
434
        const int x = skin->getOption("x", 10);
435
        const int y = skin->getOption("y", 10);
436
        const int pad = skin->getPadding();
437
        const int pad2 = 2 * pad + sz;
438
        const int skipWidth = pad2 + x;
439
        const int skipHeight = pad2 + y;
440
441
        switch (mButtonsFormat)
442
        {
443
            // 2x1
444
            case 0:
445
            default:
446
            {
447
                loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
448
                    "2", x, y, sz, sz, RIGHT, "screenActionButton1", "");
449
                loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
450
                    "1", skipWidth, y, sz, sz, RIGHT,
451
                    "screenActionButton0", "");
452
                break;
453
            }
454
            // 2x2
455
            case 1:
456
            {
457
                loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
458
                    "4", x, y, sz, sz, RIGHT, "screenActionButton3", "");
459
                loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
460
                    "3", skipWidth, y, sz, sz, RIGHT,
461
                    "screenActionButton2", "");
462
                loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
463
                    "2", x, skipHeight, sz, sz, RIGHT,
464
                    "screenActionButton1", "");
465
                loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
466
                    "1", skipWidth, skipHeight, sz, sz, RIGHT,
467
                    "screenActionButton0", "");
468
                break;
469
            }
470
            // 3x3
471
            case 2:
472
            {
473
                const int pad4 = pad2 * 2;
474
                const int skipWidth2 = pad4 + x;
475
                const int skipHeight2 = pad4 + y;
476
                loadTouchItem(&mButtons[8], "dbutton.xml", "dbutton_image.xml",
477
                    "9", x, y, sz, sz, RIGHT, "screenActionButton8", "");
478
                loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml",
479
                    "8", skipWidth, y, sz, sz, RIGHT,
480
                    "screenActionButton7", "");
481
                loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml",
482
                    "7", skipWidth2, y, sz, sz, RIGHT,
483
                    "screenActionButton6", "");
484
                loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
485
                    "6", x, skipHeight, sz, sz, RIGHT,
486
                    "screenActionButton5", "");
487
                loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
488
                    "5", skipWidth, skipHeight, sz, sz, RIGHT,
489
                    "screenActionButton4", "");
490
                loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
491
                    "4", skipWidth2, skipHeight, sz, sz, RIGHT,
492
                    "screenActionButton3", "");
493
                loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
494
                    "3", x, skipHeight2, sz, sz, RIGHT,
495
                    "screenActionButton2", "");
496
                loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
497
                    "2", skipWidth, skipHeight2, sz, sz, RIGHT,
498
                    "screenActionButton1", "");
499
                loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
500
                    "1", skipWidth2, skipHeight2, sz, sz, RIGHT,
501
                    "screenActionButton0", "");
502
                break;
503
            }
504
            // 4x2
505
            case 3:
506
            {
507
                const int skipWidth2 = pad2 * 2 + x;
508
                const int skipWidth3 = pad2 * 3 + x;
509
                loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml",
510
                    "8", x, y, sz, sz, RIGHT, "screenActionButton7", "");
511
                loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml",
512
                    "7", skipWidth, y, sz, sz, RIGHT,
513
                    "screenActionButton6", "");
514
                loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
515
                    "6", skipWidth2, y, sz, sz, RIGHT,
516
                    "screenActionButton5", "");
517
                loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
518
                    "5", skipWidth3, y, sz, sz, RIGHT,
519
                    "screenActionButton4", "");
520
                loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
521
                    "4", x, skipHeight, sz, sz, RIGHT,
522
                    "screenActionButton3", "");
523
                loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
524
                    "3", skipWidth, skipHeight, sz, sz, RIGHT,
525
                    "screenActionButton2", "");
526
                loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
527
                    "2", skipWidth2, skipHeight, sz, sz, RIGHT,
528
                    "screenActionButton1", "");
529
                loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
530
                    "1", skipWidth3, skipHeight, sz, sz, RIGHT,
531
                    "screenActionButton0", "");
532
                break;
533
            }
534
            // 4x3
535
            case 4:
536
            {
537
                const int skipWidth2 = pad2 * 2 + x;
538
                const int skipWidth3 = pad2 * 3 + x;
539
                const int skipHeight2 = pad2 * 2 + y;
540
                loadTouchItem(&mButtons[11], "dbutton.xml",
541
                    "dbutton_image.xml", "12", x, y, sz, sz, RIGHT,
542
                    "screenActionButton11", "");
543
                loadTouchItem(&mButtons[10], "dbutton.xml",
544
                    "dbutton_image.xml", "11", skipWidth, y, sz, sz, RIGHT,
545
                    "screenActionButton10", "");
546
                loadTouchItem(&mButtons[9], "dbutton.xml", "dbutton_image.xml",
547
                    "10", skipWidth2, y, sz, sz, RIGHT,
548
                    "screenActionButton9", "");
549
                loadTouchItem(&mButtons[8], "dbutton.xml", "dbutton_image.xml",
550
                    "9", skipWidth3, y, sz, sz, RIGHT,
551
                    "screenActionButton8", "");
552
                loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml",
553
                    "8", x, skipHeight, sz, sz, RIGHT,
554
                    "screenActionButton7", "");
555
                loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml",
556
                    "7", skipWidth, skipHeight, sz, sz, RIGHT,
557
                    "screenActionButton6", "");
558
                loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
559
                    "6", skipWidth2, skipHeight, sz, sz, RIGHT,
560
                    "screenActionButton5", "");
561
                loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
562
                    "5", skipWidth3, skipHeight, sz, sz, RIGHT,
563
                    "screenActionButton4", "");
564
                loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
565
                    "4", x, skipHeight2, sz, sz, RIGHT,
566
                    "screenActionButton3", "");
567
                loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
568
                    "3", skipWidth, skipHeight2, sz, sz, RIGHT,
569
                    "screenActionButton2", "");
570
                loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
571
                    "2", skipWidth2, skipHeight2, sz, sz, RIGHT,
572
                    "screenActionButton1", "");
573
                loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
574
                    "1", skipWidth3, skipHeight2, sz, sz, RIGHT,
575
                    "screenActionButton0", "");
576
                break;
577
            }
578
            // 3x2
579
            case 5:
580
            {
581
                const int pad4 = pad2 * 2;
582
                const int skipWidth2 = pad4 + x;
583
                loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
584
                    "6", x, y, sz, sz, RIGHT, "screenActionButton5", "");
585
                loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
586
                    "5", skipWidth, y, sz, sz, RIGHT,
587
                    "screenActionButton4", "");
588
                loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
589
                    "4", skipWidth2, y, sz, sz, RIGHT,
590
                    "screenActionButton3", "");
591
                loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
592
                    "3", x, skipHeight, sz, sz, RIGHT,
593
                    "screenActionButton2", "");
594
                loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
595
                    "2", skipWidth, skipHeight, sz, sz, RIGHT,
596
                    "screenActionButton1", "");
597
                loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
598
                    "1", skipWidth2, skipHeight, sz, sz, RIGHT,
599
                    "screenActionButton0", "");
600
                break;
601
            }
602
        };
603
        theme->unload(skin);
604
    }
605
}
606
607
void TouchManager::loadKeyboard() restrict2
608
{
609
    loadTouchItem(&mKeyboard, "keyboard_icon.xml", "", "", -1, -1, 28, 28,
610
        NORMAL, "", "screenActionKeyboard");
611
}
612
613
void TouchManager::optionChanged(const std::string &value) restrict2
614
{
615
    if (value == "showScreenJoystick")
616
    {
617
        if (mShowJoystick == config.getBoolValue("showScreenJoystick"))
618
            return;
619
        mShowJoystick = config.getBoolValue("showScreenJoystick");
620
        if (mShowJoystick)
621
            loadPad();
622
        else
623
            unloadTouchItem(&mPad);
624
        mRedraw = true;
625
    }
626
    else if (value == "showScreenButtons")
627
    {
628
        if (mShowButtons == config.getBoolValue("showScreenButtons"))
629
            return;
630
        mShowButtons = config.getBoolValue("showScreenButtons");
631
        if (mShowButtons)
632
        {
633
            loadButtons();
634
        }
635
        else
636
        {
637
            for (int f = 0; f < buttonsCount; f ++)
638
                unloadTouchItem(&mButtons[f]);
639
        }
640
        mRedraw = true;
641
    }
642
    else if (value == "showScreenKeyboard")
643
    {
644
        if (mShowKeyboard == config.getBoolValue("showScreenKeyboard"))
645
            return;
646
        mShowKeyboard = config.getBoolValue("showScreenKeyboard");
647
        if (mShowKeyboard)
648
            loadKeyboard();
649
        else
650
            unloadTouchItem(&mKeyboard);
651
        mRedraw = true;
652
    }
653
    else if (value == "screenButtonsSize")
654
    {
655
        if (mButtonsSize == config.getIntValue("screenButtonsSize"))
656
            return;
657
        mButtonsSize = config.getIntValue("screenButtonsSize");
658
        if (mShowButtons)
659
        {
660
            for (int f = 0; f < buttonsCount; f ++)
661
                unloadTouchItem(&mButtons[f]);
662
            loadButtons();
663
        }
664
    }
665
    else if (value == "screenJoystickSize")
666
    {
667
        if (mJoystickSize == config.getIntValue("screenJoystickSize"))
668
            return;
669
        mJoystickSize = config.getIntValue("screenJoystickSize");
670
        setHalfJoyPad(getPadSize() / 2);
671
        if (mShowJoystick)
672
        {
673
            unloadTouchItem(&mPad);
674
            loadPad();
675
        }
676
    }
677
    else if (value == "screenButtonsFormat")
678
    {
679
        if (mButtonsFormat == config.getIntValue("screenButtonsFormat"))
680
            return;
681
        mButtonsFormat = config.getIntValue("screenButtonsFormat");
682
        if (mShowButtons)
683
        {
684
            for (int f = 0; f < buttonsCount; f ++)
685
                unloadTouchItem(&mButtons[f]);
686
            loadButtons();
687
        }
688
    }
689
}
690
691
void TouchManager::setInGame(const bool b) restrict2
692
{
693
    mInGame = b;
694
    mShow = mInGame && !mTempHideButtons;
695
    mRedraw = true;
696
}
697
698
void TouchManager::setTempHide(const bool b) restrict2
699
{
700
    mTempHideButtons = b;
701
    mShow = mInGame && !mTempHideButtons;
702
    mRedraw = true;
703
}
704
705
void TouchManager::executeAction(const std::string &restrict event)
706
{
707
    inputManager.executeAction(static_cast<InputActionT>(
708
        config.getIntValue(event)));
709
4
}