mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Add per-stack descriptions using ItemStack Metadata
This commit is contained in:
parent
f2aa2c6a98
commit
f2f9a92351
@ -1473,6 +1473,10 @@ Item stacks can store metadata too. See `ItemStackMetaRef`.
|
|||||||
|
|
||||||
Item metadata only contains a key-value store.
|
Item metadata only contains a key-value store.
|
||||||
|
|
||||||
|
Some of the values in the key-value store are handled specially:
|
||||||
|
|
||||||
|
* `description`: Set the itemstack's description. Defaults to idef.description
|
||||||
|
|
||||||
Example stuff:
|
Example stuff:
|
||||||
|
|
||||||
local meta = stack:get_meta()
|
local meta = stack:get_meta()
|
||||||
|
@ -2303,7 +2303,12 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase,
|
|||||||
// Draw tooltip
|
// Draw tooltip
|
||||||
std::wstring tooltip_text = L"";
|
std::wstring tooltip_text = L"";
|
||||||
if (hovering && !m_selected_item) {
|
if (hovering && !m_selected_item) {
|
||||||
tooltip_text = utf8_to_wide(item.getDefinition(m_client->idef()).description);
|
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 (tooltip_text != L"") {
|
if (tooltip_text != L"") {
|
||||||
std::vector<std::wstring> tt_rows = str_split(tooltip_text, L'\n');
|
std::vector<std::wstring> tt_rows = str_split(tooltip_text, L'\n');
|
||||||
|
Loading…
Reference in New Issue
Block a user