added description to item

This commit is contained in:
GHOST11111100
2025-07-26 16:49:39 +03:00
parent b4b49ccd83
commit 21364af7a3
4 changed files with 41 additions and 7 deletions
+15 -7
View File
@@ -124,15 +124,23 @@ void SlotView::refreshTooltip(const ItemStack& stack, const ItemDef& item) {
}
if (itemid) {
dv::value* caption = stack.getField("caption");
if (caption != nullptr) {
tooltip = util::pascal_case(
langs::get(util::str2wstr_utf8(caption->asString()))
);
dv::value* description = stack.getField("description");
std::wstring captionText;
std::wstring descriptionText;
if (description != nullptr) {
descriptionText = util::pascal_case( langs::get( util::str2wstr_utf8( description->asString() ) ) );
} else {
tooltip = util::pascal_case(
langs::get(util::str2wstr_utf8(item.caption))
);
descriptionText = util::pascal_case( langs::get( util::str2wstr_utf8( item.description ) ) );
}
if (caption != nullptr) {
captionText = util::pascal_case( langs::get( util::str2wstr_utf8( caption->asString() ) ) );
} else {
captionText = util::pascal_case( langs::get( util::str2wstr_utf8( item.caption ) ) );
}
tooltip = captionText + L"\n" + descriptionText;
} else {
tooltip.clear();
}
+1
View File
@@ -4,6 +4,7 @@
ItemDef::ItemDef(const std::string& name) : name(name) {
caption = util::id_to_caption(name);
description = "";
}
void ItemDef::cloneTo(ItemDef& dst) {
dst.caption = caption;
+3
View File
@@ -34,6 +34,9 @@ struct ItemDef {
/// @brief Item name will shown in inventory
std::string caption;
/// @brief Item description will shown in inventory
std::string description;
dv::value properties = nullptr;
/// @brief Item max stack size