ManaPlus
touchmanager.cpp
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2012-2018 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 
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 
35 
36 #include "utils/delete2.h"
37 #include "utils/foreach.h"
38 
39 #include "render/graphics.h"
40 
42 
43 #include "resources/imagerect.h"
44 
45 #include "resources/image/image.h"
46 
47 #include "debug.h"
48 
50 
51 extern RenderType openGLMode;
52 
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  mTempHideButtons(false)
70 {
71  for (int f = 0; f < actionsSize; f ++)
72  mActions[f] = false;
73  for (int f = 0; f < buttonsCount; f ++)
74  mButtons[f] = nullptr;
75 }
76 
78 {
79  clear();
81 }
82 
84 {
85  config.removeListeners(this);
86 }
87 
89 {
90  delete mVertexes;
92 
93  config.addListener("showScreenJoystick", this);
94  config.addListener("showScreenButtons", this);
95  config.addListener("showScreenKeyboard", this);
96  config.addListener("screenButtonsSize", this);
97  config.addListener("screenJoystickSize", this);
98  config.addListener("screenButtonsFormat", this);
99 
100  mShowJoystick = config.getBoolValue("showScreenJoystick");
101  mShowButtons = config.getBoolValue("showScreenButtons");
102  mShowKeyboard = config.getBoolValue("showScreenKeyboard");
103  mButtonsSize = config.getIntValue("screenButtonsSize");
104  mJoystickSize = config.getIntValue("screenJoystickSize");
105  mButtonsFormat = config.getIntValue("screenButtonsFormat");
106 
107  setHalfJoyPad(getPadSize() / 2);
108 
109  if (mShowKeyboard)
110  loadKeyboard();
111  if (mShowJoystick)
112  loadPad();
113  if (mShowButtons)
114  loadButtons();
117 }
118 
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,
147  name,
148  "",
149  0,
150  8);
151  if (skin != nullptr)
152  {
153  Image *const image = images->grid[0];
154  if (image != nullptr)
155  {
156  if (x == -1)
157  x = skin->getOption("x", 10);
158  if (y == -1)
159  y = skin->getOption("y", 10);
160  const int pad = skin->getPadding();
161  const int pad2 = 2 * pad;
162  const int border = skin->getOption("clickborder");
163  const int border2 = border * 2;
164  const int diff = pad - border;
165  switch (type)
166  {
167  case LEFT:
168  y += (mainGraphics->mHeight - height) / 2;
169  break;
170  case RIGHT:
171  x = mainGraphics->mWidth - width - pad2 - x;
172  y = mainGraphics->mHeight - height - pad2 - y;
173  break;
174  case NORMAL:
175  default:
176  break;
177  }
178  *item = new TouchItem(text, Rect(x + diff, y + diff,
179  width + border2, height + border2), type,
180  eventPressed, eventReleased, images, icon,
181  x + pad, y + pad, width, height,
182  fAll, fPressed, fReleased, fOut);
183  mObjects.push_back(*item);
184  }
185  else
186  {
187  delete images;
188  }
189  theme->unload(skin);
190  }
191  else
192  {
193  delete images;
194  }
195  mRedraw = true;
196 }
197 
199 {
201  unload(*it);
202  mObjects.clear();
204  mRedraw = true;
205 }
206 
208 {
209  if (mRedraw)
210  {
211  mRedraw = false;
212  mVertexes->clear();
214  {
215  const TouchItem *const item = *it;
216  if ((item != nullptr) && (item->images != nullptr) && (mShow ||
217  (item == mKeyboard && mShowKeyboard)))
218  {
219  mainGraphics->calcWindow(mVertexes, item->x, item->y,
220  item->width, item->height, *item->images);
221  const Image *const icon = item->icon;
222  if (icon != nullptr)
223  {
225  item->x + (item->width - icon->mBounds.w) / 2,
226  item->y + (item->height - icon->mBounds.h) / 2);
227  }
228  }
229  }
231  }
233  drawText();
234 }
235 
237 {
239  {
240  const TouchItem *const item = *it;
241  if ((item != nullptr) && (item->images != nullptr) && (mShow ||
242  (item == mKeyboard && mShowKeyboard)))
243  {
244  mainGraphics->drawImageRect(item->x, item->y,
245  item->width, item->height, *item->images);
246  const Image *const icon = item->icon;
247  if (icon != nullptr)
248  {
249  mainGraphics->drawImage(icon,
250  item->x + (item->width - icon->mBounds.w) / 2,
251  item->y + (item->height - icon->mBounds.h) / 2);
252  }
253  }
254  }
255  drawText();
256 }
257 
259 {
260  if (gui == nullptr)
261  return;
262 
263  Font *const font = boldFont;
264  const Color &color1 = theme->getColor(ThemeColorId::TEXT, 255);
265  const Color &color2 = theme->getColor(ThemeColorId::TEXT_OUTLINE, 255);
266 
268  {
269  const TouchItem *const item = *it;
270  if ((item != nullptr) && mShow && !item->text.empty())
271  {
272  const std::string str = item->text;
273  const int textX = (item->rect.width - font->getWidth(str))
274  / 2 + item->x;
275  const int textY = (item->rect.height - font->getHeight())
276  / 2 + item->y;
277  font->drawString(mainGraphics,
278  color1,
279  color2,
280  str, textX, textY);
281  }
282  }
283 }
284 
286 {
287  const int x = mouseInput.getTouchX();
288  const int y = mouseInput.getTouchY();
289 
291  {
292  const TouchItem *const item = *it;
293  if (item == nullptr ||
294  (!mShow && (item != mKeyboard || !mShowKeyboard)))
295  {
296  continue;
297  }
298  const Rect &rect = item->rect;
299  if (rect.isPointInRect(x, y))
300  {
301  MouseInput event = mouseInput;
302  event.setX(event.getTouchX() - item->x);
303  event.setY(event.getTouchY() - item->y);
304  if (item->funcAll != nullptr)
305  item->funcAll(event);
306 
307  switch (mouseInput.getType())
308  {
310  if (!item->eventPressed.empty())
312  else if (item->funcPressed != nullptr)
313  item->funcPressed(event);
314  break;
316  if (!item->eventReleased.empty())
318  else if (item->funcReleased != nullptr)
319  item->funcReleased(event);
320  break;
321  default:
330  break;
331  }
332  return true;
333  }
334  else if (item->funcOut != nullptr)
335  {
336  item->funcOut(mouseInput);
337  }
338  }
339  return false;
340 }
341 
343 {
344  if (CAST_S32(index) < 0 ||
345  CAST_S32(index) >= actionsSize)
346  {
347  return false;
348  }
349  return mActions[CAST_SIZE(index)];
350 }
351 
352 void TouchManager::resize(const int width, const int height) restrict2
353 {
354  mRedraw = true;
355  const int maxHeight = mHeight;
356  const int diffW = width - mWidth;
357  const int diffH = height - maxHeight;
359  {
360  TouchItem *const item = *it;
361  if (item == nullptr)
362  continue;
363 
364  switch (item->type)
365  {
366  case LEFT:
367  if (height != maxHeight)
368  {
369  item->y = (height - item->height) / 2;
370  item->rect.y = (height - item->rect.y) / 2;
371  }
372  break;
373  case RIGHT:
374  {
375  item->x += diffW;
376  item->rect.x += diffW;
377  item->y += diffH;
378  item->rect.y += diffH;
379  break;
380  }
381  case NORMAL:
382  default:
383  break;
384  }
385  }
386  mWidth = mainGraphics->mWidth;
388 }
389 
391 {
392  if (item != nullptr)
393  {
394  if (item->images != nullptr)
395  {
396  Theme::unloadRect(*item->images, 0, 8);
397  delete2(item->images);
398  if (item->icon != nullptr)
399  {
400  item->icon->decRef();
401  item->icon = nullptr;
402  }
403  }
404  delete item;
405  }
406 }
407 
409 {
411  {
412  TouchItem *item = *it;
413  if ((item != nullptr) && *unloadItem == item)
414  {
415  mObjects.erase(it);
416  unload(item);
417  return;
418  }
419  }
420 }
421 
423 {
424  const int sz = (mJoystickSize + 2) * 50;
425  loadTouchItem(&mPad, "dpad.xml", "dpad_image.xml", "", -1, -1, sz, sz,
426  LEFT, "", "", &padEvents, &padClick, &padUp, &padOut);
427 }
428 
430 {
431  const int sz = (mButtonsSize + 1) * 50;
432  if (theme == nullptr)
433  return;
434  Skin *const skin = theme->load("dbutton.xml",
435  "",
436  true,
438 
439  if (skin != nullptr)
440  {
441  const int x = skin->getOption("x", 10);
442  const int y = skin->getOption("y", 10);
443  const int pad = skin->getPadding();
444  const int pad2 = 2 * pad + sz;
445  const int skipWidth = pad2 + x;
446  const int skipHeight = pad2 + y;
447 
448  switch (mButtonsFormat)
449  {
450  // 2x1
451  case 0:
452  default:
453  {
454  loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
455  "2", x, y, sz, sz, RIGHT, "screenActionButton1", "",
456  nullptr, nullptr, nullptr, nullptr);
457  loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
458  "1", skipWidth, y, sz, sz, RIGHT,
459  "screenActionButton0", "",
460  nullptr, nullptr, nullptr, nullptr);
461  break;
462  }
463  // 2x2
464  case 1:
465  {
466  loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
467  "4", x, y, sz, sz, RIGHT, "screenActionButton3", "",
468  nullptr, nullptr, nullptr, nullptr);
469  loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
470  "3", skipWidth, y, sz, sz, RIGHT,
471  "screenActionButton2", "",
472  nullptr, nullptr, nullptr, nullptr);
473  loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
474  "2", x, skipHeight, sz, sz, RIGHT,
475  "screenActionButton1", "",
476  nullptr, nullptr, nullptr, nullptr);
477  loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
478  "1", skipWidth, skipHeight, sz, sz, RIGHT,
479  "screenActionButton0", "",
480  nullptr, nullptr, nullptr, nullptr);
481  break;
482  }
483  // 3x3
484  case 2:
485  {
486  const int pad4 = pad2 * 2;
487  const int skipWidth2 = pad4 + x;
488  const int skipHeight2 = pad4 + y;
489  loadTouchItem(&mButtons[8], "dbutton.xml", "dbutton_image.xml",
490  "9", x, y, sz, sz, RIGHT, "screenActionButton8", "",
491  nullptr, nullptr, nullptr, nullptr);
492  loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml",
493  "8", skipWidth, y, sz, sz, RIGHT,
494  "screenActionButton7", "",
495  nullptr, nullptr, nullptr, nullptr);
496  loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml",
497  "7", skipWidth2, y, sz, sz, RIGHT,
498  "screenActionButton6", "",
499  nullptr, nullptr, nullptr, nullptr);
500  loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
501  "6", x, skipHeight, sz, sz, RIGHT,
502  "screenActionButton5", "",
503  nullptr, nullptr, nullptr, nullptr);
504  loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
505  "5", skipWidth, skipHeight, sz, sz, RIGHT,
506  "screenActionButton4", "",
507  nullptr, nullptr, nullptr, nullptr);
508  loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
509  "4", skipWidth2, skipHeight, sz, sz, RIGHT,
510  "screenActionButton3", "",
511  nullptr, nullptr, nullptr, nullptr);
512  loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
513  "3", x, skipHeight2, sz, sz, RIGHT,
514  "screenActionButton2", "",
515  nullptr, nullptr, nullptr, nullptr);
516  loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
517  "2", skipWidth, skipHeight2, sz, sz, RIGHT,
518  "screenActionButton1", "",
519  nullptr, nullptr, nullptr, nullptr);
520  loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
521  "1", skipWidth2, skipHeight2, sz, sz, RIGHT,
522  "screenActionButton0", "",
523  nullptr, nullptr, nullptr, nullptr);
524  break;
525  }
526  // 4x2
527  case 3:
528  {
529  const int skipWidth2 = pad2 * 2 + x;
530  const int skipWidth3 = pad2 * 3 + x;
531  loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml",
532  "8", x, y, sz, sz, RIGHT, "screenActionButton7", "",
533  nullptr, nullptr, nullptr, nullptr);
534  loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml",
535  "7", skipWidth, y, sz, sz, RIGHT,
536  "screenActionButton6", "",
537  nullptr, nullptr, nullptr, nullptr);
538  loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
539  "6", skipWidth2, y, sz, sz, RIGHT,
540  "screenActionButton5", "",
541  nullptr, nullptr, nullptr, nullptr);
542  loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
543  "5", skipWidth3, y, sz, sz, RIGHT,
544  "screenActionButton4", "",
545  nullptr, nullptr, nullptr, nullptr);
546  loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
547  "4", x, skipHeight, sz, sz, RIGHT,
548  "screenActionButton3", "",
549  nullptr, nullptr, nullptr, nullptr);
550  loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
551  "3", skipWidth, skipHeight, sz, sz, RIGHT,
552  "screenActionButton2", "",
553  nullptr, nullptr, nullptr, nullptr);
554  loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
555  "2", skipWidth2, skipHeight, sz, sz, RIGHT,
556  "screenActionButton1", "",
557  nullptr, nullptr, nullptr, nullptr);
558  loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
559  "1", skipWidth3, skipHeight, sz, sz, RIGHT,
560  "screenActionButton0", "",
561  nullptr, nullptr, nullptr, nullptr);
562  break;
563  }
564  // 4x3
565  case 4:
566  {
567  const int skipWidth2 = pad2 * 2 + x;
568  const int skipWidth3 = pad2 * 3 + x;
569  const int skipHeight2 = pad2 * 2 + y;
570  loadTouchItem(&mButtons[11], "dbutton.xml",
571  "dbutton_image.xml", "12", x, y, sz, sz, RIGHT,
572  "screenActionButton11", "",
573  nullptr, nullptr, nullptr, nullptr);
574  loadTouchItem(&mButtons[10], "dbutton.xml",
575  "dbutton_image.xml", "11", skipWidth, y, sz, sz, RIGHT,
576  "screenActionButton10", "",
577  nullptr, nullptr, nullptr, nullptr);
578  loadTouchItem(&mButtons[9], "dbutton.xml", "dbutton_image.xml",
579  "10", skipWidth2, y, sz, sz, RIGHT,
580  "screenActionButton9", "",
581  nullptr, nullptr, nullptr, nullptr);
582  loadTouchItem(&mButtons[8], "dbutton.xml", "dbutton_image.xml",
583  "9", skipWidth3, y, sz, sz, RIGHT,
584  "screenActionButton8", "",
585  nullptr, nullptr, nullptr, nullptr);
586  loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml",
587  "8", x, skipHeight, sz, sz, RIGHT,
588  "screenActionButton7", "",
589  nullptr, nullptr, nullptr, nullptr);
590  loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml",
591  "7", skipWidth, skipHeight, sz, sz, RIGHT,
592  "screenActionButton6", "",
593  nullptr, nullptr, nullptr, nullptr);
594  loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
595  "6", skipWidth2, skipHeight, sz, sz, RIGHT,
596  "screenActionButton5", "",
597  nullptr, nullptr, nullptr, nullptr);
598  loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
599  "5", skipWidth3, skipHeight, sz, sz, RIGHT,
600  "screenActionButton4", "",
601  nullptr, nullptr, nullptr, nullptr);
602  loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
603  "4", x, skipHeight2, sz, sz, RIGHT,
604  "screenActionButton3", "",
605  nullptr, nullptr, nullptr, nullptr);
606  loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
607  "3", skipWidth, skipHeight2, sz, sz, RIGHT,
608  "screenActionButton2", "",
609  nullptr, nullptr, nullptr, nullptr);
610  loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
611  "2", skipWidth2, skipHeight2, sz, sz, RIGHT,
612  "screenActionButton1", "",
613  nullptr, nullptr, nullptr, nullptr);
614  loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
615  "1", skipWidth3, skipHeight2, sz, sz, RIGHT,
616  "screenActionButton0", "",
617  nullptr, nullptr, nullptr, nullptr);
618  break;
619  }
620  // 3x2
621  case 5:
622  {
623  const int pad4 = pad2 * 2;
624  const int skipWidth2 = pad4 + x;
625  loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml",
626  "6", x, y, sz, sz, RIGHT, "screenActionButton5", "",
627  nullptr, nullptr, nullptr, nullptr);
628  loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml",
629  "5", skipWidth, y, sz, sz, RIGHT,
630  "screenActionButton4", "",
631  nullptr, nullptr, nullptr, nullptr);
632  loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml",
633  "4", skipWidth2, y, sz, sz, RIGHT,
634  "screenActionButton3", "",
635  nullptr, nullptr, nullptr, nullptr);
636  loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
637  "3", x, skipHeight, sz, sz, RIGHT,
638  "screenActionButton2", "",
639  nullptr, nullptr, nullptr, nullptr);
640  loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
641  "2", skipWidth, skipHeight, sz, sz, RIGHT,
642  "screenActionButton1", "",
643  nullptr, nullptr, nullptr, nullptr);
644  loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
645  "1", skipWidth2, skipHeight, sz, sz, RIGHT,
646  "screenActionButton0", "",
647  nullptr, nullptr, nullptr, nullptr);
648  break;
649  }
650  };
651  theme->unload(skin);
652  }
653 }
654 
656 {
657  loadTouchItem(&mKeyboard, "keyboard_icon.xml", "", "", -1, -1, 28, 28,
658  NORMAL, "", "screenActionKeyboard",
659  nullptr, nullptr, nullptr, nullptr);
660 }
661 
662 void TouchManager::optionChanged(const std::string &value) restrict2
663 {
664  if (value == "showScreenJoystick")
665  {
666  if (mShowJoystick == config.getBoolValue("showScreenJoystick"))
667  return;
668  mShowJoystick = config.getBoolValue("showScreenJoystick");
669  if (mShowJoystick)
670  loadPad();
671  else
673  mRedraw = true;
674  }
675  else if (value == "showScreenButtons")
676  {
677  if (mShowButtons == config.getBoolValue("showScreenButtons"))
678  return;
679  mShowButtons = config.getBoolValue("showScreenButtons");
680  if (mShowButtons)
681  {
682  loadButtons();
683  }
684  else
685  {
686  for (int f = 0; f < buttonsCount; f ++)
688  }
689  mRedraw = true;
690  }
691  else if (value == "showScreenKeyboard")
692  {
693  if (mShowKeyboard == config.getBoolValue("showScreenKeyboard"))
694  return;
695  mShowKeyboard = config.getBoolValue("showScreenKeyboard");
696  if (mShowKeyboard)
697  loadKeyboard();
698  else
700  mRedraw = true;
701  }
702  else if (value == "screenButtonsSize")
703  {
704  if (mButtonsSize == config.getIntValue("screenButtonsSize"))
705  return;
706  mButtonsSize = config.getIntValue("screenButtonsSize");
707  if (mShowButtons)
708  {
709  for (int f = 0; f < buttonsCount; f ++)
711  loadButtons();
712  }
713  }
714  else if (value == "screenJoystickSize")
715  {
716  if (mJoystickSize == config.getIntValue("screenJoystickSize"))
717  return;
718  mJoystickSize = config.getIntValue("screenJoystickSize");
719  setHalfJoyPad(getPadSize() / 2);
720  if (mShowJoystick)
721  {
723  loadPad();
724  }
725  }
726  else if (value == "screenButtonsFormat")
727  {
728  if (mButtonsFormat == config.getIntValue("screenButtonsFormat"))
729  return;
730  mButtonsFormat = config.getIntValue("screenButtonsFormat");
731  if (mShowButtons)
732  {
733  for (int f = 0; f < buttonsCount; f ++)
735  loadButtons();
736  }
737  }
738 }
739 
741 {
742  mInGame = b;
744  mRedraw = true;
745 }
746 
748 {
749  mTempHideButtons = b;
751  mRedraw = true;
752 }
753 
754 void TouchManager::executeAction(const std::string &restrict event)
755 {
756  inputManager.executeAction(static_cast<InputActionT>(
757  config.getIntValue(event)));
758 }
TouchItem * mPad
Definition: touchmanager.h:183
TouchItemVector::iterator TouchItemVectorIter
Definition: touchmanager.h:99
#define FOR_EACH(type, iter, array)
Definition: foreach.h:24
int width
Definition: rect.h:218
TouchItemVector mObjects
Definition: touchmanager.h:185
Font * boldFont
Definition: gui.cpp:111
TouchFuncPtr funcPressed
Definition: touchmanager.h:92
ImageRect * images
Definition: touchmanager.h:85
Definition: skin.h:35
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
void unload(Skin *const skin)
Definition: theme.cpp:249
Gui * gui
Definition: gui.cpp:110
Definition: font.h:88
bool mShowKeyboard
Definition: touchmanager.h:191
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
Definition: theme.cpp:1135
RenderType openGLMode
void setHalfJoyPad(const int s)
Definition: rect.h:72
int mWidth
Definition: graphics.h:483
void padUp(const MouseInput &mouseInput)
Configuration config
static std::string getThemePath()
Definition: theme.h:66
bool isPointInRect(const int x_, const int y_) const
Definition: rect.h:196
if(!vert) return
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
Definition: theme.cpp:178
bool mActions[actionsSize]
Definition: touchmanager.h:187
int getIntValue(const std::string &key) const
void loadButtons()
#define delete2(var)
Definition: delete2.h:24
void setTempHide(const bool b)
bool isActionActive(const InputActionT index) const
std::string text
Definition: touchmanager.h:80
std::string eventReleased
Definition: touchmanager.h:84
const int actionsSize
Definition: touchmanager.h:42
static void unload(TouchItem *const item)
void addListener(const std::string &key, ConfigListener *const listener)
ImageCollection * mVertexes
Definition: touchmanager.h:186
int getOption(const std::string &name) const
Definition: skin.h:105
virtual void finalize(ImageCollection *const col)
Definition: graphics.h:464
int x
Definition: rect.h:208
int getPadding() const
Definition: skin.h:99
bool mTempHideButtons
Definition: touchmanager.h:199
TouchItem * mKeyboard
Definition: touchmanager.h:182
bool getBoolValue(const std::string &key) const
void setX(int x)
Definition: mouseinput.h:143
TouchItemVector::const_iterator TouchItemVectorCIter
Definition: touchmanager.h:98
#define CAST_S32
Definition: cast.h:29
Image * grid[9]
Definition: imagerect.h:41
static void executeAction(const std::string &event)
void loadKeyboard()
Skin * loadSkinRect(ImageRect &image, const std::string &name, const std::string &name2, const int start, const int end)
Definition: theme.cpp:1109
int y
Definition: rect.h:213
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
Definition: font.cpp:253
Image * icon
Definition: touchmanager.h:86
InputAction ::T InputActionT
Definition: inputaction.h:714
#define nullptr
Definition: localconsts.h:44
Graphics * mainGraphics
Definition: graphics.cpp:108
TouchItem * mButtons[buttonsCount]
Definition: touchmanager.h:184
int height
Definition: rect.h:223
int mHeight
Definition: graphics.h:484
void padClick(const MouseInput &mouseInput)
const Color & getColor(ThemeColorIdT type, const unsigned int alpha)
Definition: theme.h:135
bool mShowJoystick
Definition: touchmanager.h:189
void(* TouchFuncPtr)(const MouseInput &mouseInput)
Definition: touchmanager.h:40
const int buttonsCount
Definition: touchmanager.h:43
void padOut(const MouseInput &mouseInput)
Theme * theme
Definition: theme.cpp:61
void padEvents(const MouseInput &mouseInput)
void setInGame(const bool b)
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
TouchFuncPtr funcAll
Definition: touchmanager.h:91
void removeListeners(ConfigListener *const listener)
int getWidth(const std::string &text) const
Definition: font.cpp:333
bool processEvent(const MouseInput &mouseInput)
void resize(const int width, const int height)
Definition: image.h:61
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
Definition: color.h:74
#define restrict
Definition: localconsts.h:176
#define CAST_SIZE
Definition: cast.h:33
SDL_Rect mBounds
Definition: image.h:210
#define CHECKLISTENERS
Definition: localconsts.h:305
InputManager inputManager
TouchManager touchManager
void optionChanged(const std::string &value)
int getHeight() const
Definition: font.cpp:360
TouchFuncPtr funcOut
Definition: touchmanager.h:94
static void unloadRect(const ImageRect &rect, const int start, const int end)
Definition: theme.cpp:1124
std::string eventPressed
Definition: touchmanager.h:83
void executeAction(const InputActionT keyNum)
void unloadTouchItem(TouchItem **unloadItem)
#define restrict2
Definition: localconsts.h:177
TouchFuncPtr funcReleased
Definition: touchmanager.h:93
void loadTouchItem(TouchItem **item, const std::string &name, const std::string &imageName, const std::string &text, int x, int y, const int width, const int height, const int type, const std::string &eventPressed, const std::string &eventReleased, const TouchFuncPtr fAll, const TouchFuncPtr fPressed, const TouchFuncPtr fReleased, const TouchFuncPtr fOut)
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
RenderType
Definition: rendertype.h:24
int getPadSize() const
Definition: touchmanager.h:170