From 61ed56f916f71a708b56260d7cba2160e8166529 Mon Sep 17 00:00:00 2001 From: BlockMen Date: Sun, 28 Sep 2014 10:10:43 +0200 Subject: Standardize tooltip row detection --- src/guiFormSpecMenu.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/guiFormSpecMenu.cpp') diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index cbba313bc..f50fd15e5 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -2144,7 +2144,7 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase) if (hovering && !m_selected_item) tooltip_text = item.getDefinition(m_gamedef->idef()).description; if (tooltip_text != "") { - std::vector tt_rows = split(tooltip_text,'\n'); + std::vector tt_rows = str_split(tooltip_text, '\n'); m_tooltip_element->setBackgroundColor(m_default_tooltip_bgcolor); m_tooltip_element->setOverrideColor(m_default_tooltip_color); m_tooltip_element->setVisible(true); @@ -2376,13 +2376,8 @@ void GUIFormSpecMenu::drawMenu() s32 tooltip_width = m_tooltip_element->getTextWidth() + m_btn_height; if (tooltip_x + tooltip_width > (s32)screenSize.X) tooltip_x = (s32)screenSize.X - tooltip_width - m_btn_height; - int lines_count = 1; - size_t i = 0; - while ((i = m_tooltips[iter->fname].tooltip.find("\n", i)) != std::string::npos) { - lines_count++; - i += 2; - } - s32 tooltip_height = m_tooltip_element->getTextHeight() * lines_count + 5; + std::vector tt_rows = str_split(m_tooltips[iter->fname].tooltip, '\n'); + s32 tooltip_height = m_tooltip_element->getTextHeight() * tt_rows.size() + 5; m_tooltip_element->setRelativePosition(core::rect( core::position2d(tooltip_x, tooltip_y), core::dimension2d(tooltip_width, tooltip_height))); -- cgit v1.2.3