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
+1 -1
View File
@@ -205,7 +205,7 @@ void GUI::draw(const DrawContext* pctx, Assets* assets) {
menu->setPos((wsize - menu->getSize()) / 2.0f);
uicamera->setFov(wsize.y);
Shader* uishader = assets->getShader("ui");
auto uishader = assets->get<Shader>("ui");
uishader->use();
uishader->uniformMatrix("u_projview", uicamera->getProjView());
+1 -1
View File
@@ -18,7 +18,7 @@ void Image::draw(const DrawContext* pctx, Assets* assets) {
glm::vec2 pos = calcPos();
auto batch = pctx->getBatch2D();
auto texture = assets->getTexture(this->texture);
auto texture = assets->get<Texture>(this->texture);
if (texture && autoresize) {
setSize(glm::vec2(texture->getWidth(), texture->getHeight()));
}
+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;
+1 -1
View File
@@ -158,7 +158,7 @@ uint Label::getLinesNumber() const {
void Label::draw(const DrawContext* pctx, Assets* assets) {
auto batch = pctx->getBatch2D();
auto font = assets->getFont(fontName);
auto font = assets->get<Font>(fontName);
cache.prepare(font, static_cast<size_t>(glm::abs(getSize().x)));
if (supplier) {
+1 -1
View File
@@ -37,7 +37,7 @@ void Plotter::draw(const DrawContext* pctx, Assets* assets) {
}
int current_point = static_cast<int>(points[index % dmwidth]);
auto font = assets->getFont("normal");
auto font = assets->get<Font>("normal");
for (int y = 0; y < dmheight; y += labelsInterval) {
std::wstring string;
if (current_point/16 == y/labelsInterval) {
+1 -1
View File
@@ -33,7 +33,7 @@ TextBox::TextBox(std::wstring placeholder, glm::vec4 padding)
void TextBox::draw(const DrawContext* pctx, Assets* assets) {
Panel::draw(pctx, assets);
font = assets->getFont(label->getFontName());
font = assets->get<Font>(label->getFontName());
if (!isFocused()) {
return;