aboutsummaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorPaul Ouellette <oue.paul18@gmail.com>2019-08-24 12:38:02 -0400
committersfan5 <sfan5@live.de>2019-08-24 18:38:02 +0200
commit008b80fe1ca9d46610b8971e2ac92fb56da8e69f (patch)
tree581fb878e5b5afe163c12dfc926158b9f0e5b0a8 /src/gui
parentefbac7e4466ebc576b2cc64b5b782c61136cde66 (diff)
downloadminetest-008b80fe1ca9d46610b8971e2ac92fb56da8e69f.tar.gz
minetest-008b80fe1ca9d46610b8971e2ac92fb56da8e69f.tar.bz2
minetest-008b80fe1ca9d46610b8971e2ac92fb56da8e69f.zip
Add ItemStack:get_description() to get tooltip (#8847)
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/guiFormSpecMenu.cpp30
1 files changed, 8 insertions, 22 deletions
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);
- }
}
}
}