#include "main_menu/mainmenu.h"
#include "gui/guiscenemanager.h"
#include "soundengine.h"

#include "ui_mainmenu.h"

#include <QString>
#include <QApplication>
#include <QMovie>
#include <QFileInfo>

MainMenu::MainMenu(QWidget *parent) :
    Scene(parent),
    ui(new Ui::MainMenu)
{
    ui->setupUi(this);
    // Load animated GIF
    watcher = new ButtonEventListener(this);

    ui->hotseat_button->installEventFilter(watcher);
    ui->about_us_button->installEventFilter(watcher);
    ui->leave_game_button->installEventFilter(watcher);
}

MainMenu::~MainMenu()
{
    delete ui;
    delete watcher;
}

void MainMenu::init()
{
    SoundEngine::getInstance().playlist().addMedia(QUrl("qrc:/assets/main_menu/main_menu_music_1.mp3"));
    SoundEngine::getInstance().player().play();
    GuiSceneManager::getInstance().show("main_menu_background");
    raise();
}

void MainMenu::deinit()
{

}

void MainMenu::on_hotseat_button_clicked() {
    GuiSceneManager::getInstance().changeScene("pvp_intro");
}

void MainMenu::on_leave_game_button_clicked() {
    QApplication::exit();
}

void MainMenu::on_about_us_button_clicked()
{
    GuiSceneManager::getInstance().changeScene("about_us");
}
