update Assets container - template-based now
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
ContentGfxCache::ContentGfxCache(const Content* content, Assets* assets) : content(content) {
|
||||
auto indices = content->getIndices();
|
||||
sideregions = std::make_unique<UVRegion[]>(indices->countBlockDefs() * 6);
|
||||
Atlas* atlas = assets->getAtlas("blocks");
|
||||
auto atlas = assets->get<Atlas>("blocks");
|
||||
|
||||
for (uint i = 0; i < indices->countBlockDefs(); i++) {
|
||||
Block* def = indices->getBlockDef(i);
|
||||
|
||||
@@ -30,7 +30,7 @@ LevelFrontend::LevelFrontend(LevelController* controller, Assets* assets)
|
||||
}
|
||||
|
||||
if (type == BlockInteraction::step) {
|
||||
auto sound = assets->getSound(material->stepsSound);
|
||||
auto sound = assets->get<audio::Sound>(material->stepsSound);
|
||||
audio::play(
|
||||
sound,
|
||||
glm::vec3(),
|
||||
@@ -45,10 +45,10 @@ LevelFrontend::LevelFrontend(LevelController* controller, Assets* assets)
|
||||
audio::Sound* sound = nullptr;
|
||||
switch (type) {
|
||||
case BlockInteraction::placing:
|
||||
sound = assets->getSound(material->placeSound);
|
||||
sound = assets->get<audio::Sound>(material->placeSound);
|
||||
break;
|
||||
case BlockInteraction::destruction:
|
||||
sound = assets->getSound(material->breakSound);
|
||||
sound = assets->get<audio::Sound>(material->breakSound);
|
||||
break;
|
||||
case BlockInteraction::step:
|
||||
break;
|
||||
|
||||
@@ -208,7 +208,7 @@ void Hud::processInput(bool visible) {
|
||||
}
|
||||
}
|
||||
if (!pause && Events::active(BIND_DEVTOOLS_CONSOLE)) {
|
||||
showOverlay(assets->getLayout("core:console"), false);
|
||||
showOverlay(assets->get<UiDocument>("core:console"), false);
|
||||
}
|
||||
if (!Window::isFocused() && !pause && !isInventoryOpen()) {
|
||||
setPause(true);
|
||||
@@ -305,7 +305,7 @@ void Hud::openInventory() {
|
||||
|
||||
inventoryOpen = true;
|
||||
auto inventory = player->getInventory();
|
||||
auto inventoryDocument = assets->getLayout("core:inventory");
|
||||
auto inventoryDocument = assets->get<UiDocument>("core:inventory");
|
||||
inventoryView = std::dynamic_pointer_cast<InventoryView>(inventoryDocument->getRoot());
|
||||
inventoryView->bind(inventory, content);
|
||||
add(HudElement(hud_element_mode::inventory_bound, inventoryDocument, inventoryView, false));
|
||||
@@ -460,7 +460,7 @@ void Hud::draw(const DrawContext& ctx){
|
||||
auto batch = ctx.getBatch2D();
|
||||
batch->begin();
|
||||
|
||||
Shader* uishader = assets->getShader("ui");
|
||||
auto uishader = assets->get<Shader>("ui");
|
||||
uishader->use();
|
||||
uishader->uniformMatrix("u_projview", uicamera->getProjView());
|
||||
|
||||
@@ -468,7 +468,7 @@ void Hud::draw(const DrawContext& ctx){
|
||||
if (!pause && !inventoryOpen && !player->debug) {
|
||||
DrawContext chctx = ctx.sub();
|
||||
chctx.setBlendMode(BlendMode::inversion);
|
||||
auto texture = assets->getTexture("gui/crosshair");
|
||||
auto texture = assets->get<Texture>("gui/crosshair");
|
||||
batch->texture(texture);
|
||||
int chsizex = texture != nullptr ? texture->getWidth() : 16;
|
||||
int chsizey = texture != nullptr ? texture->getHeight() : 16;
|
||||
|
||||
@@ -35,14 +35,14 @@ void MenuScreen::draw(float delta) {
|
||||
Window::setBgColor(glm::vec3(0.2f));
|
||||
|
||||
uicamera->setFov(Window::height);
|
||||
Shader* uishader = assets->getShader("ui");
|
||||
auto uishader = assets->get<Shader>("ui");
|
||||
uishader->use();
|
||||
uishader->uniformMatrix("u_projview", uicamera->getProjView());
|
||||
|
||||
uint width = Window::width;
|
||||
uint height = Window::height;
|
||||
|
||||
auto bg = assets->getTexture("gui/menubg");
|
||||
auto bg = assets->get<Texture>("gui/menubg");
|
||||
batch->begin();
|
||||
batch->texture(bg);
|
||||
batch->rect(
|
||||
|
||||
Reference in New Issue
Block a user