#pragma once

#include <iostream>
#include <initializer_list>
#include <SFML/Graphics.hpp>

enum EchoType {
	DEBUG, INFO, LOAD, WARNING, ERROR
};

class Echo { 
public:
	Echo() = delete;
	template<typename T, typename... Args>
	Echo(EchoType a, T t, Args... args);
	static void setLogLevel(int lv);
private:;
	template <typename T>
	void print(bool cerr, T t);
	template<typename T, typename... Args>
	void print(bool cerr, T t, Args... args);
	static int level;
};

template<typename T, typename... Args>
Echo::Echo(EchoType a, T t, Args... args)
{
	switch(a) {
		case EchoType::DEBUG:
			if(level < 3)
				return;
			std::cout << "[DEBUG]   ";
			break;
		case EchoType::INFO:
			if(level < 2)
				return;
			std::cout << "[INFO]    ";
			break;
		case EchoType::LOAD:
			if(level < 2)
				return;
			std::cout << "[LOAD]    ";
			break;
		case EchoType::WARNING:
			if(level < 3)
				return;
			std::cout << "[WARNING] ";
			break;
		case EchoType::ERROR:
			if(level < 1)
				return;
			std::cerr << "[ERROR]   ";
			break;
		default:
			std::cout << "          ";
			break;
	}
	print(a == ERROR, t, args...);
	if(a == ERROR) {
		std::cerr << std::endl;
	}
	else {
		std::cout << std::endl;
	}
}

template <typename T>
void Echo::print(bool cerr, T t)
{
	if(cerr) {
		std::cerr << t;
	}
	else {
		std::cout << t;
	}
}

template<typename T, typename... Args>
void Echo::print(bool cerr, T t, Args... args)
{
	if(cerr) {
		std::cerr << t;
	}
	else {
		std::cout << t;
	}

    print(cerr, args...);
}

void loadTexture(sf::Texture& texture, std::string filename);
