#include "resources.h"
#include "color.h"

namespace resources
{

render::sprite::icon icons[3][4], placeholderIcons[3][4];

render::sprite::textureAtlas atlas;
render::fx::collection effects;

void init()
{
    std::string names[3][4] = {
        {"cross.png", "circle.png", "square.png", "triangle.png"},
        {"cross-long.png", "circle-long.png", "square-long.png", "triangle-long.png"},
        {"arrow-down.png", "arrow-right.png", "arrow-left.png", "arrow-up.png"}
    };

    std::string placeholderNames[3][4] = {
        {"placeholder-cross.png", "placeholder-circle.png", "placeholder-square.png", "placeholder-triangle.png"},
        {"placeholder-cross-long.png", "placeholder-circle-long.png", "placeholder-square-long.png", "placeholder-triangle-long.png"},
        {"placeholder-down.png", "placeholder-right.png", "placeholder-left.png", "placeholder-up.png"}
    };

    atlas.load("data/textures/atlas.xml");

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 4; j++) {
            atlas.getIcon(names[i][j], icons[i][j]);
            icons[i][j].size = vec2f(1);

            atlas.getIcon(placeholderNames[i][j], placeholderIcons[i][j]);
            placeholderIcons[i][j].size = vec2f(1);
        }
    }

    effects.load("data/fx/game.fx.xml");
}

render::sprite::icon &getIcon(int32_t button, int32_t type)
{
    return icons[type][button];
}

render::sprite::icon &getPlaceholderIcon(int32_t button, int32_t type)
{
    return placeholderIcons[type][button];
}

}
