hud refactor (part II)

This commit is contained in:
MihailRis
2024-01-07 19:22:29 +03:00
parent 8118afce5c
commit e493c67dfa
13 changed files with 142 additions and 91 deletions
+11 -9
View File
@@ -3,6 +3,7 @@
#include <glm/glm.hpp>
#include "BlocksPreview.h"
#include "LevelFrontend.h"
#include "../window/Events.h"
#include "../assets/Assets.h"
#include "../graphics/Shader.h"
@@ -15,18 +16,16 @@
InventoryView::InventoryView(
int columns,
const Assets* assets,
const ContentIndices* indices,
const ContentGfxCache* cache,
std::vector<blockid_t> blocks)
: assets(assets),
indices(indices),
cache(cache),
LevelFrontend* frontend,
std::vector<blockid_t> blocks)
: indices(indices),
blocks(blocks),
frontend(frontend),
columns(columns) {
blocksPreview = new BlocksPreview(assets->getShader("ui3d"),
assets->getAtlas("blocks"),
cache);
}
InventoryView::~InventoryView() {
}
void InventoryView::setPosition(int x, int y) {
@@ -48,6 +47,7 @@ void InventoryView::setSlotConsumer(slotconsumer consumer) {
}
void InventoryView::actAndDraw(const GfxContext* ctx) {
Assets* assets = frontend->getAssets();
Shader* uiShader = assets->getShader("ui");
auto viewport = ctx->getViewport();
@@ -73,6 +73,8 @@ void InventoryView::actAndDraw(const GfxContext* ctx) {
}
scroll = std::min(scroll, int(inv_h-viewport.getHeight()));
scroll = std::max(scroll, 0);
auto blocksPreview = frontend->getBlocksPreview();
blocksPreview->begin(&ctx->getViewport());
{
Window::clearDepth();