#include "Config/Config.hpp"
#include "Utils/json/Manager.hpp"

/* Null, because instance will be initialized on demand. */
CConfig* CConfig::instance = 0;
int CConfig::m_Windowed = 1;
int CConfig::m_ResoliutionX = 1920;
int CConfig::m_ResoliutionY = 1080;
int CConfig::m_WindowedX = 1280;
int CConfig::m_WindowedY = 720;
int CConfig::m_TileCount = 10;
int CConfig::m_DialogueHeight = 100;
float CConfig::m_fTileDimension;;
bool CConfig::m_VideoHasPlayed = false;

CConfig* CConfig::getInstance()
{
	if (instance == 0)
	{
		instance = new CConfig();
	}
	return instance;
}

CConfig::CConfig()
{
	// parse config
	json::CManager* manager = json::CManager::getInstance();
	
	if (manager->openFile("Config.json"))
	{
		m_Windowed = manager->getIntForKey("Windowed");
		m_ResoliutionX = manager->getIntForKey("FullResoliutionX");
		m_ResoliutionY = manager->getIntForKey("FullResoliutionY");
		m_WindowedX = manager->getIntForKey("WindowedResoliutionX");
		m_WindowedY = manager->getIntForKey("WindowedResoliutionY");
		m_TileCount = manager->getIntForKey("TilesCount");
        m_DialogueHeight = manager->getIntForKey("DialogueHeight");
        
        m_fTileDimension = float(m_ResoliutionY) / float(m_TileCount);
	}
}

CConfig::~CConfig()
{
}
