//
// Created by sasha on 27.11.2025.
//

#include "levelselectionscreen.h"

#include "engine/engine.h"
#include "engine/widgets/image.h"
#include "engine/widgets/text.h"

#include "widgets/button_level.h"
#include "audio_effect.h"
#include "engine/locale.h"

LevelSelectionScreen::LevelSelectionScreen() : IScreen("level_selection") {
    this->setName("LevelSelectionScreen");
    SDL_Log("=> LevelSelectionScreen::LevelSelectionScreen");

    Locale *locale = Locale::getInstance();

    this->setBackgroundColor(0x57,0x74,0xD9);

    auto button_back = new Image(this,16,34,57,32,"button_back_blue.png");
    button_back->setCallback(CallbackType::EVENT_ON_CLICK,[]{
        AudioEffect::click();
        Engine::setActiveScreen("main");
    });

    auto text1 = new Text(this,16,115);
    text1->setCached(true);
    text1->setText(locale->tr("Choose"),"inter.ttf",40,{255,255,255});

    auto text2 = new Text(this,16,text1->getFRect().y+text1->getFRect().h);
    text2->setCached(true);
    text2->setText(locale->tr("Complexity"),"inter.ttf",40,{255,255,255});

    auto text3 = new Text(this,16,218);
    text3->setCached(true);
    text3->setText(locale->tr("Choose the grid size"),"inter.ttf",12,{0xD5,0xD5,0xD5});


    // легкий 3x3
    auto button_level_easy = new ButtonLevel(this, 16,335,"east");
    button_level_easy->setCallback(CallbackType::EVENT_ON_CLICK,[]{
        AudioEffect::click();
        VariantMap args = {{"level","easy"}};
        Engine::setActiveScreen("game",args);
    });

    // нормальный 4x4
    auto button_level_normal = new ButtonLevel(this,16,442,"normal");
    button_level_normal->setCallback(CallbackType::EVENT_ON_CLICK,[]{
        AudioEffect::click();
        VariantMap args = {{"level","normal"}};
        Engine::setActiveScreen("game",args);
    });

    // Сложный 5x5
    auto button_level_hard = new ButtonLevel(this, 16,549,"hard");
    button_level_hard->setCallback(CallbackType::EVENT_ON_CLICK,[]{
        AudioEffect::click();
        VariantMap args = {{"level","hard"}};
        Engine::setActiveScreen("game",args);
    });

}

LevelSelectionScreen::~LevelSelectionScreen() {

}
