#include <Page/Page.hpp>
#include <Widget/Button/Button.hpp>
#include <Widget/Layout/Center/Center.hpp>
#include <Widget/Layout/Column/Column.hpp>
#include <Widget/Layout/Column/HorizontalSeparator/HorizontalSeparator.hpp>
#include <Widget/Layout/CompoundWidget/AchievementsTab/AchievementsTab.hpp>
#include <Widget/Layout/CompoundWidget/EscapeMenu/EscapeMenu.hpp>
#include <Widget/Layout/CompoundWidget/FormSection/FormSection.hpp>
#include <Widget/Layout/CompoundWidget/SettingsPanel/SettingsPanel.hpp>
#include <Widget/Layout/CompoundWidget/WorldStatsTab/WorldStatsTab.hpp>
#include <Display/WidgetDisplay/WorldDisplay/WorldDisplay.hpp>
#include <Widget/Layout/Margin/Margin.hpp>

EscapeMenu::EscapeMenu(WorldDisplay &worldDisplay) : CompoundWidget()
{
    addChildren(
        new Margin<20>(
            new Column(
                new Button("Continue", [&worldDisplay]()
                {
                    worldDisplay.shouldCloseMenu = true;
                }),

                Layout::WithProportion<1>(),
                new FormSection(
                    new SettingsPanel(
                        new Page(
                            Material::achievementsTab,
                            "Achievements",
                            new AchievementsTab(worldDisplay.getPlayer())
                        ),

                        new Page(
                            Material::statsIcon,
                            "Stats",
                            new WorldStatsTab(*worldDisplay.getWorld())
                        )
                    )
                ),

                (new Button("Save and quit", [&worldDisplay]()
                {
                    worldDisplay.onQuit();
                }))
                    ->withIcon(Material::exitIcon)
                    ->withFaceColor(Color::back)
            )
        )
    );
}