#include <DangerousRacers/Scenes/MainMenu.h>

#include "SFML/Window/Event.hpp"

MainMenuScene::MainMenuScene(SceneManager& _sceneManager) : Scene (_sceneManager, "MainMenu") {
    backgroundTexture.loadFromFile("assets/background.png");
    backgroundSprite.setTexture(backgroundTexture);

    titleTexture.loadFromFile("assets/title.png");
    titleSprite.setTexture(titleTexture);
    titleSprite.setOrigin(titleTexture.getSize().x / 2, titleTexture.getSize().y / 2);
    titleSprite.setPosition(405.f / 2.f, 720.f / 6.f);
}

void MainMenuScene::start() {
    Scene::start();
}

void MainMenuScene::update(const float deltaTime) {
    Scene::update(deltaTime);

    tutorialButton.update(deltaTime);
    playButton.update(deltaTime);
    quitButton.update(deltaTime);
}

void MainMenuScene::render(sf::RenderWindow &window) {
    Scene::render(window);
    window.draw(backgroundSprite);
    window.draw(titleSprite);
    
    tutorialButton.render(window);
    playButton.render(window);
    quitButton.render(window);
}

void MainMenuScene::eventHandler(sf::Event &event) {
    Scene::eventHandler(event);

    tutorialButton.eventHandler(event);
    playButton.eventHandler(event);
    quitButton.eventHandler(event);
}

void MainMenuScene::startTutorialLevel() const {
    sceneManager.changeScene("DebugLevelScene");
}
void MainMenuScene::playLevelOne() const {
    sceneManager.changeScene("LevelOne");
}
