#ifndef SHUTDOWN_DISPLAY_HPP_
#define SHUTDOWN_DISPLAY_HPP_

#include <string>
#include <memory>
#include <chrono>

#include <Display/WidgetDisplay/WidgetDisplay.hpp>
#include <Widget/Button/Button.hpp>
#include <World/World.hpp>

using namespace std::chrono_literals;

/**
 * @brief A display which shows the world shutdown message.
 */
class ShutdownDisplay : public WidgetDisplay
{
private:
    std::shared_ptr<World> world;
    bool isWorldClean = false;
    std::atomic<bool> tasksFinished;
    std::chrono::steady_clock::time_point lastProgressCheckTime;

    static constexpr std::chrono::steady_clock::duration purgeTimeout = 10s;

public:
    /**
     * @brief Construct a shutdown display.
     * 
     * @param world The world.
     */
    ShutdownDisplay(std::shared_ptr<World> world);

    virtual void update() override;
    virtual void onQuit() override;
};

#endif