refactor InventoryView & add 'uses' item property (WIP)

This commit is contained in:
MihailRis
2025-02-16 20:41:13 +03:00
parent a118016c8f
commit 231fc7e0d0
5 changed files with 152 additions and 73 deletions
+28 -4
View File
@@ -4,15 +4,18 @@
#include "Container.hpp"
#include "typedefs.hpp"
#include "constants.hpp"
#include "items/ItemStack.hpp"
#include <vector>
#include <functional>
#include <glm/glm.hpp>
class Font;
class Assets;
class ItemDef;
class Batch2D;
class DrawContext;
class Content;
class ItemStack;
class ContentIndices;
class LevelFrontend;
class Inventory;
@@ -49,6 +52,11 @@ namespace gui {
};
class SlotView : public gui::UINode {
struct {
ItemStack stack {};
std::wstring countStr;
} cache;
const Content* content = nullptr;
SlotLayout layout;
bool highlighted = false;
@@ -56,11 +64,27 @@ namespace gui {
int64_t inventoryid = 0;
ItemStack* bound = nullptr;
std::wstring tooltip;
itemid_t prevItem = 0;
void performLeftClick(ItemStack& stack, ItemStack& grabbed);
void performRightClick(ItemStack& stack, ItemStack& grabbed);
void drawItemIcon(
Batch2D& batch,
const ItemStack& stack,
const ItemDef& item,
const Assets& assets,
const glm::vec4& tint,
const glm::vec2& pos
);
void drawItemInfo(
Batch2D& batch,
const ItemStack& stack,
const ItemDef& item,
const Font& font,
const glm::vec2& pos
);
void refreshTooltip(const ItemStack& stack, const ItemDef& item);
public:
SlotView(SlotLayout layout);