//
// Created by m on 12/3/21.
//
#include "../engine/game/game.hpp"
#include "../engine/rendering/renderer.hpp"
#include "../engine/utility/camera.hpp"
#include "../engine/utility/grid2d.hpp"
#include "../engine/scripting/luacontextmanager.hpp"
#include "algorithmmanager.hpp"
#include "tilemap.hpp"
#include <vector>
#include <range/v3/range.hpp>
#include <range/v3/view.hpp>
#ifndef RLA_IIPP_VISUALIZER_HPP
#define RLA_IIPP_VISUALIZER_HPP
#define DEFAULT_MAP_SIZE_W 20
#define DEFAULT_MAP_SIZE_H 20
#define DEFAULT_TILE_WIDTH 48
#define DEFAULT_TILE_HEIGHT 48
#define DEFAULT_WALL_CHAR "#"
#define DEFAULT_FLOOR_CHAR "."
#define CONFIG_FILE "visualizer.toml"

class Visualizer : public Game {
public:
    bool update(InputResult input) override;

    void render(Renderer* renderer) override;


    ~Visualizer();

    void initialize(GameInitArgs args) override;


private:
    int window_width = 0;
    int window_height = 0;
    TileMap tile_map = TileMap(0, 0, DEFAULT_WALL_CHAR[0], DEFAULT_FLOOR_CHAR[0]);
    Camera camera = Camera();
    LuaContextManager lua_context_manager;
    AlgorithmManager algorithm_manager;
    std::unordered_map<InputProcessorKeycode, DungeonAlgorithm*> keycode_to_algorithm;

    int x = 0;
    int y=0;
    int sprite_index = 1;

    char floor_char;
    char wall_char;
    int map_size_w;
    int map_size_h;
    int tile_width;
    int tile_height;

    void initialize_map(int width, int height);
    void initialize_context();
    void load_algorithms();

};

#endif //RLA_IIPP_VISUALIZER_HPP
