hud refactor

This commit is contained in:
MihailRis
2024-01-07 14:25:00 +03:00
parent 85d85dada7
commit d4c4c4d399
4 changed files with 75 additions and 66 deletions
+11 -9
View File
@@ -2,44 +2,46 @@
#define FRONTEND_INVENTORY_VIEW_H_
#include <vector>
#include <functional>
#include <glm/glm.hpp>
#include "../typedefs.h"
class Player;
class Assets;
class GfxContext;
class ContentIndices;
class BlocksPreview;
class ContentGfxCache;
typedef std::function<void(blockid_t)> slotconsumer;
class InventoryView {
Player* player;
const Assets* assets;
const ContentIndices* indices;
const ContentGfxCache* const cache;
std::vector<blockid_t> blocks;
BlocksPreview* blocksPreview;
slotconsumer consumer = nullptr;
int inventoryScroll = 0;
int invColumns;
int scroll = 0;
int columns;
uint iconSize = 48;
uint interval = 4;
int padX = interval;
int padY = interval;
int invX = 0;
int invY = 0;
glm::ivec2 padding {interval, interval};
glm::ivec2 position {0, 0};
public:
InventoryView(
int columns,
Player* player,
const Assets* assets,
const ContentIndices* indices,
const ContentGfxCache* cache,
std::vector<blockid_t> blocks);
void setPosition(int x, int y);
void actAndDraw(const GfxContext* ctx);
int getWidth() const;
int getHeight() const;
void setSlotConsumer(slotconsumer consumer);
};
#endif // FRONTEND_INVENTORY_VIEW_H_