28 #include "gui/theme.h"
40 #include "render/graphics.h"
70 mTempHideButtons(false)
122 const std::string &
restrict imageName,
125 const int width,
const int height,
127 const std::string &
restrict eventPressed,
128 const std::string &
restrict eventReleased,
135 if (
theme ==
nullptr)
138 for (
int f = 0; f < 9; f ++)
139 images->
grid[f] =
nullptr;
142 if (imageName.empty())
155 if (image !=
nullptr)
162 const int pad2 = 2 * pad;
163 const int border = skin->
getOption(
"clickborder");
164 const int border2 = border * 2;
165 const int diff = pad - border;
180 width + border2, height + border2), type,
181 eventPressed, eventReleased, images, icon,
182 x + pad,
y + pad, width, height,
183 fAll, fPressed, fReleased, fOut);
184 mObjects.push_back(*item);
217 if ((item !=
nullptr) && (item->
images !=
nullptr) && (
mShow ||
226 item->
x + (item->
width - icon->mBounds.w) / 2,
227 item->
y + (item->
height - icon->mBounds.h) / 2);
242 if ((item !=
nullptr) && (item->
images !=
nullptr) && (
mShow ||
251 item->
x + (item->
width - icon->mBounds.w) / 2,
252 item->
y + (item->
height - icon->mBounds.h) / 2);
271 if ((item !=
nullptr) &&
mShow && !item->
text.empty())
273 const std::string str = item->
text;
288 const int x = mouseInput.getTouchX();
289 const int y = mouseInput.getTouchY();
294 if (item ==
nullptr ||
295 (!mShow && (item != mKeyboard || !mShowKeyboard)))
303 event.
setX(event.getTouchX() - item->
x);
304 event.setY(event.getTouchY() - item->
y);
308 switch (mouseInput.getType())
335 else if (item->
funcOut !=
nullptr)
356 const int maxHeight = mHeight;
357 const int diffW = width - mWidth;
358 const int diffH = height - maxHeight;
368 if (height != maxHeight)
370 item->
y = (height - item->
height) / 2;
377 item->
rect.
x += diffW;
379 item->
rect.
y += diffH;
395 if (item->images !=
nullptr)
399 if (item->icon !=
nullptr)
401 item->icon->decRef();
402 item->icon =
nullptr;
414 if ((item !=
nullptr) && *unloadItem == item)
432 if (
theme ==
nullptr)
445 const int pad2 = 2 * pad + sz;
446 const int skipWidth = pad2 +
x;
447 const int skipHeight = pad2 +
y;
456 "2",
x,
y, sz, sz,
RIGHT,
"screenActionButton1",
"",
457 nullptr,
nullptr,
nullptr,
nullptr);
459 "1", skipWidth,
y, sz, sz,
RIGHT,
460 "screenActionButton0",
"",
461 nullptr,
nullptr,
nullptr,
nullptr);
468 "4",
x,
y, sz, sz,
RIGHT,
"screenActionButton3",
"",
469 nullptr,
nullptr,
nullptr,
nullptr);
471 "3", skipWidth,
y, sz, sz,
RIGHT,
472 "screenActionButton2",
"",
473 nullptr,
nullptr,
nullptr,
nullptr);
475 "2",
x, skipHeight, sz, sz,
RIGHT,
476 "screenActionButton1",
"",
477 nullptr,
nullptr,
nullptr,
nullptr);
479 "1", skipWidth, skipHeight, sz, sz,
RIGHT,
480 "screenActionButton0",
"",
481 nullptr,
nullptr,
nullptr,
nullptr);
487 const int pad4 = pad2 * 2;
488 const int skipWidth2 = pad4 +
x;
489 const int skipHeight2 = pad4 +
y;
491 "9",
x,
y, sz, sz,
RIGHT,
"screenActionButton8",
"",
492 nullptr,
nullptr,
nullptr,
nullptr);
494 "8", skipWidth,
y, sz, sz,
RIGHT,
495 "screenActionButton7",
"",
496 nullptr,
nullptr,
nullptr,
nullptr);
498 "7", skipWidth2,
y, sz, sz,
RIGHT,
499 "screenActionButton6",
"",
500 nullptr,
nullptr,
nullptr,
nullptr);
502 "6",
x, skipHeight, sz, sz,
RIGHT,
503 "screenActionButton5",
"",
504 nullptr,
nullptr,
nullptr,
nullptr);
506 "5", skipWidth, skipHeight, sz, sz,
RIGHT,
507 "screenActionButton4",
"",
508 nullptr,
nullptr,
nullptr,
nullptr);
510 "4", skipWidth2, skipHeight, sz, sz,
RIGHT,
511 "screenActionButton3",
"",
512 nullptr,
nullptr,
nullptr,
nullptr);
514 "3",
x, skipHeight2, sz, sz,
RIGHT,
515 "screenActionButton2",
"",
516 nullptr,
nullptr,
nullptr,
nullptr);
518 "2", skipWidth, skipHeight2, sz, sz,
RIGHT,
519 "screenActionButton1",
"",
520 nullptr,
nullptr,
nullptr,
nullptr);
522 "1", skipWidth2, skipHeight2, sz, sz,
RIGHT,
523 "screenActionButton0",
"",
524 nullptr,
nullptr,
nullptr,
nullptr);
530 const int skipWidth2 = pad2 * 2 +
x;
531 const int skipWidth3 = pad2 * 3 +
x;
533 "8",
x,
y, sz, sz,
RIGHT,
"screenActionButton7",
"",
534 nullptr,
nullptr,
nullptr,
nullptr);
536 "7", skipWidth,
y, sz, sz,
RIGHT,
537 "screenActionButton6",
"",
538 nullptr,
nullptr,
nullptr,
nullptr);
540 "6", skipWidth2,
y, sz, sz,
RIGHT,
541 "screenActionButton5",
"",
542 nullptr,
nullptr,
nullptr,
nullptr);
544 "5", skipWidth3,
y, sz, sz,
RIGHT,
545 "screenActionButton4",
"",
546 nullptr,
nullptr,
nullptr,
nullptr);
548 "4",
x, skipHeight, sz, sz,
RIGHT,
549 "screenActionButton3",
"",
550 nullptr,
nullptr,
nullptr,
nullptr);
552 "3", skipWidth, skipHeight, sz, sz,
RIGHT,
553 "screenActionButton2",
"",
554 nullptr,
nullptr,
nullptr,
nullptr);
556 "2", skipWidth2, skipHeight, sz, sz,
RIGHT,
557 "screenActionButton1",
"",
558 nullptr,
nullptr,
nullptr,
nullptr);
560 "1", skipWidth3, skipHeight, sz, sz,
RIGHT,
561 "screenActionButton0",
"",
562 nullptr,
nullptr,
nullptr,
nullptr);
568 const int skipWidth2 = pad2 * 2 +
x;
569 const int skipWidth3 = pad2 * 3 +
x;
570 const int skipHeight2 = pad2 * 2 +
y;
572 "dbutton_image.xml",
"12",
x,
y, sz, sz,
RIGHT,
573 "screenActionButton11",
"",
574 nullptr,
nullptr,
nullptr,
nullptr);
576 "dbutton_image.xml",
"11", skipWidth,
y, sz, sz,
RIGHT,
577 "screenActionButton10",
"",
578 nullptr,
nullptr,
nullptr,
nullptr);
580 "10", skipWidth2,
y, sz, sz,
RIGHT,
581 "screenActionButton9",
"",
582 nullptr,
nullptr,
nullptr,
nullptr);
584 "9", skipWidth3,
y, sz, sz,
RIGHT,
585 "screenActionButton8",
"",
586 nullptr,
nullptr,
nullptr,
nullptr);
588 "8",
x, skipHeight, sz, sz,
RIGHT,
589 "screenActionButton7",
"",
590 nullptr,
nullptr,
nullptr,
nullptr);
592 "7", skipWidth, skipHeight, sz, sz,
RIGHT,
593 "screenActionButton6",
"",
594 nullptr,
nullptr,
nullptr,
nullptr);
596 "6", skipWidth2, skipHeight, sz, sz,
RIGHT,
597 "screenActionButton5",
"",
598 nullptr,
nullptr,
nullptr,
nullptr);
600 "5", skipWidth3, skipHeight, sz, sz,
RIGHT,
601 "screenActionButton4",
"",
602 nullptr,
nullptr,
nullptr,
nullptr);
604 "4",
x, skipHeight2, sz, sz,
RIGHT,
605 "screenActionButton3",
"",
606 nullptr,
nullptr,
nullptr,
nullptr);
608 "3", skipWidth, skipHeight2, sz, sz,
RIGHT,
609 "screenActionButton2",
"",
610 nullptr,
nullptr,
nullptr,
nullptr);
612 "2", skipWidth2, skipHeight2, sz, sz,
RIGHT,
613 "screenActionButton1",
"",
614 nullptr,
nullptr,
nullptr,
nullptr);
616 "1", skipWidth3, skipHeight2, sz, sz,
RIGHT,
617 "screenActionButton0",
"",
618 nullptr,
nullptr,
nullptr,
nullptr);
624 const int pad4 = pad2 * 2;
625 const int skipWidth2 = pad4 +
x;
627 "6",
x,
y, sz, sz,
RIGHT,
"screenActionButton5",
"",
628 nullptr,
nullptr,
nullptr,
nullptr);
630 "5", skipWidth,
y, sz, sz,
RIGHT,
631 "screenActionButton4",
"",
632 nullptr,
nullptr,
nullptr,
nullptr);
634 "4", skipWidth2,
y, sz, sz,
RIGHT,
635 "screenActionButton3",
"",
636 nullptr,
nullptr,
nullptr,
nullptr);
638 "3",
x, skipHeight, sz, sz,
RIGHT,
639 "screenActionButton2",
"",
640 nullptr,
nullptr,
nullptr,
nullptr);
642 "2", skipWidth, skipHeight, sz, sz,
RIGHT,
643 "screenActionButton1",
"",
644 nullptr,
nullptr,
nullptr,
nullptr);
646 "1", skipWidth2, skipHeight, sz, sz,
RIGHT,
647 "screenActionButton0",
"",
648 nullptr,
nullptr,
nullptr,
nullptr);
659 NORMAL,
"",
"screenActionKeyboard",
660 nullptr,
nullptr,
nullptr,
nullptr);
665 if (value ==
"showScreenJoystick")
673 unloadTouchItem(&mPad);
676 else if (value ==
"showScreenButtons")
688 unloadTouchItem(&mButtons[f]);
692 else if (value ==
"showScreenKeyboard")
700 unloadTouchItem(&mKeyboard);
703 else if (value ==
"screenButtonsSize")
711 unloadTouchItem(&mButtons[f]);
715 else if (value ==
"screenJoystickSize")
723 unloadTouchItem(&mPad);
727 else if (value ==
"screenButtonsFormat")
735 unloadTouchItem(&mButtons[f]);
744 mShow = mInGame && !mTempHideButtons;
750 mTempHideButtons = b;
751 mShow = mInGame && !mTempHideButtons;
bool getBoolValue(const std::string &key) const
void addListener(const std::string &key, ConfigListener *const listener)
void removeListeners(ConfigListener *const listener)
int getIntValue(const std::string &key) const
int getWidth(const std::string &text) const
void drawString(Graphics *const graphics, Color col, const Color &col2, const std::string &text, const int x, const int y)
virtual void drawImage(const Image *const image, int dstX, int dstY)=0
virtual void drawTileCollection(const ImageCollection *const vertCol)=0
virtual void calcTileCollection(ImageCollection *const vertCol, const Image *const image, int x, int y)=0
virtual void finalize(ImageCollection *const col)
virtual void calcWindow(ImageCollection *const vertCol, const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
virtual void drawImageRect(const int x, const int y, const int w, const int h, const ImageRect &imgRect)=0
bool isPointInRect(const int x_, const int y_) const
int getOption(const std::string &name) const
void unload(Skin *const skin)
static std::string getThemePath()
static Image * getImageFromThemeXml(const std::string &name, const std::string &name2)
static void unloadRect(const ImageRect &rect, const int start, const int end)
Skin * load(const std::string &filename, const std::string &filename2, const bool full, const std::string &defaultPath)
const Color & getColor(const ThemeColorIdT type, const unsigned int alpha)
Skin * loadSkinRect(ImageRect &image, const std::string &name, const std::string &name2, const int start, const int end)
void optionChanged(const std::string &value)
static void executeAction(const std::string &event)
void resize(const int width, const int height)
bool isActionActive(const InputActionT index) const
void setTempHide(const bool b)
static void unload(TouchItem *const item)
bool mActions[actionsSize]
void unloadTouchItem(TouchItem **unloadItem)
TouchItem * mButtons[buttonsCount]
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)
void setInGame(const bool b)
bool processEvent(const MouseInput &mouseInput)
ImageCollection * mVertexes
#define FOR_EACH(type, iter, array)
TouchFuncPtr funcReleased
std::string eventReleased
void padClick(const MouseInput &mouseInput)
void setHalfJoyPad(const int s)
void padOut(const MouseInput &mouseInput)
void padEvents(const MouseInput &mouseInput)
void padUp(const MouseInput &mouseInput)
TouchManager touchManager
TouchItemVector::iterator TouchItemVectorIter
TouchItemVector::const_iterator TouchItemVectorCIter
void(* TouchFuncPtr)(const MouseInput &mouseInput)