From 008b80fe1ca9d46610b8971e2ac92fb56da8e69f Mon Sep 17 00:00:00 2001 From: Paul Ouellette Date: Sat, 24 Aug 2019 12:38:02 -0400 Subject: Add ItemStack:get_description() to get tooltip (#8847) --- src/gui/guiFormSpecMenu.cpp | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'src/gui') diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index e7eaefd75..c0fa2470b 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -2844,37 +2844,23 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int layer, } if (layer == 1) { - // Draw item stack if (selected) item.takeItem(m_selected_amount); if (!item.empty()) { + // Draw item stack drawItemStack(driver, m_font, item, rect, &AbsoluteClippingRect, m_client, rotation_kind); - } - - // Draw tooltip - std::wstring tooltip_text; - if (hovering && !m_selected_item) { - const std::string &desc = item.metadata.getString("description"); - if (desc.empty()) - tooltip_text = - utf8_to_wide(item.getDefinition(m_client->idef()).description); - else - tooltip_text = utf8_to_wide(desc); - - if (!item.name.empty()) { - if (tooltip_text.empty()) - tooltip_text = utf8_to_wide(item.name); - else if (m_tooltip_append_itemname) - tooltip_text += utf8_to_wide("\n[" + item.name + "]"); + // Draw tooltip + if (hovering && !m_selected_item) { + std::string tooltip = item.getDescription(m_client->idef()); + if (m_tooltip_append_itemname) + tooltip += "\n[" + item.name + "]"; + showTooltip(utf8_to_wide(tooltip), m_default_tooltip_color, + m_default_tooltip_bgcolor); } } - if (!tooltip_text.empty()) { - showTooltip(tooltip_text, m_default_tooltip_color, - m_default_tooltip_bgcolor); - } } } } -- cgit v1.2.3