#include "pch.h"
#include "ScreenManager.h"

#include "FuelScreen.h"
#include "utils.h"
ScreenManager* ScreenManager::m_pInstance = nullptr;

Screen* ScreenManager::Fuel{ nullptr };
Screen* ScreenManager::SellScreen{ nullptr };

ScreenManager* ScreenManager::GetInstance() {

	if(m_pInstance == nullptr) {
		m_pInstance = new ScreenManager();
	}
	if(!m_pInstance->m_AreScreensInitialized) {
		m_pInstance->InitializeScreens(); //TODO: Ask if this a hack
		m_pInstance->m_AreScreensInitialized = true;
	}
	return m_pInstance;
}

void ScreenManager::OpenScreen(Screen* screen) {
	if(m_IsScreenOpen == false) {
		m_currentScreen = screen;
		m_IsScreenOpen = true;
	}
}
void ScreenManager::CloseScreen() {
	if(m_IsScreenOpen == true) {
		m_IsScreenOpen = false;
		m_currentScreen = nullptr;
	}

}
void ScreenManager::InitializeScreens() {
	Vector2f fuelScreenSize = Vector2f { 492, 396 };
	Vector2f fuelScreenCenter = Vector2f { utils::GetViewport().x / 2 - fuelScreenSize.x / 2, utils::GetViewport().y / 2 - fuelScreenSize.y / 2 };
	Fuel = new FuelScreen { "gui/fuel/background.png", fuelScreenCenter, Vector2f { 0, 0 }, TextureManager::GetInstance() };

	Vector2f sellScreenSize = Vector2f { 533, 398 };
	Vector2f sellScreenCenter = Vector2f { utils::GetViewport().x / 2 - sellScreenSize.x / 2, utils::GetViewport().y / 2 - sellScreenSize.y / 2 };
	SellScreen = new Screen { "gui/sell/background.png", sellScreenCenter, sellScreenSize, TextureManager::GetInstance() };
	
	//m_Button = Button { "gui/close.png", closeButtonPos, closeButtonSize, TextureManager::GetInstance() };
}

