sprite items + tetragons format update
This commit is contained in:
+24
-4
@@ -184,7 +184,7 @@ HudRenderer::HudRenderer(Engine* engine, LevelFrontend* frontend)
|
||||
auto content = level->content;
|
||||
auto indices = content->indices;
|
||||
std::vector<itemid_t> items;
|
||||
for (itemid_t id = 0; id < indices->countItemDefs(); id++) {
|
||||
for (itemid_t id = 1; id < indices->countItemDefs(); id++) {
|
||||
items.push_back(id);
|
||||
}
|
||||
contentAccess.reset(new InventoryView(8, content, frontend, items));
|
||||
@@ -275,8 +275,7 @@ void HudRenderer::draw(const GfxContext& ctx){
|
||||
batch->color = vec4(1.0f);
|
||||
batch->render();
|
||||
|
||||
auto blocksPreview = frontend->getBlocksPreview();
|
||||
blocksPreview->begin(&ctx.getViewport());
|
||||
|
||||
{
|
||||
Window::clearDepth();
|
||||
GfxContext subctx = ctx.sub();
|
||||
@@ -285,13 +284,34 @@ void HudRenderer::draw(const GfxContext& ctx){
|
||||
|
||||
ItemDef* item = contentIds->getItemDef(player->chosenItem);
|
||||
switch (item->iconType) {
|
||||
case item_icon_type::none:
|
||||
break;
|
||||
case item_icon_type::block: {
|
||||
Block* cblock = content->findBlock(item->icon);
|
||||
assert(cblock != nullptr);
|
||||
|
||||
auto blocksPreview = frontend->getBlocksPreview();
|
||||
blocksPreview->begin(&ctx.getViewport());
|
||||
blocksPreview->draw(cblock, width - 56, uicamera->getFov() - 56, 48, vec4(1.0f));
|
||||
break;
|
||||
}
|
||||
// TODO: handle other types
|
||||
case item_icon_type::sprite: {
|
||||
size_t index = item->icon.find(':');
|
||||
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));
|
||||
} else {
|
||||
std::string atlasname = item->icon.substr(0, index);
|
||||
Atlas* atlas = assets->getAtlas(atlasname);
|
||||
if (atlas && atlas->has(name)) {
|
||||
region = atlas->get(name);
|
||||
batch->texture(atlas->getTexture());
|
||||
}
|
||||
}
|
||||
batch->rect(width - 56, uicamera->getFov() - 56, 48, 48, 0, 0, 0, region, false, true, glm::vec4(1.0f));
|
||||
batch->render();
|
||||
}
|
||||
}
|
||||
}
|
||||
uishader->use();
|
||||
|
||||
Reference in New Issue
Block a user