+
+void GUIFormSpecMenu::showTooltip(const std::wstring &text,
+ const irr::video::SColor &color, const irr::video::SColor &bgcolor)
+{
+ m_tooltip_element->setOverrideColor(color);
+ m_tooltip_element->setBackgroundColor(bgcolor);
+ setStaticText(m_tooltip_element, text.c_str());
+
+ // Tooltip size and offset
+ s32 tooltip_width = m_tooltip_element->getTextWidth() + m_btn_height;
+#if (IRRLICHT_VERSION_MAJOR <= 1 && IRRLICHT_VERSION_MINOR <= 8 && IRRLICHT_VERSION_REVISION < 2) || USE_FREETYPE == 1
+ std::vector<std::wstring> text_rows = str_split(text, L'\n');
+ s32 tooltip_height = m_tooltip_element->getTextHeight() * text_rows.size() + 5;
+#else
+ s32 tooltip_height = m_tooltip_element->getTextHeight() + 5;
+#endif
+ v2u32 screenSize = Environment->getVideoDriver()->getScreenSize();
+ int tooltip_offset_x = m_btn_height;
+ int tooltip_offset_y = m_btn_height;
+#ifdef __ANDROID__
+ tooltip_offset_x *= 3;
+ tooltip_offset_y = 0;
+ if (m_pointer.X > (s32)screenSize.X / 2)
+ tooltip_offset_x = -(tooltip_offset_x + tooltip_width);
+#endif
+
+ // Calculate and set the tooltip position
+ s32 tooltip_x = m_pointer.X + tooltip_offset_x;
+ s32 tooltip_y = m_pointer.Y + tooltip_offset_y;
+ if (tooltip_x + tooltip_width > (s32)screenSize.X)
+ tooltip_x = (s32)screenSize.X - tooltip_width - m_btn_height;
+ if (tooltip_y + tooltip_height > (s32)screenSize.Y)
+ tooltip_y = (s32)screenSize.Y - tooltip_height - m_btn_height;
+
+ m_tooltip_element->setRelativePosition(
+ core::rect<s32>(
+ core::position2d<s32>(tooltip_x, tooltip_y),
+ core::dimension2d<s32>(tooltip_width, tooltip_height)
+ )
+ );
+
+ // Display the tooltip
+ m_tooltip_element->setVisible(true);
+ bringToFront(m_tooltip_element);
+}
+