Merge pull request #1 from sofar/3984

Display custom metedata description instead of node name in tooltip.
This commit is contained in:
orwell96 2016-04-20 22:13:55 +02:00
commit 46bc51e4b5
1 changed files with 8 additions and 2 deletions

View File

@ -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<std::string> tt_rows = str_split(tooltip_text, '\n');
m_tooltip_element->setBackgroundColor(m_default_tooltip_bgcolor);