#pragma once

#include <filesystem>
#include <string>
#include <vector>

#include "../resources.hpp"
#include "../state/play/toasts.hpp"
#include "../util/dialog.hpp"
#include "console.hpp"
#include "document.hpp"

namespace game::state
{
  class Play;
}

namespace game::developer
{
  class Window
  {
    enum class Tab
    {
      CONSOLE,
      EDITOR
    };

    std::vector<Document> documents{};
    Console console{};
    util::Dialog dialog{};
    state::play::Toasts toasts{};
    std::vector<std::filesystem::path> recentFiles{};
    Tab selectedTab{Tab::CONSOLE};
    int selectedDocument{};
    bool isContextUndoRequested{};
    bool isContextRedoRequested{};
    bool isRecentFilesLoaded{};
    bool isDeveloperOpen{};

    void folder_open(const std::filesystem::path&);
    void save(int index);
    void export_to(int index, const std::filesystem::path&);
    void close(int index);
    void undo(int index);
    void redo(int index);
    Document document_load(const std::filesystem::path&);
    void editor_update(Resources&);
    void editor_shortcuts_update();
    void editor_menu_update();
    void editor_documents_update(Resources&);
    void document_info_update(const Document&);
    void document_dialogue_update(Resources&, Document&);
    void dialog_selection_update();
    void recent_files_load();
    void recent_files_save();
    void recent_file_push(const std::filesystem::path&);

  public:
    Console::Action action{};

    void dropped_file_open(const char*);
    void update(Resources&, SDL_Window*, state::Play*);
  };
}
