From 0e3f79845a0b640153d0356b35c6a36058e86c8e Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Fri, 15 Apr 2016 23:04:45 -0700 Subject: [PATCH] Display custom metedata description instead of node name in tooltip. This uses the new ItemStackMetadata subclass, and checks if the item has a 'description' metadata string set. If set, the content of the string is displayed, otherwise the description string from the nodedef is used. --- src/guiFormSpecMenu.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index 6492eb9d9..e8369a550 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -2243,8 +2243,14 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase, // Draw tooltip std::string tooltip_text = ""; - if (hovering && !m_selected_item) - tooltip_text = item.getDefinition(m_gamedef->idef()).description; + if (hovering && !m_selected_item) { + ItemStackMetadata *meta = &item.metadata; + std::string desc = meta->getString("description"); + if (desc != "") + tooltip_text = desc; + else + tooltip_text = item.getDefinition(m_gamedef->idef()).description; + } if (tooltip_text != "") { std::vector tt_rows = str_split(tooltip_text, '\n'); m_tooltip_element->setBackgroundColor(m_default_tooltip_bgcolor);