added tooltips

This commit is contained in:
MihailRis
2024-05-24 08:03:05 +03:00
parent 1c45236693
commit eb10904069
10 changed files with 146 additions and 11 deletions
+13 -1
View File
@@ -1,7 +1,9 @@
#include "InventoryView.hpp"
#include "../../../assets/Assets.hpp"
#include "../../../content/Content.hpp"
#include "../../../frontend/LevelFrontend.hpp"
#include "../../../frontend/locale.hpp"
#include "../../../items/Inventories.hpp"
#include "../../../items/Inventory.hpp"
#include "../../../items/ItemDef.hpp"
@@ -22,7 +24,6 @@
#include "../../render/BlocksPreview.hpp"
#include "../GUI.hpp"
#include <iostream>
#include <glm/glm.hpp>
using namespace gui;
@@ -270,6 +271,17 @@ void SlotView::onFocus(gui::GUI* gui) {
clicked(gui, mousecode::BUTTON_1);
}
const std::wstring SlotView::getTooltip() const {
const auto str = UINode::getTooltip();
if (!str.empty() || bound->isEmpty()) {
return str;
}
auto def = content->getIndices()->getItemDef(bound->getItemId());
return util::capitalized(
langs::get(util::str2wstr_utf8(def->caption))
); // TODO: cache
}
void SlotView::bind(
int64_t inventoryid,
ItemStack& stack,