#pragma once

/*
	GameEngine and Editor
	by John Ryland
	Copyright (c) 2023
*/

////////////////////////////////////////////////////////////////////////////////////
//	File Browser

#include "Application.h"
#include "IView.h"
#include <filesystem>
#include <vector>
#include <map>
#include <atomic>

namespace GameEngine {

class CachedDirectory
{
public:
    std::atomic<bool>                              m_loaded;
    std::string                                    m_path;
    std::vector<std::filesystem::directory_entry>  m_entries;
};

class FileBrowser : public IView
{
public:
    FileBrowser(ApplicationFramework::IApplication& app);
    ~FileBrowser();

    void AddShowMenuItem() override;

    void Initialize() override;
    void Shutdown() override;
    void Update() override;

private:
    ApplicationFramework::IApplication&     m_application;
    std::map<std::string, CachedDirectory>  m_directoryCache;
    bool                                    m_open = true;
};

} // GameEngine namespace
