update Assets container - template-based now

This commit is contained in:
MihailRis
2024-06-22 22:30:14 +03:00
parent 848d121099
commit d54b6b2e58
20 changed files with 68 additions and 143 deletions
+5 -4
View File
@@ -21,6 +21,7 @@
#include "../../core/Font.hpp"
#include "../../core/DrawContext.hpp"
#include "../../core/Shader.hpp"
#include "../../core/Texture.hpp"
#include "../../render/BlocksPreview.hpp"
#include "../GUI.hpp"
@@ -155,7 +156,7 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
batch->setColor(glm::vec4(1.0f));
auto previews = assets->getAtlas("block-previews");
auto previews = assets->get<Atlas>("block-previews");
auto indices = content->getIndices();
ItemDef* item = indices->getItemDef(stack.getItemId());
@@ -177,10 +178,10 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
std::string name = item->icon.substr(index+1);
UVRegion region(0.0f, 0.0, 1.0f, 1.0f);
if (index == std::string::npos) {
batch->texture(assets->getTexture(name));
batch->texture(assets->get<Texture>(name));
} else {
std::string atlasname = item->icon.substr(0, index);
Atlas* atlas = assets->getAtlas(atlasname);
auto atlas = assets->get<Atlas>(atlasname);
if (atlas && atlas->has(name)) {
region = atlas->get(name);
batch->texture(atlas->getTexture());
@@ -194,7 +195,7 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
}
if (stack.getCount() > 1) {
auto font = assets->getFont("normal");
auto font = assets->get<Font>("normal");
std::wstring text = std::to_wstring(stack.getCount());
int x = pos.x+slotSize-text.length()*8;