#pragma once
#include <cstdint>
#include <vector>
#include <string>
#include <SFML/Graphics.hpp>
#include <unordered_map>
#include <memory>
#include "matrix.hpp"

namespace textures {

  struct SpriteTexture {
    std::shared_ptr<sf::Sprite> sprite = nullptr;
    std::shared_ptr<sf::Texture> texture = nullptr;
    sf::Vector2i frame_size;
  };

  using SpriteTextureMap = std::unordered_map<std::string, SpriteTexture>;

  struct TextureManager {
    std::vector<sf::Image> surfaces;
    std::vector<size_t> ceilings;
    std::vector<wchar_t> map_tile_set;
    std::vector<int> ambient_light;
    SpriteTextureMap sprite_textures;
    SpriteTextureMap icon_textures;
    std::unordered_map<std::string, size_t> name_to_id;
    std::unordered_map<wchar_t, sf::Sprite> map_sprites;
    sf::Texture map_sprite_sheet{"./assets/map_tiles.png"};
  };

  void init();

  SpriteTexture get_sprite(const std::string& name);
  SpriteTexture get_icon(const std::string& name);

  sf::Image load_image(const std::string& filename);

  std::vector<int>& get_ambient_light();

  std::vector<wchar_t>& get_map_tile_set();

  const uint32_t* get_surface(size_t num);

  sf::Image& get_surface_img(size_t num);

  const uint32_t* get_ceiling(size_t num);

  sf::Sprite& get_map_sprite(wchar_t display);

  size_t get_id(const std::string& name);
}
