package de.frajul.endlessroll.entities.textures;

import android.content.Context;
import android.support.annotation.DrawableRes;

import de.frajul.endlessroll.R;
import de.frajul.endlessroll.entities.shapes.PlayerShape;
import de.frajul.endlessroll.entities.tools.ToolType;
import de.frajul.endlessroll.levels.worlds.World;

/**
 * Created by Julian on 05.12.2015.
 */
public class TexturePack {

    private TextureLoader loader;

    public final Texture goal;
    public final Texture playerArrow;
    public final Texture star;
    public final Texture energy;

    public TexturePack(Context context) {
        loader = new TextureLoader(context);
        goal = loadTexture(R.drawable.guis_goal);
        playerArrow = loadTexture(R.drawable.guis_playerarrow);

        star = loadTexture(R.drawable.currency_star);
        energy = loadAtlas(R.drawable.currency_energy_atlas, 2, 2);

        PlayerShape.loadAllTextures(this);
        ToolType.loadAllToolTextures(this);
        World.loadAllSpecificTextures(this);
    }

    public Texture loadTexture(@DrawableRes int id) {
        int texId = loader.loadTextureId(id, false);
        return new Texture(texId, 1, 1);
    }

    public Texture loadAtlas(@DrawableRes int id, int atlasWidth, int atlasHeight) {
        int texId = loader.loadTextureId(id, true);
        return new Texture(texId, atlasWidth, atlasHeight);
    }
}
