#include "pch.h"
#include "MainScreen.h"

#include "colors.h"
#include "GameManager.h"
#include "utils.h"
#include "Gui/GuiText.h"
MainScreen::MainScreen(TextureManager* manager) : Screen("", Vector2f { 0, 0 }, Vector2f { 900.f, 500.f }, manager) {
	Vector2f ScreenSize = utils::GetViewport();
	Vector2f FuelFrameSize { 336, 77 };
	Vector2f HullFrameSize { 61, 76 };

	m_FuelMeter = new GuiMeter("gui/main/fuel/fuel.png", Vector2f { HullFrameSize.x + 10, ScreenSize.y - FuelFrameSize.y }, FuelFrameSize, FuelFrameSize / 1.3, 21, manager);
	this->AddElement(m_FuelMeter);

	m_HullMeter = new GuiMeter("gui/main/hull/hull.png", Vector2f { 5, ScreenSize.y - HullFrameSize.y - 10 }, HullFrameSize, HullFrameSize, 50, manager);
	this->AddElement(m_HullMeter);

	Vector2f DepthMeterPosition { 10, ScreenSize.y - 120 };
	m_DepthText = new GuiText(DepthMeterPosition, "Depth: 20", "fonts/Arial.ttf", 20, Colors::YELLOW);
	this->AddElement(m_DepthText);

	Vector2f ScoreMeterPosition { 150, ScreenSize.y - 50 };
	m_ScoreText = new GuiText(ScoreMeterPosition, "0", "fonts/Arial.ttf", 20, Colors::YELLOW);
	this->AddElement(m_ScoreText);


	Vector2f InvButtonPosition { ScreenSize.x - 150, ScreenSize.y - 60 };
	float InvButtonScale = 1.2f;
	m_InvButton = new GuiButton("gui/main/inv.png", InvButtonPosition, Vector2f { 58 * InvButtonScale, 55 * InvButtonScale }, false, manager);
	m_InvButton->SetOnClick([]()
	{
		// GameManager::GetInstance().ToggleInventory();
		std::cout << "Inventory button clicked" << std::endl;
	});
	this->AddElement(m_InvButton);

	Vector2f OptionsButtonPosition { ScreenSize.x - 85, ScreenSize.y - 85 };
	m_OptionsButton = new GuiButton("gui/main/options.png", OptionsButtonPosition, Vector2f { 74, 56 }, false, manager);
	m_OptionsButton->SetOnClick([]()
	{
		// GameManager::GetInstance().ToggleOptions();
		std::cout << "Options button clicked" << std::endl;
	});
	this->AddElement(m_OptionsButton);

	m_HelpButton = new GuiButton("gui/main/help.png", Vector2f { ScreenSize.x - 50, ScreenSize.y - 50 }, Vector2f { 50, 50 }, false, manager);
	m_HelpButton->SetOnClick([]()
	{
		// GameManager::GetInstance().ToggleHelp();
		std::cout << "Help button clicked" << std::endl;
	});
	this->AddElement(m_HelpButton);

	m_MoneyText = new GuiText(Vector2f { ScreenSize.x - 450, ScreenSize.y - 35 }, "Filler Text", "fonts/Arial.ttf", 25, Colors::YELLOW);
	this->AddElement(m_MoneyText);
}
MainScreen::~MainScreen() = default;
void MainScreen::Draw() const {
	Screen::Draw();
}
void MainScreen::Update(float elapsedSecs) {
	Screen::Update(elapsedSecs);
}
void MainScreen::SetFuelMeterValue(float value) const {
	m_FuelMeter->SetValue(value);
}
void MainScreen::SetHullMeterValue(float value) const {
	m_HullMeter->SetValue(value);
}
void MainScreen::SetDepth(const std::string& text) const {
	m_DepthText->ChangeText(text);
}
void MainScreen::SetScore(const std::string& text) const {
	m_ScoreText->ChangeText(text);
}
void MainScreen::SetMoney(const std::string& text) const {
	m_MoneyText->ChangeText(text);
}
